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

:root {
  --green: #22c55e;
  --green-dark: #16a34a;
  --green-light: #dcfce7;
  --green-muted: #86efac;
  --blue: #3b82f6;
  --blue-dark: #1d4ed8;
  --blue-light: #dbeafe;
  --amber: #f59e0b;
  --amber-light: #fef3c7;
  --red: #ef4444;
  --red-light: #fee2e2;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --sidebar-w: 220px;
  --topbar-h: 56px;
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── APP SHELL ── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
  width: 34px; height: 34px;
  background: var(--green);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-name { font-size: 15px; font-weight: 600; color: #fff; }
.brand-sub { font-size: 10px; color: var(--gray-400); margin-top: 1px; }

.sidebar-nav { padding: 8px 0; flex: 1; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-500);
  padding: 12px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--gray-400);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  border-left: 2px solid transparent;
}

.nav-item:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-item.active { color: var(--green); background: rgba(34,197,94,0.1); border-left-color: var(--green); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.plan-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(34,197,94,0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(34,197,94,0.2);
}

.plan-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.plan-name { font-size: 12px; font-weight: 600; color: var(--green); }
.plan-detail { font-size: 10px; color: var(--gray-400); margin-top: 1px; }

/* ── MAIN ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.page-title { font-size: 16px; font-weight: 600; color: var(--gray-900); }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-500);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.status-dot.pulse {
  animation: pulse 2s infinite;
}

.status-dot.disconnected { background: var(--gray-400); animation: none; }
.status-dot.error { background: var(--red); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.content-area { flex: 1; overflow-y: auto; padding: 24px; }

/* ── PANELS ── */
.panel { display: none; }
.panel.active { display: block; }

/* ── CARDS ── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title { font-size: 13px; font-weight: 600; color: var(--gray-700); }

/* ── COMPOSE LAYOUT ── */
.compose-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

.compose-left .card { margin-bottom: 0; }
.compose-right .card:last-child { margin-bottom: 0; }

/* ── TABS ── */
.tab-row { display: flex; gap: 4px; }

.tab-btn {
  padding: 5px 12px;
  font-size: 12px;
  border: 1px solid var(--gray-200);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-500);
  transition: all 0.15s;
}

.tab-btn.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── FORM ELEMENTS ── */
.field { margin-bottom: 14px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 5px;
}

.label-hint { font-weight: 400; color: var(--gray-400); }

input[type="text"],
input[type="url"],
input[type="email"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  transition: border-color 0.15s;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.1);
}

textarea { resize: vertical; min-height: 140px; }

input[type="range"] {
  width: 100%;
  padding: 0;
  border: none;
  box-shadow: none;
  accent-color: var(--green);
}

input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--green);
  cursor: pointer;
}

.field-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
}

.char-count { font-size: 11px; color: var(--gray-400); }
.link-btn { font-size: 11px; color: var(--green); background: none; border: none; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

.range-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 12px 0;
  padding: 10px 0;
  border-top: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--gray-50);
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
}

.tool-btn:hover { background: var(--green-light); border-color: var(--green-muted); color: var(--green-dark); }

/* ── AI PANEL ── */
.ai-panel {
  margin: 12px 0;
  border: 1px solid var(--blue-light);
  border-radius: var(--radius);
  overflow: hidden;
}

.ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--blue-light);
  font-size: 12px;
  font-weight: 600;
  color: var(--blue-dark);
}

.ai-suggestions { padding: 8px; }

.ai-suggestion {
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
  background: #fff;
}

.ai-suggestion:last-child { margin-bottom: 0; }

.ai-suggestion:hover {
  border-color: var(--green);
  background: var(--green-light);
}

.ai-text { font-size: 12px; color: var(--gray-700); line-height: 1.5; margin-bottom: 4px; }
.ai-meta { font-size: 10px; color: var(--gray-400); }

/* ── SPINTAX PREVIEW ── */
.spintax-preview {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.preview-label { font-size: 10px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.preview-text { font-size: 13px; color: var(--gray-700); line-height: 1.6; }

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--gray-400);
}

.upload-zone:hover { border-color: var(--green); background: var(--green-light); color: var(--green-dark); }
.upload-text { font-size: 14px; margin: 8px 0 4px; }
.upload-hint { font-size: 12px; }

/* ── TOGGLES ── */
.toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-200);
  border-radius: 20px;
  cursor: pointer;
  transition: 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }
.toggle-label { font-size: 12px; color: var(--gray-600); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-family: inherit;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
  border: 1px solid transparent;
}

.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }

.btn-outline { background: #fff; color: var(--gray-700); border-color: var(--gray-200); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-300); }

.btn-danger { background: var(--red-light); color: var(--red); border-color: #fca5a5; }
.btn-danger:hover { background: #fecaca; }

.btn-full { width: 100%; justify-content: center; padding: 10px; }

.btn-row { display: flex; gap: 8px; }

/* ── PROGRESS ── */
.progress-header { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.progress-label { font-weight: 500; color: var(--gray-700); }
.progress-count { color: var(--gray-500); }

.progress-bar-outer {
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-inner {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-current { font-size: 11px; color: var(--gray-400); }

/* ── SELECTED BADGE ── */
.selected-badge {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--green-light);
  color: var(--green-dark);
  border-radius: 20px;
  font-weight: 600;
}

/* ── METRICS ── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.metric-label { font-size: 11px; color: var(--gray-500); margin-bottom: 4px; }
.metric-value { font-size: 24px; font-weight: 700; color: var(--gray-900); }
.metric-sub { font-size: 11px; color: var(--green-dark); margin-top: 2px; }

/* ── PANEL HEADER ── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.search-input {
  width: 280px;
  padding: 8px 12px;
}

.filter-row { display: flex; gap: 8px; align-items: center; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.data-table th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--gray-50);
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.data-table td {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-amber { background: var(--amber-light); color: #92400e; }
.badge-red { background: var(--red-light); color: #991b1b; }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-blue { background: var(--blue-light); color: var(--blue-dark); }

/* ── CAMPAIGN ROWS ── */
.campaign-item {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.campaign-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.campaign-info { flex: 1; }
.campaign-name { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.campaign-meta { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

.campaign-progress { margin-top: 8px; }
.camp-bar { height: 4px; background: var(--gray-100); border-radius: 2px; }
.camp-bar-fill { height: 100%; border-radius: 2px; background: var(--green); }

/* ── SCHEDULED ROWS ── */
.sched-item {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sched-title { font-size: 13px; font-weight: 500; color: var(--gray-800); }
.sched-meta { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ── LISTS GRID ── */
.lists-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.list-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.list-card.new-card {
  border: 2px dashed var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  min-height: 160px;
  color: var(--gray-400);
  transition: all 0.15s;
}

.list-card.new-card:hover { border-color: var(--green); color: var(--green-dark); background: var(--green-light); }

.list-title { font-size: 14px; font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.list-meta { font-size: 12px; color: var(--gray-400); margin-bottom: 12px; }
.list-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.list-tag { font-size: 11px; padding: 2px 7px; background: var(--gray-100); color: var(--gray-500); border-radius: 20px; }
.list-actions { display: flex; gap: 8px; }
.list-actions .btn { flex: 1; justify-content: center; font-size: 12px; padding: 7px 10px; }

/* ── ANALYTICS ── */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chart-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding-bottom: 4px;
}

.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar-fill { width: 100%; border-radius: 3px 3px 0 0; background: var(--green); min-height: 4px; transition: height 0.3s; }
.bar-label { font-size: 9px; color: var(--gray-400); }

.camp-stat { margin-bottom: 14px; }
.camp-stat-name { font-size: 12px; color: var(--gray-700); margin-bottom: 4px; }
.camp-stat-bar { height: 6px; background: var(--gray-100); border-radius: 3px; }
.camp-stat-fill { height: 100%; border-radius: 3px; background: var(--green); }
.camp-stat-meta { font-size: 11px; color: var(--gray-400); margin-top: 3px; }

/* ── ACTIVITY LOG ── */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.act-success { background: var(--green-light); }
.act-skip { background: var(--amber-light); }
.act-error { background: var(--red-light); }
.act-info { background: var(--blue-light); }

.activity-body { flex: 1; }
.activity-text { font-size: 13px; color: var(--gray-700); line-height: 1.4; }
.activity-text strong { color: var(--gray-900); }
.activity-time { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ── GROUP PICKER ── */
.group-picker {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-top: 6px;
}

.group-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 12px;
  cursor: pointer;
}

.group-check-row:last-child { border-bottom: none; }
.group-check-row:hover { background: var(--gray-50); }
.group-check-row input { width: 14px; height: 14px; }

/* ── SETTINGS ── */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.setting-desc { font-size: 13px; color: var(--gray-500); line-height: 1.5; margin-bottom: 12px; }

.ext-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

.ext-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gray-300); flex-shrink: 0; }
.ext-dot.connected { background: var(--green); }
.ext-dot.disconnected { background: var(--gray-300); }
.ext-version { font-size: 11px; color: var(--gray-400); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.modal-title { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-400); line-height: 1; padding: 0; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.toast.show { opacity: 1; }
.toast.success { background: var(--green-dark); }
.toast.error { background: var(--red); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .compose-grid { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: 1fr 1fr; }
  .lists-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
