:root {
  --bg: #f8f9fa;
  --surface: #fff;
  --border: #dee2e6;
  --text: #212529;
  --muted: #6c757d;
  --primary: #0d6efd;
  --primary-hover: #0b5ed7;
  --danger: #dc3545;
  --success: #198754;
  --warning: #ffc107;
  --info: #0dcaf0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: #1a1d23;
  color: #ccc;
  padding: 20px 0;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
}

.sidebar h1 {
  font-size: 18px;
  color: #fff;
  padding: 0 20px 20px;
  border-bottom: 1px solid #333;
  margin-bottom: 8px;
}

.sidebar a {
  display: block;
  padding: 10px 20px;
  color: #adb5bd;
  text-decoration: none;
  font-size: 14px;
  transition: background .15s, color .15s;
}

.sidebar a:hover, .sidebar a.active {
  background: #2c3038;
  color: #fff;
}

.sidebar a.active {
  border-left: 3px solid var(--primary);
  padding-left: 17px;
}

.main {
  flex: 1;
  margin-left: 220px;
  padding: 24px 32px;
  max-width: 1200px;
}

/* Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 4px;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar input[type="text"],
.toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
}

.toolbar input[type="text"] { flex: 1; min-width: 200px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #bb2d3b; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #157347; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Tables */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  background: #fafafa;
}

tr:hover td { background: #f0f4ff; }
tr:last-child td { border-bottom: none; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-new { background: #e9ecef; color: #495057; }
.badge-approved { background: #d1e7dd; color: #0f5132; }
.badge-sent { background: #cff4fc; color: #055160; }
.badge-replied { background: #d1e7dd; color: #0f5132; }
.badge-do_not_contact { background: #f8d7da; color: #842029; }
.badge-draft { background: #e9ecef; color: #495057; }
.badge-active { background: #d1e7dd; color: #0f5132; }
.badge-paused { background: #fff3cd; color: #664d03; }
.badge-completed { background: #cff4fc; color: #055160; }
.badge-failed { background: #f8d7da; color: #842029; }
.badge-pending { background: #fff3cd; color: #664d03; }

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding-top: 60px;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 560px;
  max-width: 95vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
}

.modal-body { padding: 20px; }

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.form-group textarea { min-height: 100px; resize: vertical; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* Pagination */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
}

/* Toast */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  animation: fadeIn .2s;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* CSV file input */
.file-upload {
  display: flex;
  gap: 8px;
  align-items: center;
}

.file-upload input[type="file"] { font-size: 13px; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar h1 { display: none; }
  .sidebar a { padding: 10px; text-align: center; font-size: 0; }
  .main { margin-left: 60px; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
