/* MedTag design system.
   Palette "Aurora": a violet -> indigo -> cyan brand gradient for identity and main actions, a mint
   heartbeat dot in the logo, and sharp status colours: emerald normal, amber borderline, crimson
   critical. Status colours come in two strengths: a darker one for text, a brighter "-fill" one for
   bars, markers and curves. Light by default for bright clinic rooms; dark mode for night shifts. */
[hidden] { display: none !important; }
:root {
  --bg: #F6F5FD;
  --surface: #FFFFFF;
  --surface-2: #EEEDF8;
  --ink: #14122B;
  --muted: #5E5B7A;
  --line: #E2E0F0;
  --line-strong: #C9C6DE;
  --violet: #6D28D9;
  --indigo: #4F46E5;
  --cyan: #06B6D4;
  --mint: #2EE6B6;
  --primary: #5B35E0;
  --primary-hover: #4A27C9;
  --on-primary: #FFFFFF;
  --primary-soft: #EDE9FE;
  --grad-brand: linear-gradient(120deg, #6D28D9 0%, #4F46E5 45%, #06B6D4 100%);
  --grad-action: linear-gradient(120deg, #6D28D9, #4F46E5);
  --grad-spec: linear-gradient(120deg, #4F46E5, #0891B2);
  --gold: #B45309;
  --gold-fill: #F59E0B;
  --gold-soft: #FEF3D7;
  --spec: #0E7490;
  --spec-soft: #DDF6FB;
  --ok: #3F7A1C;
  --ok-fill: #5FA83A;
  --ok-bg: #EDF6E4;
  --warn: #8A5D00;
  --warn-fill: #F2B200;
  --warn-bg: #FFF5D1;
  --crit: #A3122F;
  --crit-fill: #A3122F;
  --crit-bg: #FBE6EA;
  --grad-ok: linear-gradient(135deg, #5A9E2F, #3F7A1C);
  --grad-warn: linear-gradient(135deg, #C98F00, #8A5D00);
  --grad-crit: linear-gradient(135deg, #C2183A, #8E0F27);
  --shadow-sm: 0 1px 2px rgba(20, 18, 43, .05), 0 4px 14px rgba(79, 70, 229, .06);
  --shadow: 0 1px 2px rgba(20, 18, 43, .05), 0 10px 30px rgba(79, 70, 229, .08);
  --radius: 16px;
  --font: "Golos Text", "Noto Sans", "Segoe UI", system-ui, -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0A18;
    --surface: #14122A;
    --surface-2: #1C1A38;
    --ink: #ECEAFB;
    --muted: #A5A2C7;
    --line: #2A2750;
    --line-strong: #3B3870;
    --violet: #8B5CF6;
    --indigo: #818CF8;
    --cyan: #22D3EE;
    --primary: #8B7CFF;
    --primary-hover: #A496FF;
    --on-primary: #0B0A18;
    --primary-soft: #221E4A;
    --grad-brand: linear-gradient(120deg, #7C3AED 0%, #6366F1 45%, #22D3EE 100%);
    --grad-action: linear-gradient(120deg, #7C3AED, #6366F1);
    --grad-spec: linear-gradient(120deg, #6366F1, #0EA5C6);
    --gold: #FBBF24;
    --gold-fill: #FBBF24;
    --gold-soft: #2E2410;
    --spec: #22D3EE;
    --spec-soft: #0E2A33;
    --ok: #8CD45F;
    --ok-fill: #7BC24E;
    --ok-bg: #0D2A22;
    --warn: #FFD54A;
    --warn-fill: #F2B200;
    --warn-bg: #2E2410;
    --crit: #FF7A8F;
    --crit-fill: #D6304F;
    --crit-bg: #3A1424;
    --grad-ok: linear-gradient(135deg, #A6E27C, #7BC24E);
    --grad-warn: linear-gradient(135deg, #FFE27A, #F2B200);
    --grad-crit: linear-gradient(135deg, #FF9AAA, #FF6B81);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
:lang(mn) body, body:lang(mn) { word-break: normal; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-box .ic { width: 16px; height: 16px; vertical-align: -3px; }
.login-note .ic { width: 16px; height: 16px; vertical-align: -3px; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--grad-action); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(91, 53, 224, .28); }
.btn-primary:hover { border-color: transparent; filter: brightness(1.07); box-shadow: 0 8px 22px rgba(91, 53, 224, .36); }
.btn-spec { background: var(--grad-spec); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(8, 145, 178, .28); }
.btn-spec:hover { border-color: transparent; filter: brightness(1.07); }
.btn-danger { background: var(--grad-crit); border-color: transparent; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-icon { padding: 0; width: 44px; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 1.05rem; padding: 0 22px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: .9rem; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: .82rem; }
.field small.ok-text { color: var(--ok); font-weight: 600; }
.field small.warn-text { color: var(--warn); font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
input[aria-invalid="true"] { border-color: var(--crit); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.form-error { color: var(--crit); font-weight: 600; min-height: 1.5em; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px 16px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { min-height: 44px; padding: 0 16px; border: 0; background: transparent; cursor: pointer; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px max(16px, env(safe-area-inset-left)); padding-top: max(10px, env(safe-area-inset-top));
  background: var(--grad-brand); color: #fff;
  box-shadow: 0 6px 24px rgba(79, 70, 229, .25);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-weight: 800; letter-spacing: .02em; background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font-size: .8rem; color: var(--muted); display: none; }
@media (min-width: 1100px) { .brand-sub { display: inline; } }
/* Narrower screens keep the top bar on one row: "register a patient" is the big button on the list. */
@media (max-width: 1099px) {
  .mainnav a[href="#/patients/new"] { display: none; }
  .topbar .who { max-width: 170px; }
}
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; }
.mainnav a:hover { background: var(--surface-2); color: var(--ink); }
.mainnav a.active { background: var(--primary-soft); color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who { display: flex; flex-direction: column; line-height: 1.2; font-size: .9rem; max-width: 220px; }
.who small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who.spec b { color: var(--spec); }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn.on { color: var(--ok); background: var(--ok-bg); }
.conn.off { color: var(--warn); background: var(--warn-bg); }
.langsw { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.langsw button { min-width: 40px; min-height: 36px; padding: 0 10px; border: 0; background: transparent; cursor: pointer; font-weight: 700; font-size: .85rem; color: var(--muted); }
.langsw button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* On the gradient top bar everything is white. */
.topbar .brand { color: #fff; }
.topbar .brand-name { background: none; color: #fff; }
.topbar .brand-sub { color: rgba(255, 255, 255, .78); }
.topbar .brand-mark { filter: drop-shadow(0 2px 6px rgba(20, 18, 43, .35)); }
.topbar .brand-mark rect { stroke: rgba(255, 255, 255, .55); stroke-width: 2; }
.topbar .mainnav a { color: rgba(255, 255, 255, .82); }
.topbar .mainnav a:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.topbar .mainnav a.active { background: rgba(255, 255, 255, .22); color: #fff; }
.topbar .who small { color: rgba(255, 255, 255, .75); }
.topbar .who.spec b { color: #fff; }
.topbar .conn.on, .topbar .conn.off { background: rgba(255, 255, 255, .16); }
.topbar .conn.on { color: #fff; }
.topbar .conn.on::before { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.topbar .conn.off { color: #FFE2A8; }
.topbar .langsw { border-color: rgba(255, 255, 255, .45); }
.topbar .langsw button { color: rgba(255, 255, 255, .85); }
.topbar .langsw button[aria-pressed="true"] { background: #fff; color: var(--primary); }
.topbar .btn-ghost { color: #fff; }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .14); }
.topbar :focus-visible { outline-color: #fff; }

/* Logo: the mint dot beats like a heart. */
.brand-mark .bm-dot, .brand-mark .bm-ring { transform-box: fill-box; transform-origin: center; }
.brand-mark .bm-dot { animation: bm-dot 1.6s ease-in-out infinite; }
.brand-mark .bm-ring { fill: none; stroke: var(--mint); stroke-width: 2.5; animation: bm-ring 1.6s ease-out infinite; }
@keyframes bm-dot { 0%, 100% { transform: scale(1); opacity: 1; } 15% { transform: scale(1.25); } 30% { transform: scale(.95); opacity: .85; } 45% { transform: scale(1.12); } 70% { opacity: .7; } }
@keyframes bm-ring { 0% { transform: scale(.6); opacity: .9; } 70%, 100% { transform: scale(2.1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .brand-mark .bm-dot, .brand-mark .bm-ring { animation: none; } .brand-mark .bm-ring { opacity: 0; } }
.view { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
@media (min-width: 980px) { .cols { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 600; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 16px; }
.login-top { width: 100%; max-width: 420px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.login-card { width: 100%; max-width: 420px; }
.login-card h1 { font-size: 1.5rem; }
.login-note { max-width: 420px; text-align: center; font-size: .88rem; color: var(--muted); }
.login-hero { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 4px; }
.login-hero .brand-name { font-size: 1.6rem; }

/* ---------- patient list ---------- */
.search { position: relative; }
.search .ic { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search input { padding-left: 42px; }
.plist { display: flex; flex-direction: column; gap: 8px; }
.prow {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: inherit; min-width: 0;
}
.prow:hover { border-color: var(--primary); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; flex: none; }
.prow .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.prow .main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .meta { color: var(--muted); font-size: .88rem; }
.prow .right { text-align: right; color: var(--muted); font-size: .85rem; flex: none; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }
/* Backup reminder and the monthly report. */
.backup-note { display: block; text-decoration: none; }
.backup-note .ic { width: 16px; height: 16px; vertical-align: -3px; }
.rp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.rp-stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.rp-stat b { font: 800 2rem/1 var(--font); background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rp-stat span { color: var(--muted); font-size: .85rem; font-weight: 600; }
.rp-stat.crit b { background: var(--grad-crit); -webkit-background-clip: text; background-clip: text; }
.rp-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rp-table th, .rp-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.rp-table th:first-child, .rp-table td:first-child { text-align: left; }
.rp-table th { color: var(--muted); font-size: .82rem; }
.rp-bp b { font: 800 1.6rem var(--font); }
.rp-month { min-width: 140px; }
.rp-print h1 { font-size: 16pt; margin: 0 0 4pt; }
.rp-print .card { border: 1pt solid #ccc; box-shadow: none; padding: 8pt; margin-top: 8pt; }
.rp-print .rp-stat b { color: #4F46E5; -webkit-text-fill-color: #4F46E5; }

/* Patient list: today (urgent, follow-ups due, seen today). */
.today h2 { font-size: 1.05rem; }
.tgroups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.tgroup h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: .8rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tgroup.crit h3 { color: var(--crit); }
.tgroup.warn h3 { color: var(--warn); }
.tcount { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: .75rem; }
.tchips { display: flex; flex-wrap: wrap; gap: 6px; }
.tchip { display: inline-flex; align-items: baseline; gap: 8px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-decoration: none; }
.tchip small { color: var(--muted); font-size: .78rem; font-weight: 700; }
.tchip.crit { border-color: var(--crit-fill); background: var(--crit-bg); }
.tchip.crit small { color: var(--crit); }
.tchip.warn { border-color: var(--warn-fill); }
.tchip.warn small { color: var(--warn); }
.tchip:hover { border-color: var(--primary); }

/* Patient page: progress across visits. */
.trend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.trend { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; }
.trend-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; color: var(--muted); font-size: .82rem; font-weight: 600; }
.trend-last { font: 800 1.3rem/1 var(--font); color: var(--ink); }
.trend-last small { font-size: .75rem; color: var(--muted); }
.trend-last.s-crit { color: var(--crit); } .trend-last.s-warn { color: var(--warn); } .trend-last.s-ok { color: var(--ok); }
.trend-svg { width: 100%; height: auto; overflow: visible; }
.trend-line { fill: none; stroke: var(--indigo); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.trend-line.second { stroke: var(--cyan); stroke-dasharray: 5 4; }
.trend-dot { stroke: var(--surface); stroke-width: 2; fill: var(--line-strong); }
.trend-dot.s-ok { fill: var(--ok-fill); } .trend-dot.s-warn { fill: var(--warn-fill); } .trend-dot.s-crit { fill: var(--crit-fill); }
.trend-dates { display: flex; justify-content: space-between; color: var(--muted); }
.trend-dates small { font-size: .74rem; }

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.vrow { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: inherit; flex-wrap: wrap; }
.vrow:hover { border-color: var(--primary); }
.vrow small { color: var(--muted); }

/* ---------- chips & flags ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.chip.ok { color: var(--ok); background: var(--ok-bg); }
.chip.high, .chip.low, .chip.warn { color: var(--warn); background: var(--warn-bg); }
.chip.urgent, .chip.crit { color: #fff; background: var(--grad-crit); }
.chip.info { color: var(--primary); background: var(--primary-soft); }
.chip.spec { color: var(--spec); background: var(--spec-soft); }
.chip.gold { color: var(--gold); background: var(--gold-soft); }

/* ---------- measurements: one clinical panel of equal cells ---------- */
.vwrap { display: flex; flex-direction: column; gap: 12px; }
.vbody { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; }
.vb { display: inline-flex; align-items: center; gap: 8px; }
.vb-l { font-size: .85rem; font-weight: 600; color: var(--muted); }
.vb input { width: 6.5em; min-height: 44px; padding: 4px 10px; font: 700 1.25rem var(--font); text-align: right; appearance: textfield; -moz-appearance: textfield; }
.vb input::-webkit-outer-spin-button, .vb input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.vb i { font-style: normal; font-size: .85rem; color: var(--muted); }

/* Cells share one frame; the 1px gaps show the frame colour as dividers. */
.vboard { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-sm); }
.vt { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 132px; padding: 14px 18px 16px; background: var(--surface); transition: background-color .25s; }
.vt.wide { grid-column: span 2; }
.vt-top { display: flex; align-items: center; gap: 8px; height: 22px; color: var(--muted); }
.vt-top svg { width: 17px; height: 17px; flex: none; }
.vt-label { flex: 1 1 auto; min-width: 0; font-size: .82rem; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vt-status { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 800; letter-spacing: .01em; line-height: 1.25; }
.vt-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.vt-mid { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; margin-top: 4px; }
.vt-val { font: 800 2.6rem/1 var(--font); letter-spacing: -.035em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vt-unit { font-size: .85rem; font-weight: 600; color: var(--muted); }
.vt.s-none .vt-val { color: var(--line-strong); font-weight: 700; }

/* Status colours: the whole cell is tinted; borderline and critical also get an accent edge. */
/* Calm board: normal and abnormal values sit on white (the coloured number and edge carry the
   result); only critical values keep a fill, so red still stands out when much is abnormal. */
.vt.s-ok { background: var(--surface); }
.vt.s-ok .vt-status { color: var(--ok); }
.vt.s-warn { background: var(--surface); box-shadow: inset 4px 0 0 var(--warn-fill); }
.vt.s-warn .vt-status { color: var(--warn); }
.vt.s-crit { background: color-mix(in srgb, var(--crit-bg) 75%, var(--surface)); box-shadow: inset 5px 0 0 var(--crit-fill); }
.vt.s-crit .vt-status { color: var(--crit); }
.vt.s-ok .vt-val, .srow.s-ok .sv-val { background: var(--grad-ok); -webkit-background-clip: text; background-clip: text; color: transparent; }
.vt.s-warn .vt-val, .srow.s-warn .sv-val { background: var(--grad-warn); -webkit-background-clip: text; background-clip: text; color: transparent; }
.vt.s-crit .vt-val, .srow.s-crit .sv-val { background: var(--grad-crit); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Critical: a small heartbeat dot beside the number, like the logo. */
.vt-beat { display: none; position: relative; width: 10px; height: 10px; border-radius: 50%; background: var(--crit-fill); align-self: center; }
.vt.s-crit .vt-beat { display: inline-block; }
.vt-beat::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--crit-fill); animation: beat-ring 1.4s ease-out infinite; }
@keyframes beat-ring { from { transform: scale(.5); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .vt-beat::after { animation: none; } }

@media (max-width: 640px) {
  .vboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vt { min-height: 112px; padding: 12px 14px; }
  .vt-val { font-size: 2.1rem; }
}

/* Panel layout: blood pressure tall on the left, pulse + SpO2 and BMI + temperature on the right,
   ACT across the bottom. Phones: two across, blood pressure and ACT full width. */
.vboard { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "bp pulse spo2" "bp bmi temp" "act act act"; }
.vt.a-bp { grid-area: bp; } .vt.a-pulse { grid-area: pulse; } .vt.a-spo2 { grid-area: spo2; }
.vt.a-bmi { grid-area: bmi; } .vt.a-temp { grid-area: temp; } .vt.a-act { grid-area: act; }
@media (max-width: 640px) {
  .vboard { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "bp bp" "pulse spo2" "bmi temp" "act act"; }
}

/* Status as a solid colour badge, like the oximeter's chart (dark text on yellow for readability). */
.vt-status { align-self: flex-start; padding: 3px 11px 3px 9px; border-radius: 999px; background: var(--line); color: var(--ink); }
.vt-status::before { background: currentColor; opacity: .85; }
.vt.s-ok .vt-status { background: var(--ok); color: #fff; }
.vt.s-warn .vt-status { background: var(--warn-fill); color: #3A2A00; }
.vt.s-crit .vt-status { background: var(--crit-fill); color: #fff; }

/* ACT row: number and status on the left; the patient's artery and the six-level scale on the right. */
.vt.a-act { display: grid; grid-template-columns: minmax(150px, auto) minmax(0, 1fr); column-gap: 28px; row-gap: 6px; align-items: center; min-height: 0; }
.vt.a-act .vt-top { grid-column: 1 / -1; }
.vt.a-act .vt-mid, .vt.a-act .vt-status { grid-column: 1; }
.vt.a-act .act-detail { grid-column: 2; grid-row: 2 / span 2; display: flex; align-items: center; gap: 20px; min-width: 0; }
.act-detail .actp svg { width: 76px; height: 76px; }
.acts { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; align-items: start; padding-top: 16px; }
.acts-seg { position: relative; display: flex; flex-direction: column; gap: 6px; transition: opacity .3s; }
.acts.has .acts-seg { opacity: .42; }
.acts.has .acts-seg.on { opacity: 1; }
.acts-seg.l1 { --c: #4E9F3D; } .acts-seg.l2 { --c: #8CC152; } .acts-seg.l3 { --c: #E3CF2F; }
.acts-seg.l4 { --c: #E8A33D; } .acts-seg.l5 { --c: #C8463F; } .acts-seg.l6 { --c: #A3122F; }
.acts-bar { height: 12px; border-radius: 2px; background: var(--c); }
.acts-seg.l1 .acts-bar { border-radius: 6px 2px 2px 6px; }
.acts-seg.l6 .acts-bar { border-radius: 2px 6px 6px 2px; }
.acts-name { font-size: .8rem; font-weight: 600; line-height: 1.15; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.acts-seg.on .acts-bar { height: 18px; margin-top: -3px; border-radius: 4px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.acts-seg.on .acts-name { font-weight: 800; color: var(--ink); }
.acts-seg.on::before { content: ""; position: absolute; top: -15px; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top: 8px solid var(--c); }
@media (max-width: 640px) {
  .vt.a-act { grid-template-columns: minmax(0, 1fr); }
  .vt.a-act .act-detail { grid-column: 1; grid-row: auto; }
  .act-detail .actp svg { width: 60px; height: 60px; }
}

/* ---------- spirometry pictures: volume-time and flow-volume ---------- */
.sc { --c: var(--muted); --ct: var(--muted); }
.sc.s-ok { --c: var(--ok-fill); --ct: var(--ok); }
.sc.s-warn { --c: var(--warn-fill); --ct: var(--warn); }
.sc.s-crit { --c: var(--crit-fill); --ct: var(--crit); }
.sc stop.g0 { stop-color: var(--violet); }
.sc stop.g1 { stop-color: var(--cyan); }
.sc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sc figure { margin: 0; padding: 10px 10px 6px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); min-width: 0; box-shadow: var(--shadow-sm); }
.sc figcaption { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 0 4px 2px; }
.sc svg { display: block; width: 100%; height: auto; overflow: visible; }
.sc-axis text { font-size: 10px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.sc-axis .title { font-size: 9.5px; font-weight: 600; }
.sc-axis line.grid { stroke: var(--line); stroke-width: 1; }
.sc-axis line.base { stroke: var(--muted); stroke-width: 1; }
.sc-band { fill-opacity: .22; stroke: var(--indigo); stroke-opacity: .35; stroke-width: 1; opacity: 0; transition: opacity .6s ease .1s; }
.sc-pred { fill: none; stroke: var(--indigo); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: 0; transition: opacity .6s ease .3s; }
.sc-mark { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.sc-patient { fill: none; stroke: var(--c); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.4s cubic-bezier(.3, .7, .2, 1) .4s; }
.sc-dot { fill: var(--surface); stroke: var(--c); stroke-width: 2.5; opacity: 0; transition: opacity .3s ease 1.6s; }
.sc-label { font-size: 10.5px; font-weight: 700; fill: var(--ct); opacity: 0; transition: opacity .3s ease 1.6s; }
.sc-label.muted { fill: var(--indigo); font-weight: 600; }
.sc.drawn .sc-band, .sc.drawn .sc-dot, .sc.drawn .sc-label { opacity: 1; }
.sc.drawn .sc-pred { opacity: .7; }
.sc.drawn .sc-patient { stroke-dashoffset: 0; }
.sc-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); margin-top: 6px; }
.sc-legend span::before { content: ""; display: inline-block; width: 18px; margin-right: 6px; vertical-align: middle; }
.lg-patient::before { border-top: 3px solid var(--c); }
.lg-pred::before { border-top: 2px dashed var(--indigo); }
.lg-band::before { height: 10px; border-radius: 3px; background: var(--grad-brand); opacity: .35; }
@media (max-width: 640px) { .sc-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .sc .sc-patient, .sc .sc-band, .sc .sc-pred, .sc .sc-dot, .sc .sc-label { transition: none; } }

/* ---------- spirometry ---------- */
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; }
.card-head h2 svg { width: 20px; height: 20px; color: var(--indigo); }
.card-head .chip { margin-left: auto; }
.steps { margin: 0; padding-left: 1.3rem; color: var(--muted); display: grid; gap: 4px; }
.spiro-res { display: flex; flex-direction: column; gap: 10px; }
.spiro-who { margin: 0; font-size: .85rem; color: var(--muted); }
.srows { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-sm); }
.srow { display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 118px; padding: 14px 18px; background: var(--surface); }
.srow.s-ok { background: color-mix(in srgb, var(--ok-bg) 70%, var(--surface)); }
.srow.s-warn { background: var(--warn-bg); box-shadow: inset 4px 0 0 var(--warn-fill); }
.srow.s-crit { background: var(--crit-bg); box-shadow: inset 4px 0 0 var(--crit-fill); }
.sv-name { font-size: .8rem; font-weight: 600; color: var(--muted); }
.sv-val { font: 800 2.3rem/1.05 var(--font); letter-spacing: -.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.srow.s-na .sv-val { color: var(--ink); }
.sv-unit { font-size: .78rem; font-weight: 600; color: var(--muted); margin-left: 4px; }
.sv-pct { font-size: .85rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.sv-ref { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.blows { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.blows th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.blows td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.blows tr.top td { font-weight: 700; }
.blow-list summary { cursor: pointer; font-weight: 600; color: var(--muted); font-size: .88rem; padding: 4px 0; }
.spiro-read { margin: 0; padding: 12px 14px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--ok-fill) 35%, var(--line)); background: linear-gradient(135deg, var(--ok-bg), var(--surface) 80%); }
.spiro-read.s-warn { border-color: color-mix(in srgb, var(--warn-fill) 45%, var(--line)); background: linear-gradient(135deg, var(--warn-bg), var(--surface) 80%); }
.spiro-read.s-crit { border-color: var(--crit-fill); background: linear-gradient(135deg, var(--crit-bg), var(--surface) 80%); }
.small { font-size: .82rem; }
@media (max-width: 760px) { .srows { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- heart rhythm from the BP monitor (PARR) ---------- */
.rh { margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 6px; }
.rh-title { font-size: .72rem; font-weight: 700; letter-spacing: .03em; color: var(--muted); }
.rh-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.rh-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid transparent; line-height: 1.25; }
.rh-badge b { display: inline-grid; place-items: center; min-width: 26px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: .66rem; font-weight: 800; letter-spacing: .04em; color: #fff; }
.rh-badge.ok { color: var(--ok); background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok-fill) 35%, transparent); }
.rh-badge.ok b { background: var(--grad-ok); }
.rh-badge.warn { color: var(--warn); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn-fill) 40%, transparent); }
.rh-badge.warn b { background: var(--grad-warn); }
.rh-badge.strong { color: var(--crit); background: var(--crit-bg); border-color: var(--crit-fill); }
.rh-badge.strong b { background: var(--grad-crit); }
.rh-note { margin: 0; font-size: .74rem; font-weight: 600; color: var(--crit); }
.rh-note.quality { color: var(--warn); font-weight: 500; }

/* ---------- ACT: one artery picture for the patient's level ---------- */
.actp svg { display: block; width: 88px; height: 88px; filter: drop-shadow(0 2px 4px rgba(20, 18, 43, .18)); }
.vt-mid .actp { align-self: center; margin-left: 14px; }
.vt-mid .actp svg { width: 64px; height: 64px; }
.actp.pop svg { animation: act-pop .45s ease-out; }
@keyframes act-pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .actp.pop svg { animation: none; } }

/* ---------- device data log (diagnostics) ---------- */
.devlog summary { cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--muted); }
.devlog-pre { max-height: 180px; overflow: auto; margin: 6px 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font: .72rem/1.45 var(--mono); white-space: pre-wrap; word-break: break-all; }

/* ---------- visit screen: one page without scrolling ---------- */
/* Top: patient, devices (green when connected), save and print; then the section buttons and the call
   button. Below: measurements on the left; complaint, examination record and advice on the right. */
.view-visit { max-width: 1440px; gap: 12px; padding-top: 14px; padding-bottom: 16px; }
.vhead { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.vh-row { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; min-width: 0; }
.vh-who { display: flex; flex-direction: column; min-width: 0; max-width: 340px; }
.vh-who h1 { font-size: 1.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vh-who .sub { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vh-dev { display: flex; flex-direction: column; gap: 4px; flex: 1 1 420px; min-width: 0; }
.vh-devstatus { font-size: .8rem; font-weight: 600; color: var(--primary); }
.vh-devstatus:empty { display: none; }
.vh-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.vh-saved { font-size: .75rem; }
.vh-saved:not(:empty)::before { content: "· "; }
.devchips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.devchip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px 0 10px; border: 1px dashed var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--muted); font: 600 .82rem/1 var(--font); white-space: nowrap; cursor: pointer; }
.devchip .ic { width: 16px; height: 16px; }
.devchip:hover { border-color: var(--primary); color: var(--ink); }
.devchip.on { border: 1px solid transparent; background: var(--grad-ok); color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(63, 122, 28, .28); }
.devchip.on::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); animation: dev-on 1.8s ease-out infinite; }
@keyframes dev-on { 0% { box-shadow: 0 0 0 0 rgba(46, 230, 182, .75); } 70%, 100% { box-shadow: 0 0 0 7px rgba(46, 230, 182, 0); } }
@media (prefers-reduced-motion: reduce) { .devchip.on::after { animation: none; } }
/* Linked before, switched off now: it reconnects by itself when turned on. */
.devchip.wait { border-style: solid; color: var(--ink); }
.devchip.wait::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.devadd { width: 36px; min-height: 36px; color: var(--primary); }
.vh-tools { justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--line); }
.secbar { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 auto; min-width: 0; }
.secbtn { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px 0 13px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--ink); font: 700 .93rem/1.15 var(--font); cursor: pointer; }
.secbtn .ic { width: 22px; height: 22px; color: var(--primary); }
.secbtn:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.sbadge { position: absolute; top: -8px; right: -8px; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: #fff; font: 800 .72rem/1 var(--font); box-shadow: 0 0 0 2px var(--surface); }
.sbadge.s-ok { background: var(--ok); }
.sbadge.s-warn { background: var(--warn-fill); color: #3A2A00; }
.sbadge.s-crit { background: var(--crit-fill); }
.vh-call { min-height: 52px; padding: 0 24px; margin-left: auto; }
.vh-call .ic { width: 22px; height: 22px; }

.vgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 980px) { .vgrid { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); } }
.vgrid .card { padding: 14px 16px; gap: 10px; }
.vcard .card-head small { margin-left: auto; font-size: .75rem; }
.vside { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.vc-complaint textarea { min-height: 64px; }
/* Visit path: numbered steps (the next one highlighted), extra sections as small buttons, Finish. */
.vpath { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.vstep { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 4px 10px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; text-align: left; }
button.vstep { cursor: pointer; }
button.vstep:hover { background: var(--surface-2); }
.vs-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-strong); color: var(--muted); font: 800 .8rem/1 var(--font); }
.vs-num .ic { width: 15px; height: 15px; }
.vstep.done .vs-num { border-color: transparent; background: var(--ok-fill); color: #fff; }
.vstep.next { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); }
.vstep.next .vs-num { border-color: var(--primary); background: var(--primary); color: #fff; }
.vstep.urgent { border-color: var(--crit-fill); background: var(--crit-bg); }
.vstep.urgent .vs-num { border-color: var(--crit-fill); background: var(--crit-fill); color: #fff; }
.vstep.urgent small { color: var(--crit); font-weight: 700; }
.vs-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.vs-main b { font-size: .92rem; }
.vs-main small { overflow: hidden; color: var(--muted); font-size: .8rem; white-space: nowrap; text-overflow: ellipsis; }
.vstep.done .vs-main small { color: var(--ink); }
.vpath .adv-box { margin: 2px 0 6px 48px; }
.vpath-extra-head { margin-top: 4px; font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.vpath-extra { display: flex; flex-wrap: wrap; gap: 6px; }
.vx { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: 600 .82rem/1 var(--font); cursor: pointer; }
.vx .ic { width: 16px; height: 16px; color: var(--muted); }
.vx.done { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: var(--ok-bg); }
.vx.done .ic { color: var(--ok); }
.vpath-finish { flex: none; }
.vpath-finish.finished { background: var(--grad-ok); }
.btn-crit { border-color: transparent; background: var(--crit-fill); color: #fff; }
.btn-crit:hover { background: color-mix(in srgb, var(--crit-fill) 85%, #000); }
.chip-action { border: 0; cursor: pointer; font-family: var(--font); }
.chip-action:hover { filter: brightness(.96); text-decoration: underline; }
.fin-kv dd { white-space: pre-line; }

/* Early warning (NEWS2) next to the patient's name. */
.ews { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 14px 4px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.ews small { font-size: .68rem; font-weight: 800; letter-spacing: .06em; color: var(--muted); }
.ews b { font: 800 1.35rem/1 var(--font); font-variant-numeric: tabular-nums; }
.ews span { font-size: .8rem; font-weight: 700; }
.ews.s-ok b { color: var(--ok); }
.ews.s-warn { border-color: var(--warn-fill); box-shadow: inset 4px 0 0 var(--warn-fill); }
.ews.s-warn b, .ews.s-warn span { color: var(--warn); }
.ews.s-crit { border-color: var(--crit-fill); background: var(--crit-fill); color: #fff; }
.ews.s-crit small { color: rgba(255, 255, 255, .85); }
.ews-big { display: flex; align-items: baseline; gap: 12px; padding: 14px 18px; border-radius: 14px; background: var(--surface-2); }
.ews-big b { font: 800 2.6rem/1 var(--font); }
.ews-big span { font-weight: 800; }
.ews-big.s-warn { background: var(--warn-bg); color: var(--warn); }
.ews-big.s-crit { background: var(--crit-fill); color: #fff; }
.ews-big.s-ok { background: var(--ok-bg); color: var(--ok); }
.ews-parts { margin: 0; padding-left: 20px; font-size: .88rem; line-height: 1.6; }

/* Device connection dot on the spirometer and dermatoscope section buttons. */
.sdot { position: absolute; bottom: 6px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.sdot.on { background: var(--mint); box-shadow: 0 0 0 2px var(--surface), 0 0 8px var(--mint); }
.lineb.suggested { border-color: var(--crit-fill); background: var(--crit-bg); box-shadow: inset 0 4px 0 var(--crit-fill), 0 0 0 3px color-mix(in srgb, var(--crit-fill) 25%, transparent); }
.adv-box { gap: 8px; }
.adv-box .row-actions .btn { min-height: 36px; margin-left: auto; padding: 0 10px; }
.adv-short { display: -webkit-box; overflow: hidden; padding-left: 10px; border-left: 3px solid var(--spec); font-size: .9rem; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.adv-short.urgent { border-left-color: var(--crit-fill); }

/* Upright tablet (portrait): the call button moves up beside print and save, the device chips get
   their own line and all section buttons share one row (icon above the name). */
@media (min-width: 700px) and (max-width: 979px) {
  .vhead { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto auto; grid-template-areas: "back av who ews act call" "dev dev dev dev dev dev" "sec sec sec sec sec sec"; align-items: center; gap: 8px 10px; }
  .vh-row > .ews { grid-area: ews; }
  .ews span { display: none; }
  .vh-row { display: contents; }
  .vh-row > .btn-icon { grid-area: back; }
  .vh-row > .avatar { grid-area: av; }
  .vh-who { grid-area: who; max-width: none; }
  .vh-dev { grid-area: dev; }
  .vh-actions { grid-area: act; margin-left: 0; }
  .vh-call { grid-area: call; margin-left: 0; min-height: 44px; padding: 0 18px; }
  .secbar { grid-area: sec; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
  .secbtn { flex-direction: column; justify-content: center; gap: 4px; min-height: 60px; padding: 6px 4px; font-size: .8rem; text-align: center; }
  .secbtn .sbadge { right: 4px; }
}

/* Wide screens and upright tablets: the visit fills the window exactly; long content scrolls inside
   its own card. */
@media (min-width: 980px) and (min-height: 600px), (min-width: 700px) and (min-height: 1000px) {
  #app.fit { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
  #app.fit > .topbar { flex: none; }
  #app.fit > .view-visit { flex: 1; min-height: 0; width: 100%; }
  .view-visit .vgrid { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  .view-visit .vcard { min-height: 0; overflow: hidden; }
  .view-visit .vcard .vwrap { flex: 1; min-height: 0; }
  .view-visit .vcard .vboard { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .view-visit .vt { min-height: 0; overflow: hidden; }
  .view-visit .vside { min-height: 0; }
  .view-visit .vc-record { flex: 1 1 auto; min-height: 0; overflow: auto; }
}
/* Upright tablet: measurements on top, then complaint and advice beside the examination record. */
@media (min-width: 700px) and (max-width: 979px) and (min-height: 1000px) {
  .view-visit .vgrid { grid-template-rows: minmax(0, 1fr) auto; }
  .view-visit .vside { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-content: start; }
  .view-visit .vside > * { grid-column: 1 / -1; }
  .view-visit .vside > .vc-complaint, .view-visit .vside > .vpath-finish { grid-column: 1; }
  .view-visit .vside > .vpath-finish { align-self: end; }
  .view-visit .vside > .vc-record { grid-column: 2; grid-row: span 2; max-height: 380px; }
}
/* Short screens (laptops with the browser bar): tighter spacing so everything still fits. */
@media (min-width: 980px) and (min-height: 600px) and (max-height: 780px) {
  .view-visit { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .vhead { gap: 8px; padding: 8px 12px; }
  .vh-tools { padding-top: 8px; }
  .secbtn { min-height: 42px; }
  .vh-call { min-height: 44px; }
  .vgrid { gap: 8px; }
  .vside { gap: 8px; }
  .vgrid .card { gap: 8px; padding: 10px 14px; }
  .view-visit .vt { gap: 4px; padding: 8px 14px 10px; }
  .view-visit .vt-val { font-size: 2.1rem; }
  .view-visit .vt-mid { margin-top: 0; }
  .view-visit .act-detail .actp svg { width: 52px; height: 52px; }
  .view-visit .acts { padding-top: 12px; }
  .view-visit .rh { margin-top: 2px; padding-top: 4px; gap: 4px; }
  .view-visit .vb input { min-height: 36px; }
  .vc-complaint textarea { min-height: 48px; }
  .recrow { min-height: 34px; }
}
@media (max-width: 640px) {
  .vh-actions { margin-left: 0; }
  .secbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vh-call { width: 100%; }
}

/* ---------- section windows (dermatoscope, spirometry, eye, mental health, tests, camera, record) ---------- */
body.sw-open { overflow: hidden; }
.sw { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--bg); animation: sw-in .18s ease-out; }
@keyframes sw-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sw { animation: none; } }
.sw-head { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 10px max(16px, env(safe-area-inset-left)); padding-top: max(10px, env(safe-area-inset-top)); background: var(--grad-brand); color: #fff; box-shadow: 0 6px 24px rgba(79, 70, 229, .25); }
.sw-head h2 { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; }
.sw-head h2 .ic { width: 26px; height: 26px; }
.sw-patient { min-width: 0; overflow: hidden; color: rgba(255, 255, 255, .86); font-size: .92rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.sw-close { margin-left: auto; color: #fff; }
.sw-close:hover { background: rgba(255, 255, 255, .16); }
.sw-head :focus-visible { outline-color: #fff; }
.sw-strip { padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sw-body { flex: 1; min-height: 0; overflow: auto; display: grid; gap: 16px; align-content: start; width: 100%; max-width: 1440px; margin: 0 auto; padding: 16px 16px 40px; }
@media (min-width: 980px) { .sw-body.two { grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr); align-items: start; } }
.sw-tools, .sw-note { min-width: 0; }

.vstrip { display: flex; flex-wrap: wrap; gap: 6px 8px; max-width: 1408px; margin: 0 auto; }
.vs { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: .8rem; }
.vs .ic { align-self: center; width: 15px; height: 15px; color: var(--muted); }
.vs-l { color: var(--muted); font-weight: 600; }
.vs b { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.vs i { color: var(--muted); font-size: .74rem; font-style: normal; }
.vs.s-none b { color: var(--line-strong); }
.vs.s-ok { background: color-mix(in srgb, var(--ok-bg) 70%, var(--surface)); }
.vs.s-ok b { color: var(--ok); }
.vs.s-warn { background: var(--warn-bg); border-color: var(--warn-fill); }
.vs.s-warn b { color: var(--warn); }
.vs.s-crit { background: var(--crit-bg); border-color: var(--crit-fill); }
.vs.s-crit b { color: var(--crit); }

/* Section note: the doctor, then the record fields (two columns when the window has no tools). */
.nf { gap: 12px; }
.nf .card-head small { margin-left: auto; }
.sw-body:not(.two) .nf { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: end; gap: 12px 20px; }
.sw-body:not(.two) .nf > .card-head, .sw-body:not(.two) .nf > p, .sw-body:not(.two) .nf .nf-wide { grid-column: 1 / -1; }
.nf-doctor input { font-weight: 700; }
.nf-head { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nf-key > span { color: var(--primary); }
.nf-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.nf-opt { min-height: 40px; padding: 4px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font: 600 .9rem/1.2 var(--font); cursor: pointer; }
.nf-opt:hover { border-color: var(--primary); }
.nf-opt[aria-pressed="true"] { border-color: transparent; background: var(--grad-action); color: #fff; }
.nf-opt.multi[aria-pressed="true"]::before { content: "✓ "; }
.nf-eyerow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.nf-eye { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nf-eye b { color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* ---------- call: choose the line, then the doctor ---------- */
.lines { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.lineb { --c: var(--indigo); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 124px; padding: 16px 14px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: inset 0 4px 0 var(--c); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.lineb:hover { border-color: var(--c); background: color-mix(in srgb, var(--c) 7%, var(--surface)); }
.lineb .ic { width: 32px; height: 32px; color: var(--c); }
.lineb b { font-size: 1rem; line-height: 1.2; }
.lineb small { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; color: var(--muted); font-size: .8rem; font-weight: 600; }
.lineb small.on { color: var(--ok); }
.lineb small.on::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok-fill); }
.l-emergency { --c: #C2183A; }
.l-mental { --c: #7C3AED; }
.l-maternal { --c: #DB2777; }
.l-child { --c: #0891B2; }
.l-other { --c: #4F46E5; }
.l-hotel { --c: #0E7490; }
.lineb.l-emergency { background: linear-gradient(135deg, var(--crit-bg), var(--surface) 75%); }
.line-chip { background: var(--c); color: #fff; }
.line-chip .ic { width: 14px; height: 14px; }
.crit-note, .note-box.crit-note { color: var(--crit); background: var(--crit-bg); font-weight: 600; }
.note-box { font-size: .88rem; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }

/* ---------- advice ---------- */
.advice { border-left: 4px solid var(--spec); }
.advice.urgent { border-left-color: var(--crit); }
.advice ul { margin: 0; padding-left: 1.2rem; }
.advice-meta { font-size: .85rem; color: var(--muted); }

/* ---------- modal & toasts ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(8, 16, 28, .55); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
/* Callback requests: the clinic's box when nobody is free, and the specialist's list. */
.cb-box { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px dashed var(--line-strong); border-radius: 14px; background: var(--surface-2); }
.cb-box p { margin: 0; font-size: .92rem; }
.lineb small.asked { color: var(--primary); font-weight: 700; }
.cb-list { display: flex; flex-direction: column; gap: 8px; }
.cb-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.cb-row .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cb-row .main small { color: var(--muted); }
.cb-row.urgent { border-color: var(--crit-fill); background: var(--crit-bg); }
.cb-row.mine:not(.urgent) { border-color: color-mix(in srgb, var(--spec) 45%, var(--line)); }
.slist { display: flex; flex-direction: column; gap: 8px; }
.sitem { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.sitem:hover:not(:disabled) { border-color: var(--spec); }
.sitem .avatar { background: var(--spec-soft); color: var(--spec); }
.sitem .main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sitem small { color: var(--muted); }
.toasts { position: fixed; z-index: 80; right: 16px; bottom: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 440px; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow); }
.toast.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.toast.crit { background: var(--crit-bg); color: var(--crit); border: 1px solid var(--crit); }
.toast.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); }
.ring { animation: ring 1s infinite; }
@keyframes ring { 50% { transform: scale(1.06); } }

/* ---------- call ---------- */
.call-overlay { position: fixed; inset: 0; z-index: 60; background: radial-gradient(1100px 560px at 8% -10%, rgba(109, 40, 217, .38), transparent 60%), radial-gradient(900px 520px at 110% 110%, rgba(6, 182, 212, .26), transparent 60%), #0B0A18; color: #ECEAFB; display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) { .call-overlay.has-side { grid-template-columns: minmax(0, 1fr) 420px; } }
.call-main { display: flex; flex-direction: column; min-height: 0; }
.call-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
.call-head .who-call { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.call-head small { color: #A5A2C7; }
.call-status { font-size: .9rem; font-weight: 600; color: #FCD34D; }
.call-status.ok { color: #34D399; }
.call-net { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.call-net::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.call-net.weak { color: #FCD34D; background: rgba(252, 211, 77, .14); }
.call-net.poor { color: #FCA5A5; background: rgba(252, 165, 165, .16); }
.call-timer { font-family: var(--mono); color: #A5A2C7; }
.call-videos { position: relative; flex: 1; min-height: 240px; margin: 0 12px; border-radius: 14px; overflow: hidden; background: #14122A; }
.v-remote { width: 100%; height: 100%; object-fit: contain; background: #14122A; }
.v-local { position: absolute; right: 12px; bottom: 12px; width: 28%; max-width: 220px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .5); background: #1C1A38; transform: scaleX(-1); }
.call-controls { display: flex; justify-content: center; gap: 10px; padding: 14px; flex-wrap: wrap; }
.call-controls .btn { background: #1C1A38; border-color: #2E2A5C; color: #ECEAFB; }
.call-controls .btn[aria-pressed="true"] { background: #2EE6B6; color: #04201A; border-color: #2EE6B6; }
.call-controls .btn-danger { background: #E11D48; border-color: #E11D48; }
.call-side { background: var(--bg); color: var(--ink); overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; max-height: 100vh; }
@media (max-width: 979px) { .call-overlay.has-side { overflow: auto; } .call-side { max-height: none; } .call-videos { min-height: 46vh; } }
.adv-items { display: flex; flex-direction: column; gap: 6px; }
.adv-items label { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; cursor: pointer; }
.adv-items input { width: 20px; height: 20px; min-height: 0; margin-top: 2px; accent-color: var(--spec); flex: none; }

/* ---------- photos ---------- */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.pthumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); padding: 0; min-width: 0; }
button.pthumb { cursor: pointer; display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pview { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.pview:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }
.pthumb .cap { position: absolute; left: 0; right: 0; bottom: 0; font-size: .7rem; line-height: 1.3; background: rgba(5, 12, 22, .62); color: #fff; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pthumb .del { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(5, 12, 22, .62); color: #fff; display: grid; place-items: center; cursor: pointer; }
.pthumb .del .ic { width: 16px; height: 16px; }
.pthumb .del:hover { background: var(--crit); }
.pthumb .prog { font-family: var(--mono); }
.modal.wide { max-width: 880px; }
.cam-preview { width: 100%; max-height: 54vh; background: #14122A; border-radius: 12px; object-fit: contain; }
.lightbox-img { width: 100%; max-height: 74vh; object-fit: contain; background: #14122A; border-radius: 12px; }
.v-local.nomirror { transform: none; }
.call-controls .cam-switch { width: auto; max-width: 240px; min-height: 44px; background: #1C1A38; color: #ECEAFB; border-color: #2E2A5C; border-radius: 10px; }

/* ---------- camera check (face scan) ---------- */
/* The stage is mirrored like a selfie; the overlay (oval and measured patches) mirrors with it. */
.cam-stage { position: relative; width: 100%; aspect-ratio: 4 / 3; max-width: calc(52vh * 4 / 3); margin: 0 auto; border-radius: 12px; overflow: hidden; background: #14122A; transform: scaleX(-1); }
.cam-stage video, .cam-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-status { margin: 0; min-height: 1.5em; font-weight: 600; }
.cam-status.warn { color: var(--warn); }
.cam-progress { display: flex; align-items: center; gap: 10px; }
.cam-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.cam-bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width .25s linear; }
.cam-live { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cam-live > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.cam-live small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; font-weight: 600; color: var(--muted); }
.cam-live i { margin-left: 4px; font-style: normal; font-size: .8rem; color: var(--muted); }
.cam-num { font: 700 1.6rem/1.15 var(--font); font-variant-numeric: tabular-nums; }
.cam-wave { display: block; width: 100%; height: 64px; color: var(--primary); }
.cam-cmp { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: .88rem; }
@media (prefers-reduced-motion: reduce) { .cam-bar i { transition: none; } }
.cam-diff { margin-left: 8px; font-weight: 700; color: var(--muted); }
.cam-diff.warn { color: var(--crit); }
.cam-cmp li.warn { font-weight: 700; color: var(--crit); }
.note-box.warn { color: var(--warn); background: var(--warn-bg); font-weight: 600; }
.vboard.cam3 { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: none; }
.vt-note { min-height: 1.2em; font-size: .78rem; font-weight: 600; color: var(--muted); }
/* Screen light: while the camera checks, the whole screen turns white and lights the face. */
.modal-back.cam-lit { background: #FFFFFF; }
.modal-back.cam-lit .modal { --surface: #FFFFFF; --surface-2: #EEEDF8; --ink: #14122B; --muted: #5E5B7A; --line: #E2E0F0; background: #FFFFFF; color: #14122B; box-shadow: none; }
.modal-back:fullscreen { padding: 16px; }
.cam-acc table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.cam-acc th, .cam-acc td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.cam-acc th { font-size: .78rem; color: var(--muted); font-weight: 700; }
/* Camera report: four across (two on phones); plain-ink numbers for values without a normal range. */
.vboard.cam4 { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-areas: none; }
@media (max-width: 760px) { .vboard.cam4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.vt.s-info .vt-val { color: var(--ink); }
.vt.a-word .vt-val { font-size: 1.7rem; letter-spacing: -.01em; }
.vt .cam-scale { padding-top: 6px; }
.cam-factors .row-actions { gap: 8px; }
.cam-factor { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 600 .88rem var(--font); cursor: pointer; }
.cam-factor[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.cam-factor[aria-pressed="true"]::before { content: "✓ "; }

/* ---------- specialist dashboard ---------- */
.spec-hero { background: linear-gradient(135deg, var(--spec-soft), var(--surface)); }
.waiting { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.pulse-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--spec); animation: pulse 1.6s infinite; flex: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(11, 122, 113, .5); } 70% { box-shadow: 0 0 0 12px rgba(11, 122, 113, 0); } 100% { box-shadow: 0 0 0 0 rgba(11, 122, 113, 0); } }
@media (prefers-reduced-motion: reduce) { .pulse-dot, .ring { animation: none; } }

/* ---------- print ---------- */
/* ---------- printout: one A4 page (also laid out off-screen to measure it before printing) ---------- */
.print-area { display: none; color: #14122B; font: 9.5pt/1.4 var(--font); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.print-area.measuring { display: block; position: absolute; left: -10000px; top: 0; width: 188mm; }
@page { size: A4; margin: 11mm; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  body { background: #fff; }
  .print-area { display: block; }
}
.print-area h2 { margin: 0 0 4pt; font-size: 10.5pt; color: #4F46E5; letter-spacing: .02em; }
.print-area .sc *, .print-area .actp svg { transition: none !important; animation: none !important; }
.p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12pt; padding-bottom: 6pt; border-bottom: 2.5pt solid #4F46E5; border-image: linear-gradient(90deg, #6D28D9, #4F46E5, #06B6D4) 1; }
.p-brand { display: flex; align-items: center; gap: 8pt; }
.p-brand .brand-mark { width: 30pt; height: 30pt; }
.p-brand b { display: block; font-size: 15pt; line-height: 1.1; }
.p-brand span { font-size: 9pt; color: #5E5B7A; }
.p-meta { text-align: right; font-size: 8.5pt; color: #3B3858; }
.p-patient { display: flex; flex-direction: column; gap: 2pt; padding: 6pt 0; border-bottom: 1px solid #E2E0F0; }
.p-patient b { margin-right: 8pt; font-size: 12pt; }
.p-k { font-weight: 600; color: #5E5B7A; }
.p-sec { margin-top: 8pt; break-inside: avoid; }
.p-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: #D9D6EA; border: 1px solid #D9D6EA; border-radius: 6pt; overflow: hidden; }
.pc { min-height: 44pt; padding: 5pt 7pt; background: #fff; }
.pc.s-ok { background: #EEF6E5; }
.pc.s-warn { background: #FFF5D1; box-shadow: inset 3pt 0 0 #F2B200; }
.pc.s-crit { background: #FBE6EA; box-shadow: inset 3pt 0 0 #A3122F; }
.pc-l { font-size: 8pt; font-weight: 600; color: #5E5B7A; }
.pc-v { display: flex; flex-wrap: wrap; align-items: center; gap: 2pt 4pt; }
.pc-v b { font-size: 16pt; font-weight: 800; letter-spacing: -.02em; }
.pc-v span { font-size: 8pt; color: #5E5B7A; }
.pc-v em { width: 100%; font-style: normal; font-size: 7.5pt; color: #5E5B7A; }
.pc-v .actp svg { width: 26pt; height: 26pt; filter: none; }
.pc-s { font-size: 8pt; font-weight: 800; }
.pc.s-ok .pc-s, .pc.s-ok .pc-v b { color: #3F7A1C; }
.pc.s-warn .pc-s, .pc.s-warn .pc-v b { color: #8A5D00; }
.pc.s-crit .pc-s, .pc.s-crit .pc-v b { color: #A3122F; }
.p-line { margin: 4pt 0 0; }
.p-spiro { display: grid; grid-template-columns: 42% 1fr; gap: 8pt; align-items: start; }
.p-table { width: 100%; border-collapse: collapse; font-size: 8.5pt; }
.p-table th { padding: 2pt 4pt; border-bottom: 1px solid #D9D6EA; text-align: left; font-weight: 600; color: #5E5B7A; }
.p-table td { padding: 2.5pt 4pt; border-bottom: 1px solid #EEEDF8; }
.p-table tr.s-warn td:first-child { box-shadow: inset 2pt 0 0 #F2B200; }
.p-table tr.s-crit td:first-child { box-shadow: inset 2pt 0 0 #A3122F; }
.p-read { margin: 5pt 0 2pt; padding: 4pt 6pt; border-radius: 4pt; background: #EEF6E5; font-size: 8.5pt; }
.p-read.s-warn { background: #FFF5D1; }
.p-read.s-crit { background: #FBE6EA; }
.p-small { margin: 2pt 0 0; font-size: 7.5pt; color: #5E5B7A; }
.print-area .sc-grid { grid-template-columns: 1fr 1fr; gap: 4pt; }
.print-area .sc figure { padding: 3pt; border-radius: 4pt; box-shadow: none; }
.print-area .sc figcaption { font-size: 7.5pt; }
.print-area .sc-legend { gap: 8pt; margin-top: 2pt; font-size: 7pt; }
.print-area .sc .muted.small { display: none; }
.p-note { margin: 2pt 0; font-size: 8.5pt; line-height: 1.35; }
.p-advice p, .p-advice ul { margin: 2pt 0; }
.p-advice.urgent { padding-left: 6pt; border-left: 3pt solid #E11D48; }
.p-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6pt; }
.p-photos figure { margin: 0; }
.p-photos img { width: 100%; height: 34mm; object-fit: cover; border: 1px solid #ccc; border-radius: 3pt; }
.p-photos figcaption { font-size: 7.5pt; color: #3B3858; }
.p-foot { margin-top: 8pt; padding-top: 4pt; border-top: 1px solid #E2E0F0; font-size: 7.5pt; color: #5E5B7A; }

.sample-chip { margin-left: 8px; vertical-align: middle; font-size: .7rem; letter-spacing: .02em; }
h1 .sample-chip { font-size: .75rem; position: relative; top: -3px; }

/* ---------- screenings and guided tests ---------- */
.scr-group { margin-bottom: 12px; }
.scr-group h3, .scr-h { margin: 0 0 8px; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.scr-h { margin-top: 16px; }
.scr-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.scr-tool { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); font: 700 .95rem/1.25 var(--font); color: var(--ink); text-align: left; cursor: pointer; }
.scr-tool:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 40%, var(--surface)); }
.scr-tool svg { flex: none; width: 22px; height: 22px; color: var(--primary); }
.scr-form { gap: 10px; }
.scr-age input { max-width: 8em; font: 700 1.2rem var(--font); }
.scr-note { margin: -4px 0 0; font-size: .82rem; color: var(--muted); }
.scr-note.warn { color: var(--warn); font-weight: 700; }
.scr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.scr-q { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface); }
.scr-q.many { grid-template-columns: 34px minmax(0, 1fr); }
.scr-q.many .scr-btns { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.scr-q.done { background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.scr-q p { margin: 0; line-height: 1.4; }
.scr-n { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); font-weight: 800; font-size: .85rem; color: var(--muted); }
.scr-q.done .scr-n { background: var(--grad-action); color: #fff; }
.scr-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.scr-opt { min-width: 76px; min-height: 48px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); font: 700 .95rem/1.2 var(--font); color: var(--ink); cursor: pointer; }
.scr-opt:hover { border-color: var(--primary); }
.scr-opt[aria-pressed="true"] { background: var(--grad-action); border-color: transparent; color: #fff; }
.scr-count { margin-right: auto; font-weight: 700; color: var(--muted); }
.scr-copy { margin: 0; font-size: .74rem; color: var(--muted); }
.scr-results { display: grid; gap: 10px; }
.scr-res { padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); display: grid; gap: 4px; }
.scr-res.s-ok { background: color-mix(in srgb, var(--ok-bg) 70%, var(--surface)); box-shadow: inset 4px 0 0 var(--ok); }
.scr-res.s-warn { background: var(--warn-bg); box-shadow: inset 4px 0 0 var(--warn-fill); }
.scr-res.s-crit { background: var(--crit-bg); box-shadow: inset 4px 0 0 var(--crit-fill); }
.scr-res-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scr-badge { padding: 3px 11px; border-radius: 999px; font-size: .78rem; font-weight: 800; background: var(--line); }
.scr-res.s-ok .scr-badge { background: var(--ok); color: #fff; }
.scr-res.s-warn .scr-badge { background: var(--warn-fill); color: #3A2A00; }
.scr-res.s-crit .scr-badge { background: var(--crit-fill); color: #fff; }
.scr-res-mid { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.scr-score { font: 800 2.2rem/1 var(--font); letter-spacing: -.02em; }
.scr-res.s-ok .scr-score { color: var(--ok); } .scr-res.s-warn .scr-score { color: var(--warn); } .scr-res.s-crit .scr-score { color: var(--crit); }
.scr-of { color: var(--muted); font-weight: 600; }
.scr-meta { margin-left: auto; font-size: .8rem; color: var(--muted); }
.scr-adv, .scr-flag { margin: 0; font-size: .9rem; }
.scr-flag { color: var(--muted); }
.scr-alert { margin: 2px 0; padding: 8px 12px; border-radius: 10px; background: var(--crit-fill); color: #fff; font-weight: 800; font-size: .9rem; }

/* Mini-Cog */
.mc-step { margin: 0; font-weight: 700; }
.mc-words { display: flex; flex-wrap: wrap; gap: 8px; }
.mc-words span { padding: 10px 18px; border-radius: 12px; background: var(--grad-brand); color: #fff; font: 800 1.25rem var(--font); }
.mc-clock { display: grid; justify-items: center; gap: 6px; }
.mc-canvas { width: min(100%, 360px); aspect-ratio: 1; border: 1px solid var(--line-strong); border-radius: 18px; background: #fff; touch-action: none; cursor: crosshair; }

/* Ishihara answer sheet */
.ish { display: grid; gap: 10px; }
.ish-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.05rem; }
.ish-head span { color: var(--muted); font-weight: 700; }
.ish-route .btn { flex: 1; }
.ish-typed { min-height: 64px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 14px; font: 800 2.4rem/1 var(--font); letter-spacing: .1em; background: var(--surface-2); }
.ish-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 420px; width: 100%; justify-self: center; }
.ish-key { min-height: 60px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); font: 800 1.5rem var(--font); color: var(--ink); cursor: pointer; }
.ish-key:active { background: var(--primary-soft); }
.ish-key.alt { color: var(--muted); }
.ish-key.go { background: var(--grad-action); border-color: transparent; color: #fff; font-size: 1rem; }
.ish-test { display: grid; gap: 14px; align-items: start; }
@media (min-width: 760px) { .ish-test { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.ish-plate { width: min(100%, 380px); aspect-ratio: 1; justify-self: center; border-radius: 50%; }
.ish-answer { display: grid; gap: 10px; }
.ish-trace { display: grid; gap: 8px; }
.ish-trace .scr-opt { text-align: left; }

/* timed device tests */
.ortho-clock { padding: 14px; border-radius: 14px; background: var(--surface-2); text-align: center; font: 800 2rem/1 var(--font); font-variant-numeric: tabular-nums; color: var(--muted); }
.ortho-clock.ready { background: var(--grad-action); color: #fff; }
.ortho-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.ortho-steps li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface); color: var(--muted); }
.ortho-steps li.on { background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); color: var(--ink); }
.ortho-steps li.done { color: var(--ink); }
.ortho-steps li.done span { font-weight: 800; color: var(--primary); }
.walk-live { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.walk-live span { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.walk-live small { color: var(--muted); font-weight: 700; }
.walk-live b { font: 800 1.8rem/1 var(--font); }
.walk-end { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.walk-end input { font: 700 1.2rem var(--font); }
.rr-count { text-align: center; font: 800 4.5rem/1 var(--font); font-variant-numeric: tabular-nums; background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rr-tap { min-height: 180px; border: 0; border-radius: 24px; background: var(--grad-action); color: #fff; font: 800 1.4rem var(--font); cursor: pointer; touch-action: manipulation; user-select: none; }
.rr-tap:active { transform: scale(.98); }
.rr-tap:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }

@media (max-width: 640px) {
  .scr-q, .scr-q.many { grid-template-columns: 30px minmax(0, 1fr); }
  .scr-btns, .scr-q.many .scr-btns { grid-column: 1 / -1; }
  .scr-q .scr-opt { flex: 1; }
}

/* ---------- bronchodilator test (spirometry) ---------- */
.bd-box { margin: 10px 0; padding: 12px 14px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--line)); background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.bd-box p { margin: 0 0 8px; }
.bd-clock { font-size: 1.15rem; font-variant-numeric: tabular-nums; color: var(--primary); }
.bd-clock.ready { padding: 4px 12px; border-radius: 999px; background: var(--grad-action); color: #fff; }
.bd-res { display: grid; gap: 8px; margin-top: 8px; }
.bd-res h3 { margin: 0; font-size: 1rem; }
.bd-table th[scope], .bd-table tbody th { text-align: left; }
