:root {
  --bg-dark: #080c14;
  --bg-card: #0f172a;
  --bg-card-sub: #17223b;
  --border-color: #1e293b;
  --border-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #38bdf8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  font-size: 14px;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}
.brand-icon {
  width: 36px;
  height: 36px;
  background: #1877f2;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}
.brand-text h2 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand-text span { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.nav-links { list-style: none; display: flex; flex-direction: column; gap: 4px; flex-grow: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.nav-item:hover {
  background: var(--bg-card-sub);
  color: var(--text-main);
}
.nav-item.active {
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  font-weight: 600;
}
.nav-icon { font-size: 16px; }

.sidebar-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.external-link {
  font-size: 12px;
  color: #a5b4fc;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.1);
}
.external-link:hover { background: rgba(99, 102, 241, 0.2); }
.btn-logout {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.btn-logout:hover { background: var(--bg-card-sub); color: var(--danger); }

/* Main Content */
.main-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}
header.top-header {
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card-sub);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.status-dot.sim { background: var(--accent); }
.status-dot.paused { background: var(--danger); }

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sim-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-killswitch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.btn-killswitch.active {
  background: #15803d;
  color: #fff;
}
.btn-killswitch.active:hover { background: #166534; }
.btn-killswitch.paused {
  background: #b91c1c;
  color: #fff;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Page Container */
.content-area {
  padding: 28px;
  max-width: 1400px;
  width: 100%;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Metrics Row */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}
.metric-title {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 8px;
}
.metric-value {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
}
.metric-footer {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-dim);
}

/* Warning & Info Banners */
.alert-banner {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.alert-banner.warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
}
.alert-icon { font-size: 22px; line-height: 1; }
.alert-body h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; color: #f8fafc; }
.alert-body p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* Panels & Cards */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 24px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.panel-title { font-size: 16px; font-weight: 700; }
.panel-actions { display: flex; gap: 10px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-card-sub); color: #cbd5e1; border: 1px solid var(--border-color); }
.btn-secondary:hover { background: #1e293b; color: #fff; }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Two-pane Campaign Builder Layout */
.builder-layout {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 1024px) {
  .builder-layout { grid-template-columns: 1fr; }
}

.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}
.form-label small {
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 6px;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  background: #0b1120;
  border: 1px solid #222f46;
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--primary);
}
.form-textarea { resize: vertical; min-height: 84px; line-height: 1.5; }

/* Radio Cards */
.radio-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.radio-card {
  border: 1px solid #222f46;
  background: #0b1120;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.radio-card.selected {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
}
.radio-card input { margin-top: 3px; }
.radio-info strong { display: block; font-size: 13px; margin-bottom: 2px; }
.radio-info span { font-size: 11.5px; color: var(--text-muted); }

/* Live Phone Preview Mockup */
.phone-mockup-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.phone-container {
  width: 330px;
  height: 600px;
  background: #000;
  border: 10px solid #1e293b;
  border-radius: 36px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  position: relative;
}
.phone-notch {
  height: 22px;
  background: #1e293b;
  width: 140px;
  margin: 0 auto;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
}
.messenger-header {
  background: #0f172a;
  padding: 10px 14px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
}
.messenger-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1877f2;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.messenger-name h5 { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.messenger-name span { font-size: 10px; color: #10b981; }

.messenger-chat-body {
  flex-grow: 1;
  padding: 14px;
  background: #0b0f19;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-timestamp {
  text-align: center;
  font-size: 10px;
  color: #64748b;
  margin-bottom: 4px;
}
.msg-bubble-user {
  align-self: flex-end;
  background: #1877f2;
  color: #fff;
  padding: 8px 12px;
  border-radius: 16px 16px 4px 16px;
  font-size: 12.5px;
  max-width: 80%;
  word-break: break-word;
}
.msg-bubble-bot {
  align-self: flex-start;
  background: #1e293b;
  color: #f8fafc;
  padding: 10px 12px;
  border-radius: 16px 16px 16px 4px;
  font-size: 12.5px;
  line-height: 1.45;
  max-width: 90%;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #334155;
}
.preview-service-title {
  font-weight: 700;
  color: #38bdf8;
  margin-top: 6px;
  display: block;
}
.preview-service-link {
  color: #93c5fd;
  text-decoration: underline;
  word-break: break-all;
  font-size: 11.5px;
}
.preview-length-badge {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
table.data-table th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
table.data-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  color: #cbd5e1;
}
table.data-table tr:hover td {
  background: rgba(30, 41, 59, 0.4);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-sent { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-sim { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.badge-skipped { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-failed { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-active { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-draft { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }

/* Empty States */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); font-size: 13px; max-width: 400px; margin: 0 auto 16px; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}
