/* Jo-CHF design system.
   Concept: ECG paper and a live trace. Rose-white millimetre paper, deep ink, one red signal.
   The red is reserved for the trace, alerts and things that need action. */

/* Fonts are hosted with the site (no outside requests). */
@font-face { font-family: "Bricolage Grotesque"; src: url(../fonts/bricolage-latin-wdth.woff2) format("woff2-variations"); font-weight: 200 800; font-stretch: 75% 100%; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/plex-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/plex-400i.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/plex-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/plex-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(../fonts/plex-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light;
  --paper: #FBF6F5;
  --paper-2: #F6EEEC;
  --grid-minor: rgba(212, 42, 60, .055);
  --grid-major: rgba(212, 42, 60, .11);
  --surface: #FFFFFF;
  --surface-2: #FBF8F7;
  --sunken: #F3ECEA;
  --ink: #14182B;
  --ink-2: #474D66;
  --muted: #80859B;
  --line: #EAE1DF;
  --line-2: #DCD1CE;
  --trace: #D42A3C;
  --trace-soft: rgba(212, 42, 60, .1);
  --navy: #14182B;
  --on-navy: #FFFFFF;
  --focus: #2A78D6;
  --good: #0B7A5C;   --good-bg: #E3F4EE;
  --warn: #9A6200;   --warn-bg: #FCF1DA;
  --bad: #B3202F;    --bad-bg: #FBE6E7;
  --info: #2A5FB0;   --info-bg: #E5EEFA;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --chart-grid: #ECE5E3; --chart-axis: #C9C0BD;
  --shadow-1: 0 1px 0 rgba(20, 24, 43, .04), 0 1px 3px rgba(20, 24, 43, .05);
  --shadow-2: 0 2px 4px rgba(20, 24, 43, .04), 0 12px 32px -8px rgba(20, 24, 43, .14);
  --shadow-3: 0 30px 80px -20px rgba(20, 24, 43, .35);
  --r-s: 8px; --r-m: 12px; --r-l: 18px; --r-xl: 26px;
  --display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rail: 236px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0B1020; --paper-2: #0F1528;
    --grid-minor: rgba(255, 77, 94, .045); --grid-major: rgba(255, 77, 94, .09);
    --surface: #131A2E; --surface-2: #161E35; --sunken: #0E1427;
    --ink: #EEF0F8; --ink-2: #B8BDD3; --muted: #7E84A0;
    --line: #222B47; --line-2: #2D3757;
    --trace: #FF4D5E; --trace-soft: rgba(255, 77, 94, .14);
    --navy: #EEF0F8; --on-navy: #0B1020;
    --good: #3CCB9A; --good-bg: rgba(60, 203, 154, .12);
    --warn: #F2B54A; --warn-bg: rgba(242, 181, 74, .12);
    --bad: #FF6B78; --bad-bg: rgba(255, 107, 120, .13);
    --info: #79A9F2; --info-bg: rgba(121, 169, 242, .13);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --chart-grid: #1F2742; --chart-axis: #34405F;
    --shadow-1: 0 1px 0 rgba(0, 0, 0, .3); --shadow-2: 0 12px 32px -10px rgba(0, 0, 0, .6); --shadow-3: 0 30px 80px -20px rgba(0, 0, 0, .8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0B1020; --paper-2: #0F1528;
  --grid-minor: rgba(255, 77, 94, .045); --grid-major: rgba(255, 77, 94, .09);
  --surface: #131A2E; --surface-2: #161E35; --sunken: #0E1427;
  --ink: #EEF0F8; --ink-2: #B8BDD3; --muted: #7E84A0;
  --line: #222B47; --line-2: #2D3757;
  --trace: #FF4D5E; --trace-soft: rgba(255, 77, 94, .14);
  --navy: #EEF0F8; --on-navy: #0B1020;
  --good: #3CCB9A; --good-bg: rgba(60, 203, 154, .12);
  --warn: #F2B54A; --warn-bg: rgba(242, 181, 74, .12);
  --bad: #FF6B78; --bad-bg: rgba(255, 107, 120, .13);
  --info: #79A9F2; --info-bg: rgba(121, 169, 242, .13);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --chart-grid: #1F2742; --chart-axis: #34405F;
  --shadow-1: 0 1px 0 rgba(0, 0, 0, .3); --shadow-2: 0 12px 32px -10px rgba(0, 0, 0, .6); --shadow-3: 0 30px 80px -20px rgba(0, 0, 0, .8);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 15px/1.5 var(--sans); font-feature-settings: "ss02";
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
.ecg-paper {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 8px 8px, 8px 8px;
}
h1, h2, h3, h4 { font-family: var(--display); margin: 0; letter-spacing: -.015em; font-weight: 650; }
h1 { font-size: clamp(26px, 3.2vw, 36px); line-height: 1.1; font-variation-settings: "wdth" 88; }
h2 { font-size: 21px; line-height: 1.2; }
h3 { font-size: 16px; line-height: 1.3; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 16px; }
.hide { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; } }

/* ---------- buttons ---------- */
.btn {
  --b-bg: var(--surface); --b-fg: var(--ink); --b-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--b-bd);
  background: var(--b-bg); color: var(--b-fg); font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; text-decoration: none; user-select: none;
  transition: transform .12s var(--ease), background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.primary { --b-bg: var(--navy); --b-fg: var(--on-navy); --b-bd: var(--navy); }
.btn.primary:hover { box-shadow: 0 6px 18px -6px rgba(20, 24, 43, .5); }
.btn.signal { --b-bg: var(--trace); --b-fg: #fff; --b-bd: var(--trace); }
.btn.ghost { --b-bg: transparent; --b-bd: transparent; }
.btn.ghost:hover { --b-bg: var(--sunken); }
.btn.danger { --b-fg: var(--bad); }
.btn.danger:hover { --b-bd: var(--bad); --b-bg: var(--bad-bg); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn.icon { width: 40px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn.sm svg { width: 15px; height: 15px; }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.field .req { color: var(--trace); font-weight: 700; }
.field .help { font-size: 12px; color: var(--muted); }
.field.has-error .input, .field.has-error .seg { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.field .err { font-size: 12px; color: var(--bad); font-weight: 500; }
.field .warnmsg { font-size: 12px; color: var(--warn); font-weight: 500; }
.field.missing > label::after { content: "Required"; margin-left: auto; font-size: 11px; font-weight: 600; color: var(--trace); background: var(--trace-soft); padding: 1px 7px; border-radius: 99px; }
.field.nd .input, .field.nd .seg { opacity: .45; pointer-events: none; }
.input {
  height: 42px; width: 100%; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.input:hover { border-color: var(--muted); }
.input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.input[readonly] { background: var(--sunken); color: var(--ink-2); }
select.input { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%2380859B' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.with-unit { display: flex; align-items: stretch; }
.with-unit .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.with-unit .unit { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-2); border-left: 0; border-radius: 0 10px 10px 0; background: var(--sunken); color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.with-unit select.unit { appearance: none; cursor: pointer; padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%2380859B' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 6px center; background-size: 14px; outline: none; font: inherit; font-size: 13px; color: var(--ink-2); }
.date-wrap { position: relative; display: flex; }
.date-wrap .input { padding-right: 42px; font-variant-numeric: tabular-nums; }
.date-wrap .cal { position: absolute; right: 4px; top: 4px; height: 34px; width: 34px; border: 0; background: transparent; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.date-wrap .cal:hover { background: var(--sunken); color: var(--ink); }
.date-wrap input[type=date] { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.computed { height: 42px; display: flex; align-items: center; padding: 0 12px; border-radius: 10px; background: var(--sunken); border: 1px dashed var(--line-2); color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.computed:empty::before { content: "Calculated automatically"; color: var(--muted); font-weight: 400; font-size: 13px; }

/* segmented choices */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--sunken); border-radius: 12px; border: 1px solid transparent; }
.seg button { border: 0; background: transparent; padding: 7px 13px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line-2); font-weight: 600; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: 14px; transition: border-color .15s, background .15s; user-select: none; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check .box { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-2); display: grid; place-items: center; transition: background .15s, border-color .15s; flex: none; }
.chip-check .box svg { width: 12px; height: 12px; opacity: 0; transform: scale(.5); transition: .15s var(--ease); color: var(--on-navy); }
.chip-check:has(input:checked) { border-color: var(--navy); background: var(--surface-2); }
.chip-check:has(input:checked) .box { background: var(--navy); border-color: var(--navy); }
.chip-check:has(input:checked) .box svg { opacity: 1; transform: none; }
.chip-check:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.check-line { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.check-line input { position: absolute; opacity: 0; }
.check-line .box { margin-top: 1px; }
.check-line:has(input:checked) { border-color: var(--navy); }
.check-line:has(input:checked) .box { background: var(--navy); border-color: var(--navy); }
.check-line:has(input:checked) .box svg { opacity: 1; transform: none; }
.check-line .box { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center; flex: none; transition: .15s; }
.check-line .box svg { width: 13px; height: 13px; opacity: 0; transform: scale(.5); transition: .15s var(--ease); color: var(--on-navy); }
.danger-zone .check-line:has(input:checked) { border-color: var(--bad); background: var(--bad-bg); }
.danger-zone .check-line:has(input:checked) .box { background: var(--bad); border-color: var(--bad); }
.nd-toggle { margin-left: auto; display: inline-flex; gap: 2px; }
.nd-toggle button { border: 1px solid var(--line-2); background: transparent; border-radius: 6px; font-size: 10.5px; font-weight: 600; padding: 1px 6px; color: var(--muted); cursor: pointer; }
.nd-toggle button[aria-pressed="true"] { background: var(--ink-2); color: var(--surface); border-color: var(--ink-2); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-1); }
.card.pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { flex: 1; min-width: 0; }
.card-body { padding: 20px; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--sunken); color: var(--ink-2); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.ink { background: var(--navy); color: var(--on-navy); }
.badge.outline { background: transparent; border: 1px solid var(--line-2); }
.pheno { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 700; letter-spacing: .01em; }
.pheno.HFrEF { background: color-mix(in srgb, var(--s1) 14%, transparent); color: var(--s1); }
.pheno.HFpEF { background: color-mix(in srgb, var(--s2) 14%, transparent); color: var(--s2); }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--info-bg); color: var(--ink); font-size: 14px; }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--info); }
.callout.warn { background: var(--warn-bg); } .callout.warn svg { color: var(--warn); }
.callout.bad { background: var(--bad-bg); } .callout.bad svg { color: var(--bad); }
.callout.good { background: var(--good-bg); } .callout.good svg { color: var(--good); }
hr.rule { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 80%, var(--surface)); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--navy); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 26px; height: 26px; }
.brand-name { font-family: var(--display); font-weight: 750; font-size: 19px; letter-spacing: -.02em; line-height: 1; }
.brand-sub { font-size: 11px; color: var(--muted); line-height: 1.25; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin-top: 18px; padding: 0 10px 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 14px; transition: background .15s, color .15s; position: relative; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); font-weight: 600; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--trace); }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--trace); color: #fff; border-radius: 99px; padding: 1px 7px; min-width: 20px; text-align: center; }
.rail-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; text-decoration: none; }
.me:hover { background: var(--sunken); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--sunken); color: var(--ink); flex: none; border: 1px solid var(--line-2); }
.me-name { font-weight: 600; font-size: 13.5px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-flag { margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; background: var(--trace-soft); color: var(--ink); font-size: 12.5px; line-height: 1.4; }
.demo-flag strong { color: var(--trace); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid transparent; transition: border-color .2s; }
.topbar.scrolled { border-bottom-color: var(--line); }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); min-width: 0; flex: 1; }
.crumbs a { text-decoration: none; color: var(--ink-2); }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs .sep { opacity: .5; }
.crumbs .here { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page { padding: 8px 28px 64px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 10px 0 22px; }
.page-head .grow p { color: var(--ink-2); margin-top: 6px; max-width: 70ch; }
.mobile-nav { display: none; }
.session-bar { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 100; pointer-events: none; }
.session-bar i { display: block; height: 100%; background: var(--trace); transform-origin: left; transition: transform 1s linear; }

@media (max-width: 960px) {
  .crumbs a, .crumbs .sep { display: none; }
  .hide-sm { display: none; }
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .topbar { padding: 10px 16px; }
  .page { padding: 4px 16px 96px; }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 4px 0; }
  .mobile-nav a svg { width: 21px; height: 21px; }
  .mobile-nav a[aria-current="page"] { color: var(--ink); }
  .mobile-nav a[aria-current="page"] svg { color: var(--trace); }
}

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(380px, .9fr); position: relative; overflow: hidden; }
.auth-stage { position: relative; display: flex; flex-direction: column; padding: 40px 48px; min-height: 100vh; }
.auth-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-top { position: relative; display: flex; align-items: center; gap: 12px; }
.auth-hero { position: relative; margin-top: auto; margin-bottom: 9vh; max-width: 640px; }
.auth-hero .wordmark { font-family: var(--display); font-weight: 800; font-size: clamp(64px, 10vw, 148px); line-height: .82; letter-spacing: -.055em; font-variation-settings: "wdth" 78; color: var(--ink); }
.auth-hero .wordmark span { color: var(--trace); }
.auth-hero .title { font-family: var(--display); font-size: clamp(19px, 2vw, 25px); font-weight: 500; margin-top: 18px; line-height: 1.25; max-width: 30ch; font-variation-settings: "wdth" 92; }
.auth-facts { display: flex; gap: 28px; margin-top: 26px; flex-wrap: wrap; }
.auth-facts div { font-size: 13px; color: var(--ink-2); line-height: 1.35; }
.auth-facts b { display: block; font-family: var(--display); font-size: 26px; color: var(--ink); font-weight: 700; font-variation-settings: "wdth" 85; letter-spacing: -.02em; }
.auth-panel { position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 32px; background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-left: 1px solid var(--line); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 28px; font-variation-settings: "wdth" 90; }
.auth-card .lead { color: var(--ink-2); margin: 8px 0 26px; }
.auth-card form > * + * { margin-top: 16px; }
.auth-card .btn.primary { width: 100%; height: 46px; font-size: 15px; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-top: 18px; }
.auth-links a, .linkbtn { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; cursor: pointer; background: none; border: 0; padding: 0; font-size: inherit; }
.auth-links a:hover, .linkbtn:hover { color: var(--ink); text-decoration-color: currentColor; }
.demo-box { margin-top: 26px; padding: 16px; border-radius: 14px; border: 1px dashed var(--line-2); background: var(--surface-2); }
.demo-box h3 { font-size: 14px; }
.demo-box p { font-size: 13px; color: var(--ink-2); margin: 4px 0 12px; }
.demo-box .row { gap: 8px; }
.demo-box .btn { flex: 1; }
.pw-meter { height: 4px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.pw-meter i { display: block; height: 100%; width: 0; background: var(--bad); transition: width .3s var(--ease), background .3s; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-stage { min-height: 46vh; padding: 24px; }
  .auth-hero { margin-bottom: 24px; }
  .auth-facts { display: none; }
  .auth-panel { border-left: 0; border-top: 1px solid var(--line); padding: 28px 20px 48px; }
}

/* ---------- dashboard ---------- */
.hero-rhythm { position: relative; padding: 26px 28px 18px; overflow: hidden; border-radius: var(--r-xl); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-2); }
.hero-rhythm .ecg-paper { position: absolute; inset: 0; opacity: .9; }
.hero-grid { position: relative; display: grid; grid-template-columns: minmax(240px, 330px) 1fr; gap: 28px; align-items: end; }
.hero-count .big { font-family: var(--display); font-weight: 800; font-size: clamp(64px, 8vw, 104px); line-height: .85; letter-spacing: -.05em; font-variation-settings: "wdth" 76; font-variant-numeric: tabular-nums; }
.hero-count .of { font-family: var(--display); font-size: 22px; font-weight: 500; color: var(--ink-2); margin-left: 6px; font-variation-settings: "wdth" 85; }
.hero-count .caption { color: var(--ink-2); margin-top: 10px; font-size: 14px; }
.hero-count .bar { height: 8px; border-radius: 8px; background: var(--sunken); margin-top: 16px; overflow: hidden; position: relative; }
.hero-count .bar i { position: absolute; inset: 0 auto 0 0; border-radius: 8px; background: var(--navy); width: 0; transition: width 1.6s var(--ease); }
.rhythm-wrap { position: relative; min-height: 190px; }
.rhythm-wrap svg { display: block; width: 100%; height: 190px; overflow: visible; }
.rhythm-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); justify-content: flex-end; margin-top: 4px; }
.hero-stats { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin-top: 22px; border-top: 1px solid var(--line); }
.hero-stats > div { padding: 14px 16px 2px 0; }
.hero-stats > div + div { padding-left: 16px; border-left: 1px solid var(--line); }
.hero-stats .v { font-family: var(--display); font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variation-settings: "wdth" 85; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero-stats .v small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.hero-stats .l { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
@media (max-width: 1100px) { .hero-grid { grid-template-columns: 1fr; } .hero-stats { grid-template-columns: repeat(3, 1fr); } .hero-stats > div:nth-child(4) { border-left: 0; padding-left: 0; } }
@media (max-width: 600px) { .hero-rhythm { padding: 20px 18px 14px; } .hero-stats { grid-template-columns: repeat(2, 1fr); } .hero-stats > div:nth-child(odd) { border-left: 0; padding-left: 0; } .hero-stats > div:nth-child(4) { border-left: 1px solid var(--line); padding-left: 16px; } }

.section-title { display: flex; align-items: baseline; gap: 12px; margin: 34px 0 14px; }
.section-title h2 { flex: 1; }
.centers { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.ccard { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 18px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: inherit; box-shadow: var(--shadow-1); transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
a.ccard:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-2); }
.ccard.mine { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy), var(--shadow-1); }
.ccard.locked { cursor: default; }
.ccard-top { display: flex; align-items: flex-start; gap: 12px; }
.ccard .code { font-family: var(--display); font-weight: 750; font-size: 18px; letter-spacing: -.01em; font-variation-settings: "wdth" 88; }
.ccard .cname { font-size: 13px; color: var(--ink-2); }
.ring { position: relative; width: 62px; height: 62px; flex: none; margin-left: auto; }
.ring svg { width: 62px; height: 62px; transform: rotate(-90deg); }
.ring .ring-track { stroke: var(--sunken); }
.ring .ring-val { stroke: var(--navy); stroke-linecap: round; transition: stroke-dashoffset 1.4s var(--ease); }
.ring .ring-pct { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.ccard .enrolled { display: flex; align-items: baseline; gap: 6px; }
.ccard .enrolled b { font-family: var(--display); font-size: 30px; font-weight: 750; letter-spacing: -.03em; line-height: 1; font-variation-settings: "wdth" 82; font-variant-numeric: tabular-nums; }
.ccard .enrolled span { color: var(--muted); font-size: 13px; }
.spark { width: 100%; height: 34px; display: block; overflow: visible; }
.fu-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fu-bars .lab { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; }
.fu-bars .lab b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 6px; background: var(--sunken); margin-top: 5px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 6px; background: var(--s3); width: 0; transition: width 1.2s var(--ease); }
.meter.lowv i { background: var(--s4); }
.meter.badv i { background: var(--s8); }
.ccard-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }
.ccard-foot .lock { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.ccard-foot .lock svg { width: 14px; height: 14px; }
.ccard-foot .open { margin-left: auto; font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 4px; }
.ccard-foot .open svg { width: 14px; height: 14px; transition: transform .2s var(--ease); }
a.ccard:hover .ccard-foot .open svg { transform: translateX(3px); }

/* ---------- tables ---------- */
.table-tools { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search .input { padding-left: 36px; height: 38px; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; }
.tbl th[data-sort] { cursor: pointer; user-select: none; }
.tbl th[data-sort]:hover { color: var(--ink); }
.tbl th .arrow { display: inline-block; margin-left: 4px; opacity: .35; }
.tbl th.sorted .arrow { opacity: 1; color: var(--ink); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .sid { font-weight: 650; white-space: nowrap; }
.tbl .pname { color: var(--ink-2); font-size: 13px; }
.fmt-pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.fmt-pips i { width: 9px; height: 16px; border-radius: 3px; background: var(--sunken); border: 1px solid var(--line-2); }
.fmt-pips i.on { background: var(--navy); border-color: var(--navy); }
.empty { padding: 48px 24px; text-align: center; color: var(--ink-2); }
.empty svg { width: 40px; height: 40px; color: var(--muted); margin-bottom: 10px; }
.empty h3 { margin-bottom: 6px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }

/* ---------- center page ---------- */
.center-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
@media (max-width: 1440px) { .center-grid { grid-template-columns: 1fr; } .center-grid > aside { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; order: -1; } .center-grid > aside > * + * { margin-top: 0; } }
@media (max-width: 800px) { .center-grid > aside { grid-template-columns: 1fr; } }
.due-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: center; text-decoration: none; color: inherit; }
.due-item:hover { background: var(--surface-2); }
.due-item:last-child { border-bottom: 0; }
.due-item .when { width: 46px; text-align: center; flex: none; }
.due-item .when b { display: block; font-family: var(--display); font-size: 20px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.due-item .when span { font-size: 10.5px; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 16px 18px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); }
.stat .v { font-family: var(--display); font-size: 30px; font-weight: 750; letter-spacing: -.03em; line-height: 1.05; font-variation-settings: "wdth" 84; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 15px; color: var(--muted); font-weight: 500; }
.stat .l { font-size: 12.5px; color: var(--ink-2); }
@media (max-width: 760px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* ---------- patient record ---------- */
.p-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 20px 22px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); margin-bottom: 16px; }
.p-id { font-family: var(--display); font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variation-settings: "wdth" 82; }
.p-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.p-meta .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line-2); }
.p-name { font-size: 14px; color: var(--ink-2); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.p-name svg { width: 14px; height: 14px; color: var(--muted); }
.p-gauges { display: flex; gap: 18px; align-items: center; }
.gauge-mini { text-align: center; width: 66px; }
.gauge-mini .ring { margin: 0 auto; width: 54px; height: 54px; }
.gauge-mini .ring svg { width: 54px; height: 54px; }
.gauge-mini .l { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 500; line-height: 1.2; }
.p-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
.tabs-v { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; padding: 8px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); }
.tabs-v a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; text-decoration: none; font-size: 14px; color: var(--ink-2); font-weight: 500; }
.tabs-v a svg { width: 17px; height: 17px; flex: none; }
.tabs-v a:hover { background: var(--sunken); color: var(--ink); }
.tabs-v a[aria-current="page"] { background: var(--navy); color: var(--on-navy); font-weight: 600; }
.tabs-v .tick { margin-left: auto; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; flex: none; }
.tabs-v .tick.ok { background: var(--good-bg); color: var(--good); }
.tabs-v .tick.miss { background: var(--trace-soft); color: var(--trace); }
.tabs-v a[aria-current="page"] .tick.ok { background: rgba(255, 255, 255, .18); color: var(--on-navy); }
.tabs-v a[aria-current="page"] .tick.miss { background: var(--trace); color: #fff; }
.tabs-v .divider { height: 1px; background: var(--line); margin: 6px 4px; }
@media (max-width: 960px) {
  .p-layout { grid-template-columns: 1fr; }
  .tabs-v { position: static; flex-direction: row; overflow-x: auto; padding: 6px; scrollbar-width: none; }
  .tabs-v a { white-space: nowrap; }
  .tabs-v .divider { display: none; }
  .p-head { grid-template-columns: 1fr; }
}
.form-section { padding: 22px; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section > h3 { margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.form-section > .help { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.form-section > h3 + .fgrid, .form-section > h3 + div { margin-top: 14px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px 18px; }
.fgrid .full { grid-column: 1 / -1; }
.fgrid.one { grid-template-columns: 1fr; gap: 8px; }
.save-bar { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 22px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); border-radius: 0 0 var(--r-l) var(--r-l); }
.save-state { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.save-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.save-state.dirty .dot { background: var(--warn); animation: pulse 1.4s infinite; }
.save-state.error .dot { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }
@media (max-width: 960px) { .save-bar { bottom: 66px; border-radius: 0; } }

.comorb { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.comorb-item { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, background .15s; }
.comorb-item.yes { border-color: var(--navy); background: var(--surface-2); }
.comorb-item .row { justify-content: space-between; }
.comorb-item .name { font-weight: 600; font-size: 14px; }
.comorb-item .seg button { padding: 4px 10px; font-size: 13px; }
.comorb-item .subs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.comorb-item .subs .input { height: 36px; }

/* medication editor */
.med-groups { display: grid; gap: 12px; }
.med-group { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.med-group-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface-2); }
.med-group-head .gname { font-weight: 650; flex: 1; }
.med-row { display: grid; grid-template-columns: minmax(170px, 1.6fr) minmax(110px, 1fr) minmax(150px, 1.1fr) minmax(150px, 1.2fr) 36px; gap: 10px; padding: 12px 14px; align-items: center; border-top: 1px solid var(--line); }
.med-row .input { height: 38px; }
.dose-meter { display: flex; flex-direction: column; gap: 4px; }
.dose-meter .bar { height: 8px; border-radius: 8px; background: var(--sunken); position: relative; overflow: visible; }
.dose-meter .bar i { position: absolute; inset: 0 auto 0 0; border-radius: 8px; background: var(--s4); transition: width .5s var(--ease); }
.dose-meter .bar i.ok { background: var(--s3); }
.dose-meter .bar::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line-2); }
.dose-meter .txt { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.reasons { padding: 12px 14px; border-top: 1px dashed var(--line-2); background: color-mix(in srgb, var(--warn-bg) 50%, transparent); }
.reasons .lbl { font-size: 12.5px; font-weight: 600; color: var(--warn); margin-bottom: 8px; display: block; }
.reasons .chip-check { padding: 5px 10px; font-size: 13px; }
.reasons.ok { background: transparent; }
.reasons.ok .lbl { color: var(--ink-2); }
@media (max-width: 760px) { .med-row { grid-template-columns: 1fr 1fr; } .med-row .dose-meter { grid-column: 1 / -1; } }
.gdmt-summary { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.gdmt-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line-2); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.gdmt-pill.on { border-color: transparent; background: var(--navy); color: var(--on-navy); }
.gdmt-pill .p { font-weight: 500; opacity: .8; }

/* KCCQ */
.kccq-item { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.kccq-item:last-child { border-bottom: 0; }
.kccq-item .qn { font-family: var(--display); font-weight: 700; color: var(--muted); font-size: 14px; padding-top: 2px; }
.kccq-item .qt { font-weight: 500; margin-bottom: 8px; }
.kccq-item .qt .ar { display: block; direction: rtl; font-size: 15px; color: var(--ink-2); margin-top: 4px; }
.kccq-item .seg button { padding: 6px 10px; font-size: 13px; }
.kccq-scores { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.kccq-scores .s { padding: 12px; border-radius: 12px; background: var(--sunken); text-align: center; }
.kccq-scores .s b { display: block; font-family: var(--display); font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; font-variation-settings: "wdth" 84; }
.kccq-scores .s span { font-size: 11.5px; color: var(--ink-2); }
.kccq-scores .s.main { background: var(--navy); color: var(--on-navy); }
.kccq-scores .s.main span { color: inherit; opacity: .8; }
@media (max-width: 700px) { .kccq-scores { grid-template-columns: repeat(3, 1fr); } }

/* devices */
.dev-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(140px, 200px); gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dev-row:last-child { border-bottom: 0; }
.dev-row .seg button { padding: 5px 10px; font-size: 12.5px; }
@media (max-width: 900px) { .dev-row { grid-template-columns: 1fr; } }

/* follow-up timeline (patient) */
.visits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.vcard { padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.vcard h3 { display: flex; align-items: center; gap: 8px; }
.vcard .win { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.vcard.st-open { border-color: var(--s3); box-shadow: 0 0 0 1px var(--s3); }
.vcard.st-missed { border-color: var(--bad); }
.vcard.st-done { background: var(--surface-2); }
@media (max-width: 900px) { .visits { grid-template-columns: 1fr; } }
.journey { position: relative; padding: 8px 0 4px; }
.journey svg { width: 100%; display: block; overflow: visible; }
.gaps { display: flex; flex-direction: column; gap: 8px; }
.gap { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; }
.gap .lvl { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--muted); }
.gap.high .lvl { background: var(--s8); } .gap.mid .lvl { background: var(--s4); } .gap.info .lvl { background: var(--s1); }

.list-rows > div { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-rows > div:last-child { border-bottom: 0; }
.qthread { padding: 10px 12px; border-radius: 10px; background: var(--sunken); font-size: 13.5px; margin-top: 6px; }
.audit-row { display: grid; grid-template-columns: 150px 150px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit-row .chg { font-variant-numeric: tabular-nums; word-break: break-word; }
.audit-row .old { color: var(--bad); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.audit-row .new { color: var(--good); }
@media (max-width: 760px) { .audit-row { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- analytics ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 18px; position: sticky; top: 64px; z-index: 15; box-shadow: var(--shadow-1); }
.filters select.input { height: 36px; width: auto; min-width: 140px; font-size: 13.5px; }
.filters .lbl { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; }
.kpi .v { font-family: var(--display); font-size: 32px; font-weight: 750; letter-spacing: -.035em; line-height: 1.05; font-variation-settings: "wdth" 80; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi .l { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.kpi .ci { font-size: 11.5px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.viz-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.viz { grid-column: span 6; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-1); display: flex; flex-direction: column; min-width: 0; }
.viz.w12 { grid-column: span 12; } .viz.w8 { grid-column: span 8; } .viz.w4 { grid-column: span 4; } .viz.w7 { grid-column: span 7; } .viz.w5 { grid-column: span 5; }
@media (max-width: 1100px) { .viz, .viz.w8, .viz.w4, .viz.w7, .viz.w5 { grid-column: span 12; } }
.viz-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 0; }
.viz-head h3 { flex: 1; }
.viz-head p { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; font-family: var(--sans); font-weight: 400; letter-spacing: 0; }
.viz-tools { display: flex; gap: 4px; }
.viz-body { padding: 8px 10px 12px; flex: 1; min-height: 280px; }
.viz-body .chart { width: 100%; height: 300px; }
.viz-body .chart.tall { height: 380px; }
.viz-body .chart.short { height: 240px; }
.viz-note { padding: 0 18px 14px; font-size: 12px; color: var(--muted); }
.insight { margin: 0 18px 14px; padding: 10px 12px; border-radius: 10px; background: var(--sunken); font-size: 13px; color: var(--ink-2); }
.insight b { color: var(--ink); }
.analytics-section { margin: 34px 0 14px; display: flex; align-items: baseline; gap: 14px; }
.analytics-section h2 { font-size: 24px; font-variation-settings: "wdth" 88; }
.analytics-section p { color: var(--ink-2); font-size: 14px; }
.opps { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; padding: 6px 18px 18px; }
.opp { padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.opp b { font-family: var(--display); font-size: 28px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; display: block; line-height: 1.05; font-variation-settings: "wdth" 84; }
.opp span { font-size: 13px; color: var(--ink-2); }
.opp .of { font-size: 12px; color: var(--muted); margin-top: 6px; }
.heat { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 12.5px; }
.heat th { font-weight: 600; color: var(--muted); padding: 6px 8px; text-align: center; font-size: 11.5px; }
.heat th.rowh { text-align: left; color: var(--ink); font-size: 12.5px; white-space: nowrap; }
.heat td { text-align: center; padding: 9px 6px; border-radius: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- toasts, modals ---------- */
#toasts { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--navy); color: var(--on-navy); box-shadow: var(--shadow-3); font-size: 14px; font-weight: 500; max-width: 420px; animation: toastIn .35s var(--ease); }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
@media (max-width: 960px) { #toasts { left: 16px; right: 16px; bottom: 84px; align-items: stretch; } }
.modal-back { position: fixed; inset: 0; z-index: 150; background: rgba(11, 16, 32, .42); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fadeIn .2s; overflow-y: auto; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3); border: 1px solid var(--line); animation: modalIn .28s var(--ease); max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal.wide { max-width: 860px; }
.modal-head { padding: 22px 24px 0; display: flex; gap: 12px; align-items: flex-start; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 16px 24px 8px; overflow-y: auto; }
.modal-body > * + * { margin-top: 14px; }
.modal-foot { padding: 16px 24px 22px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }

/* ---------- loading ---------- */
.loader { display: grid; place-items: center; min-height: 50vh; }
.loader svg { width: 160px; height: 60px; }
.loader path { stroke: var(--trace); stroke-width: 2.5; fill: none; stroke-dasharray: 300; stroke-dashoffset: 300; animation: trace 1.4s linear infinite; }
@keyframes trace { to { stroke-dashoffset: -300; } }
.skel { background: linear-gradient(90deg, var(--sunken), var(--surface-2), var(--sunken)); background-size: 200% 100%; animation: sk 1.4s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* reveal: one orchestrated entrance per page */
.reveal > * { animation: rise .6s var(--ease) both; }
.reveal > *:nth-child(2) { animation-delay: .06s; } .reveal > *:nth-child(3) { animation-delay: .12s; } .reveal > *:nth-child(4) { animation-delay: .18s; } .reveal > *:nth-child(5) { animation-delay: .24s; } .reveal > *:nth-child(n+6) { animation-delay: .3s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- guide links / misc ---------- */
.kbd { font-size: 12px; padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }
.pill-tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--sunken); border-radius: 12px; }
.pill-tabs button, .pill-tabs a { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; text-decoration: none; }
.pill-tabs [aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line-2); font-weight: 600; }
.code-box { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 14px; padding: 12px 14px; border-radius: 10px; background: var(--sunken); word-break: break-all; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.qr { width: 180px; height: 180px; background: #fff; border-radius: 12px; padding: 10px; }
.qr img, .qr svg { width: 100%; height: 100%; }
@media print {
  .rail, .topbar, .mobile-nav, .save-bar, .filters, .viz-tools, #toasts { display: none !important; }
  .shell { display: block; } body { background: #fff; } .card, .viz { box-shadow: none; break-inside: avoid; }
}
