/* Labbook uses plain CSS, no build step. Design: off-white ground, white cards with hairline borders, one teal accent,
   amber for out-of-range, IBM Plex if installed (nothing is loaded from third parties; system fonts otherwise).
   Out-of-range never relies on colour alone: points are filled vs hollow, and every flag is written out. */
:root {
    color-scheme: light;
    --ground: #f4f5f2;
    --surface: #ffffff;
    --ink: #17211e;
    --muted: #5b6763;
    --line: #dde1dc;
    --teal: #0e6b5e;
    --teal-dark: #0a4f45;
    --teal-soft: #e3f0ec;
    --out: #b4500f;
    --out-dark: #8a3d0b;
    --out-soft: #fbeadb;
    --info-soft: #e7eef8;
    --info: #1d4a7a;
    --danger: #a3261b;
    --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --radius: 12px;
    --radius-s: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--ground); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
dl, dd { margin: 0; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.caps { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.row.between { justify-content: space-between; }
.row.baseline { align-items: baseline; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.stack-xs { display: flex; flex-direction: column; gap: 2px; }
.grow { flex: 1 1 auto; min-width: 0; }

.flag { font-size: 12px; font-weight: 600; }
.flag-in { color: var(--teal); }
.flag-below, .flag-above { color: var(--out); }
.flag-none { color: var(--muted); font-weight: 500; }

/* ── Top bar (desktop) ─────────────────────────────────────────────────── */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
.brand { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.topnav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.topnav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: var(--radius-s); color: var(--ink); text-decoration: none; }
.topnav a:hover { background: var(--ground); }
.topnav a[aria-current] { background: var(--teal-soft); color: var(--teal); font-weight: 600; }
.lang-form { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.lang-form-phone { display: none; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.profile-menu { position: relative; }
.profile-menu > summary { list-style: none; }
.profile-menu > summary::-webkit-details-marker { display: none; }
.profile-button { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); cursor: pointer; }
.profile-menu[open] .profile-button { border-color: var(--teal); }
.profile-button svg { transition: transform 120ms; }
.profile-menu[open] .profile-button svg { transform: rotate(180deg); }
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); font-weight: 600; font-size: 12px; }
.avatar-l { width: 44px; height: 44px; font-size: 18px; }
.avatar-solid { background: var(--teal); color: #fff; }
.avatar-empty { background: var(--line); color: var(--ink); }
.menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; display: flex; flex-direction: column; width: 320px; max-width: calc(100vw - 32px); padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(23, 33, 30, .12); }
.menu .caps { padding: 6px 10px; }
.menu form { margin: 0; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 10px; border: 0; border-radius: var(--radius-s); background: transparent; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--ground); color: var(--ink); }
.menu-item[aria-checked="true"] { background: var(--teal-soft); }
.menu-item .grow { display: flex; flex-direction: column; }
.menu-sep { height: 1px; margin: 6px 0; background: var(--line); }
.menu-lang { display: none; padding: 6px 10px; }

/* ── Bottom bar (phone) ───────────────────────────────────────────────── */
.bottomnav { display: none; }

/* ── Buttons and fields ───────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius-s); background: var(--surface); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); color: #fff; }
.btn-primary[disabled], .btn-primary[aria-disabled="true"] { background: #9db7b1; cursor: not-allowed; }
.btn-outline { border-color: var(--teal); color: var(--teal); font-weight: 500; }
.btn-outline:hover { background: var(--teal-soft); }
.btn-secondary { border-color: var(--line); color: var(--ink); font-weight: 400; }
.btn-secondary:hover { background: var(--ground); color: var(--ink); }
.btn-danger { border-color: var(--danger); color: var(--danger); font-weight: 500; }
.btn-danger:hover { background: #fbe9e7; color: var(--danger); }
.btn-warn { border-color: var(--out-dark); color: var(--out-dark); }
.btn-link { min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--teal); font-weight: 500; text-decoration: underline; cursor: pointer; }
.btn-link.danger { color: var(--danger); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[aria-pressed="true"] { border-color: var(--teal); background: var(--teal); color: #fff; font-weight: 500; }
.chip-btn { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); font-family: var(--mono); cursor: pointer; }
.chip-btn[aria-pressed="true"] { border-color: var(--teal); background: var(--teal); color: #fff; font-weight: 500; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); min-width: 0; }
.input { min-height: 44px; min-width: 0; width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); font-size: 14px; color: var(--ink); }
textarea.input { padding: 10px 12px; min-height: 64px; resize: vertical; }
select.input { padding: 0 10px; }
.input.mono { font-family: var(--mono); }
.input:focus { border-color: var(--teal); }
.input[aria-invalid="true"] { border: 2px solid var(--out); }
.field-hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); font-size: 14px; color: var(--ink); cursor: pointer; }
.check:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.check input { width: 18px; height: 18px; accent-color: var(--teal); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }

/* ── Page frame ───────────────────────────────────────────────────────── */
.page { max-width: 1280px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.page-narrow { max-width: 1120px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 16px; }
.page-head > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.sub { color: var(--muted); }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.split-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.card { display: flex; flex-direction: column; gap: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-tight { gap: 0; }
.card-selected { border: 2px solid var(--teal); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; }
.card-soft { background: var(--teal-soft); border-color: transparent; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--ground); border-radius: var(--radius-s); }
.tile-good { background: var(--teal-soft); }
.tile-out { background: var(--out-soft); }
.tile-value { font-family: var(--mono); font-size: 22px; font-weight: 500; }
.tile-good .tile-value { color: var(--teal-dark); }
.tile-out .tile-value { color: var(--out-dark); }
.tile-label { font-size: 12px; color: var(--muted); }

.notice { padding: 12px 14px; border-radius: var(--radius-s); }
.notice-success { background: var(--teal-soft); color: var(--teal-dark); }
.notice-error { background: var(--out-soft); color: var(--out-dark); }
.notice-info { background: var(--info-soft); color: var(--info); }
.notice strong { font-weight: 600; }
.link-notice { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.link-notice > div { flex: 1 1 360px; display: flex; flex-direction: column; gap: 6px; }

.badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 11px; background: var(--ground); color: var(--ink); font-size: 12px; white-space: nowrap; }
.badge-good { background: var(--teal-soft); color: var(--teal-dark); }
.badge-warn { background: var(--out-soft); color: var(--out-dark); }
.badge-info { background: var(--info-soft); color: var(--info); }
.pill { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 14px; background: var(--muted); color: #fff; font-size: 12px; }
.pill-teal { background: var(--teal); }

.list-link { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; min-height: 52px; padding: 6px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.list-link:hover { color: var(--ink); background: linear-gradient(90deg, transparent, var(--ground) 20%, var(--ground) 80%, transparent); }
.list-link .name { flex: 2 1 180px; font-weight: 600; }
.list-link .value { flex: 1 1 120px; font-family: var(--mono); }
.list-link .dir { flex: 1 1 110px; }
.list-link .range { flex: 1 1 130px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.spark { flex: 0 0 100px; width: 100px; height: 28px; }
.spark-line { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.spark-dot { fill: var(--out); }

.pins { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.pin { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.pin:hover { border-color: var(--teal); color: var(--ink); }
.pin-value { font-family: var(--mono); font-size: 20px; font-weight: 500; }
.pin-value small { font-size: 12px; font-weight: 400; color: var(--muted); }
.pin svg { width: 100%; height: 40px; }
.pin .spark-line { stroke: var(--teal); vector-effect: non-scaling-stroke; }

.med-block { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius-s); background: var(--muted); color: #fff; text-decoration: none; }
.med-block:first-of-type { background: var(--teal); }
a.med-block:hover { color: #fff; filter: brightness(1.08); }
.report-link { display: flex; flex-direction: column; padding: 10px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.report-link:hover { color: var(--ink); }
.report-link .strong { color: var(--ink); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.mono, th.mono { font-family: var(--mono); }
tr.is-removed td { color: var(--muted); }

/* ── Trends ───────────────────────────────────────────────────────────── */
.trends { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.test-list { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.test-list-items { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 220px); overflow-y: auto; padding: 2px; }
.test-group { display: flex; flex-direction: column; gap: 8px; }
.test-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); text-decoration: none; }
.test-item:hover { color: var(--ink); border-color: var(--teal); }
.test-item[aria-current] { border: 2px solid var(--teal); padding: 11px 13px; }
.test-item .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.test-item .name { font-weight: 600; font-size: 15px; }
.test-item .latest { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.test-item .latest .mono { font-size: 13px; }
.trend { flex: 999 1 560px; min-width: 0; transition: opacity 0.15s; }
.trend[aria-busy="true"] { opacity: 0.55; transition-delay: 0.15s; }
.trend h1:focus { outline: none; }
.unit-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.unit-buttons form { margin: 0; }
.chart-box { overflow-x: auto; }
.chart { position: relative; min-width: 720px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-hit { position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.chart-hit:focus-visible { outline: 2px solid var(--ink); }
.chart-bar-hit { position: absolute; height: 26px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key-in { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--teal); background: #fff; }
.key-out { width: 10px; height: 10px; border-radius: 50%; background: var(--out); }
.key-band { width: 16px; height: 10px; background: var(--teal-soft); }
.key-bound { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid var(--ink); }
.detail { display: flex; flex-wrap: wrap; gap: 16px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.detail > div { flex: 1 1 220px; display: flex; flex-direction: column; gap: 2px; }
.detail .big { font-family: var(--mono); font-size: 20px; font-weight: 500; }
.med-periods { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0 14px; }
.med-periods summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 500; }
.med-periods ul { margin: 0 0 12px; padding-left: 18px; }
.meds-toggle { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.meds-toggle .check { min-height: 36px; font-size: 13px; }

/* ── Add results ──────────────────────────────────────────────────────── */
.entry-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.entry-head .wide { grid-column: 1 / -1; }
.prefill-note { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 10px 14px; background: var(--teal-soft); border-radius: var(--radius-s); }
.prefill-note strong { color: var(--teal-dark); }
.entry-table { min-width: 900px; }
.entry-cols { display: grid; grid-template-columns: 2.1fr 1fr 1.2fr 1.6fr 1.3fr; gap: 12px; align-items: center; }
.entry-header { padding: 12px 20px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.entry-row { padding: 10px 20px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.entry-row.is-active { background: var(--ground); }
.entry-row .test { display: flex; flex-direction: column; }
.entry-row .test .strong { font-weight: 600; }
.range-inputs { display: flex; align-items: center; gap: 6px; }
.range-inputs .input { padding: 0 8px; }
.stored { display: flex; flex-direction: column; font-family: var(--mono); }
.stored .flag { font-family: var(--font); }
.suggested-tag { font-size: 11px; color: var(--muted); font-family: var(--font); }
.unit-choices { display: flex; flex-direction: column; gap: 8px; }
.unit-choices-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.unit-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); text-align: left; cursor: pointer; }
.unit-choice[aria-checked="true"] { border: 2px solid var(--teal); padding: 9px 11px; }
.unit-choice .mono { font-weight: 500; }
.unit-choice .why { font-size: 12px; color: var(--teal); font-weight: 600; }
.unit-choice .used { font-size: 12px; color: var(--muted); }
.unit-choice .what { font-size: 12px; color: var(--muted); }
.unit-choice .what.bad { color: var(--out); }
.warning { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; background: var(--out-soft); border-radius: var(--radius-s); }
.warning strong { color: var(--out-dark); }
.warning.kept { background: var(--ground); }
.entry-more { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 14px 20px; }
.entry-more .field { flex: 1 1 280px; }
.collapsed-rows > summary, .other-rows > summary { display: flex; align-items: center; min-height: 52px; padding: 0 20px; border-bottom: 1px solid var(--line); cursor: pointer; color: var(--teal); font-weight: 500; }
.save-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.stepper-only { display: none; }

/* ── Upload ───────────────────────────────────────────────────────────── */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 200px; padding: 24px; border: 2px dashed var(--teal); border-radius: var(--radius); background: var(--surface); text-align: center; }
.dropzone.is-over { background: var(--teal-soft); }
.dropzone svg { stroke: var(--teal); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.source-text { max-height: 640px; overflow: auto; padding: 12px; background: #fbfbf9; border: 1px solid var(--line); border-radius: var(--radius-s); font-family: var(--mono); font-size: 12px; line-height: 1.6; white-space: pre; }
.source-text .line { display: block; padding: 0 4px; border-radius: 4px; }
.source-text .line.is-read { background: var(--teal-soft); }
.source-text .line.is-current { background: #ffd9a8; outline: 2px solid var(--out); }
.review-table { min-width: 860px; }
.review-cols { display: grid; grid-template-columns: 1.3fr 1.7fr 1.6fr 1.1fr 0.9fr; gap: 12px; align-items: center; }
.review-row { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.review-row.needs { background: var(--out-soft); }
.review-row.skipped { opacity: .6; }
.review-row.is-current { outline: 2px solid var(--teal); outline-offset: -2px; }
.test-filter { min-height: 32px; padding: 0 8px; font-size: 13px; }
.value-unit { display: grid; grid-template-columns: 1fr 1.1fr; gap: 6px; }
.status { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 0 10px; border-radius: 14px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-ready { background: var(--teal-soft); color: var(--teal-dark); }
.status-needs { background: var(--out); color: #fff; }
.status-skipped { background: var(--ground); color: var(--muted); }
.duplicate { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

/* ── Treatment ────────────────────────────────────────────────────────── */
.med { display: flex; flex-direction: column; gap: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.steps { display: flex; flex-wrap: wrap; gap: 6px; }
.step { display: flex; flex-direction: column; min-width: 92px; padding: 8px 10px; border-radius: var(--radius-s); background: var(--teal-soft); }
.step.is-now { background: var(--teal); color: #fff; }
.step .mono { font-weight: 500; }
.watch { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.watch a { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); color: var(--ink); text-decoration: none; }
.watch a:hover { border-color: var(--teal); color: var(--ink); }
.past { display: flex; flex-direction: column; }
.past > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.dose-step-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.dose-step-row .wide { grid-column: 1 / -1; }

/* ── Profiles ─────────────────────────────────────────────────────────── */
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.facts dt { color: var(--muted); }
.danger-zone { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.danger-zone .field { flex: 1 1 200px; }

/* ── Labs ─────────────────────────────────────────────────────────────── */
.names { display: flex; flex-direction: column; }
.name-row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(260px, 2fr) auto; gap: 8px 16px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.name-row.caps { border-top: 0; padding-top: 0; }
.name-row form { margin: 0; }
@media (max-width: 760px) {
    .name-row { grid-template-columns: 1fr auto; }
    .name-row > form:first-of-type { grid-column: 1 / -1; grid-row: 2; }
    .name-row.caps { display: none; }
}

/* ── Sign-in and errors ───────────────────────────────────────────────── */
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login { width: 100%; max-width: 420px; align-items: flex-start; text-align: left; }

/* ── Phone ────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
    body { padding-bottom: 72px; }
    .topbar { padding: 8px 16px; gap: 8px 12px; justify-content: space-between; }
    .topnav, .lang-form, .topbar-actions { display: none; }
    .profile-menu .menu { left: auto; right: 0; }
    .menu-lang { display: block; }
    .lang-form-phone { display: flex; color: var(--muted); }
    .profile-label { display: none; }
    .page { padding: 16px; gap: 16px; }
    h1 { font-size: 22px; }
    .card { padding: 16px; }
    .bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
    .bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; color: var(--muted); font-size: 12px; text-decoration: none; }
    .bottomnav a[aria-current] { color: var(--teal); font-weight: 600; }
    .bottomnav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
    .trend { order: -1; }
    .test-list-items { max-height: 320px; }
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pins { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .list-link .range, .list-link .spark { display: none; }

    /* Add results, one test per step (enabled by app.js). */
    .is-stepper .entry-header, .is-stepper .collapsed-rows > summary, .is-stepper .other-rows > summary { display: none; }
    .is-stepper .entry-table { min-width: 0; }
    .is-stepper .table-wrap { overflow: visible; }
    .is-stepper .entry-row { display: none; }
    .is-stepper .entry-row.is-step { display: flex; padding: 16px; border: 2px solid var(--teal); border-radius: var(--radius); background: var(--surface); }
    .is-stepper .entry-row.is-step .entry-cols { grid-template-columns: 1fr; }
    .is-stepper .collapsed-rows, .is-stepper .other-rows { display: contents; }
    .is-stepper .stepper-only { display: flex; }
    .is-stepper .desktop-only { display: none; }
    .is-stepper .values-card { border: 0; background: transparent; }
}
.done-list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.done-list > div { display: flex; justify-content: space-between; gap: 8px; align-items: center; min-height: 44px; padding: 0 14px; border-top: 1px solid var(--line); }
.done-list > div:first-child { border-top: 0; }
.step-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.step-nav .btn { min-height: 48px; padding: 6px 10px; white-space: normal; line-height: 1.2; text-align: center; }

@media print {
    .topbar, .bottomnav, .btn, .unit-buttons { display: none !important; }
    body { background: #fff; }
}
