:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e1e4e9;
  --text: #1b1f24;
  --muted: #5d6673;
  --accent: #1f6feb;
  --accent-soft: #e6effd;
  --warn: #b35900;
  --warn-soft: #fff4e5;
  --danger: #c62828;
  --ok: #1e7b45;
  --chart-line: #1f6feb;
  --chart-fill: rgba(31, 111, 235, 0.12);
  --chart-grid: #e6e9ee;
  --ecg-bg: #fff;
  --ecg-sm: #f7cfcf;
  --ecg-lg: #eb9c9c;
  --ecg-trace: #111;
  --radius: 10px;
  --stage-deep: #3949ab;
  --stage-light: #7da7f5;
  --stage-rem: #4fb3bf;
  --stage-awake: #f0a04b;
  --band-normal: rgba(30, 123, 69, 0.09);
  --band-usual: rgba(93, 102, 115, 0.10);
  --ev-medication: #7b3fc4;
  --ev-illness: #c62828;
  --ev-lifestyle: #1e7b45;
  --ev-procedure: #0b7285;
  --ev-other: #5d6673;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1f242c;
    --border: #2b313a;
    --text: #e6e9ee;
    --muted: #97a0ad;
    --accent: #5b9dff;
    --accent-soft: #1b2a42;
    --warn: #f0a04b;
    --warn-soft: #2c2217;
    --danger: #ff6b6b;
    --ok: #4cc27f;
    --chart-line: #5b9dff;
    --chart-fill: rgba(91, 157, 255, 0.15);
    --chart-grid: #262c35;
    --band-normal: rgba(76, 194, 127, 0.13);
    --band-usual: rgba(151, 160, 173, 0.16);
    --ev-medication: #b38cf0;
    --ev-illness: #ff6b6b;
    --ev-lifestyle: #4cc27f;
    --ev-procedure: #3bc9db;
    --ev-other: #97a0ad;
    color-scheme: dark;
  }
}

/* Chosen with the theme toggle */
:root[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1f242c;
  --border: #2b313a;
  --text: #e6e9ee;
  --muted: #97a0ad;
  --accent: #5b9dff;
  --accent-soft: #1b2a42;
  --warn: #f0a04b;
  --warn-soft: #2c2217;
  --danger: #ff6b6b;
  --ok: #4cc27f;
  --chart-line: #5b9dff;
  --chart-fill: rgba(91, 157, 255, 0.15);
  --chart-grid: #262c35;
  --band-normal: rgba(76, 194, 127, 0.13);
  --band-usual: rgba(151, 160, 173, 0.16);
  --ev-medication: #b38cf0;
  --ev-illness: #ff6b6b;
  --ev-lifestyle: #4cc27f;
  --ev-procedure: #3bc9db;
  --ev-other: #97a0ad;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; margin-top: 2rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner, main { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.topbar-inner { display: flex; align-items: center; gap: 1rem; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 650; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.brand svg { color: var(--danger); }
nav.main { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
nav.main a {
  text-decoration: none; color: var(--muted); padding: .35rem .7rem; border-radius: 6px; font-size: .92rem;
}
nav.main a:hover { background: var(--surface-2); color: var(--text); }
nav.main a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { padding-top: 1.5rem; padding-bottom: 4rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* controls */
.btn, button {
  font: inherit; font-size: .9rem;
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .9rem; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none;
}
.btn:hover, button:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover, button.primary:hover { filter: brightness(1.08); }
button.link { border: 0; background: none; color: var(--muted); padding: .35rem .5rem; }
button.danger { color: var(--danger); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 7px; padding: .4rem .6rem;
}
textarea { width: 100%; min-height: 6rem; resize: vertical; }
label { font-size: .85rem; color: var(--muted); display: grid; gap: .25rem; }

.range { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg a { padding: .35rem .7rem; text-decoration: none; color: var(--muted); font-size: .88rem; border-right: 1px solid var(--border); }
.seg a:last-child { border-right: 0; }
.seg a.active { background: var(--accent); color: #fff; }
.range form { display: flex; gap: .35rem; align-items: center; }
.range input[type=date] { padding: .3rem .4rem; font-size: .85rem; }

.banner { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.info { background: var(--accent-soft); color: var(--accent); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 1rem; }
.stat .v { font-size: 1.6rem; font-weight: 650; }
.stat .v small { font-size: .85rem; font-weight: 500; color: var(--muted); margin-left: .2rem; }
.metric-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.metric-head h3 { margin: 0; font-size: .95rem; }
.metric-value { font-size: 1.7rem; font-weight: 650; margin: .15rem 0 0; }
.metric-value small { font-size: .85rem; font-weight: 500; color: var(--muted); margin-left: .25rem; }
.metric-meta { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-bottom: .5rem; }
.chart-box { position: relative; height: 170px; }
.chart-box canvas { width: 100% !important; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; background: var(--surface-2); }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; }
.pill { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; background: var(--surface-2); color: var(--muted); }
.pill.alert { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }

/* sleep stage bar */
.stagebar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; min-width: 140px; background: var(--surface-2); }
.stagebar span { display: block; height: 100%; }
.st-Deep { background: var(--stage-deep); }
.st-Light { background: var(--stage-light); }
.st-REM { background: var(--stage-rem); }
.st-Awake { background: var(--stage-awake); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }

/* food diary */
.diary { display: grid; gap: .75rem; }
.food-day { padding-bottom: .5rem; }
.food-table { margin-top: .5rem; }
.food-table th, .food-table td { padding: .3rem .5rem; }
.food-table th { background: none; }
.food-table .meal-row td { font-weight: 600; background: var(--surface-2); border-bottom: 0; }
.food-table .food-name { padding-left: 1.25rem; min-width: 12rem; }
.food-table tfoot td { font-weight: 600; border-top: 2px solid var(--border); border-bottom: 0; }
.food-day { overflow-x: auto; }

/* ECG */
.ecg { width: 100%; height: auto; display: block; background: var(--ecg-bg); border-radius: 6px; }
.ecg-grid-sm { fill: none; stroke: var(--ecg-sm); stroke-width: .5; }
.ecg-grid-lg { fill: none; stroke: var(--ecg-lg); stroke-width: 1; }
.ecg-trace polyline { fill: none; stroke: var(--ecg-trace); stroke-width: 1.2; stroke-linejoin: round; }
details.ecg-detail summary { cursor: pointer; color: var(--accent); font-size: .88rem; }

/* login */
.login { max-width: 400px; margin: 12vh auto; text-align: center; }
.login .card { padding: 2rem; }
.error { color: var(--danger); }

/* report */
.report-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 2px solid var(--text); padding-bottom: .75rem; margin-bottom: 1rem; }
.report-head h1 { margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .15rem 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.report .grid { grid-template-columns: repeat(2, 1fr); }
.report .chart-box { height: 150px; }
.notes { white-space: pre-wrap; }
.no-print { }
.share-url { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; word-break: break-all; background: var(--surface-2); padding: .5rem .75rem; border-radius: 6px; }

@media (max-width: 700px) {
  .grid, .report .grid { grid-template-columns: 1fr; }
  .metric-value { font-size: 1.4rem; }
  .topbar { position: static; }
  .topbar-inner { gap: 0 1rem; padding-top: .4rem; }
  .brand { flex: 1; }
  nav.main { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: .25rem 16px .5rem; }
  nav.main a { white-space: nowrap; }
  .stats { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .range, .range form { width: 100%; }
  .range form { flex-wrap: wrap; }
  .range input[type=date] { flex: 1 1 120px; min-width: 0; }
  .stat .v { font-size: 1.3rem; }
}

@media print {
  :root, :root:not([data-theme="light"]), :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --border: #ccc; --text: #000; --muted: #444;
    --chart-line: #1f4fa8; --chart-fill: rgba(31, 79, 168, .1); --chart-grid: #ddd;
    color-scheme: light;
  }
  body { font-size: 11pt; }
  .topbar, .no-print, .range, .banner, .info-btn, [popover] { display: none !important; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .highlights { break-inside: avoid; border-color: #999; }
  .event-legend { break-inside: avoid; }
  main { max-width: none; padding: 0; }
  .card { break-inside: avoid; border-color: #bbb; }
  /* Long tables may continue on the next page, but never split a row; headers repeat. */
  .table-wrap { border-color: #bbb; overflow: visible; }
  tr { break-inside: avoid; }
  thead { display: table-header-group; }
  .table-wrap:has(tbody tr:nth-child(-n+8):last-child) { break-inside: avoid; }
  h2 { break-after: avoid; margin-top: 1.25rem; }
  .report .grid { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .report .chart-box { height: 130px; }
  a { color: inherit; text-decoration: none; }
  th, td { padding: .3rem .5rem; }
  .ecg-block { break-inside: avoid; }
  .page-break { break-before: page; }
  .food-day { break-inside: avoid; overflow: visible; }
}
@page { margin: 14mm; }

/* sync progress */
.sync-hero { display: flex; gap: 1.5rem; align-items: center; margin-bottom: 1rem; padding: 1.25rem 1.5rem; position: relative; overflow: hidden; }
.sync-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: radial-gradient(600px 180px at 0% 0%, var(--accent-soft), transparent 70%);
}
.sync-hero[data-state="running"]::before, .sync-hero[data-state="queued"]::before, .sync-hero[data-state="busy"]::before { opacity: 1; }
.ring { position: relative; width: 112px; height: 112px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dasharray .6s cubic-bezier(.2,.8,.2,1), stroke .3s; }
.ring-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring-label small { font-size: .8rem; color: var(--muted); font-weight: 500; margin-left: 1px; }
.ring-done { position: absolute; inset: 30px; width: 52px !important; height: 52px !important; transform: scale(.4) !important; opacity: 0; fill: none; stroke: var(--ok); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; transition: transform .4s cubic-bezier(.3,1.6,.5,1), opacity .3s; }
.sync-hero[data-state="done"] .ring-fill { stroke: var(--ok); }
.sync-hero[data-state="done"] .ring-label { opacity: 0; }
.sync-hero[data-state="done"] .ring-done { opacity: 1; transform: scale(1) !important; }
.sync-hero[data-state="failed"] .ring-fill, .sync-hero[data-state="stalled"] .ring-fill, .sync-hero[data-state="nostart"] .ring-fill { stroke: var(--warn); }
.sync-hero[data-state="queued"] .ring svg, .sync-hero[data-state="busy"] .ring svg { animation: ring-spin 1.2s linear infinite; }
.sync-hero[data-state="queued"] .ring-fill, .sync-hero[data-state="busy"] .ring-fill { stroke-dasharray: 22 100; }
.sync-hero[data-state="queued"] .ring-label, .sync-hero[data-state="busy"] .ring-label { opacity: 0; }
@keyframes ring-spin { to { transform: rotate(270deg); } }
.sync-hero.celebrate .ring { animation: pop .6s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { 40% { transform: scale(1.08); } }

.sync-body { flex: 1; min-width: 0; position: relative; }
.sync-body h2 { margin: 0 0 .15rem; font-size: 1.2rem; }
.sync-now { margin: 0 0 .75rem; color: var(--muted); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-now strong { color: var(--text); }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: .45rem; vertical-align: 1px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }
.sync-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-bottom: .9rem; }
.sync-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.sync-hero[data-state="running"] .sync-bar span {
  background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%);
  background-size: 16px 16px; animation: stripes .8s linear infinite;
}
.sync-hero[data-state="done"] .sync-bar span { background: var(--ok); }
@keyframes stripes { to { background-position: 16px 0; } }
.sync-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem 1rem; margin: 0; }
.sync-stats dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sync-stats dd { margin: 0; font-size: 1.1rem; font-weight: 650; }

.sync-table .progress-col { width: 22%; min-width: 90px; }
.mini-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.mini-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .5s ease; }
.sync-table tr[data-state="ok"] .mini-bar span { background: var(--ok); }
.sync-table tr[data-state="error"] .mini-bar span { background: var(--warn); }
.sync-table tr[data-state="running"] td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.st { font-size: .82rem; display: inline-flex; align-items: center; gap: .4rem; }
.st-wait { color: var(--muted); }
.st-run { color: var(--accent); font-weight: 600; }
.spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ring-spin-plain .7s linear infinite; }
@keyframes ring-spin-plain { to { transform: rotate(360deg); } }

@media (max-width: 700px) {
  .sync-hero { flex-direction: column; align-items: stretch; text-align: left; }
  .ring { align-self: center; }
  .sync-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .sync-hero *, .sync-hero::before { animation: none !important; transition: none !important; }
}
.force-btn { margin-top: .9rem; border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); color: var(--warn); }
.force-btn[hidden] { display: none; }
.diag { margin-top: 1rem; }
.diag summary { cursor: pointer; }
.diag pre { background: var(--surface-2); border-radius: 6px; padding: .75rem; font-size: .8rem; overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: .75rem 0 .5rem; }

/* highlights */
.highlights { margin-bottom: 1rem; }
.highlights h2 { margin: 0 0 .6rem; font-size: 1.05rem; }
.highlights ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.highlights li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .5rem; align-items: start; line-height: 1.45; }
.highlights li::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; margin-top: .45rem; background: var(--muted); }
.highlights li.hl-alert::before { background: var(--warn); }
.highlights li.hl-event::before { background: var(--ev-medication); }
.highlights li.hl-change::before { background: var(--accent); }
.highlights .none { color: var(--muted); }

/* event legend and timeline */
.event-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .85rem; margin: .25rem 0 1rem; }
.event-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.ev-badge { display: inline-grid; place-items: center; width: 1.15rem; height: 1.15rem; border-radius: 50%; color: #fff; font-size: .7rem; font-weight: 700; flex: none; background: var(--ev-other); }
.ev-medication { background: var(--ev-medication); }
.ev-illness { background: var(--ev-illness); }
.ev-lifestyle { background: var(--ev-lifestyle); }
.ev-procedure { background: var(--ev-procedure); }
.ev-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; }
.band-key { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--muted); }
.band-key i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.band-key i.normal { background: var(--band-normal); outline: 1px solid color-mix(in srgb, var(--ok) 60%, transparent); }
.band-key i.usual { background: var(--band-usual); outline: 1px solid var(--muted); }

.timeline-list { display: grid; gap: .75rem; }
.timeline-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .9rem; align-items: start; }
@media (max-width: 700px) {
  .timeline-item { grid-template-columns: auto minmax(0, 1fr); }
  .timeline-item > form { grid-column: 2; }
}
.timeline-item .when { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.timeline-item h3 { margin: 0 0 .15rem; }
.timeline-item .effects { font-size: .88rem; margin-top: .4rem; }
.timeline-item details summary { cursor: pointer; font-size: .85rem; color: var(--accent); }
.form-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); align-items: end; }
.form-grid .wide { grid-column: 1 / -1; }
.form-errors { color: var(--danger); font-size: .88rem; }
.flash { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); padding: .5rem .8rem; border-radius: 7px; margin-bottom: 1rem; font-size: .9rem; }

/* info popovers */
.info-btn { width: 1.15rem; height: 1.15rem; padding: 0; border-radius: 50%; font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; color: var(--muted); border: 1px solid var(--border); background: transparent; vertical-align: 1px; margin-left: .3rem; }
.info-btn:hover { color: var(--accent); border-color: var(--accent); background: transparent; }
[popover].about { max-width: min(360px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1rem; background: var(--surface); color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: .9rem; line-height: 1.5; }
[popover].about h4 { margin: 0 0 .35rem; }
[popover].about p { margin: 0 0 .5rem; }
[popover].about p:last-child { margin: 0; }
[popover].about::backdrop { background: rgba(0,0,0,.08); }

/* theme toggle */
.theme-toggle { border: 0; background: none; color: var(--muted); padding: .35rem .5rem; }
.theme-toggle svg { width: 18px; height: 18px; display: block; }

/* day view */
.day-nav { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.day-metrics { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.day-metric { padding: .75rem .9rem; }
.day-metric .lbl { font-size: .8rem; color: var(--muted); }
.day-metric .val { font-size: 1.35rem; font-weight: 650; }
.day-metric .val small { font-size: .8rem; color: var(--muted); font-weight: 500; margin-left: .2rem; }
.day-metric .ctx { font-size: .75rem; color: var(--muted); }
.day-metric.is-alert { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.day-metric.is-alert .val { color: var(--warn); }
.hypno { width: 100%; height: auto; display: block; }
.hypno .lane { fill: var(--surface-2); }
.hypno text { fill: var(--muted); font-size: 21px; font-family: system-ui, sans-serif; }
.hypno .seg-Deep { fill: var(--stage-deep); }
.hypno .seg-Light { fill: var(--stage-light); }
.hypno .seg-REM { fill: var(--stage-rem); }
.hypno .seg-Awake { fill: var(--stage-awake); }
.hypno .tick { stroke: var(--border); }

/* blood pressure entry */
.bp-form input[type=number] { width: 100%; }

/* labs & documents */
.lab-grid { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.lab-card .metric-value .pill { vertical-align: 4px; margin-left: .4rem; }
.lab-history { margin-top: .5rem; font-size: .85rem; }
.lab-history summary { cursor: pointer; color: var(--accent); }
.lab-history table { margin-top: .4rem; font-size: .85rem; }
.lab-history td { padding: .3rem .4rem; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.review-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.review-preview { position: sticky; top: 72px; padding: .5rem; }
.review-preview object, .review-preview img { width: 100%; height: 78vh; display: block; border: 0; border-radius: 6px; object-fit: contain; background: var(--surface-2); }
.review-table td { padding: .3rem .35rem; }
.review-table input:not([type=checkbox]), .review-table select { width: 100%; padding: .3rem .4rem; font-size: .88rem; }
.review-table td:nth-child(2) { min-width: 11rem; }
.review-table .num-input { min-width: 4.5rem; }
.review-table .unit-input { min-width: 4.5rem; }
.review-table .range-input { min-width: 5.5rem; }
@media (max-width: 900px) {
  .review-layout { grid-template-columns: 1fr; }
  .review-preview { position: static; }
  .review-preview object, .review-preview img { height: 60vh; }
}
.doc-list { display: grid; gap: .5rem; }
.ecg-measures { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .85rem; color: var(--muted); }
