/* =====================================================================
   StrengthNorm - interface styles
   Signature element: the calibrated scale (.scale) used for every reading.
   ===================================================================== */

:root {
  color-scheme: light;
  --bench: #eef2f1;      /* page ground */
  --sheet: #ffffff;      /* panels */
  --sheet-2: #f6f8f7;    /* inset areas */
  --ink: #15232b;
  --ink-2: #4c5b62;
  --muted: #73838a;
  --rule: #d6dedc;
  --rule-strong: #b9c5c2;
  --pine: #0e6b5a;
  --pine-ink: #ffffff;
  --pine-wash: #e1f0ec;
  --focus: #0e6b5a;

  /* level scale: diverging red - grey - blue (validated for CVD separation) */
  --lv1: #a8302a;
  --lv2: #e0786b;
  --lv3: #dcdbd5;
  --lv4: #6aa3e6;
  --lv5: #1f5aa6;
  --lv0: #e6ebea;

  /* status (always with an icon and a label) */
  --good: #0a7d0a;
  --serious: #b9531f;
  --critical: #c43333;
  --serious-wash: #fbeee6;
  --critical-wash: #fbeaea;
  --good-wash: #e7f4e7;

  /* sides in charts: right, left, bilateral (validated categorical slots 2, 1, 3) */
  --side-r: #eb6834;
  --side-l: #2a78d6;
  --side-b: #1baf7a;

  --radius: 10px;
  --radius-sm: 6px;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-head: "Barlow Semi Condensed", "Arial Narrow", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bench: #11181c;
    --sheet: #182126;
    --sheet-2: #1d282e;
    --ink: #e7eef0;
    --ink-2: #a9b7bc;
    --muted: #87979d;
    --rule: #2a363c;
    --rule-strong: #3b4a51;
    --pine: #3fb59a;
    --pine-ink: #0b1a16;
    --pine-wash: #17332d;
    --focus: #3fb59a;
    --lv1: #f59a90;
    --lv2: #bf4f45;
    --lv3: #454b51;
    --lv4: #3d7fd0;
    --lv5: #a3cefa;
    --lv0: #263238;
    --good: #45c445;
    --serious: #ec835a;
    --critical: #f07070;
    --serious-wash: #3a2519;
    --critical-wash: #3b1f1f;
    --good-wash: #18301a;
    --side-r: #d95926;
    --side-l: #3987e5;
    --side-b: #199e70;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bench);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}
a { color: var(--pine); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0; letter-spacing: 0.005em; }
h1 { font-size: 2rem; font-weight: 600; }
h2 { font-size: 1.375rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }
p { margin: 0 0 0.75rem; }
small, .small { font-size: 0.875rem; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.rail {
  background: var(--sheet);
  border-right: 1px solid var(--rule);
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
}
.wordmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 0 8px; }
.wordmark svg { flex: none; }
.wordmark span { font-family: var(--font-head); font-weight: 600; font-size: 1.35rem; letter-spacing: 0.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: block; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-size: 0.95rem;
}
.nav a:hover { background: var(--sheet-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--pine-wash); color: var(--ink); font-weight: 700; }
.nav .nav-group { margin: 14px 10px 4px; font-size: 0.8rem; color: var(--muted); }
.rail-foot { margin-top: auto; padding: 0 10px; font-size: 0.85rem; color: var(--muted); }
.rail-foot a { color: var(--ink-2); }
.rail .menu-toggle { display: none; }

.main { padding: 28px clamp(16px, 3vw, 40px) 64px; max-width: 1240px; width: 100%; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 22px; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 8px; }
  .rail .menu-toggle { display: inline-flex; margin-left: auto; }
  .nav, .rail-foot { display: none; width: 100%; }
  .rail.open .nav, .rail.open .rail-foot { display: flex; }
  .rail-foot { padding: 8px 10px 0; flex-direction: column; }
  .main { padding: 20px 16px 48px; }
  h1 { font-size: 1.7rem; }
}

/* ------------------------------------------------------------ panels */
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px; }
.panel + .panel { margin-top: 18px; }
.cols > .panel + .panel, .cols-2 > .panel + .panel { margin-top: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; margin-bottom: 14px; }
.panel-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 0.92rem; }
.stack > * + * { margin-top: 18px; }
.cols { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.cols-2 { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .cols-2 { grid-template-columns: minmax(0, 1fr); } }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); }
.figure { padding: 16px 18px; border-left: 1px solid var(--rule); }
.figure:first-child { border-left: 0; }
.figure .value { font-family: var(--font-head); font-size: 2rem; font-weight: 600; line-height: 1.1; }
.figure .label { color: var(--ink-2); font-size: 0.9rem; }
@media (max-width: 640px) { .figure { border-left: 0; border-top: 1px solid var(--rule); } .figure:first-child { border-top: 0; } }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th { font-weight: 700; color: var(--ink-2); font-size: 0.85rem; border-bottom-color: var(--rule-strong); }
table.data td.n, table.data th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--sheet-2); }
table.data tr:last-child td { border-bottom: 0; }
table.compact th, table.compact td { padding: 6px 8px; }
.row-link { color: inherit; text-decoration: none; font-weight: 700; }
.row-link:hover { color: var(--pine); text-decoration: underline; }

/* ------------------------------------------------------------ forms */
label { font-weight: 700; font-size: 0.92rem; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.field .error { color: var(--critical); font-size: 0.85rem; font-weight: 700; }
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--sheet);
  border: 1px solid var(--rule-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; width: 100%; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
input[aria-invalid="true"] { border-color: var(--critical); }
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: 0.85rem; min-height: 320px; white-space: pre; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg label { font-weight: 400; display: inline-flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 8px 14px; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; }
.seg label + label span { border-left: 1px solid var(--rule-strong); }
.seg input:checked + span { background: var(--pine); color: var(--pine-ink); font-weight: 700; }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -3px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: 18px; height: 18px; accent-color: var(--pine); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 0.95rem;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--pine); background: var(--pine); color: var(--pine-ink);
  text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn-quiet:hover { background: var(--sheet-2); filter: none; }
.btn-danger { background: transparent; color: var(--critical); border-color: var(--critical); }
.btn-danger:hover { background: var(--critical-wash); filter: none; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 0.875rem; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--pine); text-decoration: underline; cursor: pointer; }

.alert { border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert-ok { background: var(--good-wash); border-color: var(--good); }
.alert-error { background: var(--critical-wash); border-color: var(--critical); }
.alert-info { background: var(--sheet); border-color: var(--rule-strong); }

/* ------------------------------------------------------------ levels & status */
.lvl { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 0.92rem; white-space: nowrap; }
.lvl::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--lv0); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); flex: none; }
.lvl.lv1::before { background: var(--lv1); }
.lvl.lv2::before { background: var(--lv2); }
.lvl.lv3::before { background: var(--lv3); }
.lvl.lv4::before { background: var(--lv4); }
.lvl.lv5::before { background: var(--lv5); }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.92rem; }
.status svg { flex: none; }
.status-ok { color: var(--good); }
.status-warn { color: var(--serious); }
.status-crit { color: var(--critical); }
.status-info { color: var(--ink-2); }
.tag { display: inline-block; font-size: 0.78rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--rule-strong); color: var(--ink-2); white-space: nowrap; }
.tag-conv { border-style: dashed; }

.flags { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.flags li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--critical-wash); }
.flags li.warn { background: var(--serious-wash); }
.flags li svg { flex: none; margin-top: 2px; }

/* ------------------------------------------------------------ the scale (signature) */
.scale { position: relative; width: 100%; min-width: 0; }
.scale svg { display: block; width: 100%; height: auto; overflow: visible; }
.scale .seg-rect { stroke: var(--sheet); stroke-width: 2; }
.scale .tick { fill: var(--muted); font-size: 11px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.scale .needle { fill: var(--ink); }
.scale .needle-line { stroke: var(--ink); stroke-width: 2; }
.scale .needle-label { fill: var(--ink); font-size: 12px; font-weight: 700; font-family: var(--font-body); }
.scale .target-band { fill: none; stroke: var(--pine); stroke-width: 2; }
.scale .base { fill: var(--lv0); }
.tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 260px;
  background: var(--ink); color: var(--sheet); font-size: 0.85rem; line-height: 1.35;
  padding: 7px 10px; border-radius: var(--radius-sm); box-shadow: 0 4px 14px rgba(0,0,0,.18);
  opacity: 0; transition: opacity .08s;
}
.tip.show { opacity: 1; }

/* ------------------------------------------------------------ readout rows (report & live form) */
.readouts { display: grid; }
.readout {
  display: grid; gap: 6px 22px; align-items: center;
  grid-template-columns: minmax(150px, 1.1fr) minmax(90px, .5fr) minmax(200px, 1.8fr) minmax(150px, .9fr);
  padding: 14px 0; border-bottom: 1px solid var(--rule);
}
.readout:last-child { border-bottom: 0; }
.readout .r-name { font-weight: 700; }
.readout .r-name small { display: block; font-weight: 400; color: var(--muted); }
.readout .r-value { font-family: var(--font-head); font-size: 1.5rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.readout .r-value small { font-family: var(--font-body); font-size: 0.8rem; font-weight: 400; color: var(--ink-2); margin-left: 3px; }
.readout .r-rate .pct { display: block; color: var(--ink-2); font-size: 0.875rem; }
.readout .r-rate .lvl, .live .lvl { white-space: normal; align-items: flex-start; }
.readout .r-rate .lvl::before, .live .lvl::before { margin-top: 4px; }
.readout .r-detail { grid-column: 1 / -1; color: var(--ink-2); font-size: 0.875rem; }
.readout .r-detail details summary { cursor: pointer; color: var(--pine); }
.readout .r-detail ul { margin: 6px 0 0; padding-left: 18px; }
.readout.no-norm .r-scale { color: var(--muted); font-size: 0.9rem; }
@media (max-width: 760px) {
  .readout { grid-template-columns: 1fr auto; }
  .readout .r-scale { grid-column: 1 / -1; }
  .readout .r-rate { grid-column: 1 / -1; }
}
.delta-up { color: var(--good); font-size: 0.8rem; font-weight: 700; }
.delta-down { color: var(--critical); font-size: 0.8rem; font-weight: 700; }

/* ratio cards */
.ratio-list { display: grid; gap: 14px; }
.ratio { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.6fr) minmax(150px, 1fr); gap: 8px 20px; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.ratio:last-child { border-bottom: 0; padding-bottom: 0; }
.ratio .r-val { font-family: var(--font-head); font-size: 1.6rem; font-weight: 600; }
@media (max-width: 760px) { .ratio { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ assessment form */
.battery-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  font: inherit; font-size: 0.9rem; cursor: pointer;
  border: 1px solid var(--rule-strong); background: var(--sheet); color: var(--ink);
  border-radius: 99px; padding: 6px 14px; min-height: 36px;
}
.chip[aria-pressed="true"] { background: var(--pine); color: var(--pine-ink); border-color: var(--pine); font-weight: 700; }
.test-group h2 { margin: 26px 0 10px; }
.test-block { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.test-block[hidden] { display: none; }
.test-block.has-value { border-color: var(--rule-strong); }
.tb-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.tb-head h3 { font-size: 1.2rem; }
.tb-head .unit { color: var(--ink-2); font-size: 0.9rem; }
.tb-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px 24px; margin-top: 12px; }
@media (max-width: 860px) { .tb-body { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 480px) {
  .side-row, .trial-head { grid-template-columns: 52px repeat(3, minmax(0, 1fr)) 52px; gap: 6px; }
  .side-row.single { grid-template-columns: 52px minmax(0, 1fr) 52px; }
  .test-block { padding: 14px; }
  .panel { padding: 16px; }
}
.side-row { display: grid; grid-template-columns: 70px repeat(3, minmax(0, 1fr)) 64px; gap: 8px; align-items: center; margin-bottom: 8px; }
.side-row.single { grid-template-columns: 70px minmax(0, 1fr) 64px; }
.side-row .side-name { font-weight: 700; font-size: 0.9rem; }
.side-row .computed { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.side-row input { min-height: 38px; padding: 6px 8px; }
.trial-head { display: grid; grid-template-columns: 70px repeat(3, minmax(0, 1fr)) 64px; gap: 8px; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.trial-head span:last-child { text-align: right; }
.live { min-height: 54px; }
.live .live-line { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; margin-top: 6px; font-size: 0.9rem; color: var(--ink-2); }
.protocol summary { cursor: pointer; color: var(--pine); font-size: 0.9rem; }
.protocol p { color: var(--ink-2); font-size: 0.9rem; margin: 6px 0 0; }
.est1rm { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 10px; padding: 10px; background: var(--sheet-2); border-radius: var(--radius-sm); }
.est1rm .field { width: 96px; }
.est1rm .out { font-size: 0.9rem; color: var(--ink-2); }

.savebar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  padding: 12px 16px; margin-top: 18px; box-shadow: 0 -6px 18px rgba(21,35,43,.06);
}

/* ------------------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 400px; }
.login .wordmark { justify-content: center; margin-bottom: 18px; }

/* ------------------------------------------------------------ misc */
.empty { text-align: left; padding: 28px 4px; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--ink-2); }
.legend .lvl { font-weight: 400; font-size: 0.85rem; }
.source-list { font-size: 0.875rem; color: var(--ink-2); padding-left: 18px; margin: 0; }
.source-list li + li { margin-top: 6px; }
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series-label { font-size: 12px; font-weight: 700; fill: var(--ink); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { min-width: 200px; }

/* ------------------------------------------------------------ print (reports) */
@media print {
  :root { --bench: #fff; }
  .rail, .no-print, .savebar, .page-head .actions { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .panel { border: 0; padding: 0; break-inside: avoid; }
  .panel + .panel { margin-top: 16px; }
  .readout { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  body { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.readout .r-rate .r-cut { display: flex; margin-top: 6px; font-size: 0.8rem; font-weight: 600; line-height: 1.3; }

/* ------------------------------------------------------------ force-time tests */
.ft-tools { display: grid; gap: 10px; margin-bottom: 14px; }
.ft-tool { border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 10px 14px; background: var(--sheet-2); }
.ft-tool summary { cursor: pointer; font-weight: 700; color: var(--pine); }
.ft-tool[open] summary { margin-bottom: 8px; }
.ft-grid-wrap { border: 1px solid var(--rule); border-radius: var(--radius-sm); max-height: 70vh; overflow: auto; }
table.ft-grid { width: auto; min-width: 100%; font-size: 0.85rem; }
table.ft-grid th, table.ft-grid td { padding: 3px 4px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.ft-grid thead th { position: sticky; top: 0; background: var(--sheet); z-index: 2; }
table.ft-grid thead tr:nth-child(2) th { top: 31px; }
table.ft-grid th.ft-metric, table.ft-grid th.ft-metric-h { position: sticky; left: 0; background: var(--sheet); z-index: 1; text-align: left; font-weight: 700; color: var(--ink); min-width: 190px; }
table.ft-grid th.ft-metric-h { z-index: 3; }
table.ft-grid .hint { font-weight: 400; color: var(--muted); font-size: 0.78rem; }
table.ft-grid input { width: 74px; min-height: 30px; padding: 3px 6px; text-align: right; font-variant-numeric: tabular-nums; font-size: 0.85rem; }
table.ft-grid .ft-off { display: none; }
table.ft-grid .ft-first { border-left: 2px solid var(--rule-strong); }
table.ft-grid th.ft-side-h { text-align: center; border-left: 2px solid var(--rule-strong); border-top: 3px solid var(--rule-strong); }
table.ft-grid th.ft-R { border-top-color: var(--side-r); }
table.ft-grid th.ft-L { border-top-color: var(--side-l); }
table.ft-grid th.ft-B { border-top-color: var(--side-b); }
.ft-curve-mark { color: var(--pine); font-weight: 700; }
.ft-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 18px; margin-top: 18px; }
.ft-charts .panel + .panel { margin-top: 0; }
.ft-canvas { position: relative; height: 300px; width: 100%; }
.ft-canvas-tall { height: 330px; }
.lsi-bars { display: grid; gap: 8px; margin: 4px 0 14px; }
.lsi-bar { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(0, 3fr) minmax(150px, 1.1fr); gap: 4px 12px; align-items: center; font-size: 0.9rem; }
.lsi-bar .track { position: relative; height: 16px; background: var(--sheet-2); border-radius: 4px; }
.lsi-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--pine); border-radius: 0 4px 4px 0; }
.lsi-bar .mark { position: absolute; top: -4px; bottom: -4px; border-left: 2px dashed var(--critical); }
.lsi-bar .val { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.lsi-bar .val strong { color: var(--ink); }
@media (max-width: 640px) { .lsi-bar { grid-template-columns: 1fr; } }
@media print {
  .ft-tools, .ft-chart .btn, [data-ft-png] { display: none !important; }
  .ft-grid-wrap { max-height: none; overflow: visible; border: 0; }
  table.ft-grid input { border: 0; padding: 0; width: 56px; }
  .ft-charts { grid-template-columns: 1fr 1fr; }
}
.ft-analysis .panel-head { flex-wrap: nowrap; align-items: flex-start; }
.ft-analysis .panel-head > div { flex: 1 1 auto; min-width: 0; }
.ft-analysis .panel-head > .btn { flex: none; }
[hidden] { display: none !important; }
fieldset.fs { border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 10px 16px 16px; margin: 0; min-width: 0; }
fieldset.fs legend { font-weight: 700; padding: 0 6px; font-family: var(--font-head); font-size: 1.05rem; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.95rem; }
.dx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px 14px; margin-top: 10px; }
.dx-field label { font-family: var(--font-head); }
.dx-field .hint { min-height: 1.2em; font-size: 0.8rem; color: var(--muted); }
table.sb-lines input { min-height: 34px; padding: 4px 6px; }
table.sb-lines input[readonly] { background: var(--sheet-2); color: var(--ink-2); }
table.sb-lines td { vertical-align: top; }
/* printable documents (superbill) */
.doc { max-width: 980px; }
.doc-head { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 14px; }
.doc-title { font-family: var(--font-head); font-size: 1.6rem; font-weight: 600; }
.doc-sub { color: var(--ink-2); }
.doc-prov { text-align: right; font-size: 0.92rem; }
.doc-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 22px; }
.doc-cols h3, .doc h3 { font-size: 1.05rem; margin-bottom: 6px; }
.doc-sign { display: grid; grid-template-columns: 2fr 1fr; gap: 30px; margin-top: 40px; }
.doc-sign div { border-top: 1px solid var(--ink); padding-top: 4px; font-size: 0.85rem; color: var(--ink-2); }
.guide h2 { margin-top: 6px; }
.guide h3 { margin: 16px 0 6px; }
.guide p, .guide li { max-width: 78ch; }
.guide ul { padding-left: 20px; margin: 0 0 10px; }
.guide li + li { margin-top: 4px; }
@media print { .doc { max-width: none; } .doc-prov { text-align: left; } }
.flags li.info { background: var(--sheet-2); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--serious); color: var(--sheet); font-size: 0.75rem; font-weight: 700; line-height: 20px; text-align: center; margin-left: 4px; }
.status-list dd { font-variant-numeric: normal; }
.status-list dd .status { margin-right: 6px; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--sheet-2); border: 1px solid var(--rule-strong); color: var(--ink-2); font-size: 0.75rem; font-weight: 700; line-height: 18px; text-align: center; margin-left: 4px; }
table.signups .btn { white-space: nowrap; }
.nav a .count, .nav a .badge { vertical-align: 1px; }
/* ------------------------------------------------------------ print: desktop layout on paper, always light */
@media print {
  :root, :root:where(:not([data-theme="light"])) {
    color-scheme: light;
    --bench: #fff; --sheet: #fff; --sheet-2: #f6f8f7; --ink: #15232b; --ink-2: #4c5b62; --muted: #73838a; --rule: #d6dedc; --rule-strong: #b9c5c2;
    --pine: #0e6b5a; --pine-ink: #fff; --pine-wash: #e1f0ec; --focus: #0e6b5a;
    --lv1: #a8302a; --lv2: #e0786b; --lv3: #dcdbd5; --lv4: #6aa3e6; --lv5: #1f5aa6; --lv0: #e6ebea;
    --good: #0a7d0a; --serious: #b9531f; --critical: #c43333; --serious-wash: #fbeee6; --critical-wash: #fbeaea; --good-wash: #e7f4e7;
    --side-r: #eb6834; --side-l: #2a78d6; --side-b: #1baf7a;
  }
  body { font-size: 11px; background: #fff; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1rem; }
  .main { padding: 0 !important; }
  .page-head { margin-bottom: 12px; }
  .panel-head { margin-bottom: 8px; }
  .cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; }
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .figure .value { font-size: 1.4rem; }
  .readout { grid-template-columns: minmax(120px, 1.1fr) minmax(70px, .45fr) minmax(170px, 1.8fr) minmax(110px, .9fr) !important; padding: 5px 0; gap: 2px 12px; }
  .readout .r-scale, .readout .r-rate { grid-column: auto !important; }
  .readout .r-value { font-size: 1.15rem; }
  .readout .r-detail { font-size: 0.78rem; }
  .ratio { grid-template-columns: minmax(140px, 1fr) minmax(190px, 1.6fr) minmax(120px, 1fr) !important; gap: 4px 14px; padding-bottom: 8px; }
  .ratio .r-val { font-size: 1.2rem; }
  .lsi-bar { grid-template-columns: minmax(120px, 1.2fr) minmax(0, 3fr) minmax(150px, 1.1fr) !important; }
  .ft-entry .toolbar, .ft-entry .panel-head p { display: none !important; }
  table.data th, table.data td { padding: 4px 6px; }
}
@media print {
  /* let long panels flow across pages; keep single rows and headings together instead */
  .panel { break-inside: auto !important; }
  .readout, .ratio, .lsi-bar, .ft-chart, .figures, .doc-cols > section, table.data tr, .flags li, dl.kv { break-inside: avoid; }
  h2, h3, .panel-head { break-after: avoid; }
}
@media print {
  .ft-charts { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .ft-canvas { height: auto; }
  .ft-canvas canvas { max-width: 100%; }
}

/* ------------------------------------------------------------ clinician guide (public page ?p=guide) */
.g-top { position: sticky; top: 0; z-index: 20; background: var(--sheet); border-bottom: 1px solid var(--rule); }
.g-top-in { max-width: 1160px; margin: 0 auto; padding: 10px clamp(16px, 3vw, 32px); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.g-top .wordmark { padding: 0; }
.g-hero { max-width: 1160px; margin: 0 auto; padding: 40px clamp(16px, 3vw, 32px) 12px; }
.g-kicker { margin: 0 0 6px; font-weight: 700; font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--pine); }
.g-hero h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); max-width: 22ch; }
.g-lead { font-size: 1.12rem; color: var(--ink-2); max-width: 68ch; margin: 12px 0 18px; }
.g-res { gap: 10px; }
.g-layout { max-width: 1160px; margin: 0 auto; padding: 18px clamp(16px, 3vw, 32px) 48px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; align-items: start; }
.g-toc { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; font-size: 0.92rem; }
.g-toc-h { margin: 0 0 6px; font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.g-toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.g-toc li { counter-increment: toc; }
.g-toc a { display: flex; gap: 8px; padding: 5px 8px; border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; line-height: 1.3; }
.g-toc a::before { content: counter(toc); min-width: 1.4em; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-toc a:hover { background: var(--sheet); color: var(--ink); }
.g-toc a[aria-current] { background: var(--pine-wash); color: var(--ink); font-weight: 700; }
.g-body { max-width: 800px; min-width: 0; }
.g-body > section { padding-top: 8px; margin-bottom: 52px; scroll-margin-top: 72px; }
.g-body h2 { font-size: 1.7rem; display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.g-num { flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--pine); color: var(--pine-ink); font-size: 1.05rem; font-family: var(--font-body); font-weight: 700; }
.g-body h3 { font-size: 1.25rem; margin: 26px 0 8px; }
.g-body p, .g-body li, .g-body dd { line-height: 1.6; }
.g-list { padding-left: 20px; margin: 0 0 14px; }
.g-list li + li { margin-top: 6px; }
.g-steps { list-style: none; counter-reset: st; padding: 0; margin: 0 0 16px; }
.g-steps[start="6"] { counter-reset: st 5; }
.g-steps li { counter-increment: st; position: relative; padding-left: 40px; min-height: 28px; }
.g-steps li + li { margin-top: 8px; }
.g-steps li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--pine); color: var(--pine); font-weight: 700; display: grid; place-items: center; font-size: 0.9rem; }
.g-steps li p { margin: 0; padding-top: 2px; }
.g-fig { margin: 16px 0 24px; }
.g-fig a { display: block; }
.g-fig img { display: block; max-width: 100%; height: auto; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: #fff; box-shadow: 0 1px 2px rgba(20, 35, 43, .06), 0 6px 18px rgba(20, 35, 43, .06); }
.g-fig.narrow img { max-width: min(100%, 460px); }
.g-fig figcaption { margin-top: 8px; font-size: 0.9rem; color: var(--ink-2); }
.g-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.g-pair .g-fig { margin: 8px 0 18px; }
.g-tip, .g-note { border-radius: var(--radius-sm); padding: 12px 16px; margin: 16px 0; line-height: 1.55; }
.g-tip { background: var(--pine-wash); border-left: 4px solid var(--pine); }
.g-note { background: var(--sheet); border: 1px solid var(--rule); border-left: 4px solid var(--rule-strong); }
.g-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.g-table th, .g-table td { text-align: left; vertical-align: top; padding: 9px 14px; border-top: 1px solid var(--rule); }
.g-table tr:first-child th, .g-table tr:first-child td { border-top: 0; }
.g-table th { width: 30%; white-space: nowrap; font-weight: 700; }
.g-faq { margin: 0; }
.g-faq dt { font-weight: 700; margin-top: 16px; }
.g-faq dd { margin: 4px 0 0; color: var(--ink-2); }
.g-cta { margin-top: 32px; padding: 18px 20px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.g-foot { border-top: 1px solid var(--rule); padding: 18px clamp(16px, 3vw, 32px); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 0.85rem; max-width: 1160px; margin: 0 auto; }
@media (max-width: 900px) {
  .g-layout { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .g-toc { position: static; max-height: none; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px; }
  .g-toc ol { columns: 2; column-gap: 12px; }
  .g-pair { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .g-toc ol { columns: 1; }
  .g-top .btn-quiet { display: none; }
  .g-table th { white-space: normal; width: 38%; }
}
@media print {
  .g-top, .g-toc, .g-res, .g-cta, .g-foot { display: none !important; }
  .g-hero { padding: 0 0 8px; }
  .g-layout { display: block; padding: 0; }
  .g-body { max-width: none; }
  .g-body > section { margin-bottom: 22px; }
  .g-body h2, .g-body h3 { break-after: avoid; }
  .g-body h2 { font-size: 1.35rem; }
  .g-fig { break-inside: avoid; margin: 10px 0 14px; }
  .g-fig img { box-shadow: none; max-height: 125mm; width: auto; }
  .g-fig.narrow img { max-height: 110mm; }
  .g-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-tip, .g-note, .g-faq dt { break-inside: avoid; }
  body.guide-page { font-size: 11pt; }
}

/* links to the guide and sample report on the sign-in and sign-up pages */
.help-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 10px 12px; background: var(--sheet-2); border: 1px solid var(--rule); border-radius: var(--radius-sm); font-size: 0.9rem; }
.help-links strong { width: 100%; font-size: 0.85rem; color: var(--ink-2); }
.help-links a { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.help-links svg { flex: none; }

/* ------------------------------------------------------------ range of motion */
.rom-table td { vertical-align: top; }
.rom-table td.rom-v strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.rom-table td.rom-v .lvl { margin-left: 6px; font-size: 0.8rem; }
.rom-table tr.rom-note td { border-top: 0; padding-top: 0; }
.rom-bar { position: relative; display: block; width: 120px; max-width: 100%; height: 6px; margin: 5px 0 4px; border-radius: 3px; background: var(--lv0); }
.rom-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--lv3); }
.rom-bar i.lv1 { background: var(--lv1); } .rom-bar i.lv2 { background: var(--lv2); } .rom-bar i.lv3 { background: var(--ink-2); }
.rom-bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .55; }
.est1rm.dual .field { min-width: 0; }
.est1rm.dual select { min-width: 90px; }
[data-consist]:empty { display: none; }
[data-consist] { margin-top: 8px; }
@media print { .rom-bar { width: 90px; } .rom-table tr { break-inside: avoid; } }
.rom-table .rom-tag { display: block; margin-bottom: 2px; }
.iso-table tr.iso-sub th { background: var(--sheet-2); }
