/* Biolink Web UI — light health dashboard (design port from "Biolink webui").
   Left sidebar (grouped nav) + per-screen page header + soft white cards.
   Class names are shared with app.js. All dynamic content is set via textContent (no innerHTML). */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
::selection { background: rgba(29,31,36,0.14); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(20,24,31,0.14); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
/* Global icon-size default: any icon() without a contextual size rule renders at a sane 18px
   instead of ballooning to its intrinsic box. Specific `.x .ico` rules below still override. */
svg.ico { width: 18px; height: 18px; flex: none; }

/* ================= app shell ================= */
#app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 248px; z-index: 40;
  display: flex; flex-direction: column;
  background: linear-gradient(185deg, var(--sidebar), var(--sidebar-2));
  border-right: 1px solid var(--border);
  padding: 16px 14px;
  transition: width .2s ease;
}
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 8px 8px 6px; position: relative; }
.brand .mark { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--gradient); color: #fff; box-shadow: var(--glow-accent); }
.brand .mark .ico { width: 20px; height: 20px; }
.brand .name { font-size: 16px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.1; }
.brand .sub { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.collapse-btn { position: absolute; top: -2px; right: -4px; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.collapse-btn:hover { color: var(--accent); border-color: var(--border-accent); }
.collapse-btn .ico { width: 15px; height: 15px; }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin-top: 10px; }
.nav .group-label { font-size: 9.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-3);
  font-weight: 700; padding: 14px 12px 5px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 8px 11px; border-radius: 10px;
  color: var(--text-2); font-weight: 600; font-size: 13px; border: none; background: none; width: 100%; text-align: left;
  position: relative; transition: background .15s, color .15s, box-shadow .15s;
}
.nav-item:hover { background: rgba(29,31,36,0.05); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-nav); font-weight: 700; }
.nav-item .ico { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav-item.active .ico { color: var(--accent); opacity: 1; }
.nav-item .lbl { white-space: nowrap; overflow: hidden; }

.sidebar .foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.node-status { display: flex; align-items: center; gap: 8px; padding: 6px 10px 10px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.node-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; box-shadow: 0 0 0 3px var(--success-soft); }
.node-status .dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; width: 100%; border: none;
  background: var(--surface); box-shadow: var(--shadow-card); text-align: left; }
.user-card:hover { box-shadow: var(--shadow-nav); }
.user-card .avatar { width: 32px; height: 32px; border-radius: 9px; background: var(--gradient); color: #fff; }
.user-card .nm { font-weight: 700; font-size: 13px; }
.user-card .sub { font-size: 11px; color: var(--text-3); }

/* collapsed rail */
#app.collapsed .sidebar { width: 74px; }
#app.collapsed .brand .name, #app.collapsed .brand .sub,
#app.collapsed .nav-item .lbl, #app.collapsed .group-label,
#app.collapsed .node-status span:last-child, #app.collapsed .user-card .nm, #app.collapsed .user-card .sub { display: none; }
#app.collapsed .nav-item { justify-content: center; padding: 11px; }
#app.collapsed .main { margin-left: 74px; }
#app.collapsed .user-card { justify-content: center; }

/* main column */
.main { flex: 1; min-width: 0; margin-left: 248px; display: flex; flex-direction: column; transition: margin-left .2s ease; }
.topbar { position: sticky; top: 0; z-index: 30; display: none; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(248,247,244,0.82); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.menu-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); width: 40px; height: 40px; display: grid; place-items: center; }
.content { padding: 20px 26px; max-width: 1140px; width: 100%; }

/* scrim for mobile drawer */
.scrim { display: none; position: fixed; inset: 0; background: rgba(20,24,31,0.35); z-index: 35; }

/* ================= page header (per screen) ================= */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .eyebrow { color: var(--text-3); font-weight: 700; font-size: 11px; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 2.4px; }
.page-head .page-title { font-family: var(--serif); font-size: clamp(26px, 3.6vw, 34px); font-weight: 560; letter-spacing: -0.4px; line-height: 1.04; font-variation-settings: "opsz" 72; }
.page-head .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ================= headings ================= */
.screen h2 { display: none; }  /* legacy titles suppressed — page-head owns the title now */
.eyebrow { color: var(--text-3); font-weight: 700; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.section-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-3); margin: 16px 2px 9px; }
.section-row { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 12px; gap: 12px; }
.section-row .head-ico { display: inline-flex; color: var(--text-3); }
.section-row .head-ico .ico { width: 17px; height: 17px; }
.section-row .section-label { margin: 0; }

/* ================= cards ================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px;
  margin-bottom: 14px; box-shadow: var(--shadow-card);
}
.card.pad-lg { padding: 18px; border-radius: var(--r-xl); }
.card h3 { margin: 0 0 4px; font-size: 15.5px; font-weight: 700; }
.card .muted, .muted { color: var(--text-2); }
.card .sub { color: var(--text-3); font-size: 12.5px; }
.card.hero { background: var(--surface); border-color: var(--border); border-radius: var(--r-2xl); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.row + .row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ================= grids ================= */
.grid { display: grid; gap: 12px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.dash { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; align-items: start; }
/* Today is a single-column feed — a focused centered column, not side-by-side cards. */
.screen.today { max-width: 900px; margin-left: auto; margin-right: auto; }
.screen.today .quick-add { margin-bottom: 16px; }

/* ================= stat / metric cards ================= */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px;
  box-shadow: var(--shadow-card); transition: transform .18s, box-shadow .18s; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-nav); }
.stat .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat .name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--text-3); }
.stat .chip-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); }
.stat .chip-ico .ico { width: 17px; height: 17px; }
.stat .value { font-size: 23px; font-weight: 800; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .value small { font-size: 13px; font-weight: 600; color: var(--text-2); margin-left: 3px; }
.stat .delta { font-size: 12px; color: var(--text-3); margin-top: 6px; font-weight: 600; }
.stat .delta.up { color: var(--success); }
.stat .delta.down { color: var(--danger); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; box-shadow: var(--shadow-card); }
.metric .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); font-weight: 700; }
.metric .value { font-size: 18px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.metric .value small { font-size: 12px; font-weight: 600; color: var(--text-2); }

/* ================= pills / badges ================= */
.pill, .badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 700; background: var(--muted-soft); color: var(--text-2); border: 1px solid transparent; white-space: nowrap; }
.pill.accent { background: var(--accent-soft); color: var(--accent-deep); }
.pill.ok { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warning-soft); color: var(--warning); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: rgba(29,31,36,0.06); color: var(--text-2); }
.pill.info .d { background: var(--accent-2); }
.pill.outline { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.pill .d { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.pill.live .d, .pill.ok .d { background: var(--success); }
.pill.warn .d { background: var(--warning); }
.pill.bad .d { background: var(--danger); }

/* ================= buttons ================= */
.btn { border: 1px solid transparent; border-radius: var(--r-md); padding: 9px 14px; font-size: 13px; font-weight: 700;
  background: var(--gradient); color: #fff; box-shadow: var(--glow-accent);
  transition: filter .15s, transform .1s, box-shadow .15s; display: inline-flex; align-items: center; gap: 7px; justify-content: center; }
.btn .ico { width: 16px; height: 16px; }
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; filter: none; }
.btn.block { display: flex; width: 100%; }
.btn.grad { background: var(--gradient); }
.btn.accent { background: var(--gradient); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: none; }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.btn.soft { background: var(--accent-soft); color: var(--accent-deep); box-shadow: none; }
.btn.soft:hover { filter: brightness(0.98); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; box-shadow: none; }
.btn.danger:hover { filter: brightness(0.97); }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; box-shadow: none; }

/* ================= inputs ================= */
label.field { display: block; margin-bottom: 14px; }
label.field .lbl { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
.input, textarea, select { width: 100%; padding: 11px 13px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); font-size: 14px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s; }
.input::placeholder, textarea::placeholder { color: var(--text-3); }
.input:focus, textarea:focus, select:focus { outline: none; border-color: var(--text-3); box-shadow: 0 0 0 3px rgba(29,31,36,0.06); }
textarea { min-height: 92px; resize: vertical; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); font-size: 13px; font-weight: 700; transition: .15s; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--gradient); color: #fff; border-color: transparent; box-shadow: var(--glow-accent); }

/* segmented control (range chips / tabs) */
.segmented { display: inline-flex; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--r-md); padding: 4px; gap: 2px; }
.segmented .seg { border: none; background: none; padding: 7px 16px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.segmented .seg:hover { color: var(--text); }
.segmented .seg.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-card); }

/* ================= switch ================= */
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--r-pill); transition: .18s; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ================= login ================= */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: var(--bg); }
.login-card { width: 100%; max-width: 392px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-pop); border-radius: var(--r-xl); }
.login-card .brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-card .brand .mark { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center;
  background: var(--gradient); color: #fff; box-shadow: var(--glow-accent); }
.login-card .brand .mark .ico { width: 26px; height: 26px; }
.login-card .brand .logo { font-size: 23px; font-weight: 800; letter-spacing: -0.5px; }
.login-card .brand .sub { color: var(--text-3); font-size: 12.5px; }
.err { color: var(--danger); font-size: 13px; margin: 6px 0; min-height: 18px; font-weight: 600; }
.note { color: var(--text-3); font-size: 11.5px; margin-top: 14px; line-height: 1.5; }

/* ================= chat (AI Coach) ================= */
.chat-screen { display: flex; flex-direction: column; min-height: calc(100vh - 150px); }
.chat-log { display: flex; flex-direction: column; gap: 14px; padding-bottom: 14px; flex: 1; }
.bubble { max-width: 78%; padding: 13px 16px; border-radius: 16px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.bubble.user { align-self: flex-end; background: var(--gradient); color: #fff; border-bottom-right-radius: 5px; box-shadow: var(--glow-accent); }
.bubble.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; box-shadow: var(--shadow-card); }
.bubble .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sources { margin-top: 10px; border-top: 1px dashed var(--border-strong); padding-top: 8px; }
.sources summary { font-size: 11.5px; font-weight: 700; color: var(--accent-deep); cursor: pointer; }
.sources li { font-size: 11.5px; color: var(--text-2); margin-top: 4px; }
.composer { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 14px 0 6px; background: linear-gradient(180deg, transparent, var(--bg) 34%); }
.composer .input { flex: 1; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chat-empty { text-align: center; padding: 30px 0 18px; }
.chat-empty .ic { width: 54px; height: 54px; border-radius: 16px; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; }
.chat-empty .ic .ico { width: 28px; height: 28px; }

/* ================= chart ================= */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart svg.line-chart { cursor: crosshair; touch-action: pan-y; }
.chart text { font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* ================= list-row ================= */
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .lead { display: flex; align-items: center; gap: 12px; min-width: 0; }
.list-row .lead .t { font-weight: 700; }
.list-row .lead .s { color: var(--text-3); font-size: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 12px; }
.avatar .ico { width: 18px; height: 18px; }

/* ================= ring / donut (built in JS via SVG) ================= */
.ring { position: relative; display: inline-grid; place-items: center; }
.ring .ring-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .ring-val { font-size: 28px; font-weight: 800; letter-spacing: -0.8px; line-height: 1; font-variant-numeric: tabular-nums; }
.ring .ring-lbl { font-size: 9.5px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--text-3); margin-top: 3px; }
.ring-stack { display: inline-grid; justify-items: center; gap: 9px; }
.ring-stack .ring-lbl.below { font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--text-3); }
.ring-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.ring-card .rc-label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.ring-card .rc-sub { font-size: 11px; color: var(--text-3); }

/* ================= score dial (hero) — segmented biometric dial ================= */
/* Precision-instrument dial: hairline chronometer ticks, ink fill, serif numeral, rotating
   notch. Entirely token-driven (works on any theme); depth via the instrument face + tick
   weight, no gradients or glow. */
.score-dial { position: relative; display: inline-grid; place-items: center; width: var(--sd-size, 168px); flex: none; }
.score-dial svg { width: 100%; height: auto; display: block; }
.score-dial .sd-face { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.score-dial .tk { stroke: var(--border-strong); stroke-width: 1.5; stroke-linecap: round; transition: stroke .34s ease, stroke-width .34s ease; }
.score-dial .tk.on { stroke: var(--text); }
.score-dial .tk.major.on { stroke-width: 2; }
.score-dial .sd-notch { transition: transform .52s cubic-bezier(.3,.85,.3,1), opacity .3s ease; }
.score-dial .sd-notch .nl { stroke: var(--text); stroke-width: 2.2; stroke-linecap: round; }
.score-dial .sd-notch .nd { fill: var(--text); }
.score-dial .sd-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; transition: opacity .13s ease, transform .13s ease; }
.score-dial .sd-center.swap { opacity: 0; transform: translateY(3px); }
.score-dial .sd-eyebrow { font-size: 9px; font-weight: 800; letter-spacing: 1.8px; text-transform: uppercase; color: var(--text-3); }
.score-dial .sd-num { font-family: var(--serif); font-weight: 560; font-size: 40px; line-height: 1; letter-spacing: -1px;
  font-variation-settings: "opsz" 60; font-variant-numeric: tabular-nums; color: var(--text); margin-top: 3px; }
.score-dial .sd-status { font-size: 10px; font-weight: 750; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-2); margin-top: 5px; min-height: 12px; }
.score-dial.compact { --sd-size: 128px; }
.score-dial.compact .sd-num { font-size: 30px; }
@media (prefers-reduced-motion: reduce) {
  .score-dial .tk, .score-dial .sd-notch, .score-dial .sd-center, .hero-text { transition: none !important; }
}

/* ================= hero (Today carousel) ================= */
.hero-wrap { position: relative; }
.hero-body { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; }
.hero-text { transition: opacity .16s ease; min-width: 0; }
.hero-text.swapping { opacity: 0; }
.hero-insight { font-size: 15px; line-height: 1.5; font-weight: 500; color: var(--text); }
.hero-stats { display: flex; gap: 26px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border); }
.hero-stats .hs .l { font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; }
.hero-stats .hs .v { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero-stats .hs .v small { font-size: 11px; color: var(--text-2); font-weight: 600; }
.hero-stats .hs .d { font-size: 11.5px; font-weight: 700; margin-top: 2px; }
.hero-nav { position: absolute; top: 16px; right: 16px; display: flex; gap: 6px; }
.hero-nav button { width: 30px; height: 30px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); display: grid; place-items: center; }
.hero-nav button:hover { color: var(--accent); }
.carousel-dots { display: flex; gap: 6px; justify-content: center; margin-top: 14px; }
.carousel-dots .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); border: none; padding: 0; }
.carousel-dots .dot.active { background: var(--accent); width: 20px; border-radius: 4px; }

/* ================= health monitor (2x2 gauges) ================= */
/* 3 or 4 uniform tiles (HRV joins async once its balance resolves) — auto-fit keeps the row
   evenly filled either way. */
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 11px; }
.monitor-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 13px; box-shadow: var(--shadow-card); display: flex; gap: 12px; align-items: stretch; }
.monitor-card .mc-main { flex: 1; min-width: 0; }
.monitor-card .mc-top { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
.monitor-card .mc-top .ico { width: 14px; height: 14px; }
.monitor-card .mc-val { font-family: var(--serif); font-weight: 560; font-size: 22px; letter-spacing: -0.2px;
  font-variation-settings: "opsz" 50; margin-top: 8px; font-variant-numeric: tabular-nums; line-height: 1; }
.monitor-card .mc-val small { font-family: var(--font); font-size: 11px; color: var(--text-3); font-weight: 650; margin-left: 3px; letter-spacing: 0; }
.monitor-card .mc-status { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; margin-top: 10px; }
.monitor-card .mc-status .ico { width: 15px; height: 15px; }
.monitor-card .mc-status.ok { color: var(--success); }
.monitor-card .mc-status.warn { color: var(--warning); }
.monitor-card .mc-status.bad { color: var(--danger); }
.monitor-card .mc-status.info { color: var(--accent); }
.monitor-card .mc-sub { font-size: 11px; color: var(--text-3); font-weight: 600; margin-top: 6px; }
.monitor-card .mc-gauge { width: 8px; border-radius: 999px; background: var(--surface-3); position: relative; align-self: stretch; min-height: 70px; flex: none; }
.monitor-card .mc-gauge .band { position: absolute; left: 0; right: 0; background: rgba(76,175,125,0.22); border-radius: 999px; }
.monitor-card .mc-gauge .thumb { position: absolute; left: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); transform: translate(-50%,-50%); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

/* Clickable vitals — drill into the Metrics detail. Keyboard-focusable (role=button/tabindex). */
.clickable { cursor: pointer; transition: transform .18s, box-shadow .18s, border-color .18s, background .15s; }
.monitor-card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-nav); border-color: var(--border-accent); }
.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ================= sleep hypnogram ================= */
/* Stepped stage chart (Apple/Oura style): stage bands at 4 levels over the night timeline. */
.hypno-svg { width: 100%; height: auto; display: block; margin-top: 6px; cursor: crosshair; touch-action: pan-y; }
/* Fallback flat proportional bar (only when no per-stage intervals exist). */
.hypno { display: flex; gap: 0; height: 40px; border-radius: 7px; overflow: hidden; }
.hypno .seg { height: 100%; min-width: 0.5px; }
.hypno-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; }
.hypno-legend .lg { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.hypno-legend .lg .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.hypno-legend .lg-name { color: var(--text-2); font-weight: 600; }
.hypno-legend .lg-val { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.hypno-legend .lg-pct { color: var(--text-3); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ================= today timeline ================= */
.timeline { position: relative; }
.tl-ev { display: flex; gap: 13px; padding: 11px 0; align-items: flex-start; }
.tl-ev .ic { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tl-ev .ic .ico { width: 17px; height: 17px; }
.tl-ev .body { flex: 1; min-width: 0; }
.tl-ev .ttl { font-weight: 700; font-size: 13.5px; }
.tl-ev .det { color: var(--text-2); font-size: 12.5px; margin-top: 1px; }
.tl-ev .when { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* ================= quick-add tiles (square) ================= */
/* Quick add — hairline action pills (actions are pills, never content-weight cards). */
.quick-add { display: flex; flex-wrap: wrap; gap: 8px; }
.qa-pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px 9px 12px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2);
  font-weight: 700; font-size: 12.5px;
  transition: color .15s, border-color .15s, transform .12s, box-shadow .15s; }
.qa-pill .ico { width: 15px; height: 15px; color: var(--text-2); transition: color .15s; flex: none; }
.qa-pill .ico.plus { width: 11px; height: 11px; margin-left: 2px; color: var(--text-3); }
.qa-pill:hover { color: var(--text); border-color: var(--border-accent); transform: translateY(-1px); box-shadow: var(--shadow-nav); }
.qa-pill:hover .ico { color: var(--text); }
.qa-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .qa-pill { transition: none; } }

/* ================= connections (MCP) ================= */
.mcp-prov { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-card); color: var(--text); transition: .15s; }
.mcp-prov:hover { border-color: var(--border-accent); box-shadow: var(--shadow-nav); transform: translateY(-1px); }
.mcp-prov .mcp-ic { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.mcp-prov .mcp-ic .ico { width: 20px; height: 20px; }
.mcp-prov .mcp-chev { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.code-block { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 13px;
  overflow-x: auto; font-family: var(--mono); font-size: 11.5px; line-height: 1.55; color: var(--text); white-space: pre; margin: 0; }

/* ================= CTA (doctor visit) ================= */
/* Doctor-brief prompt — plain paper card in the ink system (no gradient wash), serif heading. */
.cta { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 22px; box-shadow: var(--shadow-card); }
.cta .ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; }
.cta h3 { font-family: var(--serif); font-size: 18px; font-weight: 560; letter-spacing: -0.1px; font-variation-settings: "opsz" 40; }
.cta p { color: var(--text-2); font-size: 13.5px; line-height: 1.5; margin: 6px 0 14px; }

/* ================= hydration pips ================= */
.pips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
/* pips are BUTTONS (tap cup N to log up to N cups) — clickable affordance, not decoration */
.pip { width: 26px; height: 32px; border-radius: 7px; border: 2px solid var(--border-strong); background: var(--surface-3); display: grid; place-items: center; color: var(--accent); padding: 0; transition: border-color .15s, background .15s, transform .12s; }
.pip:hover { border-color: var(--accent); transform: translateY(-1px); }
.pip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pip.full { background: var(--accent-soft); border-color: var(--accent); }
.pip .ico { width: 14px; height: 14px; }
.pip-ctl { display: flex; align-items: center; gap: 12px; }
.pip-ctl button { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--accent); font-size: 20px; font-weight: 700; }
.pip-ctl button:hover { border-color: var(--accent); }

/* ================= lab / panel rows ================= */
.lab-row { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--border); }
.lab-row:last-child { border-bottom: none; }
.lab-row .ln { font-weight: 700; font-size: 13.5px; }
.lab-row .ln .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.lab-row .lv { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
/* Thin editorial bar (nutrition's 3px bar language) — track hairline, tinted good-zone band,
   crisp white-ringed thumb. Shared by metric tiles + Explore pattern cards. */
.range-bar { position: relative; height: 3px; border-radius: 999px; background: rgba(29,31,36,0.08); margin-top: 13px; }
.range-bar .band { position: absolute; top: 0; bottom: 0; background: rgba(63,157,110,0.30); border-radius: 999px; }
.range-bar .thumb { position: absolute; top: 50%; width: 9px; height: 9px; border-radius: 50%; transform: translate(-50%,-50%); box-shadow: 0 0 0 2px var(--surface), 0 1px 3px rgba(0,0,0,0.22); }

/* metric tiles (Metrics grid) — ink editorial: eyebrow label, serif tabular numeral, quiet
   right-aligned status word; NO chrome status dot. */
.metric-tile .mt-label { font-size: 10px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase; color: var(--text-3); }
.metric-tile .mt-row { display: flex; align-items: baseline; gap: 10px; margin-top: 9px; }
.metric-tile .mt-val { font-family: var(--serif); font-weight: 560; font-size: 23px; letter-spacing: -0.2px;
  font-variation-settings: "opsz" 50; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.05; }
.metric-tile .mt-val small { font-family: var(--font); font-size: 11px; font-weight: 650; color: var(--text-3); margin-left: 4px; letter-spacing: 0; }
.metric-tile .mt-status { margin-left: auto; font-size: 11.5px; font-weight: 750; flex: none; }
.metric-tile .mt-cap { font-size: 10.5px; font-weight: 600; color: var(--text-3); margin-top: 8px; font-variant-numeric: tabular-nums; }
.metric-tile.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-nav); border-color: var(--border-accent); }

/* ================= two-column report/brief viewer ================= */
.doc-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px; align-items: start; }
.doc-body h4 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); margin: 20px 0 8px; }
.doc-body h4:first-child { margin-top: 0; }
.doc-body p, .doc-body li { line-height: 1.6; color: var(--text); }
.doc-trend { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.doc-trend .mono { font-weight: 700; }

/* ================= misc ================= */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(29,31,36,0.15); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.hidden { display: none !important; }
.empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 26px 0; }
.placeholder { border: 1px dashed var(--border-strong); border-radius: var(--r-lg); padding: 28px; text-align: center; color: var(--text-2); background: var(--surface-2); }
.placeholder .ic { width: 44px; height: 44px; border-radius: 12px; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 10px; }
.placeholder .ic .ico { width: 22px; height: 22px; }
.placeholder .ph-title { font-weight: 800; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff;
  padding: 11px 18px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; z-index: 80; opacity: 0; transition: opacity .2s; box-shadow: var(--shadow-pop); }
.toast.show { opacity: 1; }

/* ================= modals ================= */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,24,31,0.4); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 18px; backdrop-filter: blur(2px); }
.modal-card { width: 100%; max-width: 460px; margin: 0; box-shadow: var(--shadow-pop); border-radius: var(--r-xl); max-height: 90vh; overflow-y: auto; }
.modal-card.wide { max-width: 560px; }
.modal-card video { width: 100%; max-height: 240px; background: #000; border-radius: var(--r-md); object-fit: cover; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head .x { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); display: grid; place-items: center; }

/* ---- sync modal ---- */
.sync-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.sync-row:last-of-type { border-bottom: none; }
.sync-row .mid { flex: 1; min-width: 0; }
.sync-row .nm { font-weight: 700; }
.sync-row .st { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.sync-row .st.bad { color: var(--danger); }
.sync-row .st.ok { color: var(--success); }
.prog { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 7px; }
.prog .fill { height: 100%; width: 100%; border-radius: 999px; background: var(--accent); transition: width .4s ease; }
.prog .fill.ok { background: var(--success); }
.prog .fill.bad { background: var(--danger); }
.prog .fill.muted { background: var(--border-strong); }
.prog.indet { position: relative; }
.prog.indet .fill { width: 38%; animation: indet 1.15s infinite ease-in-out; }
@keyframes indet { 0% { transform: translateX(-110%); } 100% { transform: translateX(285%); } }
.sync-row .tick { width: 22px; text-align: center; font-weight: 800; }
.sync-row .tick.ok { color: var(--success); }
.sync-row .tick.bad { color: var(--danger); }

/* ================= collapsible (settings/panels) ================= */
.collapse { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-card); margin-bottom: 14px; overflow: hidden; }
.collapse > .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; cursor: pointer; }
.collapse > .head .ttl { font-weight: 700; font-size: 14.5px; }
.collapse > .head .chev { transition: transform .2s; color: var(--text-3); }
.collapse.open > .head .chev { transform: rotate(180deg); }
.collapse > .body { padding: 0 20px 18px; }

/* ================= responsive ================= */
@media (max-width: 1080px) {
  .dash { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: repeat(2,1fr); }
  .hero-body { grid-template-columns: 1fr; gap: 18px; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-pop); width: 248px; }
  #app.nav-open .sidebar { transform: translateX(0); }
  #app.collapsed .sidebar { width: 248px; }
  #app.nav-open .scrim { display: block; }
  .main, #app.collapsed .main { margin-left: 0; }
  .topbar { display: flex; }
  .collapse-btn { display: none; }
  .content { padding: 18px; }
  .page-head .page-title { font-size: 25px; }
}
@media (max-width: 620px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .metric-grid { grid-template-columns: 1fr 1fr; }
  .monitor-grid { grid-template-columns: 1fr 1fr; }
  .score-dial { --sd-size: 136px; margin: 0 auto; }
  .score-dial .sd-num { font-size: 32px; }
  .bubble { max-width: 90%; }
  .hero-stats { gap: 18px; flex-wrap: wrap; }
}

/* ---- Backup & restore (backup.js) ---- */
.bk-danger { border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger);
  border-radius: var(--r-md); padding: 9px 11px; font-size: 12.5px; font-weight: 600; margin-top: 10px; }
.bk-note { border: 1px solid var(--border); background: var(--warning-soft); color: var(--text-1);
  border-radius: var(--r-md); padding: 8px 11px; font-size: 12.5px; margin: 6px 0; }
.bk-counts { border: 1px solid var(--border); border-radius: var(--r-md); margin: 8px 0; overflow: hidden; }
.bk-counts-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 5px 10px;
  font-size: 12px; border-top: 1px solid var(--border); }
.bk-counts-row:first-child { border-top: none; }
.bk-counts-head { color: var(--text-3); font-weight: 700; text-transform: uppercase; font-size: 10.5px;
  letter-spacing: .04em; }
.bk-counts-row span:nth-child(2), .bk-counts-row span:nth-child(3) { text-align: right; min-width: 56px; }
