/* Sehat Map — mobile-first. App chrome follows the system theme; the body map is always "blueprint" dark. */
:root {
  --bg: #f3f5fa; --panel: #ffffff; --panel-2: #f6f7fb; --text: #161b26; --muted: #6b7486; --line: #e3e7ef;
  --accent: #4f6bed; --accent-soft: #e9edff; --danger: #d63b5b;
  --ok: #16a34a; --ok-soft: #e3f6ea; --warn: #d99a06; --warn-soft: #fbf1d6; --bad: #e0445f; --bad-soft: #fde6ea;
  --info: #3b82f6; --info-soft: #e3eefe; --none: #9aa3b5;
  --radius: 16px; --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .05);
  --tabbar: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  /* blueprint map */
  --map-bg: #0b1226; --map-grid: rgba(120, 150, 255, .07); --map-body: rgba(92, 120, 210, .16); --map-body-line: rgba(130, 165, 255, .28);
  --m-ok: #3ddc97; --m-warn: #f6c344; --m-bad: #ff5c8a; --m-none: #52608a; --m-info: #7aa2ff;
  color-scheme: light;
}
/* dark: follows the phone's setting unless Profile → Appearance picks Light or Dark (html[data-theme]) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c111d; --panel: #151b2b; --panel-2: #1a2134; --text: #e7eaf2; --muted: #8e97ab; --line: #252d42;
    --accent: #7c93ff; --accent-soft: #1f2947; --ok-soft: #12301f; --warn-soft: #362a0b; --bad-soft: #3a1520; --info-soft: #14264a;
    --ok: #3fd07f; --warn: #f2bd3a; --bad: #ff6b88; --info: #6aa4ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c111d; --panel: #151b2b; --panel-2: #1a2134; --text: #e7eaf2; --muted: #8e97ab; --line: #252d42;
  --accent: #7c93ff; --accent-soft: #1f2947; --ok-soft: #12301f; --warn-soft: #362a0b; --bad-soft: #3a1520; --info-soft: #14264a;
  --ok: #3fd07f; --warn: #f2bd3a; --bad: #ff6b88; --info: #6aa4ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }  /* short and long pages keep the same edges */
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
:root { --page-max: 1100px; }
.app { min-height: 100dvh; padding-bottom: calc(var(--tabbar) + var(--safe-b) + 8px); }
.page { max-width: var(--page-max); margin: 0 auto; padding: 12px 14px 24px; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-t)) 14px 8px;
          background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.topbar h1 { font-size: 20px; margin: 0; flex: 1; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; flex: none; }
.iconbtn svg { width: 20px; height: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { font-size: 19px; margin: 0; }
.home-grid { display: grid; gap: 14px; }
/* phones/tablets: one scroll, the map then the list; wide screens: side by side */
@media (min-width: 900px) {
  .home-grid { grid-template-columns: minmax(380px, 460px) minmax(0, 1fr); align-items: start; }
  .home-grid .map-col { position: sticky; top: 64px; }
}
@media (min-width: 1024px) {
  .home-grid { grid-template-columns: minmax(400px, 480px) minmax(0, 1fr); gap: 24px; }
  .home-grid .map-col { top: 72px; }
  .home-grid .map svg { height: min(calc(100dvh - 120px), 780px); }
  .map .organ text { font-size: 15px; }
}

/* profile switcher (like "Subarna ⇆") */
.switcher { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line);
            background: var(--panel); min-width: 0; max-width: 62vw; }
.switcher .name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b);
          display: grid; grid-template-columns: repeat(5, 1fr); background: var(--panel); border-top: 1px solid var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 11.5px; }
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a.on { color: var(--accent); }
.tabbar .up { display: grid; place-items: center; }
.tabbar .up span { width: 50px; height: 50px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center;
                   box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); margin-top: -18px; }
@media (min-width: 900px) and (max-width: 1023px) { .tabbar { left: 50%; transform: translateX(-50%); width: 560px; bottom: 12px; border: 1px solid var(--line); border-radius: 20px; height: var(--tabbar); padding: 0; }
  .app { padding-bottom: 100px; } }
.tabbar .brand, .tabbar .up-label { display: none; }

/* ---------- desktop: navigation becomes a sidebar, pages use the width ---------- */
@media (min-width: 1024px) {
  :root { --side: 232px; --page-max: 1480px; }
  .app { padding: 0 0 32px var(--side); }
  .tabbar { top: 0; bottom: 0; left: 0; right: auto; width: var(--side); height: auto; padding: 18px 14px; transform: none;
            display: flex; flex-direction: column; gap: 4px; border-top: 0; border-right: 1px solid var(--line); }
  .tabbar .brand { display: flex; order: -2; align-items: center; gap: 10px; padding: 4px 10px 20px; font-weight: 750; font-size: 17px; color: var(--text); }
  .tabbar .brand-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
  .tabbar .brand-ico svg { width: 20px; height: 20px; }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 12px; font-size: 15px; font-weight: 600; }
  .tabbar a svg { width: 21px; height: 21px; }
  .tabbar a:hover { background: var(--panel-2); color: var(--text); }
  .tabbar a.on { background: var(--accent-soft); color: var(--accent); }
  .tabbar .up { order: -1; display: flex; justify-content: center; margin-bottom: 16px; background: var(--accent); color: #fff; }
  .tabbar .up:hover { background: var(--accent); color: #fff; filter: brightness(1.08); }
  .tabbar .up span { width: auto; height: auto; margin: 0; background: none; box-shadow: none; border-radius: 0; }
  .tabbar .up-label { display: inline; font-weight: 650; }
  /* every page keeps the same width and edges; lists fill it as grids of cards */
  .list.records-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); align-items: start; }
  .records-list > .month, .records-list > .visit { grid-column: 1 / -1; }
  .visit .list, .list.med-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); align-items: start; }
  .app[data-route="records"] .page > .seg { max-width: 480px; }
  .page.settings { max-width: var(--page-max); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; align-items: start; }
  .settings > .acct, .settings > .set-sec.wide { grid-column: 1 / -1; }
  .settings > .btn.block { grid-column: 1 / -1; justify-self: start; width: auto; min-width: 260px; }
  /* the top bar lines up with the page below it */
  .topbar { padding-left: max(20px, calc((100% - var(--page-max)) / 2 + 14px)); padding-right: max(20px, calc((100% - var(--page-max)) / 2 + 14px)); }
  .page { padding: 16px 20px 32px; }
}

/* ---------- buttons, inputs, chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px;
       border: 1px solid var(--line); background: var(--panel); font-weight: 600; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
                                       background: var(--panel); font-size: 16px; }
label.lbl, span.lbl { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 5px; }
/* date inputs have a built-in minimum width (and iOS ignores width without appearance:none) -> let them shrink */
input.input[type="date"] { min-width: 0; display: block; -webkit-appearance: none; appearance: none; }
.sub-head { font-weight: 650; margin: 18px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 340px) { .two { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--accent-soft); }
.seg button { border: 0; background: none; border-radius: 10px; min-height: 38px; font-weight: 600; color: var(--muted); padding: 0 8px; }
.seg button.on { background: var(--panel); color: var(--accent); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 12px; font-size: 13.5px; font-weight: 550; white-space: nowrap; }
.chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* status badges (light cards) */
.badge { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 8px; white-space: nowrap; }
.s-in_range { --c: var(--ok); --cs: var(--ok-soft); }
.s-keep_an_eye { --c: var(--warn); --cs: var(--warn-soft); }
.s-needs_review { --c: var(--bad); --cs: var(--bad-soft); }
.s-unknown, .s-info, .s-no_data { --c: var(--muted); --cs: var(--panel-2); }
.badge { color: var(--text); background: var(--cs); }
.val { color: var(--c); }

/* ---------- metric cards (reference: body composition grid) ---------- */
.mgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .mgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.metric { background: var(--panel-2); border-radius: 16px; padding: 14px 8px 12px; text-align: center; border: 1px solid transparent; min-width: 0;
          display: flex; flex-direction: column; align-items: center; gap: 6px; }
button.metric { border: 1px solid transparent; }
button.metric:active { transform: scale(.98); }
button.metric:hover, button.finding:hover { border-color: var(--line); }
.metric .mname { font-size: 13px; color: var(--muted); line-height: 1.2; min-height: 2.4em; overflow-wrap: anywhere;
                 display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.metric .mval { font-size: 23px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.metric .mval small { font-size: 12px; font-weight: 600; margin-left: 2px; display: inline-block; white-space: nowrap; letter-spacing: 0; }
.metric .mtext { font-size: 15px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere;
                 display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* written findings (ultrasound, X-ray, ECG remarks): a readable list under the organ's numbers */
.findings { display: grid; gap: 8px; margin-top: 10px; }
@media (min-width: 1024px) { .findings { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); } }
.finding { text-align: left; background: var(--panel-2); border: 1px solid transparent; border-radius: 14px; padding: 10px 14px; display: grid; gap: 4px; min-width: 0; }
.finding .fname { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.finding .ftext { font-size: 14px; line-height: 1.45; color: var(--text); overflow-wrap: anywhere;
                  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.metric .delta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.metric .delta b { font-weight: 700; }
.organ-group h3 { font-size: 14px; margin: 18px 2px 8px; color: var(--muted); font-weight: 650; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); display: inline-block; }

/* ---------- health map (blueprint) ---------- */
.map { position: relative; background: var(--map-bg); border-radius: 22px; overflow: hidden; color: #cfd8ff; user-select: none; -webkit-user-select: none;
       background-image: linear-gradient(var(--map-grid) 1px, transparent 1px), linear-gradient(90deg, var(--map-grid) 1px, transparent 1px);
       background-size: 22px 22px; box-shadow: inset 0 0 80px rgba(0, 0, 0, .45); }
.map-head { position: absolute; left: 0; right: 0; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 14px; pointer-events: none; }
.map-head .who { font-weight: 700; color: #eef2ff; }
.map-head .when { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #8b98c9; font-family: ui-monospace, Consolas, monospace; }
.bmi { pointer-events: auto; border: 1px solid rgba(160, 180, 255, .3); background: rgba(10, 16, 36, .7); border-radius: 10px; padding: 5px 9px; text-align: right; color: #eef2ff; }
.bmi b { font-size: 18px; display: block; line-height: 1.1; }
.bmi span { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; font-family: ui-monospace, Consolas, monospace; color: #9aa6d6; }
.map svg { display: block; width: 100%; height: min(72vh, 640px); }
.map .bodypart { fill: var(--map-body); stroke: var(--map-body-line); stroke-width: 1.2; }
.map .organ { cursor: pointer; transition: opacity .25s; }
.map .organ .shape { fill: color-mix(in srgb, var(--oc) 22%, transparent); stroke: var(--oc); stroke-width: 2; filter: drop-shadow(0 0 5px color-mix(in srgb, var(--oc) 70%, transparent)); }
.map .organ .shape.fillish { fill: color-mix(in srgb, var(--oc) 30%, transparent); }
.map .organ text { fill: var(--oc); font: 700 13.5px ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .06em; text-transform: uppercase;
                   paint-order: stroke; stroke: var(--map-bg); stroke-width: 3px; }
.map .organ.dim { opacity: .14; }
.map .organ.sel .shape { stroke-width: 3.2; animation: pulse 1.6s ease-in-out infinite; }
.map .organ .hit { fill: transparent; stroke: none; }
.map .tap-area { fill: transparent; stroke: none; cursor: pointer; }
@keyframes pulse { 50% { filter: drop-shadow(0 0 12px var(--oc)); } }
.o-in_range { --oc: var(--m-ok); } .o-keep_an_eye { --oc: var(--m-warn); } .o-needs_review { --oc: var(--m-bad); }
.o-no_data { --oc: var(--m-none); } .o-info { --oc: var(--m-info); } .o-outdated { --oc: #9aa6c9; }
.map .organ.o-no_data .shape { fill: none; stroke-dasharray: 4 3; filter: none; }
.map .organ.o-outdated .shape { fill: color-mix(in srgb, var(--oc) 10%, transparent); filter: none; }
.map .organ .ico { fill: var(--map-bg); stroke: var(--oc); stroke-width: 1.4; }
.map .organ .ico-t { fill: var(--oc); font: 700 10px system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; letter-spacing: 0; stroke: none; text-transform: none; }
.s-outdated { --c: var(--muted); --cs: var(--panel-2); }
.rangebar { position: relative; height: 6px; border-radius: 3px; background: var(--line); margin: 6px 0 2px; }
.rangebar .band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--m-ok) 45%, transparent); border-radius: 3px; }
.rangebar .dotv { position: absolute; top: 50%; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%;
                  background: var(--c, var(--m-ok)); border: 2px solid var(--panel); }
.sheet.dark .rangebar .dotv { border-color: #111a33; }
.tag { display: inline-block; font: 600 10px ui-monospace, Consolas, monospace; letter-spacing: .06em; text-transform: uppercase;
       padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.legend { position: absolute; left: 12px; bottom: 12px; z-index: 2; display: flex; flex-direction: column; gap: 6px; }
.legend button { display: flex; align-items: center; gap: 8px; border: 1px solid rgba(160, 180, 255, .22); background: rgba(10, 16, 36, .75); color: #dfe5ff;
                 border-radius: 10px; padding: 5px 10px; font: 600 12px ui-monospace, Consolas, monospace; min-height: 30px; }
.legend button.on { border-color: var(--oc); box-shadow: 0 0 0 1px var(--oc) inset; }
.legend .dot { background: var(--oc); box-shadow: 0 0 8px var(--oc); }
.zoom { position: absolute; right: 12px; bottom: 12px; z-index: 2; display: flex; flex-direction: column; gap: 6px; }
.zoom button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid rgba(160, 180, 255, .22); background: rgba(10, 16, 36, .75); color: #dfe5ff; font-size: 18px; }
.map-empty { position: absolute; inset: auto 16px 64px 16px; z-index: 2; text-align: center; color: #b8c3ef; font-size: 14px; }
.processing { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- bottom sheet ---------- */
.backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(5, 8, 20, .45); animation: fade .2s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 86dvh; overflow: auto; background: var(--panel); border-radius: 22px 22px 0 0;
         padding: 8px 16px calc(18px + var(--safe-b)); animation: up .24s cubic-bezier(.2, .8, .2, 1); overscroll-behavior: contain; }
.sheet.dark { background: #111a33; color: #e6ebff; --line: rgba(160, 180, 255, .16); --muted: #93a0cf; }
@media (min-width: 700px) { .sheet { left: 50%; width: 560px; transform: translateX(-50%); bottom: 16px; border-radius: 22px; animation: fade .2s; } }
.sheet .handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sheet-head h3 { margin: 0; font-size: 19px; flex: 1; }
.sheet .x { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: transparent; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.pill { font: 700 10.5px ui-monospace, Consolas, monospace; letter-spacing: .1em; text-transform: uppercase; padding: 4px 8px; border-radius: 7px;
        color: var(--oc); border: 1px solid color-mix(in srgb, var(--oc) 55%, transparent); background: color-mix(in srgb, var(--oc) 12%, transparent); }
.note { line-height: 1.55; margin: 6px 0 14px; }
.note .ai { font: 600 10px ui-monospace, Consolas, monospace; letter-spacing: .1em; color: var(--muted); display: block; margin-top: 6px; }
.rows { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: grid; grid-template-columns: 3px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px 10px 0; border-top: 1px solid var(--line); background: transparent; width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0; }
.row:first-child { border-top: 0; }
.row .bar { align-self: stretch; background: var(--c); border-radius: 0 3px 3px 0; opacity: 0; }
.row.s-keep_an_eye .bar, .row.s-needs_review .bar { opacity: 1; }
.row .n { font-weight: 600; }
.row .r { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
.row .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.row .v small { font-weight: 500; font-size: 11px; color: var(--muted); margin-left: 3px; }
.row.s-keep_an_eye .v, .row.s-needs_review .v { color: var(--c); }
.sheet.dark .s-in_range { --c: var(--m-ok); } .sheet.dark .s-keep_an_eye { --c: var(--m-warn); } .sheet.dark .s-needs_review { --c: var(--m-bad); }
.foot { text-align: center; font: 11px ui-monospace, Consolas, monospace; color: var(--muted); margin-top: 14px; letter-spacing: .04em; }
.trend { padding: 6px 12px 12px 13px; }
.trend svg { width: 100%; height: auto; display: block; margin: 4px 0 6px; }
.trend-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seg.mini { padding: 3px; border-radius: 10px; gap: 2px; flex: none; }
.seg.mini button { min-height: 30px; padding: 2px 10px; font-size: 12.5px; }
.trend .tband { fill: rgba(61, 220, 151, .10); }
.trend .tref { stroke: rgba(61, 220, 151, .45); stroke-dasharray: 3 3; stroke-width: 1; }
.trend .taxis { stroke: var(--line); stroke-width: 1; }
.trend .tline { fill: none; stroke: #7aa2ff; stroke-width: 2; stroke-linejoin: round; }
.trend .tlab { fill: var(--muted); font: 10px ui-monospace, Consolas, monospace; }
.trend .tval { fill: currentColor; font: 700 11px ui-monospace, Consolas, monospace; }
.trend .pts { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }

/* severity gradient: --h (hue) is set per element from how far the value is outside its range
   (after the status colours so it wins; the words and icons stay the discrete status) */
.sev { --c: hsl(var(--h) 72% 36%); --cs: hsl(var(--h) 80% 92%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sev { --c: hsl(var(--h) 78% 62%); --cs: hsl(var(--h) 45% 17%); }
}
:root[data-theme="dark"] .sev { --c: hsl(var(--h) 78% 62%); --cs: hsl(var(--h) 45% 17%); }
.map .organ.sev, .pill.sev, .sheet.dark .sev { --oc: hsl(var(--h) 88% 62%); --c: hsl(var(--h) 88% 64%); }
.row.sev .bar { opacity: 1; }
.row.sev .v { color: var(--c); }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.doc { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 12px; align-items: center; text-decoration: none; color: inherit; }
.doc .thumb { width: 56px; height: 70px; border-radius: 10px; background: var(--panel-2) center/cover no-repeat; border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); }
.doc .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .m { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc .prog { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.doc .prog i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.visit { border: 1px solid var(--line); border-radius: 20px; padding: 10px; background: var(--panel-2); }
.visit-head { display: flex; gap: 10px; align-items: center; padding: 2px 4px 10px; }
.visit-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month { font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin: 16px 2px 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.med { padding: 12px 14px; }
.med .t { font-weight: 650; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 64px; height: 64px; opacity: .6; }
.banner { padding: 12px 14px; border-radius: 14px; background: var(--warn-soft); font-size: 14px; margin-bottom: 12px; }
.banner.bad { background: var(--bad-soft); }
.banner-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fixrow { padding: 10px 12px 12px; }
.fixrow-head { display: flex; gap: 8px; align-items: center; }
.fixrow-head .input { flex: 1; min-width: 0; font-weight: 600; }
.fix-actions { position: sticky; bottom: calc(var(--tabbar) + var(--safe-b) + 6px); display: grid; grid-template-columns: 1fr 2fr; gap: 10px;
               margin-top: 14px; padding: 10px 0; background: var(--bg); }
.tag.warn { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + var(--safe-b) + 14px); z-index: 80; background: #111827; color: #fff;
         padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: up .2s;
         display: flex; align-items: center; gap: 14px; }
.toast-act { border: 0; background: none; color: #9db2ff; font-weight: 700; padding: 6px 2px; min-height: 32px; margin-left: auto; }

/* ---------- Profile tab: grouped settings list ---------- */
.settings { max-width: 680px; }
.acct { display: flex; align-items: center; gap: 14px; padding: 16px; margin-top: 4px; }
.acct-main { flex: 1; min-width: 0; }
.acct-name { font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-title { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin: 24px 6px 8px; }
.set-group { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 9px 14px; border: 0; margin: 0;
           border-top: 1px solid var(--line); background: none; color: inherit; text-align: left; text-decoration: none; font: inherit; }
.set-group > .set-row:first-child { border-top: 0; }
button.set-row, a.set-row { cursor: pointer; }
button.set-row:active, a.set-row:active { background: var(--panel-2); }
.set-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.set-ico.plain { background: none; }
.set-ico svg { width: 18px; height: 18px; }
.set-main { flex: 1; min-width: 0; }
.set-label { display: flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; }
.set-detail { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.set-badge { font-size: 10.5px; padding: 1px 7px; font-weight: 600; flex: none; }
.set-row .chev { color: var(--muted); display: grid; place-items: center; flex: none; }
.set-row .chev svg { width: 18px; height: 18px; }
.set-row.danger .set-label { color: var(--bad); }
.set-row.danger .set-ico { background: var(--bad-soft); color: var(--bad); }
.mini-select { width: auto; min-height: 36px; padding: 4px 8px; font-size: 13px; flex: none; }
.set-note { font-size: 12.5px; color: var(--muted); margin: 8px 6px 0; }

/* ---------- medicine safety check ---------- */
.safety { padding: 14px; }
.safety-head { display: flex; gap: 12px; align-items: center; }
.alerts { display: grid; gap: 8px; margin-top: 12px; }
.alert-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px;
             background: color-mix(in srgb, var(--c) 10%, transparent); border-left: 4px solid var(--c); }
.alert-tag { font: 700 10px ui-monospace, Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--c);
             flex: none; padding-top: 3px; min-width: 64px; }
.alert-title { font-weight: 650; }

/* ---------- privacy ---------- */
.consent { max-width: 640px; padding-top: calc(18px + var(--safe-t)); padding-bottom: calc(24px + var(--safe-b)); }
.consent h1 { font-size: 24px; margin: 6px 0 4px; }
.notice h3 { font-size: 14.5px; margin: 14px 0 4px; }
.notice ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.5; }
.notice li { margin: 3px 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 16px 2px 14px; font-size: 14.5px; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--accent); }
a.btn { text-decoration: none; display: flex; align-items: center; justify-content: center; gap: 8px; color: inherit; }

/* ---------- trash ---------- */
.trash-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.trash-row:first-of-type { border-top: 0; }
.trash-row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-row .btn { min-height: 36px; padding: 6px 12px; flex: none; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px; background: var(--map-bg); color: #e6ebff;
         background-image: linear-gradient(var(--map-grid) 1px, transparent 1px), linear-gradient(90deg, var(--map-grid) 1px, transparent 1px); background-size: 22px 22px; }
.login .box { width: 100%; max-width: 380px; }
.login h1 { font-size: 30px; margin: 12px 0 4px; }
.login p { color: #9eabdb; margin: 0 0 22px; }
.login .input { background: rgba(255, 255, 255, .06); border-color: rgba(160, 180, 255, .25); color: #fff; }
.login .btn { background: rgba(255, 255, 255, .08); border-color: rgba(160, 180, 255, .25); color: #fff; }
.login .btn.primary { background: #6d86ff; border-color: #6d86ff; }
.login .or { text-align: center; color: #7f8bbb; font-size: 12.5px; margin: 16px 0; }
.login .fine { font-size: 12px; color: #7f8bbb; margin-top: 18px; }
