/* GrowHealth Dashboard — prototype styles
   Tone: Thai community public health (green), light mode only.
   Colors are role tokens defined once here. */

:root {
  color-scheme: light;
  --page: #f2f6fa;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #10202f;
  --ink-2: #475766;
  --muted: #7a8794;
  --grid: #e1e8ef;
  --axis: #c3cdd8;
  --border: rgba(14, 46, 80, 0.12);
  --shadow: 0 1px 2px rgba(14, 46, 80, 0.04), 0 8px 24px rgba(14, 46, 80, 0.06);

  /* brand: public-health green with a gold accent */
  --accent: #1c6bb0;
  --accent-wash: #e3eefa;
  --accent-ink: #124f86;
  --gold: #c9971c;
  --side-bg: #0e3a63;
  --side-ink: #e6f0fa;
  --side-muted: #9fbad6;

  /* categorical series (fixed order, validated) */
  --s-temp: #2a78d6;
  --s-spo2: #eb6834;
  --s-bp: #1baf7a;
  --s-full: #eda100;
  --s-ecg: #c2417a;
  --s-glucose: #8a5a00;
  --s-body: #2a7f86;
  --s-dia: #4a3aa7;

  /* status (reserved; always shown with icon + label) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-wash: #e6f5e6;
  --warning-wash: #fdf3d9;
  --serious-wash: #fcebe4;
  --critical-wash: #f9e3e3;
  --delta-good: #006300;
  --delta-bad: #a82a2a;

  --radius: 14px;
  --radius-sm: 8px;
  --font: 'IBM Plex Sans Thai Looped', 'Leelawadee UI', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px;
  background: var(--side-bg);
  color: var(--side-ink);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: #fff; color: var(--accent);
}
.brand-name { font-weight: 600; font-size: 16px; line-height: 1.2; color: #fff; }
.brand-sub { font-size: 12px; color: var(--side-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; color: var(--side-muted); padding: 0 10px 6px; letter-spacing: 0.04em; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--side-ink); font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, 0.16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav a svg { flex: none; }
.nav .count {
  margin-left: auto; font-size: 12px; padding: 0 7px; border-radius: 999px;
  background: var(--critical-wash); color: var(--ink);
}
.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--side-muted); padding: 0 10px; }
.sidebar-foot .org { color: #fff; font-weight: 500; font-size: 13px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.14); }
.sidebar-foot .org span { display: block; font-weight: 400; font-size: 12px; color: var(--side-muted); }
.live { display: flex; align-items: center; gap: 8px; color: var(--side-ink); margin-bottom: 6px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #6fe3a6; box-shadow: 0 0 0 4px rgba(111, 227, 166, 0.22); }

.main { min-width: 0; padding: 22px 28px 48px; }
.topbar { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; font-weight: 600; line-height: 1.3; }
.topbar .sub { color: var(--ink-2); font-size: 13px; }
.topbar .actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.proto-tag {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--ink-2); background: var(--surface);
}

/* ---------- Hero banner ---------- */
.hero {
  position: relative; overflow: hidden; display: flex; align-items: center;
  min-height: 220px; margin-bottom: 18px;
  border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow);
  background: linear-gradient(110deg, #f5f9fd 0%, #e6eff9 100%);
}
.hero-art {
  position: absolute; top: 0; right: 0; bottom: 0; aspect-ratio: 2 / 1;
  background: url(../img/hero.jpg) right center / cover no-repeat;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 38%);
  mask-image: linear-gradient(90deg, transparent 0, #000 38%);
}
.hero-body { position: relative; padding: 26px 30px; max-width: 660px; }
.hero .org { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--accent-ink); }
.hero .org i { width: 18px; height: 3px; border-radius: 2px; background: var(--gold); }
.hero h2 { font-size: 26px; font-weight: 600; line-height: 1.35; margin: 6px 0; }
.hero p { color: var(--ink-2); margin-bottom: 16px; }
.hero p b { color: var(--ink); font-weight: 600; }
.btn.primary { display: inline-flex; align-items: center; background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--accent-ink); }

/* ---------- Illustrations ---------- */
.thumb { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; flex: none; background: var(--accent-wash); }
.thumb.sm { width: 30px; height: 30px; border-radius: 8px; }
.thumb.lg { width: 58px; height: 58px; border-radius: 14px; }
.banner { display: block; width: 100%; height: 180px; object-fit: cover; border-radius: 10px; margin-bottom: 16px; }

/* ---------- Forms ---------- */
.form-field { display: grid; gap: 6px; margin-bottom: 14px; }
.form-field span { font-size: 13.5px; color: var(--ink-2); font-weight: 500; }
.form-field .field { width: 100%; }
select.field { padding-right: 8px; }
.field.small { height: 32px; font-size: 13px; border-radius: 8px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form .field { flex: 1; min-width: 120px; }
td .inline-form .field { max-width: 150px; }
a.btn { display: inline-flex; align-items: center; }
.btn.block { display: flex; justify-content: center; width: 100%; }
.inline-form.rename { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.form-error, .form-ok { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.form-error { background: var(--critical-wash); color: var(--delta-bad); }
.form-ok { background: var(--good-wash); color: var(--delta-good); }
.btn.danger { color: var(--delta-bad); }
.btn.danger:hover { background: var(--critical-wash); }
.user-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--ink-2); }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row pre.code { flex: 1; white-space: pre-wrap; word-break: break-all; }
.copy-row .btn { height: auto; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.seg button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 7px;
  cursor: pointer; color: var(--ink-2); font-weight: 500;
}
.seg button[aria-pressed='true'] { background: var(--accent-wash); color: var(--accent-ink); }
.field {
  height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); min-width: 0;
}
.field:focus-visible, .seg button:focus-visible, .icon-btn:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input.field { width: 280px; max-width: 100%; }
.filters .spacer { flex: 1; }
.btn {
  height: 38px; padding: 0 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); margin-bottom: 16px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; min-width: 0;
}
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-head .hint { font-size: 12.5px; color: var(--ink-2); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 18px 20px 0; }

/* ---------- KPI tiles ---------- */
.kpi .label { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kpi .label .ico {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-wash); color: var(--accent-ink);
}
.kpi .value { font-size: 32px; font-weight: 600; line-height: 1.2; margin-top: 10px; }
.kpi .value small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.kpi .foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 6px; }
.delta { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.delta b { font-weight: 600; }
.delta.good b { color: var(--delta-good); }
.delta.bad b { color: var(--delta-bad); }
.spark { width: 96px; height: 30px; flex: none; }

/* ---------- Status chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px 2px 7px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap; color: var(--ink);
}
.chip svg { flex: none; }
.chip.good { background: var(--good-wash); }
.chip.warning { background: var(--warning-wash); }
.chip.serious { background: var(--serious-wash); }
.chip.critical { background: var(--critical-wash); }
.chip.none { background: var(--surface-2); color: var(--ink-2); }
/* how a person without an ID card was identified */
.id-tag { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; padding: 1px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.id-tag svg { flex: none; }
.id-tag.vouched { background: var(--accent-wash); color: var(--accent-ink); }
.id-tag.anonymous { background: var(--surface-2); color: var(--ink-2); }
.chip.good svg { color: var(--good); }
.chip.warning svg { color: var(--warning); }
.chip.serious svg { color: var(--serious); }
.chip.critical svg { color: var(--critical); }
.type-tag { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.type-tag i { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ---------- Charts ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--font); font-size: 11.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart text.end-label { fill: var(--ink-2); font-size: 12px; font-weight: 500; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart text.threshold-label { fill: var(--ink-2); paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.chart .threshold { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .hit { fill: transparent; }
.chart .hover-band { fill: var(--ink); opacity: 0; }
.chart .hit:hover + .hover-band, .chart .hover-band.on { opacity: 0.05; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
  padding: 9px 12px; font-size: 12.5px; min-width: 150px; display: none;
}
.tooltip .tt-title { font-weight: 600; margin-bottom: 5px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.tooltip .tt-row i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.tooltip .tt-row b { margin-left: auto; padding-left: 14px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .tt-total { border-top: 1px solid var(--border); margin-top: 5px; padding-top: 5px; }

.dist-row { margin-bottom: 16px; }
.dist-row:last-child { margin-bottom: 0; }
.dist-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 8px; }
.dist-top b { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; }
.dist-top span { color: var(--muted); }
.dist-bar { display: flex; gap: 2px; height: 12px; }
.dist-bar i { display: block; border-radius: 3px; min-width: 3px; }
.dist-bar i.good { background: var(--good); }
.dist-bar i.warning { background: var(--warning); }
.dist-bar i.serious { background: var(--serious); }
.dist-bar i.critical { background: var(--critical); }
.dist-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-top: 7px; }
.dist-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dist-legend svg { flex: none; }
.dist-legend .good svg { color: var(--good); }
.dist-legend .warning svg { color: var(--warning); }
.dist-legend .serious svg { color: var(--serious); }
.dist-legend .critical svg { color: var(--critical); }
.dist-legend b { color: var(--ink); font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; white-space: nowrap; }
th { font-size: 12px; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sub, .sub { color: var(--muted); font-size: 12.5px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); color: var(--ink-2); font-size: 13px; }
.pager .spacer { flex: 1; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; }

/* ---------- Attention list ---------- */
.alert-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.alert-item:last-child { border-bottom: 0; padding-bottom: 0; }
.alert-item:first-child { padding-top: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
  background: var(--accent-wash); color: var(--accent-ink);
}
.avatar.lg { width: 76px; height: 76px; font-size: 24px; }
img.avatar { display: block; object-fit: cover; object-position: center top; border: 1px solid var(--border); }
.person-row .avatar, .alert-item .avatar { width: 42px; height: 42px; }
.alert-item .who { min-width: 0; flex: 1; }
.alert-item .who .sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-item .who b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-item .chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 30; display: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); z-index: 31;
  background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform 0.2s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
/* the same panel as a window in the middle of the page (the detail of a result) */
.drawer.modal {
  top: 50%; left: 50%; right: auto; bottom: auto; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  transform: translate(-50%, -48%); opacity: 0; visibility: hidden; transition: transform 0.18s ease, opacity 0.18s ease, visibility 0.18s;
}
.drawer.modal.wide { width: min(1060px, calc(100vw - 32px)); }
.drawer.modal.open { transform: translate(-50%, -50%); opacity: 1; visibility: visible; }
/* with body circumferences: the picture of the body in a column of its own on the right */
.girth-side { margin-top: 4px; }
@media (min-width: 900px) {
  .drawer.modal .drawer-body.has-girths { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 470px); column-gap: 28px; align-content: start; }
  .drawer.modal .drawer-body.has-girths > * { grid-column: 1; }
  .drawer.modal .drawer-body.has-girths > .girth-side { grid-column: 2; grid-row: 1 / span 40; align-self: start; position: sticky; top: 0; margin-top: 0; }
  .drawer.modal .drawer-body.has-girths > .girth-side .section-title { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) { .drawer.modal { transition: none; } }
.girth-figure { display: grid; grid-template-columns: 1fr 150px 1fr; gap: 10px; align-items: center; }
.girth-col { display: grid; gap: 8px; }
.girth-box { display: grid; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; }
.girth-box span { font-size: 12px; color: var(--muted); }
.girth-box b { font-size: 15px; }
.girth-box.girth-empty b { font-weight: 400; color: var(--muted); }
.girth-body { position: relative; width: 150px; aspect-ratio: 387 / 1000; background: #fff; border-radius: 10px; }
.girth-body img { display: block; width: 100%; height: 100%; object-fit: contain; }
.girth-body svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.girth-body ellipse { fill: none; stroke: var(--accent); stroke-width: 7; }
.girth-whr { margin: 14px 0 0; text-align: center; }
.girth-inline { max-width: 560px; }
.girth-inline + .girth-whr { max-width: 560px; }
@media (max-width: 480px) { .girth-figure { grid-template-columns: 1fr 110px 1fr; gap: 6px; } .girth-body { width: 110px; } }
.drawer.open + .drawer-backdrop, .drawer-backdrop.open { display: block; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 16px; font-weight: 600; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-body { padding: 18px 20px 28px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin-bottom: 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.section-title { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; margin: 18px 0 8px; }
pre.code {
  margin: 0; padding: 14px; border-radius: 10px; overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; line-height: 1.55;
}
.vitals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.vital { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.vital > div { min-width: 0; flex: 1; }
.vital .v-label { color: var(--ink-2); font-size: 12.5px; }
.vital .v-label small { color: var(--muted); font-size: 12px; }
.vital .v-value { font-size: 24px; font-weight: 600; line-height: 1.3; }
.vital .v-value small { font-size: 12.5px; font-weight: 400; color: var(--muted); margin-left: 4px; }

/* ---------- People page ---------- */
.split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.people-list { max-height: calc(100vh - 150px); overflow-y: auto; }
.person-row { display: flex; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.person-row:last-child { border-bottom: 0; }
.person-row:hover { background: var(--surface-2); }
.person-row.active { background: var(--accent-wash); }
.person-row .who { min-width: 0; flex: 1; }
.person-row .who b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.person-head h2 { font-size: 19px; font-weight: 600; }
.person-head .meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--ink-2); font-size: 13px; }
.person-head .right { margin-left: auto; }
.grid.vit4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.qa { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.qa:last-child { border-bottom: 0; }
.qa span { color: var(--ink-2); }
.qa b { font-weight: 500; white-space: nowrap; }
.stack { display: grid; gap: 16px; }

/* ---------- Map ---------- */
.grid.map-layout { grid-template-columns: minmax(0, 1.9fr) minmax(280px, 1fr); align-items: start; }
.map { height: 660px; background: var(--surface-2); z-index: 0; }
.leaflet-container { font-family: var(--font); font-size: 13px; }
/* mute the basemap so the data points carry the colour */
.leaflet-tile-pane .basemap { filter: grayscale(0.8) brightness(1.05) contrast(0.92); }
.site-pin { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: #fff; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
.map-pop { display: grid; gap: 5px; min-width: 190px; }
.map-pop b { font-weight: 600; font-size: 14px; }
.map-pop a { color: var(--accent); text-decoration: underline; }
.legend-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.legend-row .dot { border-radius: 50%; flex: none; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--border); }
.legend-row .swatch { width: 22px; height: 14px; border-radius: 4px; flex: none; }
.legend-row b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend-row .sub { min-width: 34px; text-align: right; }
.hot { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.hot:last-child { border-bottom: 0; padding-bottom: 0; }
.hot:first-child { padding-top: 0; }
.hot:hover .where b { color: var(--accent); }
.hot .rank { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; font-size: 13px; }
.hot .where { flex: 1; min-width: 0; display: grid; gap: 2px; }
.hot .where b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hot .meter { height: 6px; border-radius: 3px; background: var(--critical-wash); margin-top: 4px; }
.hot .meter i { display: block; height: 100%; border-radius: 3px; background: var(--critical); }
.hot .count { text-align: right; flex: none; display: grid; }
.hot .count b { font-size: 18px; font-weight: 600; line-height: 1.2; }

/* ---------- Devices ---------- */
.device-card .d-top { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.device-card .d-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent-ink); }
.device-card h3 { font-size: 15px; font-weight: 600; }
.device-card .kv { grid-template-columns: 110px 1fr; margin-bottom: 0; }
.steps { margin: 0; padding-left: 20px; color: var(--ink-2); }
.steps li { margin-bottom: 6px; }
.steps code, p code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; color: var(--ink); }
.note { font-size: 13px; color: var(--ink-2); }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--warning-wash); font-size: 13px; margin-top: 14px; }
.callout svg { flex: none; color: var(--warning); margin-top: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .grid.three, .grid.map-layout { grid-template-columns: minmax(0, 1fr); }
  .map { height: 480px; }
  .grid.vit4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .nav { flex-direction: row; }
  .nav-label, .sidebar-foot, .brand-sub, .nav .count { display: none; }
  .nav a.active { box-shadow: inset 0 -3px 0 var(--gold); }
  .hero-art { opacity: 0.35; }
  .nav a span { display: none; }
  .main { padding: 16px; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .people-list { max-height: 280px; }
}
@media (max-width: 560px) {
  .grid.kpis, .grid.vit4 { grid-template-columns: minmax(0, 1fr); }
  input.field { width: 100%; }
}

/* ECG in the record details */
.ecg-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; font-size: 14px; }
.ecg-stat span { color: var(--muted); margin-right: 6px; }
.ecg-strip { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: #fffafa; cursor: zoom-in; }
.ecg-strip canvas { display: block; }
.ecg-note { margin-top: 6px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.ecg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 10px; }
.ecg-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.ecg-actions .ecg-note { margin: 0; flex: 1; min-width: 200px; }

/* examiner performance: months as a heat table */
table.perf th, table.perf td { white-space: nowrap; }
table.perf td.heat { min-width: 44px; border-radius: 0; }
table.perf td.future { color: var(--muted); }
table.perf tr.idle td { color: var(--muted); }
table.perf tfoot th { border-top: 1px solid var(--border); font-weight: 600; }
.perf-name { font-weight: 500; }
.perf-badge { display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 500; background: var(--accent-wash); color: var(--accent-ink); vertical-align: middle; }
/* period, links into the list, and the list itself */
.range-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.range-field .field { width: auto; }
a.kpi-link { color: inherit; text-decoration: none; transition: box-shadow .15s; }
a.kpi-link:hover { box-shadow: 0 0 0 2px var(--accent-wash); }
.kpi .hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
table.perf td.heat a { color: inherit; text-decoration: none; display: block; }
table.perf td.heat a:hover { text-decoration: underline; }
table.perf td.heat.on { outline: 2px solid var(--accent-ink); outline-offset: -2px; }
table.perf a.perf-name { color: inherit; text-decoration: none; }
table.perf a.perf-name:hover, table.perf td.num > a:hover, table.perf tfoot a:hover { text-decoration: underline; }
table.perf td.num > a, table.perf tfoot a { color: inherit; text-decoration: none; }
table.perf-list tr.perf-more > td { background: var(--surface-2); padding: 12px 18px 16px; }
.perf-detail .kv { margin-bottom: 8px; }
.perf-detail .qa { max-width: 560px; }

/* values read from photos of device screens */
.photo-mark { display: inline-flex; vertical-align: middle; margin-left: 4px; color: var(--accent-ink); }
.sources { display: grid; gap: 12px; margin-bottom: 18px; }
.source { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: start; }
.source img, .source .no-photo { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.source .no-photo { display: grid; place-items: center; color: var(--muted); font-size: 12.5px; }
.source .chip { margin-top: 4px; }

/* full-screen ECG */
.ecg-viewer { position: fixed; inset: 0; z-index: 60; display: none; flex-direction: column; gap: 10px; padding: 16px 20px; background: var(--surface); overflow: hidden; }
.ecg-viewer.open { display: flex; }
.ecg-viewer-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.ecg-viewer-title { flex: 1; min-width: 220px; }
.ecg-viewer-title h2 { font-size: 18px; font-weight: 600; }
.ecg-viewer-title .sub { color: var(--muted); font-size: 13.5px; }
.ecg-viewer-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ecg-viewer-tools label { font-size: 13px; color: var(--muted); }
.ecg-viewer-tools .seg button { padding: 5px 10px; font-size: 13px; }
.ecg-viewer .ecg-stats { margin: 0; }
.ecg-viewer-body { flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: #fffafa; }
.ecg-viewer-body canvas { display: block; }
.ecg-viewer .ecg-note { margin: 0; }
body.ecg-open { overflow: hidden; }

/* staff register */
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.stack { display: grid; gap: 16px; }

/* menu: more entries than a short screen can show */
.sidebar .nav { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.nav a .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--gold); color: #1c1503; font-size: 12px; font-weight: 600; text-align: center; }

/* follow-up notes */
.timeline-item { padding: 12px 0; border-top: 1px solid var(--border); }
.timeline-item:first-of-type { border-top: 0; padding-top: 0; }
.timeline-item .t-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.timeline-item .t-head span { color: var(--muted); }
.timeline-item .t-body { margin-top: 4px; line-height: 1.6; }
.seg .seg-link { display: inline-flex; align-items: center; padding: 0 14px; height: 100%; border-radius: inherit; }
.seg .seg-link[aria-pressed="true"] { background: var(--accent-wash, #e3eefa); color: var(--accent-ink, #0e3a63); font-weight: 600; }
textarea.field { resize: vertical; font: inherit; }

/* printing a report: the page content only */
@media print {
  .sidebar, .topbar .actions, .no-print, .drawer, .drawer-backdrop { display: none !important; }
  /* with the ECG view open, print only the graph */
  body.ecg-open > *:not(.ecg-viewer) { display: none !important; }
  body.ecg-open .ecg-viewer { position: static; display: block; padding: 0; overflow: visible; }
  body.ecg-open .ecg-viewer-body { overflow: visible; border: 0; margin: 8px 0; }
  body.ecg-open .ecg-viewer-body canvas { max-width: 100%; height: auto !important; }
  .shell { display: block; }
  .main { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  .table-wrap { overflow: visible; }
  table { font-size: 10.5px; width: 100%; }
  th, td { white-space: normal !important; padding: 5px 6px !important; }
  .grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* reports are wide: print them across the page */
@page { size: A4 landscape; margin: 10mm; }

/* device card: name, unit and the option below them */
.inline-form.rename { flex-wrap: wrap; }
.inline-form.rename .check { flex: 1 0 100%; color: var(--muted); }

/* 43-file export */
.grid.kpis.f43-files { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.f43-notes { margin: 0 0 12px; padding-left: 20px; color: var(--ink-2); font-size: 13.5px; display: grid; gap: 4px; }
.f43-notes:empty { display: none; }
.f43-count { margin: 0 0 14px; color: var(--ink-2); }
.f43-count b { font-size: 24px; font-weight: 600; color: var(--ink); }
.f43-staff .field { width: 100%; min-width: 130px; }
@media (max-width: 1100px) { .grid.kpis.f43-files { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* map: several results at one place on the screen, shown as their number */
.cluster-pin {
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 700; font-size: 13.5px; line-height: 1;
  border: 2px solid #fff; cursor: pointer;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 30%, transparent), 0 1px 4px rgba(0, 0, 0, .25);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
}

/* app versions */
.release { padding: 14px 0; border-top: 1px solid var(--border); }
.release:first-of-type { border-top: 0; padding-top: 0; }
.release-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.release-head b { font-size: 17px; }
.meter-bar { height: 8px; border-radius: 4px; background: var(--accent-wash); margin-bottom: 8px; overflow: hidden; }
.meter-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.meter-bar[hidden] { display: none; }

/* announcements */
.announce { padding: 16px 0; border-top: 1px solid var(--border); }
.announce:first-of-type { border-top: 0; padding-top: 0; }
.announce-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.announce-top h3 { margin: 0 0 2px; font-size: 17px; font-weight: 600; }
.announce-chips { display: flex; gap: 6px; flex: none; }
.announce-body { margin: 10px 0; font-size: 14.5px; line-height: 1.65; color: var(--ink); overflow-wrap: anywhere; }
.announce-body p { margin: 0 0 8px; }
.announce-body h3 { margin: 12px 0 6px; font-size: 15.5px; font-weight: 600; }
.announce-body ul, .announce-body ol { margin: 0 0 8px; padding-left: 22px; }
.announce-body a { color: var(--accent); text-decoration: underline; }
.announce-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.announce-read { display: grid; gap: 4px; min-width: 260px; color: var(--ink-2); font-size: 13.5px; text-decoration: none; }
.announce-read .meter-bar { margin: 0; }
.announce-sub { font-weight: 600; margin-bottom: 8px; }
.announce-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14.5px; }
.announce-people .hint { display: block; }
.editor { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.editor-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.editor-bar button { font: inherit; font-size: 13px; min-width: 32px; padding: 5px 9px; border: 1px solid transparent; border-radius: 7px; background: none; color: var(--ink); cursor: pointer; }
.editor-bar button:hover { background: var(--surface); border-color: var(--border); }
.editor-body { min-height: 190px; max-height: 420px; overflow-y: auto; margin: 0; padding: 12px 14px; outline: none; }

/* map: the results behind a group that cannot be split by zooming */
.map-pop-head { display: grid; gap: 2px; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.map-pop-list .map-pop { padding: 8px 0; border-bottom: 1px solid var(--border); }
.map-pop-list .map-pop:last-child { border-bottom: 0; padding-bottom: 0; }

/* overview: who was screened, by identity, sex and age */
.who-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.who-col h3 { margin: 0 0 10px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.who-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 44px 40px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13.5px; }
.who-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.who-bar i { display: block; height: 100%; border-radius: 5px; min-width: 2px; }
.who-row b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.who-row .sub { text-align: right; }
@media (max-width: 1100px) { .who-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; } }

/* watching individuals: three readings in a row, and long addresses */
.watch-name { font-weight: 600; }
a.watch-name[href]:hover { text-decoration: underline; }
.watch-steps { display: flex; align-items: center; gap: 8px; }
.watch-steps > i { font-style: normal; color: var(--muted); }
.watch-step { display: grid; gap: 1px; padding: 4px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.watch-step b { font-weight: 600; font-variant-numeric: tabular-nums; }
.watch-step small { font-size: 11.5px; color: var(--muted); }
.watch-step.last { background: var(--warning-wash); }
table.watch td.watch-addr { white-space: normal; min-width: 180px; max-width: 280px; }

/* monthly report: the written summary, and the sheet the PDF is made from */
.report-summary { margin: 0; line-height: 1.75; max-width: 110ch; }
.pdf-doc {
  position: absolute; left: -10000px; top: 0; width: 720px; /* the text width of an A4 page */
  background: #fff; color: #10202f; font-size: 13px; line-height: 1.55; letter-spacing: normal;
}
.pdf-block { background: #fff; padding: 0; }
.pdf-doc h1 { margin: 6px 0 2px; font-size: 19px; font-weight: 600; line-height: 1.4; }
.pdf-doc h2 { margin: 0 0 6px; padding-bottom: 5px; font-size: 14.5px; font-weight: 600; color: var(--accent-ink); border-bottom: 2px solid var(--accent); }
.pdf-doc h3 { margin: 0 0 6px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.pdf-head { padding-bottom: 10px; border-bottom: 1px solid var(--grid); }
.pdf-org { font-size: 15px; font-weight: 600; color: var(--accent-ink); }
.pdf-area, .pdf-meta, .pdf-note { font-size: 12px; color: var(--ink-2); }
.pdf-note { margin-bottom: 6px; }
.pdf-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.pdf-kpis > div { padding: 10px 12px; border: 1px solid var(--grid); border-radius: 8px; }
.pdf-kpis span, .pdf-kpis em { display: block; font-size: 11.5px; font-style: normal; color: var(--ink-2); }
.pdf-kpis b { font-size: 24px; font-weight: 600; line-height: 1.3; }
.pdf-kpis small { margin-left: 5px; font-size: 12px; color: var(--muted); }
.pdf-text { margin: 0; line-height: 1.8; text-align: left; }
.pdf-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.pdf-bar { display: grid; grid-template-columns: 112px minmax(0, 1fr) 50px 42px; gap: 8px; align-items: center; padding: 3px 0; font-size: 12.5px; }
.pdf-bar > div { height: 12px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.pdf-bar i { display: block; height: 100%; border-radius: 3px; }
.pdf-bar b { text-align: right; font-weight: 600; }
.pdf-bar small { font-size: 11.5px; color: var(--muted); }
.pdf-doc table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.pdf-doc th, .pdf-doc td { padding: 6px 6px; white-space: normal; border-bottom: 1px solid var(--grid); vertical-align: top; }
.pdf-doc th:first-child, .pdf-doc td:first-child { padding-left: 6px; }
.pdf-doc th:last-child, .pdf-doc td:last-child { padding-right: 6px; }
.pdf-doc th:first-child { width: 25%; }
.pdf-doc th { font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border-bottom: 1px solid var(--axis); }
.pdf-doc tbody tr:last-child td { border-bottom: 1px solid var(--grid); }
.pdf-doc td.pdf-empty { padding: 18px; text-align: center; color: var(--muted); }
.pdf-sign { display: flex; justify-content: flex-end; padding-top: 34px; }
.pdf-sign > div { width: 300px; }
.pdf-sign p { display: flex; align-items: flex-end; gap: 6px; margin: 0 0 16px; }
.pdf-sign i { flex: 1; height: 1px; margin-bottom: 4px; border-bottom: 1px dotted var(--ink-2); }

/* a section of a side panel that folds away (registry.php) */
details.fold { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
details.fold > summary { cursor: pointer; font-weight: 600; font-size: 15px; list-style: none; display: flex; align-items: center; gap: 6px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: '+'; width: 18px; height: 18px; border-radius: 9px; background: var(--surface-2); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
details.fold[open] > summary::before { content: '−'; }
details.fold[open] > summary { margin-bottom: 10px; }
