/* Steady — design system.
   Tokens first; components use tokens only. Light and dark are both
   designed (not inverted). Wearer screens run a larger type scale. */

:root {
  color-scheme: light;
  --brand: #00d4aa;
  --brand-ink: #06231c;          /* text on brand fill */
  --accent: #007a64;             /* brand-coloured text/icons on light */
  --accent-soft: #dff7f0;

  --bg: #f4f6fb;
  --bg-glow: radial-gradient(1200px 500px at 50% -180px, #d9f3ec 0%, rgba(217, 243, 236, 0) 70%);
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --surface-3: #e3e9f3;
  --ink: #0d1733;
  --ink-2: #3d4866;
  --muted: #5f6b86;
  --line: #dfe5ef;
  --line-strong: #c7d0df;
  --shadow: 0 1px 2px rgba(13, 23, 51, 0.06), 0 8px 24px rgba(13, 23, 51, 0.06);
  --overlay: rgba(7, 13, 31, 0.45);

  /* status: fill for marks, ink for text — always paired with icon + label */
  --good: #0ca30c;       --good-ink: #0a7d0a;   --good-soft: #e3f5e3;
  --watch: #fab219;      --watch-ink: #8a5a00;  --watch-soft: #fff3d6;
  --review: #ec835a;     --review-ink: #a8481f; --review-soft: #fde9e0;
  --urgent: #d03b3b;     --urgent-ink: #b42323; --urgent-soft: #fbe3e3;
  --info: #2a78d6;       --info-ink: #1f5fae;   --info-soft: #e1ecfa;

  /* data viz */
  --series-1: #2a78d6;   /* left foot / primary series */
  --series-2: #eb6834;   /* right foot */
  --series-3: #1baf7a;
  --band: rgba(42, 120, 214, 0.12);
  --grid: #e1e0d9;
  --axis: #c3c2b7;

  --radius: 20px;
  --radius-sm: 12px;
  --space: 16px;
  --tap: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs: 1.125rem;      /* body scale, set per role */
  --fs-scale: 1;       /* user text size */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --accent: #00d4aa;
    --accent-soft: rgba(0, 212, 170, 0.14);
    --bg: #070d1f;
    --bg-glow: radial-gradient(1200px 520px at 50% -200px, rgba(0, 212, 170, 0.16) 0%, rgba(0, 212, 170, 0) 70%);
    --surface: #0e1834;
    --surface-2: #15224a;
    --surface-3: #1c2b58;
    --ink: #f3f6ff;
    --ink-2: #c1cae0;
    --muted: #8e9ab8;
    --line: #24335f;
    --line-strong: #31447a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
    --overlay: rgba(0, 0, 0, 0.6);
    --good-ink: #3ccf5b;   --good-soft: rgba(12, 163, 12, 0.18);
    --watch-ink: #ffc94d;  --watch-soft: rgba(250, 178, 25, 0.16);
    --review-ink: #ff9a72; --review-soft: rgba(236, 131, 90, 0.18);
    --urgent-ink: #ff7b7b; --urgent-soft: rgba(208, 59, 59, 0.22);
    --info-ink: #6aa7f0;   --info-soft: rgba(42, 120, 214, 0.2);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --band: rgba(57, 135, 229, 0.18);
    --grid: #2c2c2a;
    --axis: #383835;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #00d4aa;
  --accent-soft: rgba(0, 212, 170, 0.14);
  --bg: #070d1f;
  --bg-glow: radial-gradient(1200px 520px at 50% -200px, rgba(0, 212, 170, 0.16) 0%, rgba(0, 212, 170, 0) 70%);
  --surface: #0e1834;
  --surface-2: #15224a;
  --surface-3: #1c2b58;
  --ink: #f3f6ff;
  --ink-2: #c1cae0;
  --muted: #8e9ab8;
  --line: #24335f;
  --line-strong: #31447a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
  --overlay: rgba(0, 0, 0, 0.6);
  --good-ink: #3ccf5b;   --good-soft: rgba(12, 163, 12, 0.18);
  --watch-ink: #ffc94d;  --watch-soft: rgba(250, 178, 25, 0.16);
  --review-ink: #ff9a72; --review-soft: rgba(236, 131, 90, 0.18);
  --urgent-ink: #ff7b7b; --urgent-soft: rgba(208, 59, 59, 0.22);
  --info-ink: #6aa7f0;   --info-soft: rgba(42, 120, 214, 0.2);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --band: rgba(57, 135, 229, 0.18);
  --grid: #2c2c2a;
  --axis: #383835;
}

/* iOS Dynamic Type: honour the person's text-size setting */
@supports (font: -apple-system-body) {
  html { font: -apple-system-body; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: calc(var(--fs) * var(--fs-scale));
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.role-wearer { --fs: 1.25rem; --tap: 60px; }
body.role-family { --fs: 1.125rem; }
body.role-clinic { --fs: 0.95rem; --radius: 14px; --tap: 40px; }
body.text-large { --fs-scale: 1.12; }
body.text-larger { --fs-scale: 1.25; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.75em; font-weight: 750; }
h2 { font-size: 1.3em; font-weight: 700; }
h3 { font-size: 1.05em; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small { font-size: 0.85em; }
.tiny { font-size: 0.75em; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: var(--space); }
.stack-sm { display: grid; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- app frame ---------- */
#app { min-height: 100dvh; }
.shell { max-width: 620px; margin: 0 auto; padding: calc(8px + var(--safe-top)) 16px calc(96px + var(--safe-bottom)); }
.shell.wide { max-width: 1320px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  margin: calc(-8px - var(--safe-top)) -16px 8px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.05em; text-decoration: none; color: var(--ink); }
.brand svg { width: 30px; height: 30px; }
.brand small { display: block; font-size: 0.62em; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.topbar .spacer { flex: 1; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  min-width: 44px; height: 44px; border-radius: 999px; border: 0;
  background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot { position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--urgent); box-shadow: 0 0 0 2px var(--bg); }
.icon { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.fill { fill: currentColor; stroke: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(var(--n, 4), 1fr);
  padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border-radius: 14px;
  color: var(--muted); text-decoration: none; font-size: 0.78em; font-weight: 600;
  min-height: 56px;
}
.tabbar a .icon { width: 26px; height: 26px; }
.tabbar a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.role-clinic .tabbar { display: none; }

/* ---------- cards & surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card.tinted { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { flex: 1; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link.row { display: flex; }
.card-link:hover .card, .card-link:hover.card { border-color: var(--line-strong); }
.section-title { font-size: 0.8em; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 8px 2px 0; }
.divider { height: 1px; background: var(--line); margin: 6px 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 0 22px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 650; cursor: pointer; text-decoration: none; transition: transform 0.06s ease, background 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.primary:hover { background: #12e0b6; }
.btn.danger { background: var(--urgent); color: #fff; border-color: transparent; }
.btn.good { background: var(--good); color: #fff; border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 0.88em; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn .icon { width: 1.2em; height: 1.2em; }

.action {
  display: flex; align-items: center; gap: 16px; width: 100%;
  min-height: 84px; padding: 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-align: left; cursor: pointer; text-decoration: none; box-shadow: var(--shadow);
}
.action:hover { border-color: var(--line-strong); }
.action .badge-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.action .badge-icon .icon { width: 28px; height: 28px; }
.action b { display: block; font-size: 1.02em; }
.action span.sub { color: var(--muted); font-size: 0.85em; }
.action .chev { color: var(--muted); }

/* ---------- status ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px;
  font-size: 0.8em; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--ink-2);
}
.pill .icon { width: 1.05em; height: 1.05em; }
.pill.good { background: var(--good-soft); color: var(--good-ink); }
.pill.watch { background: var(--watch-soft); color: var(--watch-ink); }
.pill.review { background: var(--review-soft); color: var(--review-ink); }
.pill.urgent { background: var(--urgent-soft); color: var(--urgent-ink); }
.pill.info { background: var(--info-soft); color: var(--info-ink); }
.pill.brand { background: var(--accent-soft); color: var(--accent); }

.hero {
  position: relative; overflow: hidden;
  border-radius: calc(var(--radius) + 4px); padding: 22px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow);
}
.hero .halo { position: absolute; inset: -40% -20% auto auto; width: 260px; height: 260px; border-radius: 50%; filter: blur(30px); opacity: 0.55; pointer-events: none; }
.hero.good .halo { background: var(--good-soft); }
.hero.watch .halo { background: var(--watch-soft); }
.hero.review .halo, .hero.urgent .halo { background: var(--review-soft); }
.hero.learning .halo, .hero.nodata .halo { background: var(--info-soft); }
.hero .status-mark { width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; flex: none; }
.hero .status-mark .icon { width: 36px; height: 36px; }
.hero.good .status-mark { background: var(--good-soft); color: var(--good-ink); }
.hero.watch .status-mark { background: var(--watch-soft); color: var(--watch-ink); }
.hero.review .status-mark, .hero.urgent .status-mark { background: var(--review-soft); color: var(--review-ink); }
.hero.learning .status-mark, .hero.nodata .status-mark { background: var(--info-soft); color: var(--info-ink); }
.hero h2 { font-size: 1.6em; }

/* ---------- metrics ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.tile .label { font-size: 0.78em; color: var(--muted); font-weight: 650; }
.tile .value { font-size: 1.45em; font-weight: 750; letter-spacing: -0.02em; }
.tile .delta { font-size: 0.75em; font-weight: 650; color: var(--muted); }
.ring-wrap { position: relative; width: 92px; height: 92px; margin: 2px auto 6px; font-size: 16px; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-wrap .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.05; }
.ring-wrap .ring-label b { font-size: 1.05em; letter-spacing: -0.02em; }
.ring-wrap .ring-label small { display: block; font-size: 0.6em; color: var(--muted); font-weight: 600; }
.ring-track { stroke: var(--surface-3); }
.ring-fill { transition: stroke-dashoffset 0.8s cubic-bezier(.2,.8,.2,1); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 650; text-align: right; }

.stat { display: grid; gap: 2px; }
.stat .label { font-size: 0.78em; color: var(--muted); font-weight: 650; }
.stat .value { font-size: 1.6em; font-weight: 750; letter-spacing: -0.02em; }
.stat .value .unit, .tile .value .unit { font-size: 0.55em; font-weight: 650; color: var(--muted); letter-spacing: 0; }
.stat .delta { font-size: 0.78em; font-weight: 650; }
.delta.worse { color: var(--review-ink); }
.delta.better { color: var(--good-ink); }
.delta.same { color: var(--muted); }

.note-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.note-list li { display: flex; gap: 12px; align-items: flex-start; }
.note-list .icon { margin-top: 3px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field label { font-weight: 650; font-size: 0.9em; }
.input, select.input, textarea.input {
  min-height: var(--tap); padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); width: 100%;
}
textarea.input { padding: 12px 14px; min-height: 96px; resize: vertical; }
.code-input { letter-spacing: 0.3em; text-transform: uppercase; font-size: 1.4em; text-align: center; font-weight: 700; }
.switch { position: relative; display: inline-block; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: 0.2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 26px; height: 26px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: 0.2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.segmented { display: inline-flex; max-width: 100%; overflow-x: auto; background: var(--surface-2); padding: 4px; border-radius: 999px; gap: 2px; }
.segmented button { white-space: nowrap; border: 0; background: transparent; padding: 8px 14px; border-radius: 999px; font-weight: 650; color: var(--muted); cursor: pointer; min-height: 36px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- lists & tables ---------- */
.list { display: grid; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.list > * { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.list > *:last-child { border-bottom: 0; }
.list a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; }
.list a:hover { background: var(--surface-2); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; background: var(--accent-soft); color: var(--accent); flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.3em; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92em; }
table.data th { text-align: left; font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.data td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .band { fill: var(--band); }
.chart .median { stroke: var(--series-1); stroke-width: 1; opacity: 0.6; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--line-strong); stroke-width: 1; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 8px 10px; font-size: 0.8em; min-width: 120px; z-index: 5; }
.chart-tip b { display: block; font-size: 1.1em; }
.chart-box { position: relative; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.8em; color: var(--ink-2); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.box { height: 10px; width: 14px; }

.zbar { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); }
.zbar .mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--line-strong); }
.zbar .fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.zbar .fill.worse { background: var(--review); }
.zbar .fill.better { background: var(--good); }
.zbar .fill.same { background: var(--muted); }

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-strip .d { display: grid; justify-items: center; gap: 6px; font-size: 0.75em; color: var(--muted); }
.week-strip .bar { width: 100%; max-width: 30px; height: 64px; border-radius: 8px; background: var(--surface-2); position: relative; overflow: hidden; }
.week-strip .bar i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--series-1); border-radius: 8px 8px 0 0; }
.week-strip .mark { width: 10px; height: 10px; border-radius: 50%; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal div { aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center; font-size: 0.72em; background: var(--surface-2); color: var(--muted); }
.cal div.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.cal div.blank { background: transparent; }

/* ---------- overlays ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 60; display: grid; align-items: end; justify-items: center; animation: fade 0.18s ease; }
.sheet { width: min(620px, 100%); max-height: 92dvh; overflow: auto; background: var(--surface); border-radius: 26px 26px 0 0; padding: 20px 20px calc(20px + var(--safe-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.25); animation: rise 0.25s cubic-bezier(.2,.8,.2,1); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: -6px auto 14px; }
@media (min-width: 900px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 26px; } }
.fullscreen { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 650; z-index: 90; box-shadow: var(--shadow); animation: rise 0.2s ease; max-width: calc(100% - 32px); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 14px; font-size: 0.85em; font-weight: 600; background: var(--info-soft); color: var(--info-ink); }
.banner.demo { background: var(--accent-soft); color: var(--accent); }
.banner .grow { color: inherit; }
.footnote { font-size: 0.78em; color: var(--muted); line-height: 1.5; }

/* ---------- welcome ---------- */
.welcome { max-width: 560px; margin: 0 auto; padding: calc(40px + var(--safe-top)) 20px 40px; display: grid; gap: 22px; }
.welcome .logo-xl { width: 84px; height: 84px; }
.welcome h1 { font-size: 2.2em; }
.role-card { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; width: 100%; color: var(--ink); box-shadow: var(--shadow); }
.role-card:hover { border-color: var(--brand); }
.role-card .badge-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.role-card .badge-icon .icon { width: 30px; height: 30px; }
.role-card b { font-size: 1.1em; display: block; }

/* ---------- clinic layout ---------- */
.clinic { display: grid; grid-template-columns: 240px 1fr; min-height: 100dvh; }
.clinic-nav { position: sticky; top: 0; height: 100dvh; padding: 18px 12px; border-right: 1px solid var(--line); background: var(--surface); display: grid; grid-template-rows: auto 1fr auto; gap: 18px; }
.clinic-nav nav { display: grid; gap: 4px; align-content: start; }
.clinic-nav nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.clinic-nav nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.clinic-nav nav a:hover { background: var(--surface-2); }
.clinic-main { padding: 22px 28px 60px; min-width: 0; }
.clinic-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 650; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-weight: 650; font-size: 0.85em; cursor: pointer; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .count { opacity: 0.7; margin-left: 4px; }
@media (max-width: 1000px) {
  .clinic { grid-template-columns: 1fr; }
  .clinic-nav { position: static; height: auto; grid-template-rows: auto; grid-auto-flow: column; overflow-x: auto; padding: 10px; }
  .clinic-nav nav { grid-auto-flow: column; }
  .clinic-nav .nav-foot { display: none; }
  .clinic-main { padding: 16px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .tiles { gap: 8px; }
  .ring-wrap { width: 80px; height: 80px; }
}

/* ---------- live & exercise ---------- */
.live-stage { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.live-stage canvas { width: 100%; display: block; }
.big-count { font-size: 5em; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.timer-ring { width: 220px; height: 220px; margin: 0 auto; position: relative; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.step-dots { display: flex; gap: 6px; justify-content: center; }
.step-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.step-dots i.on { background: var(--brand); width: 22px; border-radius: 4px; }
.pictogram { width: 100%; max-width: 260px; margin: 0 auto; display: block; color: var(--accent); }

.alarm { animation: pulse 1.2s ease-in-out infinite; }

/* ---------- print (clinician month report) ---------- */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; }
  .clinic-nav, .tabbar, .topbar, .banner.demo, button, .btn, .filters, .tabs { display: none !important; }
  .clinic { display: block; }
  .clinic-main { padding: 0; }
  .card, .table-wrap { box-shadow: none; break-inside: avoid; }
}
