/* Refined theme: soft tinted surfaces, one indigo accent, gentle elevation,
   full light/dark support driven by the [data-theme] attribute on <html>.
   Every surface/border/ink colour is a token so both themes stay in sync. */
:root, :root[data-theme="light"] {
  /* Surfaces */
  --bg: #f3f4f8;
  --bg-grad:
    radial-gradient(1200px 620px at 12% -12%, #e9edfb 0%, rgba(233,237,251,0) 58%),
    radial-gradient(1000px 520px at 100% -6%, #f1ecfb 0%, rgba(241,236,251,0) 55%);
  --card: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f7fb;        /* table headers, subtle raised fills */
  --surface-hover: #f0f2f7;    /* row / nav hover */
  --surface-sunken: #f4f6fb;   /* transcripts, answer chips, history rows */
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --input-bg: #ffffff;

  /* Lines & elevation */
  --border: #e5e7ec;
  --border-hover: #d2d5dd;
  --track: #eceef4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 17, 19, 0.04), 0 8px 22px -14px rgba(16, 17, 19, 0.14);
  --shadow-lg: 0 24px 48px -14px rgba(16, 17, 19, 0.22);

  /* Text */
  --text: #17181a;
  --text-muted: #6b7180;

  /* Ink (high-contrast buttons, FAB, toast) — flips to light-on-dark in dark mode */
  --ink-bg: #101113;
  --ink-bg-hover: #26282d;
  --ink-fg: #ffffff;
  --navy: #101113;             /* legacy alias: chart bar-hover + login brand text */
  --navy-light: #26282d;

  /* Accent (indigo) */
  --blue: #4f46e5;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --accent-text: #4f46e5;
  --accent-border: #c7cbf7;
  --brand-grad-a: #4f46e5;
  --brand-grad-b: #7c3aed;

  /* Feedback colours */
  --danger-soft: #fef2f2;
  --danger-soft-hover: #fee2e2;
  --danger-text: #b91c1c;
  --danger-border: #fecaca;
  --warning-soft: #fef3c7;
  --warning-text: #92400e;
  --focus-ring: rgba(79, 70, 229, 0.32);

  --status-new: #64748b;
  --status-calling: #2563eb;
  --status-queued: #b45309;
  --status-qualified: #15803d;
  --status-unqualified: #6b7280;
  --status-callback: #7c3aed;
  --status-no_answer: #b45309;
  --status-dnc: #b91c1c;
}

:root[data-theme="dark"] {
  --bg: #0d0e12;
  --bg-grad:
    radial-gradient(1200px 620px at 12% -12%, rgba(79, 70, 229, 0.16) 0%, rgba(79, 70, 229, 0) 58%),
    radial-gradient(1000px 520px at 100% -6%, rgba(124, 58, 237, 0.14) 0%, rgba(124, 58, 237, 0) 55%);
  --card: #16181e;
  --surface: #16181e;
  --surface-2: #1b1e25;
  --surface-hover: #222630;
  --surface-sunken: #1a1d24;
  --topbar-bg: rgba(18, 20, 25, 0.72);
  --input-bg: #1b1e25;

  --border: #2a2e38;
  --border-hover: #3a3f4b;
  --track: #262a34;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 26px -14px rgba(0, 0, 0, 0.65);
  --shadow-lg: 0 26px 52px -14px rgba(0, 0, 0, 0.72);

  --text: #e7e9ef;
  --text-muted: #99a0b0;

  --ink-bg: #e9eaef;
  --ink-bg-hover: #ffffff;
  --ink-fg: #101113;
  --navy: #e7e9ef;
  --navy-light: #ffffff;

  --blue: #8b93f8;
  --accent: #8b93f8;
  --accent-hover: #a6acfb;
  --accent-soft: rgba(129, 140, 248, 0.16);
  --accent-text: #aab1fb;
  --accent-border: rgba(129, 140, 248, 0.42);
  --brand-grad-a: #6366f1;
  --brand-grad-b: #8b5cf6;

  --danger-soft: rgba(248, 113, 113, 0.15);
  --danger-soft-hover: rgba(248, 113, 113, 0.24);
  --danger-text: #f6a1a1;
  --danger-border: rgba(248, 113, 113, 0.34);
  --warning-soft: rgba(251, 191, 36, 0.16);
  --warning-text: #f5cd6b;
  --focus-ring: rgba(139, 147, 248, 0.42);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Smooth the flip between themes on the main surfaces (not on everything, to
   keep it cheap). */
body, .topbar, .stat-card, .table-card, .chart-card, .editor-empty,
.agent-card, .modal, .notice-card, .support-panel, .login-card, .theme-toggle,
input, select, textarea, .btn {
  transition: background-color 0.25s ease, border-color 0.2s ease, color 0.2s ease;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: none;
}
.theme-toggle:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-hover); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 17px; height: 17px; display: block; }
.theme-toggle-float { position: fixed; top: 16px; right: 16px; z-index: 60; box-shadow: var(--shadow); }

/* ---------- User menu (account dropdown) ---------- */
.user-menu-wrap { position: relative; display: inline-flex; }

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  font: inherit;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 8px;
}
.user-menu-trigger:hover { background: var(--surface-hover); color: var(--text); }
.user-menu-trigger .caret { font-size: 10px; opacity: 0.7; }

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 60;
  display: none;
}
.user-menu.open { display: block; }

.user-menu-head { padding: 8px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-menu-head .um-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.user-menu-head .um-email { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--surface-hover); }
.user-menu-item svg { color: var(--text-muted); flex: none; }

/* ---------- Login page ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 360px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.login-brand .logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-grad-a) 0%, var(--brand-grad-b) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

.login-brand .brand-text {
  font-weight: 700;
  font-size: 17px;
  color: var(--navy);
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
}

.login-card p.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 24px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
}

.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.btn-primary { background: var(--ink-bg); color: var(--ink-fg); }
.btn-primary:hover { background: var(--ink-bg-hover); }
.btn-secondary { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-danger { background: var(--danger-soft); color: var(--danger-text); }
.btn-danger:hover { background: var(--danger-soft-hover); }
.btn-block { width: 100%; }

.error-msg {
  background: var(--danger-soft);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.hint-box {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-sunken);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.5;
}

/* ---------- App shell ---------- */
.topbar {
  background: var(--topbar-bg);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  color: var(--text);
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.topbar-brand .logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-grad-a) 0%, var(--brand-grad-b) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  letter-spacing: 0;
}

.topbar-nav {
  display: flex;
  gap: 2px;
  margin-left: 22px;
}

.topbar-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 7px;
  transition: color 0.12s ease, background 0.12s ease;
}

.topbar-nav a:hover { color: var(--text); background: var(--surface-hover); }
.topbar-nav a.active { color: var(--blue); background: var(--accent-soft); font-weight: 600; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.org-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--blue);
  white-space: nowrap;
}

.mode-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning-text);
}

.error-banner {
  background: var(--danger-soft);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13.5px;
  margin-bottom: 18px;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 20px;
  margin: 0;
}

.page-header .page-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  transition: border-color 0.12s ease;
}

.stat-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-lg); transform: translateY(-1px); }

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.toolbar input[type="search"] {
  flex: 1;
  min-width: 220px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
}

.toolbar select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
}

.toolbar input[type="date"].date-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
}
.toolbar input[type="date"].date-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
/* Make the native date-picker icon legible in dark mode. */
:root[data-theme="dark"] .toolbar input[type="date"].date-input::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.6);
}

.toolbar-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- Table ---------- */
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

thead th {
  text-align: left;
  padding: 11px 16px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
  cursor: pointer;
  transition: background 0.1s ease;
}

tbody tr:hover { background: var(--surface-hover); }

.name-cell { font-weight: 600; }
.muted { color: var(--text-muted); }
.num-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }

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

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.chart-card.full { grid-column: 1 / -1; }

.chart-card h3 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 600;
}

.chart-card .chart-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 16px;
}

.chart-card svg { display: block; width: 100%; height: auto; overflow: visible; }

/* bar chart */
.bar { fill: var(--blue); transition: fill 0.12s ease; }
.bar:hover { fill: var(--navy); }
.bar-label, .axis-label {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: inherit;
}
.grid-line { stroke: var(--border); stroke-width: 1; }

/* horizontal outcome bars */
.hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.hbar-label { width: 110px; font-size: 12.5px; color: var(--text); flex: none; }
.hbar-track { flex: 1; background: var(--track); border-radius: 6px; height: 20px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; }
.hbar-value {
  width: 44px; text-align: right; font-size: 12.5px; flex: none;
  font-variant-numeric: tabular-nums; color: var(--text-muted);
}

@media (max-width: 720px) {
  .analytics-grid { grid-template-columns: 1fr; }
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.score-dots {
  display: inline-flex;
  white-space: nowrap;
}

.score-dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  margin-right: 2px;
  flex: none;
}

.score-dots span.filled { background: var(--blue); }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

/* ---------- Scenario editor (scenarios.html) ---------- */
.toolbar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.toolbar select#scenarioSelect { min-width: 260px; }

.editor-card { padding: 22px 24px; }

.editor-empty {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 18px;
}

.inline-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.45;
}

.inline-hint-strong {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.optional-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.questions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.questions-head label {
  font-size: 13px;
  font-weight: 600;
}

.btn-sm { padding: 6px 12px; font-size: 13px; }

.question-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.question-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  width: 20px;
  flex: none;
  text-align: right;
}

.question-row input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
}

.question-row input[type="text"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.question-row .question-text { flex: 2.2; min-width: 0; }
.question-row .question-key { flex: 1; min-width: 0; }

.question-required {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  flex: none;
}

.btn-icon {
  padding: 6px 9px;
  font-size: 13px;
  line-height: 1;
  flex: none;
}

.btn-icon:disabled { opacity: 0.35; cursor: default; }

.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  gap: 10px;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .question-row { flex-wrap: wrap; }
  .question-row .question-text { flex-basis: 100%; }
}

/* ---------- Detail modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}

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

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.modal-header .modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

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

.modal-body {
  padding: 20px 24px;
  max-height: 62vh;
  overflow-y: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin-bottom: 18px;
}

.detail-item .detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.detail-item .detail-value {
  font-size: 14px;
}

.detail-item .detail-value a { color: var(--blue); text-decoration: none; }
.detail-item .detail-value a:hover { text-decoration: underline; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.transcript-text {
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 4px;
}

.transcript-text a { color: var(--blue); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  margin-top: 4px;
}

.checkbox-row input { width: 16px; height: 16px; }

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  gap: 10px;
}

/* ---------- Notices: status banners, announcements, block screen ---------- */
.notice-banner {
  padding: 10px 24px;
  font-size: 13.5px;
  text-align: center;
  line-height: 1.4;
}

.notice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 17, 19, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.notice-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(16, 17, 19, 0.3);
  width: 100%;
  max-width: 440px;
  padding: 24px;
}

.notice-sev {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.notice-card h2 { margin: 0 0 8px; font-size: 17px; }
.notice-card p { margin: 0; color: var(--text-muted); font-size: 14px; line-height: 1.55; }

.notice-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
}

.notice-count { font-size: 12px; color: var(--text-muted); }

.block-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 300;
}

.block-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 32px;
  text-align: center;
}

.block-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--danger-text);
  margin-bottom: 12px;
}

.block-card p { color: var(--text); font-size: 14.5px; line-height: 1.6; margin: 0 0 8px; }
.block-card .block-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

/* ---------- Support widget ---------- */
.support-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--ink-bg);
  color: var(--ink-fg);
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(16, 17, 19, 0.22);
  z-index: 90;
  transition: transform 0.12s ease, background 0.12s ease;
}

.support-fab:hover { background: var(--ink-bg-hover); transform: translateY(-1px); }

.support-panel {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 340px;
  max-width: calc(100vw - 48px);
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.28);
  border: 1px solid var(--border);
  padding: 18px;
  display: none;
  z-index: 95;
}

.support-panel.open { display: block; }

.support-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 15px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink-bg);
  color: var(--ink-fg);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Call history (lead modal) ---------- */
.call-history { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

.call-history-row {
  display: grid;
  grid-template-columns: 1fr auto 70px 70px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.call-history-row .ch-date { color: var(--text-muted); }
.call-history-row .ch-mins, .call-history-row .ch-charge { text-align: right; }

/* ---------- Survey response answers ---------- */
.qa-list { display: flex; flex-direction: column; gap: 8px; }

.qa-item {
  padding: 10px 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.qa-item .qa-key {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: capitalize;
  margin-bottom: 3px;
}

.qa-item .qa-val { font-size: 14px; color: var(--text); }

/* ---------- Platform-admin org switcher ---------- */
.org-switcher {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 5px 26px 5px 10px;
  max-width: 200px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%234f46e5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
.org-switcher:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
/* When the switcher is present (admins), hide the static org pill it replaces. */
body.admin-switcher .org-badge { display: none !important; }

/* ---------- Admin console ---------- */
.topbar-nav a.admin-link { color: var(--blue); }
.topbar-nav a.admin-link.active { color: var(--blue); background: var(--accent-soft); }

.admin-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1px;
}

.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1;
  background: var(--danger-text); color: #fff; vertical-align: middle;
}

.admin-panel-head { display: flex; justify-content: flex-end; margin-bottom: 14px; }

/* Squad member picker (agent editor) */
.squad-picker { display: flex; flex-direction: column; gap: 6px; }
.squad-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
.squad-opt:hover { background: var(--surface-hover); }
.squad-opt input { width: 16px; height: 16px; }

.admin-panel .table-card tbody tr { cursor: pointer; }

/* ---------- Agents ---------- */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.agent-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
}

.agent-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.agent-card .agent-name { font-size: 15.5px; font-weight: 700; }
.agent-card .agent-type { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

.agent-meta { margin: 14px 0 16px; display: grid; gap: 8px; }
.agent-meta > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.agent-meta dt { color: var(--text-muted); margin: 0; }
.agent-meta dd { margin: 0; text-align: right; font-weight: 500; }

.price-note {
  margin-top: 12px;
  padding: 9px 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .detail-grid { grid-template-columns: 1fr; }
  table { font-size: 12.5px; }
  thead th:nth-child(4), tbody td:nth-child(4) { display: none; }
}
