:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --ink: #16211f;
  --muted: #5b6a67;
  --line: #dde5e2;
  --brand: #0f6b63;
  --brand-ink: #ffffff;
  --brand-soft: #e2f1ee;
  --warn: #8a5a00;
  --warn-soft: #fdf2d8;
  --bad: #a8261d;
  --bad-soft: #fde8e5;
  --ok: #1d7a46;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 40, 36, .06), 0 6px 20px rgba(16, 40, 36, .05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1615;
    --surface: #18211f;
    --ink: #e8efed;
    --muted: #9bacA8;
    --line: #2a3835;
    --brand: #3fb5a8;
    --brand-ink: #06201d;
    --brand-soft: #173430;
    --warn: #f1c46a;
    --warn-soft: #3a2e12;
    --bad: #ff9b90;
    --bad-soft: #401c18;
    --ok: #6fd39a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
h2 { font-size: 1.35rem; margin: 0 0 4px; line-height: 1.25; }
h3 { font-size: 1.02rem; margin: 0 0 8px; }
p { margin: 0 0 10px; }
ul, ol { margin: 0; padding-left: 20px; }
a { color: var(--brand); }
img { max-width: 100%; }

.muted { color: var(--muted); }
.center { text-align: center; }
.hint { color: var(--muted); font-size: .85rem; font-weight: 400; }
.error { color: var(--bad); background: var(--bad-soft); padding: 8px 12px; border-radius: 10px; margin: 0; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- controls ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
label.inline { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
.input {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; min-width: 0;
}
.input.small { padding: 8px 10px; font-size: .95rem; width: auto; }
.input.small.grow { flex: 1 1 220px; }
textarea.input { resize: vertical; font-weight: 400; }
.input:focus-visible, .btn:focus-visible, .chip:focus-visible, a:focus-visible, .link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px;
}
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; padding: 10px 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 44px;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn.danger-ghost { color: var(--bad); }
.btn.danger-ghost:hover { border-color: var(--bad); }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .9rem; align-self: flex-start; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }

.badge {
  display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--line); color: var(--ink); margin-left: 6px; vertical-align: middle; white-space: nowrap;
}
.meta .badge { margin-left: 0; }
.badge.soft { background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.notice { border-radius: var(--radius); padding: 12px 16px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- sign in ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px 16px; }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.auth-card form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand img { border-radius: 8px; }
.brand.big { font-size: 1.7rem; justify-content: center; }

.segs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--line); border-radius: 12px; }
.seg { font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 9px; padding: 9px 10px; background: transparent; color: var(--muted); min-height: 40px; }
.seg.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.input.code { font-size: 1.4rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.auth-card .notice, .card .notice { margin: 0; font-size: .9rem; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 10px max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.tabs { display: flex; gap: 4px; max-width: 100%; overflow-x: auto; }
.tab { white-space: nowrap; padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .95rem; }
.tab.active { background: var(--brand-soft); color: var(--brand); }
.page { max-width: 1040px; margin: 0 auto; padding: 20px 16px 8px; display: flex; flex-direction: column; gap: 16px; }
.foot { max-width: 1040px; margin: 0 auto; padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); color: var(--muted); font-size: .84rem; }

.add { display: flex; flex-direction: column; gap: 14px; }
.add.drag { border-color: var(--brand); background: var(--brand-soft); }
.add-main { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.add-main p { margin: 0; max-width: 520px; }
.uploads { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; font-size: .92rem; }
.uploads li { display: flex; gap: 10px; align-items: baseline; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.uploads .error .dot { background: var(--bad); }
.uploads .working .dot { background: var(--brand); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .uploads .working .dot { animation: none; } }

.filters { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip { font: inherit; font-size: .9rem; font-weight: 600; white-space: nowrap; cursor: pointer; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.group { display: flex; flex-direction: column; gap: 10px; }
.month { margin: 8px 0 0; color: var(--muted); font-size: .86rem; text-transform: uppercase; letter-spacing: .06em; display: flex; gap: 8px; align-items: center; }
.count { background: var(--line); color: var(--ink); border-radius: 999px; padding: 0 8px; font-size: .78rem; letter-spacing: 0; }
.rx { display: flex; gap: 16px; align-items: flex-start; text-decoration: none; color: inherit; padding: 14px 16px; }
.rx:hover { border-color: var(--brand); }
.rx .date { flex: none; width: 54px; text-align: center; background: var(--brand-soft); color: var(--brand); border-radius: 12px; padding: 6px 0; font-size: .8rem; font-weight: 600; text-transform: uppercase; line-height: 1.2; }
.rx .date strong { display: block; font-size: 1.35rem; }
.rx .title { font-weight: 650; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.table-wrap { padding: 0; overflow-x: auto; }
.table-wrap .pad { padding: 16px 16px 4px; margin: 0; }
.results tr.panel td { background: var(--bg); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-top: 8px; padding-bottom: 8px; }
.results tr.hit td { background: var(--bad-soft); }
.badge.flag-high, .badge.flag-low, .badge.flag-positive, .badge.flag-abnormal { background: var(--bad); color: var(--surface); }
.badge.flag-normal { background: var(--brand-soft); color: var(--brand); }
.badge.flag-unknown { background: var(--line); color: var(--muted); }
.card.positives { border-color: var(--bad); border-left-width: 5px; }
.pos-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.pos-list + .pos-list { margin-top: 12px; }
.pos-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.pos-value { font-weight: 650; }
.pos-source { display: block; margin-bottom: 12px; color: inherit; text-decoration: none; }
.pos-source:hover { color: var(--brand); }
.count.hot { background: var(--bad); color: var(--surface); margin-left: 6px; }
.detail-head h2 .badge { font-weight: 600; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table th, .table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- detail ---------- */
.detail { display: flex; flex-direction: column; gap: 16px; }
.detail.busy { opacity: .55; pointer-events: none; }
.back { align-self: flex-start; text-decoration: none; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.detail-head h2 { margin-bottom: 8px; overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.original { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.original img { display: block; width: 100%; border-radius: 8px; max-height: 75vh; object-fit: contain; background: var(--bg); }
.original iframe { width: 100%; height: 70vh; border: 0; border-radius: 8px; background: var(--bg); }
.kvs { display: grid; gap: 6px; margin-top: 6px; }
.kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; font-size: .95rem; overflow-wrap: anywhere; }
/* Wide content (tables) scrolls inside its card instead of stretching the page. */
.detail-grid > *, .detail-grid .stack > *, .page > * { min-width: 0; }
.meds { display: flex; flex-direction: column; gap: 12px; padding-left: 22px; }
.meds li { padding-left: 4px; }
.meds li.uncertain { background: var(--warn-soft); border-radius: 10px; padding: 8px 10px; }
.med-name { font-weight: 650; font-size: 1.03rem; }
.med-name span { font-weight: 500; }
.sched { display: inline-flex; gap: 6px; margin: 6px 0 4px; flex-wrap: wrap; }
.slot { display: inline-flex; gap: 6px; align-items: baseline; font-size: .82rem; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; background: var(--surface); }
.slot strong { font-size: .95rem; color: var(--muted); }
.slot.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.slot.on strong { color: var(--brand); }
.generic { font-size: .93rem; }
.doubt { color: var(--warn); font-size: .92rem; font-weight: 600; }
.written { font-size: .84rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin-top: 2px; }
.med-edit { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.med-edit .input { width: 100%; }
.med-edit .wide2 { grid-column: span 2; }
.med-edit .check { grid-column: 1 / -1; font-weight: 500; color: var(--warn); flex-wrap: nowrap; align-items: flex-start; }
.med-edit .check input { margin-top: 4px; flex: none; }
.card h3:not(:first-child) { margin-top: 14px; }

/* ---------- patients ---------- */
.patients { display: flex; align-items: center; gap: 10px; }
.patients-label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); flex: none; }
.patients .chips { flex: 1; min-width: 0; }
.chip.add-chip { border-style: dashed; color: var(--brand); }
.badge.who { background: var(--ink); color: var(--bg); }
.plist { list-style: none; padding: 0; display: flex; flex-direction: column; }
.plist li { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.plist li:first-child { border-top: 0; padding-top: 0; }
.plist li > .pform { flex: 1 1 100%; }
.pform h4 { margin: 0; font-size: 1rem; }
.paddr { white-space: pre-line; font-size: .92rem; }
.input:disabled { opacity: .55; }
.notice.row { align-items: center; }
.notice.row .grow { flex: 1 1 220px; }
.notice.row .btn { align-self: center; }
select.input { appearance: auto; }

/* ---------- test history ---------- */
.test-row { display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit; padding: 14px 16px; }
.test-row:hover { border-color: var(--brand); }
.test-row .title { font-weight: 650; }
.test-latest { margin-top: 4px; }
.test-latest .badge { margin-left: 4px; }
.spark { flex: none; overflow: visible; }
.spark polyline { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--brand); }
.spark circle.hit, .chart .dot.hit, .key-dot.hit { fill: var(--bad); background: var(--bad); }
.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .band { fill: var(--brand-soft); }
.chart .band-label { fill: var(--brand); font-size: 12px; font-weight: 600; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; font-family: inherit; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.chart .dot.on { r: 8; }
.chart-tip { position: absolute; transform: translate(-50%, calc(-100% - 14px)); background: var(--ink); color: var(--bg); padding: 8px 10px; border-radius: 10px; font-size: .85rem; line-height: 1.35; pointer-events: none; white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.chart-tip .muted { color: inherit; opacity: .75; }
.chart-key { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; }
.chart-key > span { white-space: nowrap; }
@media (max-width: 600px) { .wide-only { display: none; } .chart .axis, .chart .band-label { font-size: 11px; } }
@media (max-width: 480px) { .tabs { flex-wrap: wrap; justify-content: center; row-gap: 2px; overflow: visible; } .tab { padding: 6px 9px; } }
.key-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.table tr.hit td { background: var(--bad-soft); }

/* ---------- install ---------- */
.install.compact { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; border-color: var(--brand); }
.install.compact p { margin: 0; }
.install.compact .grow { flex: 1 1 240px; }
.install.compact .row { flex: 1 1 auto; }
.install.compact .row .btn { flex: 1; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 18, 16, .55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.dialog { background: var(--surface); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 30; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.toast.error { background: var(--bad); color: #fff; }

@media (max-width: 760px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .original { position: static; }
  .original img { max-height: 55vh; }
  .original iframe { height: 55vh; }
  .add-main .row { width: 100%; }
  .add-main .btn { flex: 1; }
  .med-edit { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { justify-content: center; }
  .tab { padding: 7px 9px; font-size: .9rem; }
  .tabs { gap: 0; }
  .table th, .table td { padding: 10px 12px; }
}
@media print {
  .topbar, .add, .filters, .foot, .btn, .back { display: none !important; }
  body { background: #fff; }
}

/* Privacy policy page */
.policy { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; line-height: 1.6; }
.policy h1 { font-size: 1.9rem; margin: 8px 0 0; }
.policy h2 { margin: 28px 0 6px; font-size: 1.2rem; scroll-margin-top: 16px; }
.policy ul { padding-left: 1.2em; }
.policy li { margin: 6px 0; }
.policy .policy-back { font-weight: 600; text-decoration: none; }
.policy-toc { font-size: .92rem; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; color: var(--muted); }
.policy .missing { color: var(--bad); }
.consent { display: flex; flex-direction: row; font-weight: 400; gap: 10px; align-items: flex-start; font-size: .92rem; line-height: 1.4; }
.consent input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.foot a { color: inherit; }

/* Medicines A–Z */
.med-sort { max-width: 280px; }
.medaz { list-style: none; margin: 0; padding: 0; }
.medaz > li + li { border-top: 1px solid var(--line); }
.medaz summary { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; cursor: pointer; list-style: none; line-height: 1.45; }
.medaz summary::-webkit-details-marker { display: none; }
.medaz summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: -3px; border-radius: 12px; }
.medaz summary .badge { margin-left: 6px; }
.medaz .chev { font-size: 1.5rem; line-height: 1; color: var(--muted); transition: transform .15s; }
.medaz details[open] .chev { transform: rotate(90deg); }
.meduses { list-style: none; margin: 0 16px 14px; padding: 0 0 0 12px; border-left: 3px solid var(--line); }
.meduses li { display: flex; gap: 14px; padding: 8px 0; line-height: 1.45; }
.meduses li + li { border-top: 1px dashed var(--line); }
.meduses .sched { margin: 4px 0; }

/* Site statistics (admins) */
.admin-link { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; padding: 14px 16px; text-decoration: none; color: inherit; }
.admin-link .muted { flex: 1; min-width: 200px; }
.admin-link .chev { font-size: 1.5rem; line-height: 1; color: var(--muted); }
.stats-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { color: var(--muted); font-size: .86rem; }
.stat-value { font-size: 1.6rem; line-height: 1.2; color: var(--ink); overflow-wrap: anywhere; }
.stats-controls .chips { flex-wrap: wrap; }
.card .chips { flex-wrap: wrap; }
.chart.cols .col { fill: var(--brand); }
.chart.cols .baseline { stroke: var(--muted); stroke-width: 1; }
.chart.cols .hit-area { fill: transparent; cursor: crosshair; }
.chart.cols .hit-area.on { fill: var(--ink); fill-opacity: .06; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.stats-table summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.stats-table .table-wrap { margin-top: 10px; }

/* Beta */
.beta-badge { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; vertical-align: middle; background: var(--brand-soft); color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent); }
.brand.big .beta-badge { font-size: .8rem; }
.beta-note { font-size: .9rem; text-align: center; background: var(--brand-soft); color: var(--ink); margin: 0; }
.limit-line { margin: 0; font-size: .92rem; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.limit-line.full { color: var(--bad); font-weight: 600; }
.meter { display: block; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; max-width: 320px; }
.meter-fill { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.limit-line.full .meter-fill { background: var(--bad); }
.meter-fill.w0 { width: 0%; }
.meter-fill.w1 { width: 10%; }
.meter-fill.w2 { width: 20%; }
.meter-fill.w3 { width: 30%; }
.meter-fill.w4 { width: 40%; }
.meter-fill.w5 { width: 50%; }
.meter-fill.w6 { width: 60%; }
.meter-fill.w7 { width: 70%; }
.meter-fill.w8 { width: 80%; }
.meter-fill.w9 { width: 90%; }
.meter-fill.w10 { width: 100%; }

/* Feedback */
.fb-kinds { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fb-kinds legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.fb-kinds .chips { flex-wrap: wrap; }
.fb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.fb-head { align-items: center; gap: 6px 10px; }
.fb-msg { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.badge.fb-problem { background: var(--bad-soft, #fde8e5); color: var(--bad); }
.badge.fb-idea { background: var(--brand-soft); color: var(--brand); }
.badge.fb-praise { background: var(--warn-soft); color: var(--warn); }
.admin-link .count { margin-left: -4px; }

/* Manual entry */
.btn.disabled { opacity: .5; pointer-events: none; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.new-type { max-width: 360px; }
.new-type .seg { text-align: center; text-decoration: none; display: flex; align-items: center; justify-content: center; }
.original.manual { padding: 18px; display: flex; flex-direction: column; gap: 8px; align-self: start; }
.original.manual h3, .original.manual p { margin: 0; }

/* Plans & balance */
.plan-line { margin: 0; font-size: .92rem; color: var(--muted); }
.plan-line.full { color: var(--bad); font-weight: 600; }
.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .plans { grid-template-columns: minmax(0, 1fr); } }
.plan-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.plan-card.current { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.plan-card h3 { margin: 0; }
.plan-card ul { margin: 0; padding-left: 1.1em; line-height: 1.6; flex: 1; }
.plan-card .btn.wide { width: 100%; }
.plan-price strong { font-size: 1.8rem; }
.bill-head { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.table .num.plus { color: var(--brand); font-weight: 600; }
ul.plain { list-style: none; margin: 0; padding: 0; line-height: 1.8; }
.plan-link { border-color: var(--brand); }

.policy-nav { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .92rem; color: var(--muted); line-height: 1.9; }
.policy .table-wrap { overflow-x: auto; }

/* Vitals */
.vital-form .chips { flex-wrap: wrap; }
.bp-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: end; }
.bp-pair .slash { font-size: 1.6rem; color: var(--muted); padding-bottom: 8px; }
.with-unit { display: flex; align-items: center; gap: 8px; }
.with-unit .input { min-width: 0; flex: 1; }
.with-unit .unit { color: var(--muted); font-size: .9rem; white-space: nowrap; }
:root { --series-1: #2a78d6; --series-2: #eb6834; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-1: #3987e5; --series-2: #d95926; } }
:root[data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; }
.vchart .line.s1, .spark polyline.s1 { stroke: var(--series-1); }
.vchart .line.s2, .spark polyline.s2 { stroke: var(--series-2); }
.vchart .dot.s1 { fill: var(--series-1); }
.vchart .dot.s2 { fill: var(--series-2); }
.vchart .band.b1 { fill: var(--series-1); fill-opacity: .08; }
.vchart .band.b2 { fill: var(--series-2); fill-opacity: .08; }
.vchart .end-label { font-size: 12px; font-weight: 600; fill: var(--ink); }
.key-line { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--brand); vertical-align: middle; }
.key-line.s1 { border-color: var(--series-1); }
.key-line.s2 { border-color: var(--series-2); }
.chart-key > span.wrap-ok { white-space: normal; }
.admin-toggle { max-width: 320px; }
.reader-line { margin: 0; font-size: .9rem; color: var(--muted); }
.notice.reader-note { background: var(--brand-soft); color: var(--ink); }

/* ---------- sign out in the top bar, free trial ---------- */
.signout { order: 3; }
.trial-bar { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--brand-soft); color: var(--ink); font-size: .92rem; }
.lock-card h2 { margin: 0; }
.lock-card p { margin: 0; }
@media (max-width: 640px) {
  .signout { position: absolute; right: 12px; top: 12px; }
}

/* ---------- guide video ---------- */
.guide-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--brand-soft); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.guide-btn:hover { border-color: var(--brand); }
.guide-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.guide-play { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .95rem; padding-left: 3px; }
button.card.admin-link { width: 100%; font: inherit; text-align: left; cursor: pointer; }
.row.between { justify-content: space-between; align-items: center; }
.guide-dialog { width: min(440px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; gap: 10px; }
.guide-dialog h3 { margin: 0; }
.guide-video { width: 100%; max-height: calc(100vh - 120px); border-radius: 12px; background: #000; }

/* ---------- storage meter ---------- */
.storage-meter { display: flex; flex-direction: column; gap: 6px; }
.storage-meter .meter { max-width: none; height: 8px; }
.storage-meter.high .meter-fill { background: var(--warn); }
.storage-meter.full .meter-fill { background: var(--bad); }
.plan-line .storage-meter { max-width: 420px; }
.pack-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: .92rem; }
.plan-then { margin: -6px 0 0; }

/* ---------- admin: accounts and payments ---------- */
.admin-table td { vertical-align: top; }
.admin-table .hint { font-size: .8rem; margin-top: 2px; }
.admin-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; color: var(--muted); word-break: break-all; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 650; background: var(--line); color: var(--ink); white-space: nowrap; }
.pill.hot { background: #d2531c; color: #fff; }
.pill.soft { background: var(--brand-soft); color: var(--brand); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.admin-table { font-size: .86rem; }
.admin-table th, .admin-table td { padding: 9px 10px; }
.admin-table td:first-child { min-width: 90px; }

/* ---------- add panel: read with AI / save only ---------- */
.add-actions { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; }
.add-group { display: flex; flex-direction: column; gap: 6px; }
.add-group-label { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 640px) {
  .add-actions { width: 100%; flex-direction: column; align-items: stretch; }
  .add-group .row { width: 100%; }
  .add-group .btn { flex: 1; }
}

/* ---------- copyright ---------- */
.copyright { margin: 10px 0 0; color: var(--muted); font-size: .8rem; text-align: center; }
.foot .copyright { text-align: left; }

/* ---------- public home page ---------- */
.home { min-height: 100dvh; display: flex; flex-direction: column; }
.home-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.home-top-links { display: flex; gap: 8px; }
.home main { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.home-hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; padding: 56px 0 32px; }
.home-hero h1 { font-size: clamp(2rem, 4.4vw, 3.1rem); line-height: 1.08; letter-spacing: -.025em; margin: 0 0 16px; }
.home-lead { font-size: 1.15rem; line-height: 1.55; color: var(--muted); margin: 0 0 22px; max-width: 34em; }
.home-cta { gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.home-phone { margin: 0; justify-self: center; }
.home-phone img, .home-shots img { width: 100%; max-width: 300px; height: auto; border-radius: 24px; border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(15, 60, 55, .18); display: block; }
.home-section { padding: 36px 0; border-top: 1px solid var(--line); }
.home-section h2 { font-size: 1.6rem; letter-spacing: -.015em; margin: 0 0 18px; }
.home-features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.home-feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.home-feature h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--brand); }
.home-feature p { margin: 0; color: var(--muted); line-height: 1.5; }
.home-shots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; justify-items: center; }
.home-shots figure { margin: 0; text-align: center; }
.home-shots figcaption { margin-top: 10px; font-weight: 650; }
.home-prices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 12px; }
.home-price { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.home-price.best { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.home-price h3 { margin: 0; }
.home-amount { font-size: 1.8rem; font-weight: 800; margin: 6px 0; }
.home-amount span { font-size: .95rem; font-weight: 500; color: var(--muted); }
.home-price p:last-child { margin: 0; color: var(--muted); line-height: 1.5; }
.home-faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; }
.home-faq summary { font-weight: 650; cursor: pointer; }
.home-faq p { margin: 10px 0 0; color: var(--muted); line-height: 1.55; }
.home-final { text-align: center; padding-bottom: 48px; }
.home-foot { width: 100%; max-width: 1080px; text-align: center; margin-top: auto; }
.home-foot .copyright { text-align: center; }
@media (max-width: 820px) {
  .home-hero { grid-template-columns: 1fr; padding-top: 32px; gap: 24px; }
  .home-features, .home-prices { grid-template-columns: 1fr; }
  .home-shots { grid-template-columns: 1fr 1fr; }
  .home-shots figure:last-child { display: none; }
  .home-phone img { max-width: 260px; }
}

/* ---------- Records header with "+ Add record" ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-head h2 { margin: 0; }
