/* Healfolio. Light theme only.
   A calm app: soft grey canvas, white panels, one blue accent, system font.
   Status is a small shape plus a word. Red is reserved for "needs attention". */

:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #4a4a50;
  --ink-3: #6b6b72;
  --line: #e4e4e9;
  --line-2: #efeff2;
  --field: #d2d2d8;
  --accent: #2a78d6;
  --accent-ink: #1b60b4;
  --accent-bg: #eaf2fc;
  --band: rgba(42, 120, 214, 0.1);
  --dot-ok: #34b457;
  --dot-near: #f0a500;
  --dot-out: #ee6b3b;
  --near-ink: #8a5a00;
  --out-ink: #b8400f;
  --alert: #d92d2d;
  --alert-ink: #b42323;
  --alert-bg: #fdf3f2;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.05), 0 0 0 1px rgba(20, 20, 30, 0.045);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 24px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 80; border-radius: 8px; }
.skip:focus { left: 8px; }
.ic { width: 20px; height: 20px; flex: none; }

/* ---------- shell */
.app { display: grid; grid-template-columns: 76px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 18px 0; background: #fbfbfd; border-right: 1px solid var(--line); z-index: 30; }
.brand { display: flex; align-items: center; justify-content: center; margin-bottom: 22px; color: var(--ink); text-decoration: none; border-radius: 12px; }
.nav { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; flex: 1; }
.nav ul { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nav .add-btn, .nav ul a { position: relative; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: var(--ink-2); text-decoration: none; }
.nav .add-btn { background: var(--accent); color: #fff; margin-bottom: 14px; box-shadow: 0 4px 12px rgba(42, 120, 214, 0.3); }
.nav .add-btn:hover { background: var(--accent-ink); }
.nav ul a:hover { background: #efeff3; color: var(--ink); }
.nav ul a[aria-current="page"] { background: var(--accent-bg); color: var(--accent-ink); }
.nav-sep { width: 28px; height: 1px; background: var(--line); margin: 12px 0 8px; border: 0; }
.nav .ic { width: 22px; height: 22px; }
.cinit { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--line-2); color: var(--ink-2); font-size: 13px; font-weight: 700; }
.nav-conds a[aria-current="page"] .cinit { background: var(--accent); color: #fff; }
.cdot { position: absolute; top: 7px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--alert); box-shadow: 0 0 0 2px #fbfbfd; }
/* tooltip with the name, shown on hover or keyboard focus */
.nav [data-label]:hover::after, .nav [data-label]:focus-visible::after { content: attr(data-label); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%); padding: 6px 11px; border-radius: 9px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; pointer-events: none; z-index: 60; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2); }
.mobile-only { display: none; }
.content { min-width: 0; }
main { max-width: 1240px; margin: 0 auto; padding: 40px 44px 32px; outline: none; }
.foot { max-width: 1240px; margin: 0 auto; padding: 0 44px 56px; color: var(--ink-3); font-size: 13px; }
.foot p { max-width: 64ch; }

/* ---------- type and buttons */
h1 { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -0.025em; }
.sub { color: var(--ink-3); margin-top: 4px; }
h2.sec { font-size: 21px; font-weight: 700; letter-spacing: -0.015em; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section { margin-top: 40px; }
.section > .sec { margin-bottom: 12px; }
.section-note { color: var(--ink-3); margin: -6px 0 12px; font-size: 15px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--field); background: var(--panel); color: var(--ink); font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; }
.btn:hover { background: #fafafb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--alert-ink); }
.btn.quiet { border-color: transparent; background: none; color: var(--accent-ink); padding-inline: 8px; }
.btn.quiet:hover { background: var(--accent-bg); }
.btn.small { min-height: 30px; padding: 3px 12px; font-size: 13.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.back { display: inline-flex; align-items: center; gap: 2px; margin-bottom: 14px; color: var(--accent-ink); font-weight: 600; text-decoration: none; font-size: 15px; }
.back .ic { width: 18px; height: 18px; }

/* ---------- panels, lists, tables */
.panel { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); }
.panel-pad { padding: 20px 24px; }
.list > li, .list > a { display: block; padding: 16px 24px; border-top: 1px solid var(--line-2); }
.list > li:first-child, .list > a:first-child { border-top: 0; }
a.row-link { display: grid; align-items: center; color: inherit; text-decoration: none; }
a.row-link:hover { background: #fafafb; }
.more { display: flex; justify-content: center; border-top: 1px solid var(--line-2); padding: 8px; }
.chev { color: #b4b4bb; width: 18px; height: 18px; }

table.t { width: 100%; border-collapse: collapse; }
table.t thead th { text-align: left; color: var(--ink-3); font-size: 13px; font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td, table.t tbody th { text-align: left; padding: 12px 14px; border-top: 1px solid var(--line-2); vertical-align: top; font-size: 15px; color: var(--ink); font-weight: 400; }
table.t tbody tr:first-child td, table.t tbody tr:first-child th { border-top: 0; }
table.t th:first-child, table.t td:first-child { padding-left: 24px; }
table.t th:last-child, table.t td:last-child { padding-right: 24px; }
table.t td.num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
table.t td.nowrap { white-space: nowrap; }
table.t caption { text-align: left; padding: 18px 24px 8px; font-size: 18px; font-weight: 700; }
.table-wrap { overflow-x: auto; }

/* status shapes + words */
.st { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.st i { display: inline-block; width: 9px; height: 9px; background: var(--dot-ok); border-radius: 50%; flex: none; }
.st-near-high, .st-near-low { color: var(--near-ink); }
.st-near-high i, .st-near-low i { background: var(--dot-near); border-radius: 2px; transform: rotate(45deg) scale(0.9); }
.st-high, .st-low { color: var(--out-ink); }
.st-high i, .st-low i { background: var(--dot-out); border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 11px; height: 10px; }
.st-low i { transform: rotate(180deg); }
.st-none i { background: #c4c4cb; }
.flag { display: inline-flex; align-items: center; gap: 7px; color: var(--alert-ink); font-size: 14px; font-weight: 700; white-space: nowrap; }
.flag-mark { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--alert); color: #fff; font-size: 12px; font-weight: 800; line-height: 1; flex: none; }

.val { font-variant-numeric: tabular-nums; font-weight: 600; }
.val.big { font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; }
.unit { color: var(--ink-3); font-size: 13.5px; font-weight: 400; }
.val.big .unit { font-size: 15px; }

/* ---------- summary */
.att { }
.att-head { padding: 0 4px 16px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.att-head h2 { display: flex; align-items: center; gap: 10px; }
.att-head p { color: var(--ink-3); font-size: 14px; }
.att-list { display: grid; gap: 12px; }
.att-card { grid-template-columns: 22px minmax(0, 1fr) 120px 18px; gap: 6px 16px; padding: 18px 22px; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); }
.att-card:hover { background: var(--panel) !important; }
.att-mark { align-self: start; margin-top: 3px; }
.att-name { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; }
.att-name strong { font-size: 16.5px; }
.att-name .cat { color: var(--ink-3); font-size: 13.5px; }
.att-why { margin-top: 4px; display: grid; gap: 2px; color: var(--ink-2); font-size: 15px; }
.att-spark { width: 120px; }
.calm { padding: 22px 24px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.tile { display: grid; gap: 14px; padding: 22px 24px; color: inherit; text-decoration: none; transition: box-shadow 0.15s; }
.tile:hover { box-shadow: 0 2px 10px rgba(20, 20, 30, 0.1), 0 0 0 1px rgba(20, 20, 30, 0.06); }
.tile h3 { font-size: 18px; font-weight: 700; }
.tile .meta { color: var(--ink-3); font-size: 14.5px; margin-top: 2px; }
.tile-main { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: end; }
.tile-name { grid-column: 1 / -1; color: var(--ink-2); font-size: 14.5px; }
.tile-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line-2); padding-top: 12px; font-size: 14.5px; }
.tile-foot .go { color: var(--accent-ink); font-weight: 600; }

.meds { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px 36px; padding: 6px 24px 22px; }
.meds h3 { font-size: 13px; color: var(--ink-3); font-weight: 600; margin-bottom: 6px; }
.meds li { padding: 3px 0; }
.meds .when { color: var(--ink); font-weight: 600; }
.panel-top { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px 8px; gap: 10px; }

details.fold > summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 18px 24px; font-weight: 600; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: ""; width: 9px; height: 9px; border: solid var(--ink-3); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform 0.15s; margin-right: 4px; }
details.fold[open] > summary::after { transform: rotate(-135deg); }
details.fold > .fold-body { border-top: 1px solid var(--line-2); }
.noted li { display: grid; grid-template-columns: auto 1fr; gap: 14px; }
.noted p { margin-top: 2px; font-size: 14.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 24px 22px; }
.chips-group { padding: 12px 0 0; }
.chips-group h4 { padding: 0 24px 8px; font-size: 13px; color: var(--ink-3); font-weight: 600; }
.pill-link { padding: 5px 13px; border-radius: 999px; background: var(--bg); color: var(--ink); text-decoration: none; font-size: 14.5px; }
.pill-link span { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pill-link:hover { background: var(--accent-bg); }

/* ---------- condition + test charts */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.chart-card { padding: 18px 20px 14px; min-width: 0; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chart-card .name { font-weight: 600; color: var(--ink); text-decoration: none; }
.chart-card .name:hover { text-decoration: underline; }
.chart-card .now { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; margin: 6px 0 8px; }
.why { margin: 8px 0 2px; display: grid; gap: 2px; font-size: 14.5px; color: var(--ink); }
.why li { padding-left: 14px; position: relative; }
.why li::before { content: ""; position: absolute; left: 1px; top: 0.6em; width: 6px; height: 6px; border-radius: 50%; background: var(--alert); }
.small-note { color: var(--ink-3); font-size: 13.5px; margin-top: 6px; }
.cond-intro { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 22px; }
.med-tag { background: var(--panel); border-radius: 999px; padding: 5px 14px; font-size: 14.5px; box-shadow: var(--shadow); }

/* ---------- charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart .band rect { fill: var(--band); }
.chart .grid line { stroke: var(--line-2); stroke-width: 1; }
.chart .tick { fill: var(--ink-3); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt path, .chart .pt circle { stroke: var(--panel); stroke-width: 4; paint-order: stroke; transform-box: fill-box; transform-origin: center; transition: transform 0.1s; }
.chart .pt-ok { fill: var(--accent); } .chart .pt-near { fill: var(--dot-near); } .chart .pt-out { fill: var(--dot-out); } .chart .pt-none { fill: #9a9aa2; }
.chart .pt.active path, .chart .pt.active circle { transform: scale(1.3); }
.chart .pt:focus { outline: none; }
.chart .pt:focus-visible path, .chart .pt:focus-visible circle { stroke: var(--ink); stroke-width: 3; }
.chart .cross { stroke: #9a9aa2; stroke-width: 1; }
.chart .endlabel { fill: var(--ink); font-size: 12.5px; font-weight: 600; }
.chart .event line { stroke: #9a9aa2; stroke-width: 1; stroke-dasharray: 2 3; }
.chart .flag-ring { fill: none; stroke: var(--alert); stroke-width: 2; }
.chart .hit { cursor: pointer; }
.tip { position: absolute; z-index: 6; pointer-events: none; background: var(--panel); border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 28px rgba(20, 20, 30, 0.18), 0 0 0 1px rgba(20, 20, 30, 0.06); font-size: 13.5px; max-width: 250px; display: grid; gap: 4px; justify-items: start; }
.tip-val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tip-unit { font-size: 13px; font-weight: 400; color: var(--ink-3); }
.tip-date, .tip-row { color: var(--ink-2); }
.tip-hint { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }

/* ---------- results (all tests) */
.results { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; align-items: start; }
.res-nav { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow: auto; padding: 8px; }
.search { width: 100%; padding: 10px 14px; border: 0; border-radius: 10px; background: var(--bg); margin-bottom: 6px; }
.search:focus-visible { outline-offset: 0; }
.res-group h3 { padding: 14px 12px 4px; font-size: 13px; color: var(--ink-3); font-weight: 600; }
.res-link { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 15px; }
.res-link:hover { background: var(--bg); }
.res-link[aria-current="page"] { background: var(--accent-bg); color: var(--accent-ink); font-weight: 600; }
.res-link .rv { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 400; }
.res-link .st i { margin: 0; }
.rv-flag { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--alert); color: #fff; font-size: 11px; font-weight: 800; }
.res-head .crumb { color: var(--ink-3); font-size: 14px; }
.res-head h1 { margin: 2px 0 10px; }
.res-now { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px; }
.res-line { color: var(--ink-2); margin-top: 6px; }
.note-flag { margin: 20px 0 0; padding: 16px 20px; background: var(--alert-bg); border-radius: 14px; display: grid; gap: 8px; justify-items: start; }
.note-flag .why { margin: 0; font-weight: 500; }
.note-flag .small-note { margin: 0; }
.watch-note { margin-top: 16px; color: var(--ink-2); }
.res-chart { margin-top: 22px; padding: 20px 20px 14px; }
.about { margin-top: 26px; padding: 0; }
.about summary { padding: 16px 24px; }
.about p { padding: 0 24px 20px; color: var(--ink-2); max-width: 66ch; }
.res-table { margin-top: 26px; }

/* ---------- reports */
.rep-row { grid-template-columns: 112px minmax(0, 1.6fr) minmax(0, 1.2fr) 18px; gap: 16px; }
.rep-row .when { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.rep-row .what strong { display: block; font-size: 16.5px; }
.rep-row .what span { color: var(--ink-3); font-size: 14px; }
.rep-row .flags { display: grid; gap: 2px; justify-items: start; }
.year { padding: 18px 24px 6px !important; color: var(--ink-3); font-size: 13px; font-weight: 600; background: #fafafb; }
.hist li { display: grid; grid-template-columns: 112px 1fr; gap: 16px; }
.hist .when { color: var(--ink-2); font-weight: 600; }
.detail-meta { color: var(--ink-3); margin-top: 4px; }
.file-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.file-link { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); text-decoration: none; font-size: 14.5px; font-weight: 500; word-break: break-all; }
.file-link:hover { background: var(--accent-bg); }
.note-box { margin-top: 18px; padding: 14px 18px; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); max-width: 70ch; }
.findings li { display: grid; grid-template-columns: 120px 1fr; gap: 14px; }
.stack > * + * { margin-top: 18px; }
.rep-actions { display: flex; gap: 10px; margin-top: 32px; }

/* ---------- medicines */
.med-list li { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; }
.med-main { flex: 1 1 320px; display: grid; gap: 2px; }
.med-title { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; }
.med-title strong { font-size: 17px; }
.med-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.med-upcoming strong { font-size: 17px; }

/* ---------- forms */
.field { display: grid; gap: 6px; align-content: start; }
.field-label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.hint { color: var(--ink-3); font-size: 13.5px; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--field); border-radius: 10px; background: var(--panel); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[readonly] { background: var(--bg); color: var(--ink-3); border-color: transparent; }
input[type="checkbox"] { width: 18px; min-height: 0; height: 18px; }
textarea { resize: vertical; }
.form { display: grid; gap: 22px; }
.step { padding: 24px 26px 26px; display: grid; gap: 16px; }
.step-title { display: flex; align-items: center; gap: 12px; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.step-no { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-ink); font-size: 14px; font-weight: 700; }
.step-title small { font-size: 14px; font-weight: 400; color: var(--ink-3); letter-spacing: 0; }
.grid-4 { display: grid; grid-template-columns: 1fr 1.6fr 1.6fr 1fr; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 230px; }
.rows { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: minmax(150px, 2.2fr) 1fr 0.9fr 0.8fr 0.8fr 1.4fr 40px; gap: 8px; align-items: center; }
.row.head { color: var(--ink-3); font-size: 13px; font-weight: 600; }
.row.finding { grid-template-columns: 1.5fr 2fr 1.1fr 1.4fr 40px; }
.row.med-row { grid-template-columns: minmax(150px, 2fr) 1.2fr 1.2fr 1.2fr 40px; }
.icon-btn { width: 40px; height: 40px; border: 0; background: none; border-radius: 10px; cursor: pointer; font-size: 22px; line-height: 1; color: var(--ink-3); }
.icon-btn:hover { background: var(--alert-bg); color: var(--alert-ink); }
.new-test { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.new-test select, .new-test input { width: auto; min-width: 150px; }
.tag-new { background: var(--accent-bg); color: var(--accent-ink); border-radius: 999px; padding: 2px 12px; font-size: 13px; font-weight: 600; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.file-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.file-row select { width: auto; max-width: 340px; }
.file-box { display: contents; }
.file-pill { display: inline-flex; align-items: center; gap: 4px; background: var(--bg); border-radius: 999px; padding: 4px 6px 4px 14px; font-size: 14px; }
.file-pill button { border: 0; background: none; cursor: pointer; color: var(--ink-3); font-size: 18px; padding: 0 8px; }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload:focus-within .btn { outline: 2px solid var(--accent); outline-offset: 2px; }
.upload { cursor: pointer; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { margin-top: 3px; }
.form-error { color: var(--alert-ink); background: var(--alert-bg); border-radius: 10px; padding: 12px 16px; font-weight: 600; }
.savebar { position: sticky; bottom: 0; z-index: 10; display: flex; gap: 10px; align-items: center; padding: 16px 0 18px; background: linear-gradient(to top, var(--bg) 70%, rgba(245, 245, 247, 0)); }
details.more-opt > summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); padding: 4px 0; }
details.more-opt[open] > summary { margin-bottom: 10px; }

dialog { border: 0; border-radius: 20px; padding: 0; width: min(680px, calc(100% - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 30px 90px rgba(10, 10, 30, 0.35); color: var(--ink); }
dialog::backdrop { background: rgba(20, 20, 30, 0.4); }
.dlg { padding: 26px 28px 24px; display: grid; gap: 18px; }
.dlg h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
.dlg-actions { display: flex; gap: 10px; }

.empty { text-align: center; padding: 70px 20px; color: var(--ink-2); }
.empty h3 { font-size: 21px; margin-bottom: 6px; color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 90; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--alert-ink); }

/* ---------- narrower screens */
@media (max-width: 1100px) {
  main { padding: 32px 28px 24px; } .foot { padding: 0 28px 48px; }
  .results { grid-template-columns: 240px minmax(0, 1fr); gap: 20px; }
}
@media (max-width: 860px) {
  .app { display: block; }
  .side { position: fixed; z-index: 40; inset: auto 0 0 0; width: auto; height: auto; flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: rgba(251, 251, 253, 0.94); backdrop-filter: blur(14px); }
  .brand, .nav .add-btn, .nav-sep, .nav ul.nav-conds { display: none; }
  .nav { width: 100%; flex-direction: row; align-items: stretch; }
  .nav ul { display: flex; flex-direction: row; width: 100%; gap: 0; }
  .nav ul.nav-bottom { margin: 0; padding: 0; width: auto; flex: 1; }
  .nav > ul:first-of-type { flex: 5; }
  .nav ul li { flex: 1; }
  .nav ul a { width: auto; height: auto; display: flex; flex-direction: column; gap: 2px; padding: 7px 2px; font-size: 11.5px; justify-content: center; border-radius: 10px; text-align: center; }
  .nav .ic { width: 20px; height: 20px; }
  .nav .lbl { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .nav [data-label]:hover::after, .nav [data-label]:focus-visible::after { content: none; }
  .mobile-only { display: block; }
  main { padding: 24px 18px 20px; } .foot { padding: 0 18px 100px; }
  .results { grid-template-columns: 1fr; }
  .res-nav { position: static; max-height: 280px; }
  .grid-4, .grid-2 { grid-template-columns: 1fr 1fr; }
  .att-card { grid-template-columns: 22px minmax(0, 1fr) 18px; } .att-spark { display: none; }
  .rep-row { grid-template-columns: 1fr 18px; } .rep-row .when { grid-column: 1; } .rep-row .flags { grid-column: 1; } .rep-row .chev { grid-row: 1 / span 3; grid-column: 2; }
  .row { grid-template-columns: repeat(4, 1fr) 40px; }
  .row.head { display: none; }
  .row > :nth-child(1) { grid-column: 1 / -1; } .row > :nth-child(6) { grid-column: 1 / 5; }
  .row.finding { grid-template-columns: 1fr 1fr; } .row.finding > :nth-child(1), .row.finding > :nth-child(2) { grid-column: 1 / -1; }
  .row.med-row { grid-template-columns: 1fr 1fr 1fr; } .row.med-row > :nth-child(1) { grid-column: 1 / -1; }
  .row-wrap { padding-bottom: 12px; border-bottom: 1px solid var(--line-2); }
  .savebar { bottom: 62px; }
  .findings li, .hist li { grid-template-columns: 1fr; gap: 4px; }
  .table-wrap table.t { min-width: 520px; }
}
@media (max-width: 560px) {
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
  .step { padding: 20px 18px 22px; }
  .val.big { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.att-head .flag-mark { width: auto; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; font-size: 14px; vertical-align: 2px; }
.att-head h2 { display: block; }

/* ---------- hover: cards lift a little */
.tile, .chart-card, .att-card, .file-link, .med-tag {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.tile:hover, .chart-card:hover, .att-card:hover, .file-link:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(20, 20, 40, 0.13), 0 0 0 1px rgba(20, 20, 30, 0.04);
}
.tile:active, .att-card:active { transform: translateY(-1px); }
.att-section .more { border: 0; padding: 14px 0 0; }
@media (prefers-reduced-motion: reduce) {
  .tile:hover, .chart-card:hover, .att-card:hover, .file-link:hover { transform: none; }
}

/* ---------- add a report: drop zone, reading, review next to the original */
main.wide { max-width: 1640px; }
.drop { position: relative; display: grid; justify-items: center; gap: 6px; padding: 60px 24px; text-align: center; cursor: pointer; background: var(--panel); border-radius: 22px; outline: 2px dashed #c6d3e6; outline-offset: -2px; transition: background 0.15s, outline-color 0.15s, transform 0.15s; }
.drop:hover, .drop.over, .drop:focus-within { background: var(--accent-bg); outline-color: var(--accent); }
.drop.over { transform: scale(1.01); }
.drop strong { font-size: 21px; letter-spacing: -0.01em; }
.drop-ic { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); margin-bottom: 8px; }
.drop-ic .ic { width: 30px; height: 30px; }
.drop-hint { color: var(--ink-3); font-size: 14px; max-width: 46ch; margin-top: 8px; }
.drop input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; }
.by-hand { text-align: center; margin-top: 22px; }
.list > li.file-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.file-item span { display: inline-flex; align-items: center; gap: 10px; word-break: break-all; }
.file-item .ic { width: 18px; height: 18px; color: var(--ink-3); }
.reading { display: flex; align-items: center; gap: 18px; padding: 28px 28px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent-bg); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.review { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.review-main { display: grid; gap: 20px; min-width: 0; }
.read-note { padding: 18px 22px; display: grid; gap: 8px; }
.read-note .warn { color: var(--near-ink); font-weight: 600; }
.merge { display: grid; gap: 8px; padding: 14px 16px; border-radius: 12px; background: var(--accent-bg); }
.merge-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pdf-pane { position: sticky; top: 20px; height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.pdf-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); font-size: 14px; word-break: break-all; }
.pdf-pane iframe { flex: 1; width: 100%; border: 0; background: #eee; }
.pdf-img { flex: 1; overflow: auto; padding: 12px; } .pdf-img img { max-width: 100%; }
.row-hint { margin: 4px 0 0; color: var(--near-ink); font-size: 13px; font-weight: 500; }
.other-found { margin-top: 6px; }
.other-found > summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); padding: 4px 0; }
.other-found ul { margin-top: 8px; display: grid; gap: 6px; }
.other-found li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line-2); font-size: 14.5px; }
.open-orig { display: none; }

/* in the review the form column is narrower, so each result stays on one line and the note field is hidden unless used */
.review .row { grid-template-columns: minmax(0, 2.5fr) minmax(0, 0.85fr) minmax(0, 0.9fr) minmax(0, 0.7fr) minmax(0, 0.7fr) 36px; gap: 6px; }
.review .row > :nth-child(6) { display: none; }
.review .row.has-note > :nth-child(6) { display: block; grid-column: 1 / 6; grid-row: 2; }
.review .row.finding { grid-template-columns: 1fr 1fr; }
.review .row.finding > :nth-child(1), .review .row.finding > :nth-child(2) { grid-column: 1 / -1; }
.review .row.finding > :nth-child(6) { display: block; }
.review .row.med-row { grid-template-columns: 1fr 1fr 1fr; }
.review .row.med-row > :nth-child(1) { grid-column: 1 / -1; }
.review .row.med-row > :nth-child(6) { display: block; }
.review .row-wrap { padding: 2px 0; }
.review .rows { gap: 4px; }
.review input, .review select { min-height: 38px; padding: 6px 10px; }
.review .grid-4 { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) {
  .review { grid-template-columns: 1fr; }
  .pdf-pane { display: none; }
  .open-orig { display: inline-flex; }
}

/* ---------- settings */
.settings { display: grid; gap: 20px; max-width: 820px; }
.set-section { padding: 24px 26px; display: grid; gap: 16px; }
.set-section .sub { margin-top: 2px; max-width: 62ch; }
.set-list > li { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; }
.set-list { border: 0; }
.set-main { display: grid; gap: 2px; min-width: 0; }
.last-backup { font-weight: 600; }
.backup-box { display: grid; gap: 12px; padding: 18px 20px; background: var(--bg); border-radius: 14px; }
.backup-box h3 { font-size: 16px; }
.backup-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pw-box { display: grid; gap: 8px; max-width: 360px; }
.nudge { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 22px; margin-bottom: 24px; }
.nudge p { font-size: 14px; margin-top: 2px; }
.nudge-actions { display: flex; gap: 6px; align-items: center; }
.nav-bottom { margin-top: auto; padding-top: 12px; }
.restore-sum { padding: 12px 16px; background: var(--bg); border-radius: 12px; }

/* ---------- condition picker */
.picker { max-height: 280px; overflow: auto; border-radius: 12px; background: var(--bg); padding: 4px 10px; }
.pick-group > summary { cursor: pointer; padding: 10px 2px; font-weight: 600; }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 14px; padding: 0 2px 10px; }
.pick-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14.5px; cursor: pointer; }
.pick-item input { width: 16px; height: 16px; min-height: 0; }

/* ---------- first-run setup */
.app.setup { grid-template-columns: 1fr; }
.app.setup .side { display: none; }
.setup-card { max-width: 680px; margin: 3vh auto 0; background: var(--panel); border-radius: 24px; box-shadow: var(--shadow); padding: 34px 40px 36px; }
.steps { display: flex; gap: 8px; justify-content: center; margin-bottom: 28px; }
.steps li { width: 28px; height: 5px; border-radius: 3px; background: var(--line); }
.steps li.done { background: #b9d3f3; } .steps li.on { background: var(--accent); }
.setup-step { display: grid; gap: 18px; }
.setup-step h1 { font-size: 28px; }
.setup-step .sub { max-width: 52ch; margin: 0; font-size: 16.5px; }
.setup-logo { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--accent-bg); color: var(--accent); }
.setup-logo .ic { width: 30px; height: 30px; }
.setup-logo.ok { background: #e4f6e9; color: var(--dot-ok); }
.setup-choices { display: grid; gap: 10px; justify-items: start; margin-top: 6px; }
.btn.big { min-height: 48px; padding: 10px 24px; font-size: 16px; border-radius: 12px; }
.setup-fields { display: grid; gap: 16px; max-width: 420px; }
.setup-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.preset { position: relative; display: grid; gap: 3px; align-content: start; text-align: left; padding: 14px 16px 14px 46px; background: var(--bg); border: 0; border-radius: 14px; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s, background 0.15s; }
.preset:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(20, 20, 40, 0.1); background: #fff; }
.preset strong { font-size: 15.5px; }
.preset span:not(.tick) { font-size: 13px; color: var(--ink-3); }
.preset .tick { position: absolute; left: 14px; top: 15px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #c2c9d4; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; }
.preset.on { background: var(--accent-bg); box-shadow: 0 0 0 2px var(--accent) inset; }
.preset.on .tick { background: var(--accent); border-color: var(--accent); }
.preset.add .tick { border-style: dashed; color: var(--ink-3); font-size: 16px; }
.ready-list { display: grid; gap: 6px; color: var(--ink-2); } .ready-list li { padding-left: 24px; position: relative; }
.ready-list li::before { content: "✓"; position: absolute; left: 0; color: var(--dot-ok); font-weight: 800; }
.row.med-setup { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr) 40px; }
@media (max-width: 760px) {
  .setup-card { padding: 26px 20px 28px; border-radius: 20px; }
  .row.med-setup { grid-template-columns: 1fr 1fr 40px; } .row.med-setup > :nth-child(1) { grid-column: 1 / -1; } .row.med-setup > :nth-child(4) { grid-column: 1 / 3; }
}
.app.setup .foot { max-width: 680px; margin: 18px auto 0; padding: 0 12px 40px; text-align: center; }

/* ---------- "saved only in this browser" notices (browser-only version) */
.store-note { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; background: var(--accent-bg); border-radius: 14px; color: var(--ink); }
.store-note > .ic { width: 24px; height: 24px; color: var(--accent-ink); flex: none; margin-top: 2px; }
.store-note p { margin-top: 4px; color: var(--ink-2); font-size: 15px; }
.safe-banner { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 18px 22px; margin-bottom: 24px; background: var(--accent-bg); box-shadow: none; }
.safe-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--panel); color: var(--accent-ink); }
.safe-ic .ic { width: 22px; height: 22px; }
.safe-text strong { font-size: 16.5px; }
.safe-text p { margin-top: 2px; color: var(--ink-2); font-size: 14.5px; }
.safe-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.safe-steps { display: grid; gap: 10px; margin: 2px 0 6px; }
.safe-steps li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.safe-steps .n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-ink); font-size: 13px; font-weight: 700; }
@media (max-width: 760px) { .safe-banner { grid-template-columns: auto 1fr; } .safe-actions { grid-column: 1 / -1; justify-content: flex-start; } }

/* Report tables: the Range and note columns fold under the test name and status on phones, so nothing hides off-screen. */
.sub-only { display: none; }
@media (max-width: 760px) {
  .table-wrap table.t { min-width: 0; }
  table.t .wide-only { display: none; }
  table.t .sub-only { display: block; color: var(--ink-3); font-size: 13.5px; font-weight: 400; margin-top: 3px; }
  table.t td, table.t tbody th { padding-left: 6px; padding-right: 6px; }
  table.t th:first-child, table.t td:first-child { padding-left: 14px; }
  table.t th:last-child, table.t td:last-child { padding-right: 14px; }
  table.t td.num { white-space: normal; }
}
