/* ==========================================================================
   Dandali — Nigeria Health + PM Dashboard — styles (redesign-spec.md)
   "Editorial national atlas": warm paper, deep green ink, gold accents,
   Fraunces display + Space Grotesk body + mono numerals, woven pattern
   identity. Light + dark themes via [data-theme] on <html> (set pre-paint
   by an inline script in index.html).
   ========================================================================== */

/* ---------- Tokens: light (paper atlas, default) ----------
   Also matched on any [data-theme="light"] element, not just <html>: custom
   properties inherit, so a nested element can opt back into the light palette
   while the page stays dark. js/pdf.js relies on this for its offscreen
   capture stage (#pdf-stage) — print = paper. */
:root,
[data-theme="light"] {
  --bg: #f6f1e7;
  --bg-raised: #fbf8f0;
  --card: #fffdf7;
  --ink: #12352a;
  --ink-soft: #4c6359;
  --ink-faint: #7c8f85;
  --green: #0e6b4c;
  --green-deep: #0a4d36;
  --green-soft: #3d9e78;
  --gold: #c99a2e;
  --gold-deep: #a67c1e;
  --gold-bright: #e9b94a;
  --gold-soft: #f3e2b3;
  --paper-line: #e6dcc6;
  --hairline: #efe8d8;
  --ok: #0e6b4c;
  --warn: #b7791f;
  --bad: #c0392b;
  --info: #2f6f8f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 53, 42, 0.05), 0 8px 24px rgba(18, 53, 42, 0.06);
  --shadow-lift: 0 2px 4px rgba(18, 53, 42, 0.06), 0 16px 40px rgba(18, 53, 42, 0.12);
  --header-from: #0a4d36;
  --header-to: #12352a;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --tabbar-h: 64px;
}

/* ---------- Tokens: dark (forest control room) ---------- */
[data-theme="dark"] {
  --bg: #0e1a15;
  --bg-raised: #132219;
  --card: #16241e;
  --ink: #e9efe9;
  --ink-soft: #a8b8ad;
  --ink-faint: #75897e;
  --green: #2eae7d;
  --green-deep: #3ec693;
  --green-soft: #4fc298;
  --gold: #e8b64c;
  --gold-deep: #d9a83c;
  --gold-bright: #f3c45a;
  --gold-soft: #3a2f14;
  --paper-line: #24362c;
  --hairline: #1e2e25;
  --ok: #3ec693;
  --warn: #e8b64c;
  --bad: #e27d70;
  --info: #5aa7c7;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
  --header-from: #08130e;
  --header-to: #0e1a15;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  transition: background 0.25s ease, color 0.25s ease;
}

/* Focus visibility — gold ring on every interactive element. */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- Header: wordmark + live status + theme toggle ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(135deg, var(--header-from), var(--header-to));
  color: #f3ead6;
}
.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  color: var(--gold);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.3px;
  line-height: 1.1;
}
.brand-sub {
  display: block;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: #b9c9bd;
  margin-top: 1px;
}
.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 5px 11px;
  background: rgba(255, 255, 255, 0.08);
  color: #e9efe9;
  border: 1px solid rgba(255, 255, 255, 0.18);
  white-space: nowrap;
}
.live-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ec693;
  box-shadow: 0 0 0 0 rgba(62, 198, 147, 0.5);
  animation: livePulse 2.4s ease-out infinite;
}
.live-chip.sample { color: #f3e2b3; border-color: rgba(233, 182, 76, 0.4); }
.live-chip.sample .dot { background: var(--gold); animation: none; }
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(62, 198, 147, 0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(62, 198, 147, 0); }
  100% { box-shadow: 0 0 0 0 rgba(62, 198, 147, 0); }
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #f3ead6;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 19px; height: 19px; }

/* The signature woven band — chevron rhythm in green/gold. */
.woven-band {
  height: 5px;
  background:
    repeating-linear-gradient(90deg,
      var(--gold) 0 10px,
      transparent 10px 22px,
      #2eae7d 22px 32px,
      transparent 32px 44px);
  opacity: 0.85;
}

/* ---------- Main column ---------- */
.app-main {
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 16px calc(var(--tabbar-h) + 28px);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Panel transition: cross-fade + rise on activation (reduced-motion off). */
.tab-panel.active.panel-in { animation: panelIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--ink);
}

/* ---------- Section rule (motif divider) ---------- */
.section-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 12px;
}
.section-rule::before {
  content: "";
  flex: 0 0 26px;
  height: 4px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 5px, transparent 5px 9px);
  border-radius: 2px;
}
.section-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--paper-line);
}
.section-rule span {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 17px; height: 17px; }
.btn-secondary { background: var(--green); color: #f7fbf8; box-shadow: 0 2px 6px rgba(14, 107, 76, 0.25); }
.btn-secondary:hover { background: var(--green-deep); }
.btn-ghost {
  background: transparent;
  color: var(--green);
  border: 1.5px solid var(--green);
}
.btn-ghost:hover { background: rgba(14, 107, 76, 0.07); }
[data-theme="dark"] .btn-ghost:hover { background: rgba(46, 174, 125, 0.12); }
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
/* "Small" is type scale and padding, not hit area — 44px is the floor for
   every target (dashboard-spec §5, redesign-spec R-mobile). */
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: 0.82rem; }
.btn-sm svg { width: 14px; height: 14px; }

/* ---------- Icon sprite sizing ---------- */
.pm-icon { width: 20px; height: 20px; flex: 0 0 auto; }
/* All hand-drawn glyphs are stroke-based and inherit currentColor. */
.pm-icon, .brand-mark, .card-icon, .ev-emoji,
.tab-btn svg, .icon-btn svg, .btn svg, .kpi-chip svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.card-icon {
  width: 20px;
  height: 20px;
  color: var(--green);
  margin-right: 8px;
  vertical-align: -4px;
}
.card-head .card-icon { vertical-align: -5px; }

/* ---------- Card heads ---------- */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.card-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.08rem;
  margin: 0;
  display: flex;
  align-items: center;
}
.card-tag {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* ---------- Upload zone ---------- */
.drop-zone {
  border: 2px dashed var(--green);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 22px 12px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.drop-zone.dragover { background: var(--gold-soft); border-color: var(--gold); }
.drop-hint { margin: 8px 0 0; font-size: 0.92rem; color: var(--ink-soft); }
.drop-hint strong { color: var(--green); }
.drop-zone .pm-icon { width: 26px; height: 26px; color: var(--green); }
.upload-report {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
}
.upload-report.ok { color: var(--ok); }
.upload-report.err { color: var(--bad); }

/* ---------- KPI grid ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.kpi-card {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 14px;
  position: relative;
  overflow: hidden;
  border-top: 3px solid var(--paper-line);
}
.kpi-card.accent-green { border-top-color: var(--green); }
.kpi-card.accent-gold  { border-top-color: var(--gold); }
.kpi-card.accent-teal  { border-top-color: var(--info); }
.kpi-card.accent-red   { border-top-color: var(--bad); }
.kpi-chip { position: absolute; top: 10px; right: 10px; opacity: 0.8; }
.kpi-chip svg { width: 18px; height: 18px; color: var(--ink-faint); }
.kpi-value {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}
.kpi-label { font-size: 0.74rem; color: var(--ink-faint); margin-top: 2px; letter-spacing: 0.3px; }
.kpi-context {
  font-size: 0.7rem;
  color: var(--ink-faint);
  margin-top: 4px;
  min-height: 1em;
}

/* ---------- Portfolio health bar ---------- */
.health-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--hairline);
  margin: 4px 0 10px;
}
.health-seg { height: 100%; min-width: 2px; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.health-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 8px; }
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 600;
}
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Chips + select ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--paper-line);
  background: var(--card);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.chip:hover { border-color: var(--green); color: var(--green); }
.chip:active { transform: scale(0.96); }
.chip.active {
  background: var(--green);
  border-color: var(--green);
  color: #f7fbf8;
}
.select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.select {
  flex: 1;
  min-height: 44px;
  padding: 8px 12px;
  border: 1.5px solid var(--paper-line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
}

/* ---------- Project cards + progress rings ---------- */
.project-card {
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--card);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.project-card:hover { border-color: var(--paper-line); box-shadow: var(--shadow-lift); }
.project-card:active { transform: scale(0.99); }
.project-card .card-head { margin-bottom: 0; }
.project-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.ring { position: relative; width: 58px; height: 58px; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); }
.ring-track { stroke: var(--hairline); }
.ring-fill { stroke-linecap: round; transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
}
.pc-main { flex: 1; min-width: 0; }
.pc-name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.pc-meta { font-size: 0.74rem; color: var(--ink-faint); margin-top: 2px; }
.pc-side { text-align: right; flex: 0 0 auto; }
.status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.status-pill.on-track { background: rgba(14, 107, 76, 0.12); color: var(--ok); }
.status-pill.completed { background: rgba(61, 158, 120, 0.14); color: var(--green-soft); }
.status-pill.at-risk { background: var(--gold-soft); color: var(--warn); }
.status-pill.on-hold { background: rgba(192, 57, 43, 0.1); color: var(--bad); }
.pc-budget { font-family: var(--font-mono); font-size: 0.76rem; font-weight: 600; color: var(--green); margin-top: 2px; }
.pc-expand { margin-left: 2px; color: var(--ink-faint); font-size: 0.9rem; }

/* Expanded detail */
.project-detail { display: none; padding-top: 10px; margin-top: 10px; border-top: 1px dashed var(--paper-line); }
.project-card.open .project-detail { display: block; }
.pd-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.pd-cell { background: var(--bg-raised); border-radius: 10px; padding: 8px; text-align: center; }
.pd-cell b { display: block; font-family: var(--font-mono); font-size: 0.9rem; color: var(--ink); }
.pd-cell span { font-size: 0.62rem; color: var(--ink-faint); }
.pd-finance { font-size: 0.74rem; color: var(--ink-soft); }
.pd-finance b { color: var(--ink); }
.pd-tasks { font-size: 0.72rem; color: var(--ink-soft); line-height: 1.6; }
.pd-tasks b { color: var(--ink); }

/* ---------- Charts ---------- */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap-sm { height: 190px; }
.chart-wrap-tall { height: 300px; }
.chart-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.chart-duo .card { margin-bottom: 0; }
.chart-duo .card h2 { font-size: 0.9rem; }

/* ---------- PDF capture stage (js/pdf.js) ----------
   Offscreen host for the pdfcap-* canvases the PDF report renders for itself.
   Parked off the left edge rather than display:none on purpose: a hidden
   element gets no layout, so its canvases would capture blank — that is
   exactly why the report shipped without charts for four commits.
   The stage carries data-theme="light" so the light token block above applies
   inside it and the captured charts are paper-themed regardless of the active
   UI theme. Sizes mirror CAP_SIZE in js/pdf.js (the canvas width/height
   attributes are what Chart.js actually draws at) — keep the two in step. */
#pdf-stage {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 960px;
  background: var(--card);
  pointer-events: none;
  z-index: -1;
}
#pdf-stage .pdf-stage-wrap { position: relative; width: 960px; height: 406px; }
#pdf-stage .pdf-stage-wrap.is-doughnut { width: 640px; height: 400px; }
#pdf-stage .pdf-stage-wrap.is-trends { height: 404px; }
#pdf-stage canvas { display: block; }

/* ---------- Summary ---------- */
.summary-text { margin: 0; color: var(--ink-soft); }

/* ---------- Task tracker ---------- */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
}
.task-item:last-child { border-bottom: none; }
.task-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; margin-top: 5px; }
.task-dot.done { background: var(--ok); }
.task-dot.in-progress { background: var(--warn); }
.task-dot.todo { background: var(--ink-faint); }
.task-main { flex: 1; min-width: 0; }
.task-title-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.task-title {
  flex: 1;
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-prio {
  flex: 0 0 auto;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 999px;
}
.task-prio.high { background: rgba(192, 57, 43, 0.1); color: var(--bad); }
.task-prio.medium { background: var(--gold-soft); color: var(--warn); }
.task-prio.low { background: rgba(47, 111, 143, 0.1); color: var(--info); }
.task-project {
  display: inline-block;
  font-size: 0.66rem;
  color: var(--green);
  background: rgba(14, 107, 76, 0.1);
  border-radius: 6px;
  padding: 1px 7px;
  margin-top: 3px;
  font-weight: 600;
}
.task-meta { font-size: 0.78rem; color: var(--ink-faint); }
.task-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--hairline);
  margin-top: 6px;
  overflow: hidden;
}
.task-progress i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--green-soft));
}
.task-side { text-align: right; flex: 0 0 auto; }
.task-pct { font-family: var(--font-mono); font-weight: 600; font-size: 0.84rem; color: var(--ink); }
.task-due { font-size: 0.74rem; color: var(--ink-faint); }
.task-due.overdue { color: var(--bad); font-weight: 700; }
.task-empty { color: var(--ink-soft); text-align: center; padding: 12px 0; margin: 0; }

/* ---------- Health tab ---------- */
/* ---------- Health tab (atlas) ---------- */
.source-line {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: var(--ink-soft);
  line-height: 1.5;
}
.data-badge {
  display: inline-block;
  margin: 0 0 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--warn);
  border: 1px solid rgba(201, 154, 46, 0.45);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.health-map {
  height: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--hairline);
  z-index: 1;
  position: relative;
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}
.map-hint { margin: 10px 0 0; font-size: 0.78rem; color: var(--ink-faint); line-height: 1.5; }
.map-empty {
  margin: 18px 0 0;
  text-align: center;
  font-size: 0.86rem;
  color: var(--ink-soft);
}
.list-empty {
  margin: 14px 0 0;
  text-align: center;
  font-size: 0.86rem;
  color: var(--ink-soft);
  padding: 18px 0;
}
.chart-empty {
  margin: 14px 0 0;
  text-align: center;
  font-size: 0.86rem;
  color: var(--ink-soft);
}
.indicator-list { list-style: none; margin: 10px 0 0; padding: 0; }
/* The row's own padding used to supply the visual rhythm while the <label>
   stayed text-height (~21px) — a real but tiny tap target. The padding now
   lives on the label instead, so the full-width label *is* the 44px target
   and the row height is unchanged (13+21+13 = 47 -> 44). */
.indicator-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--hairline);
}
.indicator-row:last-child { border-bottom: none; }
.indicator-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--green);
  flex: 0 0 auto;
  cursor: pointer;
}
.indicator-label {
  flex: 1;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 0;
  font-size: 0.92rem;
  color: var(--ink);
  line-height: 1.4;
  cursor: pointer;
}
/* The checkbox renders at 24px and cannot be padded up to 44 without drawing
   a giant box. Instead the label — which already toggles it via `for` —
   stretches an invisible overlay across the whole row, so the effective
   target is the full 44px row including the checkbox and the value. Keeps
   js/health.js untouched; the label click still fires exactly one change. */
.indicator-label::before {
  content: "";
  position: absolute;
  inset: 0;
}
.indicator-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--green);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.credit {
  margin: 14px 2px 6px;
  font-size: 0.68rem;
  color: var(--ink-faint);
  text-align: center;
  letter-spacing: 0.2px;
}
.health-map .leaflet-container {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg-raised);
}
/* Health KPI cards — green top band + mono numerals */
#tab-health .kpi-card {
  border-top-color: var(--green);
}
#tab-health .kpi-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}
#tab-health .kpi-label {
  font-size: 0.72rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
#tab-health .kpi-context {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
/* Section rules under the two Health chart-section headers ("Facility
   profile" and "Indicators over time") — reuse the global .section-rule
   component; the ::before/::after are already defined globally for it. */
#tab-health .section-rule { margin-top: 18px; }
/* Desktop split: map 2/3 + indicator panel 1/3 */
@media (min-width: 900px) {
  #tab-health .health-split {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
  }
  #tab-health .health-split .card { margin-bottom: 0; }
}

/* Leaflet chrome restyled to the atlas (light + dark) — same OSM tiles,
   app-layer only (no API key, per the locked Phase 2 decision). */
.health-map .leaflet-container {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg-raised);
}
/* Leaflet ships 30x30 zoom buttons; the 44px floor applies to third-party
   chrome too, so they are resized here rather than left as the one exception. */
.health-map .leaflet-control-zoom a {
  width: 44px !important;
  height: 44px !important;
  line-height: 44px !important;
  font-size: 20px !important;
  background: var(--card) !important;
  color: var(--ink) !important;
  border-color: var(--hairline) !important;
  box-shadow: var(--shadow) !important;
}
.health-map .leaflet-control-zoom a:hover {
  background: var(--bg-raised) !important;
}
.health-map .leaflet-control-attribution {
  background: rgba(255, 253, 247, 0.7) !important;
  color: var(--ink-faint) !important;
  font-size: 10px;
  backdrop-filter: blur(2px);
}
[data-theme="dark"] .health-map .leaflet-control-attribution {
  background: rgba(22, 36, 30, 0.75) !important;
}
.health-map .leaflet-popup-content-wrapper {
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  border: 1px solid var(--hairline);
}
.health-map .leaflet-popup-tip {
  background: var(--card);
  border: 1px solid var(--hairline);
}
.health-map .leaflet-popup-close-button {
  color: var(--ink-faint) !important;
}
/* Bespoke HTML legend for the Health indicator trend chart (redesign-spec §4.6).
   Two dots: DPT3 = green, Malaria = bright gold with a dark outline. Placed
   directly under the trend canvas so the legend hue matches the in-chart dots and
   lines exactly, with no Chart.js auto-swatch ambiguity. */
.hl-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--paper-line);
}
.hl-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.hl-dot {
  flex: 0 0 auto;
  box-sizing: border-box;
}
.hl-label {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.3;
  white-space: nowrap;
}

/* Atlas tooltip for the state aggregate circles — paper card, gold rule,
   mono numerals, Space Grotesk labels (redesign-spec §4.6 tooltip accent). */
.atlas-tooltip {
  background: var(--card) !important;
  color: var(--ink) !important;
  border: 1px solid var(--hairline) !important;
  border-left: 3px solid var(--gold) !important;
  border-radius: 8px !important;
  padding: 8px 11px !important;
  box-shadow: var(--shadow-lift) !important;
  backdrop-filter: blur(4px);
  font-family: var(--font-body);
  font-size: 0.78rem;
  line-height: 1.35;
}
.atlas-tooltip .mt-state {
  display: block;
  font-weight: 600;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 0.74rem;
}
.atlas-tooltip .mt-count {
  display: inline;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--green);
  margin-right: 1px;
}
.atlas-tooltip .mt-unit {
  display: inline;
  color: var(--ink-faint);
}
[data-theme="dark"] .atlas-tooltip {
  background: var(--card) !important;
  border-left-color: var(--gold) !important;
}
#tab-health .card-head {
  margin-bottom: 6px;
}
#tab-health .card-head + p.map-hint,
#tab-health .card-head + p,
#tab-health .card-head + ul,
#tab-health .card-head + .chart-wrap,
#tab-health .health-split .card-head + p,
#tab-health .health-split .card-head + ul {
  margin-top: 0;
}
#tab-health h2 {
  font-size: 1.1rem;
}
/* Health charts inherit atlas chrome from the global chart-wrap; the
   doughnut/trend get the same mono ticks + gold-accent tooltips via
   PMCharts (redesign-spec §4.6).

   The 'tall' wrapper holds two children: the trend canvas and the bespoke
   HTML legend that renderHealthLegend() appends alongside it. It used to be
   a flat `height: 280px`, sized for the canvas alone — so the legend painted
   outside its parent's box and reserved no space. On desktop the legend is
   one line and the slack hid it; at 375px it wraps to two and overprinted
   the source-credit paragraph below the card (dashboard-spec §9.2).

   Fixed here rather than in renderHealthLegend(), which is the protected
   legend path (redesign-spec §4.6 lessons-learned).

   The wrapper reserves a padding band for the legend and the legend is
   absolutely positioned into it, so the wrapper's *content* box stays
   exactly 280px. That matters: Chart.js sizes its backing store from the
   canvas's parent, so anything that lets the parent grow (a column flex
   with an auto height, say) makes it allocate a 344px surface and squash it
   into a 280px box — the chart renders ~19% compressed and pointer
   hit-testing drifts by the same amount. Verified by asserting
   canvas.height === canvasCssHeight * devicePixelRatio.

   The band fits the two-line wrap the two-series legend reaches at 375px
   (59px measured). A third series would need a taller band. */
#tab-health .chart-wrap-tall {
  --hl-band: 64px;
  height: calc(280px + var(--hl-band));
  padding-bottom: var(--hl-band);
}
#tab-health .chart-wrap-tall > .hl-legend {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - var(--hl-band));
  margin-top: 0;
}

/* ---------- Showcase: hero art moment ---------- */
.show-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--paper-line);
  background:
    repeating-linear-gradient(-12deg,
      rgba(201, 154, 46, 0.05) 0 18px,
      transparent 18px 44px),
    var(--card);
}
.show-hero::before {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 150px;
  height: 150px;
  opacity: 0.06;
  background: radial-gradient(circle, var(--gold) 0 12%, transparent 13%);
  background-size: 26px 26px;
  pointer-events: none;
}
.show-eyebrow {
  position: relative;
  margin: 0 0 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.show-h1 {
  position: relative;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.18;
  margin: 0 0 10px;
  letter-spacing: 0.2px;
}
.show-blurb { position: relative; margin: 0 0 14px; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.55; }
.show-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.show-stat {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.show-stat .kpi-value { display: block; font-size: 1.2rem; }
.show-stat .kpi-label { display: block; margin-top: 2px; font-size: 0.6rem; line-height: 1.3; letter-spacing: 0.2px; }
.show-email-line { position: relative; margin: 10px 0 0; font-size: 0.8rem; color: var(--ink-faint); }
.show-email { font-weight: 600; color: var(--green); word-break: break-all; }

/* Evidence cards */
.show-evidence { display: flex; flex-direction: column; gap: 10px; }
.ev-card {
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 12px;
  background: var(--card);
}
.ev-underline { background: var(--bg-raised); }
.ev-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.ev-emoji { width: 26px; height: 26px; color: var(--green); flex: 0 0 auto; margin-top: 1px; }
.ev-title { font-weight: 600; font-size: 0.98rem; line-height: 1.3; }
.ev-desc { margin: 0 0 8px; color: var(--ink-soft); font-size: 0.85rem; line-height: 1.5; }
.ev-list { margin: 0 0 10px; padding-left: 18px; color: var(--ink-soft); font-size: 0.85rem; line-height: 1.6; }
.ev-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.skill-tag {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--green);
  background: rgba(14, 107, 76, 0.1);
  border-radius: 999px;
  padding: 3px 9px;
}
.coming-next {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--warn);
  background: var(--gold-soft);
  border: 1px solid rgba(201, 154, 46, 0.45);
  border-radius: 999px;
  padding: 5px 12px;
}
.try-it { width: auto; }

/* Toolchain chips */
.show-subhead { margin: 0 0 8px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink-faint); }
.show-subhead.adjacent { margin-top: 14px; }
.show-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-chip {
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 6px 13px;
}
.tool-chip.proven { background: rgba(14, 107, 76, 0.1); color: var(--green); border: 1px solid rgba(14, 107, 76, 0.25); }
.tool-chip.adjacent { background: var(--bg-raised); color: var(--ink-soft); border: 1px solid var(--hairline); }

/* CTA footer */
.show-cta { text-align: center; }
.show-cta .show-blurb { margin-bottom: 4px; }

/* ---------- Ask tab (atlas) ---------- */
#tab-ask .section-rule { margin-top: 18px; }
.ask-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ask-input-col { display: flex; flex-direction: column; gap: 10px; }
.ask-chip-col { display: flex; flex-direction: column; gap: 12px; }
.nlq-form { display: flex; gap: 8px; }
.nlq-input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--paper-line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.nlq-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(14, 107, 76, 0.15); }
[data-theme="dark"] .nlq-input:focus { box-shadow: 0 0 0 3px rgba(46, 174, 125, 0.2); }
.nlq-answer {
  margin: 0;
  border-radius: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--gold);
  padding: 12px;
  font-size: 0.9rem;
  color: var(--ink);
}
.nlq-answer:empty { display: none; }
.nlq-reply { margin: 0 0 6px; line-height: 1.55; color: var(--ink); }
.nlq-reply b, .nlq-reply strong { color: var(--green); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.nlq-list { margin: 2px 0 0; padding-left: 18px; }
.nlq-list li { margin: 4px 0; font-size: 0.86rem; color: var(--ink-soft); line-height: 1.5; }
.nlq-list li b, .nlq-list li strong { color: var(--green); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.nlq-open { margin-top: 10px; }
.nlq-hint { margin: 0 0 8px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink-faint); }
.ask-how { margin-top: 4px; }
.ask-how h2 { font-size: 1rem; }
.ask-how .summary-text { color: var(--ink-soft); font-size: 0.88rem; line-height: 1.55; }
/* Desktop Ask split: input + answer left, chips + how-it-works right */
@media (min-width: 900px) {
  .ask-wrap { flex-direction: row; align-items: flex-start; gap: 18px; }
  .ask-input-col { flex: 1 1 55%; min-width: 0; }
  .ask-chip-col { flex: 1 1 45%; min-width: 0; }
  .ask-chip-col .nlq-hint { margin-top: 0; }
}

/* ---------- Export tab (atlas) ---------- */
#tab-export .section-rule { margin-top: 18px; }
.export-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.export-card { padding: 16px; }
.export-card h2 { font-size: 1.08rem; }
.export-card .summary-text { color: var(--ink-soft); font-size: 0.88rem; line-height: 1.55; margin: 6px 0 12px; }
.export-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.export-status {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  min-height: 1em;
}
.export-status.ok { color: var(--ok); }
.export-status.err { color: var(--bad); }
.export-deferred { background: var(--bg-raised); }
.export-deferred .coming-next { margin-top: 4px; display: inline-block; }
@media (min-width: 600px) {
  .export-grid { flex-direction: row; flex-wrap: wrap; }
  .export-card { flex: 1 1 280px; min-width: 0; margin-bottom: 0; }
  .export-deferred { flex: 1 1 100%; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-lift);
  max-width: 90vw;
  text-align: center;
  z-index: 30;
  border-left: 3px solid var(--gold);
  animation: toastIn 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Bottom tab bar ---------- */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--paper-line);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  background: none;
  border: none;
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
  position: relative;
}
.tab-btn svg { width: 22px; height: 22px; transition: transform 0.15s ease; }
.tab-btn:active svg { transform: scale(0.9); }
.tab-btn.active { color: var(--green); }
.tab-btn.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--gold);
}

/* ---------- Reveal-on-load motion ---------- */
.reveal-1, .reveal-2, .reveal-3 {
  animation: cardReveal 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.reveal-2 { animation-delay: 0.06s; }
.reveal-3 { animation-delay: 0.12s; }
@keyframes cardReveal {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Reduced motion: kill all animation ---------- */
@media (prefers-reduced-motion: reduce) {
  .reveal-1, .reveal-2, .reveal-3, .tab-panel.active.panel-in { animation: none; }
  .ring-track .ring-fill { transition: none !important; }
  .live-chip .dot { animation: none; }
  .toast { animation: none; }
}

/* ---------- Hidden helper ---------- */
.hidden { display: none !important; }

/* ---------- Desktop: multi-column atlas (spec §4.5) ---------- */
@media (min-width: 600px) {
  .app-main { max-width: 720px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 900px) {
  .app-main { max-width: 1200px; }

  /* Projects: KPI row → two-column chart band → two-column charts → tracker */
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .project-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .project-card { margin-bottom: 0; }
  .chart-band {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .chart-band .card { margin-bottom: 0; }
  .chart-duo { grid-template-columns: 1fr 1fr; }

  /* Showcase: hero full width, evidence 2-col, radar + toolchain side by side */
  .show-evidence { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .ev-card { margin: 0; }
  .show-hero { padding: 28px; }
  .show-h1 { font-size: 2.1rem; max-width: 16em; }
  .show-stats { max-width: 420px; }
  .toolchain-band {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .toolchain-band .card { margin-bottom: 0; }

  /* Health: map 2/3 + side panel 1/3 */
  .health-split {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
  }
  .health-split .card { margin-bottom: 0; }

  /* Ask: input + chips left, answer right */
  .ask-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
  }
  .ask-split .card { margin-bottom: 0; }
}

/* ---------- Print: always the light 'paper' theme ---------- */
@media print {
  body { background: #fffdf7; color: #12352a; }
  .tab-bar, .app-header, .toast { display: none !important; }
  .card { box-shadow: none; border-color: #e6dcc6; }
}