/* ═══════════════════════════════════════════════════════════════════
   CUREDOK MANAGE — DESIGN TOKENS  (mirrors provider-portal theme)
═══════════════════════════════════════════════════════════════════ */

:root {

  /* ── Surface & Background ────────────────────────────────────────── */
  --bg:              rgb(250 250 250 / var(--tw-bg-opacity, 1));
  --bg-subtle:       #f8f7fd;
  --surface:         #ffffff;
  --surface-overlay: rgba(255, 255, 255, 0.82);

  /* ── Borders ─────────────────────────────────────────────────────── */
  --border:          #dbd2f2;
  --border-light:    #eae5f8;
  --border-strong:   #c0b4e0;

  /* ── Structural surfaces ─────────────────────────────────────────── */
  --sidebar-bg:      #ffffff;
  --topbar-bg:       #ffffff;

  /* ── Typography ──────────────────────────────────────────────────── */
  --text-primary:    #11082a;
  --text-secondary:  #352852;
  --text-muted:      #7866a8;
  --text-label:      #261b42;
  --text-disabled:   #b5aece;

  /* ── Accent — Electric Violet ────────────────────────────────────── */
  --accent:          #6d40f5;
  --accent-hover:    #5c30e6;
  --accent-active:   #4b22d4;
  --accent-mid:      #9265fa;
  --accent-light:    #a78bfb;
  --accent-soft:     rgba(109, 64, 245, 0.09);
  --accent-badge:    rgba(109, 64, 245, 0.13);
  --accent-glow:     rgba(109, 64, 245, 0.30);
  --accent-gradient: linear-gradient(135deg, #5c30e6 0%, #a78bfb 100%);

  /* ── Green ───────────────────────────────────────────────────────── */
  --green:           #16a34a;
  --green-soft:      rgba(22, 163, 74, 0.09);
  --green-border:    rgba(22, 163, 74, 0.22);

  /* ── Cyan ────────────────────────────────────────────────────────── */
  --cyan:            #0891b2;
  --cyan-soft:       rgba(8, 145, 178, 0.09);
  --cyan-border:     rgba(8, 145, 178, 0.22);

  /* ── Amber ───────────────────────────────────────────────────────── */
  --amber:           #b45309;
  --amber-soft:      rgba(180, 83, 9, 0.09);
  --amber-border:    rgba(180, 83, 9, 0.22);

  /* ── Red ─────────────────────────────────────────────────────────── */
  --red:             #dc2626;
  --red-soft:        rgba(220, 38, 38, 0.08);
  --red-border:      rgba(220, 38, 38, 0.20);

  /* ── Logo zone ───────────────────────────────────────────────────── */
  --logo-bg:         #ffffff;
  --logo-text:       #11082a;
  --logo-subtext:    #7866a8;
  --logo-border:     var(--border-light);

  /* ── Topbar ──────────────────────────────────────────────────────── */
  --topbar-h:        60px;
  --topbar-accent-line: linear-gradient(90deg, #2e1278 0%, #6d40f5 28%, rgba(109,64,245,0.25) 65%, transparent 100%);

  /* ── Sidebar ─────────────────────────────────────────────────────── */
  --sidebar-w:       252px;

  /* ── Elevation ───────────────────────────────────────────────────── */
  --shadow-xs:       0 1px 2px  rgba(17, 8, 42, 0.05);
  --shadow-sm:       0 1px 4px  rgba(17, 8, 42, 0.08), 0 1px 2px rgba(17, 8, 42, 0.05);
  --shadow-md:       0 4px 12px rgba(17, 8, 42, 0.10), 0 2px 4px rgba(17, 8, 42, 0.06);
  --shadow-lg:       0 8px 28px rgba(17, 8, 42, 0.13), 0 4px 8px rgba(17, 8, 42, 0.07);
  --shadow-accent:   0 4px 20px rgba(109, 64, 245, 0.38);

  /* ── Shape ───────────────────────────────────────────────────────── */
  --radius-xs:       4px;
  --radius-sm:       8px;
  --radius:          12px;
  --radius-lg:       16px;
  --radius-xl:       24px;
  --radius-full:     9999px;

  /* ── Motion ──────────────────────────────────────────────────────── */
  --ease-std:        cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:        cubic-bezier(0, 0, 0.2, 1);
  --dur-2:           150ms;
  --dur-3:           200ms;
  --dur-4:           300ms;
}

/* ── Reset & base ───────────────────────────────────────────────────── */

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

html { font-size: 16px; }

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

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Layout shell ───────────────────────────────────────────────────── */

.shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1.5px solid var(--border-light);
  overflow-y: auto;
  z-index: 40;
}

.sidebar-logo {
  background: var(--logo-bg);
  padding: 18px 20px;
  border-bottom: 1px solid var(--logo-border);
  flex-shrink: 0;
}

.sidebar-logo .app-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--logo-text);
  letter-spacing: -0.3px;
}

.sidebar-logo .app-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--logo-subtext);
  margin-top: 2px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-group-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-disabled);
  padding: 10px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--dur-2) var(--ease-std), color var(--dur-2) var(--ease-std);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1.5px solid var(--border-light);
  flex-shrink: 0;
}

/* ── Topbar ─────────────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1.5px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 30;
}

.topbar-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.topbar-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-spacer { flex: 1; }

/* ── Main content ───────────────────────────────────────────────────── */

.main {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

.page {
  padding: 28px 32px;
  max-width: 1300px;
}

/* ── Cards ──────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  background: var(--bg-subtle);
  border-bottom: 1.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-body { padding: 20px; }

/* ── Stat cards ─────────────────────────────────────────────────────── */

.stat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 18px 20px;
  transition: box-shadow var(--dur-3) var(--ease-std), transform var(--dur-3) var(--ease-std);
}

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

/* ── Buttons ────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--dur-2) var(--ease-std);
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1.5px solid var(--red-border);
}
.btn-danger:hover { background: var(--red); color: white; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
}

/* ── Table ──────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

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

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1.5px solid var(--border-light);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--dur-2) var(--ease-std);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-subtle); }

tbody td {
  padding: 11px 14px;
  color: var(--text-secondary);
  vertical-align: middle;
}

/* ── Badges ─────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-active   { background: var(--green-soft);  color: var(--green);  border: 1px solid var(--green-border); }
.badge-inactive { background: var(--red-soft);    color: var(--red);    border: 1px solid var(--red-border); }
.badge-accent   { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-badge); }
.badge-amber    { background: var(--amber-soft);  color: var(--amber);  border: 1px solid var(--amber-border); }
.badge-cyan     { background: var(--cyan-soft);   color: var(--cyan);   border: 1px solid var(--cyan-border); }

/* ── Forms ──────────────────────────────────────────────────────────── */

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field label .req { color: var(--red); margin-left: 2px; }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--dur-2) var(--ease-std), box-shadow var(--dur-2) var(--ease-std);
  appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea { resize: vertical; min-height: 80px; }

.field .error-msg {
  font-size: 11.5px;
  color: var(--red);
  margin-top: 5px;
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

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

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--dur-3) var(--ease-std);
}

.toggle input:checked + .toggle-track { background: var(--accent); }

.toggle-track::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform var(--dur-3) var(--ease-std);
  box-shadow: var(--shadow-xs);
}

.toggle input:checked + .toggle-track::before { transform: translateX(16px); }

/* ── Alerts / Flash ─────────────────────────────────────────────────── */

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
}

.alert-success { background: var(--green-soft);  color: var(--green);  border: 1.5px solid var(--green-border); }
.alert-error   { background: var(--red-soft);    color: var(--red);    border: 1.5px solid var(--red-border); }
.alert-info    { background: var(--accent-soft); color: var(--accent); border: 1.5px solid var(--accent-badge); }

/* ── Modal ──────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 8, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl, 0 16px 48px rgba(17,8,42,0.18));
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
}

.modal-body { padding: 22px; }

.modal-footer {
  padding: 16px 22px;
  border-top: 1.5px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Search bar ─────────────────────────────────────────────────────── */

.search-bar {
  position: relative;
}

.search-bar svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-bar input {
  padding-left: 34px;
  padding-right: 12px;
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 13px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--dur-2) var(--ease-std);
  width: 240px;
}

.search-bar input:focus { border-color: var(--accent); }

/* ── Pagination ─────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 20px;
  border-top: 1.5px solid var(--border-light);
}

.page-btn {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  background: var(--surface);
  transition: all var(--dur-2) var(--ease-std);
}

.page-btn:hover, .page-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ── Toast ──────────────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  min-width: 280px;
  animation: slideUp var(--dur-4) var(--ease-out);
}

.toast.success { border-color: var(--green-border); color: var(--green); }
.toast.error   { border-color: var(--red-border);   color: var(--red); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Empty state ────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  color: var(--text-muted);
}

/* ── Utility ────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border-light); margin: 16px 0; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 12px; }
.font-bold   { font-weight: 700; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex        { display: flex; }
.items-center{ align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.ml-auto     { margin-left: auto; }
.grid-2      { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3      { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4      { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}

/* ═══════════════════════════════════════════════════════════════════
   RICH TEXT EDITOR (Quill) — restyled onto the design tokens above so
   the article body editor doesn't read as a bolted-on third-party
   widget. Only loaded on views that render a `richtext` field.
═══════════════════════════════════════════════════════════════════ */

.ql-toolbar.ql-snow {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--bg-subtle);
  padding: 8px;
}
.ql-container.ql-snow {
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 14px;
}
.richtext-editor .ql-editor {
  min-height: 320px;
  color: var(--text-primary);
  line-height: 1.7;
}
.richtext-editor .ql-editor.ql-blank::before {
  color: var(--text-disabled);
  font-style: normal;
}
.richtext-editor .ql-editor h2 { font-size: 21px; font-weight: 700; margin: 20px 0 8px; }
.richtext-editor .ql-editor h3 { font-size: 17px; font-weight: 700; margin: 16px 0 6px; }
.richtext-editor .ql-editor p  { margin: 0 0 12px; }
.richtext-editor .ql-editor blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  margin: 12px 0;
  padding: 8px 14px;
  color: var(--text-secondary);
}
.richtext-editor .ql-editor img { max-width: 100%; border-radius: 6px; }
.richtext-editor .ql-editor a   { color: var(--accent); }

.ql-snow .ql-stroke  { stroke: var(--text-muted); }
.ql-snow .ql-fill    { fill: var(--text-muted); }
.ql-snow .ql-picker  { color: var(--text-secondary); }
.ql-snow .ql-toolbar button:hover .ql-stroke,
.ql-snow .ql-toolbar button.ql-active .ql-stroke,
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent); }
.ql-snow .ql-toolbar button:hover .ql-fill,
.ql-snow .ql-toolbar button.ql-active .ql-fill,
.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent); }
.ql-snow .ql-picker-options { border-color: var(--border); border-radius: var(--radius-sm); }

/* Image field */
.image-field-preview { margin-top: 8px; }

/* ═══════════════════════════════════════════════════════════════════
   DASHBOARD — analytics overview
   Every colour below comes from the tokens at the top of this file, so the
   dashboard restyles with the rest of the portal rather than pinning its own
   palette. Charts are inline SVG (this repo has no bundler), so the chart
   primitives are styled here rather than with per-element fill attributes.
═══════════════════════════════════════════════════════════════════ */

/* ── Headline KPI cards ─────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.kpi-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .18s ease, transform .18s ease;
  overflow: hidden;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
/* The lead metric gets the accent rail; the rest stay quiet so the eye lands
   on patients first rather than on four equally-loud cards. */
.kpi-accent::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--accent-gradient);
}
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.kpi-label {
  font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--text-muted);
}
.kpi-icon {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
}
.kpi-icon-cyan  { background: var(--cyan-soft);  color: var(--cyan); }
.kpi-icon-green { background: var(--green-soft); color: var(--green); }
.kpi-icon-amber { background: var(--amber-soft); color: var(--amber); }
.kpi-value {
  font-size: 30px; font-weight: 800; line-height: 1.05; color: var(--text-primary);
  letter-spacing: -.5px; font-variant-numeric: tabular-nums;
}
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.kpi-sub  { font-size: 11.5px; color: var(--text-muted); }
.kpi-split {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-light);
  font-size: 11.5px; color: var(--text-muted);
}
.kpi-split strong { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.kpi-delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
  font-variant-numeric: tabular-nums;
}
.kpi-delta-up   { background: var(--green-soft);  color: var(--green);  border: 1px solid var(--green-border); }
.kpi-delta-down { background: var(--red-soft);    color: var(--red);    border: 1px solid var(--red-border); }
.kpi-delta-flat { background: var(--bg);          color: var(--text-muted); border: 1px solid var(--border-light); }
.kpi-delta-new  { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-badge); }

/* ── Two-column card layout ─────────────────────────────────────────── */
.dash-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.dash-cols > .card { margin-bottom: 0; }

/* ── Trend chart ────────────────────────────────────────────────────── */
.trend-chart { width: 100%; height: auto; display: block; overflow: visible; }
.grid-line   { stroke: var(--border-light); stroke-width: 1; }
.axis-text   { fill: var(--text-muted); font-size: 9.5px; font-weight: 600; }
.line-accent { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-cyan   { fill: none; stroke: var(--cyan);   stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.area-accent { fill: var(--accent-soft); stroke: none; }
.area-cyan   { fill: var(--cyan-soft);   stroke: none; }
.dot-accent  { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.dot-cyan    { fill: var(--cyan);   stroke: var(--surface); stroke-width: 1.5; }

.legend      { display: flex; gap: 14px; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.swatch        { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.swatch-accent { background: var(--accent); }
.swatch-cyan   { background: var(--cyan); }

/* ── Activation gauge ───────────────────────────────────────────────── */
.gauge-value {
  font-size: 34px; font-weight: 800; color: var(--accent);
  letter-spacing: -.5px; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.gauge-track {
  height: 8px; border-radius: 20px; background: var(--bg-subtle);
  overflow: hidden; margin: 10px 0 8px;
}
.gauge-fill { height: 100%; border-radius: 20px; background: var(--accent-gradient); transition: width .4s ease; }
.gauge-caption { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; }
.gauge-caption strong { color: var(--text-primary); }

/* ── Inline insight callouts ────────────────────────────────────────── */
/* These carry the "so what" next to a number. Toned by severity so a genuine
   problem doesn't read the same as an observation. */
.insight {
  margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; line-height: 1.6; color: var(--text-secondary);
  background: var(--accent-soft); border: 1px solid var(--accent-badge);
  border-left: 3px solid var(--accent);
}
.insight-amber { background: var(--amber-soft); border-color: var(--amber-border); border-left-color: var(--amber); }
.insight-red   { background: var(--red-soft);   border-color: var(--red-border);   border-left-color: var(--red); }
.insight code {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 4px; padding: 1px 5px; font-size: 11.5px;
}

/* ── Small stat pairs ───────────────────────────────────────────────── */
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.mini-stats > div {
  background: var(--bg-subtle); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.mini-label { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); }
.mini-value { display: block; font-size: 18px; font-weight: 800; color: var(--text-primary); margin-top: 3px; font-variant-numeric: tabular-nums; }

.section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 10px;
}

/* ── Bars ───────────────────────────────────────────────────────────── */
.bar-track { height: 6px; border-radius: 20px; background: var(--bg-subtle); overflow: hidden; min-width: 40px; }
.bar-thin  { height: 4px; margin-top: 5px; }
.bar-fill  { height: 100%; border-radius: 20px; background: var(--accent-gradient); }

.split-row  { display: grid; grid-template-columns: 1fr 90px 46px; align-items: center; gap: 10px; margin-bottom: 8px; }
.split-name { font-size: 12.5px; color: var(--text-secondary); font-weight: 600; }
.split-num  { font-size: 12.5px; text-align: right; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ── Funnel ─────────────────────────────────────────────────────────── */
.funnel-row   { display: grid; grid-template-columns: 78px 1fr 52px; align-items: center; gap: 10px; margin-bottom: 9px; }
.funnel-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.funnel-track { height: 22px; border-radius: var(--radius-sm); background: var(--bg-subtle); overflow: hidden; }
.funnel-fill  { height: 100%; border-radius: var(--radius-sm); transition: width .4s ease; min-width: 2px; }
.funnel-accent { background: var(--accent-gradient); }
.funnel-cyan   { background: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%); }
.funnel-green  { background: linear-gradient(135deg, #15803d 0%, #4ade80 100%); }
.funnel-num    { font-size: 12.5px; font-weight: 700; text-align: right; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.rate-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.rate-box {
  text-align: center; padding: 10px 8px; border-radius: var(--radius-sm);
  background: var(--bg-subtle); border: 1px solid var(--border-light);
}
.rate-red   { background: var(--red-soft);   border-color: var(--red-border); }
.rate-amber { background: var(--amber-soft); border-color: var(--amber-border); }
.rate-value { font-size: 19px; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.rate-red   .rate-value { color: var(--red); }
.rate-amber .rate-value { color: var(--amber); }
.rate-label { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); margin-top: 2px; }

/* ── Tables ─────────────────────────────────────────────────────────── */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.compact th, table.compact td { padding: 8px 12px; font-size: 12.5px; }

/* A drillable row has to look and behave clickable for pointer AND keyboard —
   these rows are the only navigation into the geo breakdown. */
.row-drill { cursor: pointer; transition: background .12s ease; }
.row-drill:hover { background: var(--accent-soft); }
.row-drill:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row-drill .chev { color: var(--text-disabled); }
.row-drill:hover .chev { color: var(--accent); }

.flag { font-size: 15px; margin-right: 7px; }
.flag-blank { color: var(--text-disabled); }

.muted-note { font-size: 11.5px; color: var(--text-muted); }
.text-amber { color: var(--amber); font-weight: 700; }
.text-red   { color: var(--red); }

/* ── Plain list rows ────────────────────────────────────────────────── */
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 12.5px;
}
.plain-list li:last-child { border-bottom: 0; }
.err-msg {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
  color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Master data tiles ──────────────────────────────────────────────── */
.master-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.master-tile {
  display: block; text-decoration: none; padding: 12px;
  background: var(--bg-subtle); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); transition: border-color .15s ease, transform .15s ease;
}
.master-tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.master-value { font-size: 20px; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.master-label { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); margin-top: 2px; }
.master-sub   { font-size: 10.5px; color: var(--text-muted); margin-top: 1px; }

/* The drill-down modal carries tables, which need more room than the default. */
#geo-modal .modal { max-width: 720px; }
#geo-modal .modal-body { max-height: 62vh; overflow-y: auto; padding: 0; }
#geo-modal table { width: 100%; }
#geo-modal .empty-state, #geo-modal .alert, #geo-modal .muted-note { margin: 20px; }

@media (prefers-reduced-motion: reduce) {
  .kpi-card, .bar-fill, .gauge-fill, .funnel-fill, .master-tile { transition: none; }
  .kpi-card:hover, .master-tile:hover { transform: none; }
}
