/* Mātes pase — Canvas design (tokens as in the Canvas frontend and Stoks-AI): icon rail, top bar, white panels on a
   dotted canvas, inspector on the right, blue for action, green / amber / red only for state. */
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(fonts/inter-latin-ext-wght-normal.woff2) format("woff2-variations"), url(fonts/inter-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(fonts/inter-latin-wght-normal.woff2) format("woff2-variations"), url(fonts/inter-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --radius: 6px;
  --canvas: #f7f8fa;
  --canvas-alt: #f4f6f8;
  --surface: #ffffff;
  --elevated: #fbfcfd;
  --line: #e3e7ec;
  --line-strong: #d2d8e0;
  --ink: #17202a;
  --ink-2: #536170;
  --ink-muted: #85909d;
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --verified: #22a06b;
  --verified-light: #ecfdf3;
  --suspected: #d97706;
  --suspected-light: #fff7e6;
  --compromised: #dc3545;
  --compromised-light: #fff1f2;
  --indigo: #6366f1;
  --indigo-light: #eef2ff;
  --teal: #0e7490;
  --teal-light: #ecfeff;
  --dot: rgb(133 144 157 / 0.28);
  --shadow: 0 6px 24px -12px rgb(23 32 42 / 0.18);
  --font: "Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --focus: #2563eb;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0b1120; --canvas-alt: #111827; --surface: #131a2b; --elevated: #182033;
    --line: #243049; --line-strong: #2e3b57; --ink: #f1f5f9; --ink-2: #b6c2d4; --ink-muted: #8391a7;
    --blue: #4c8dff; --blue-light: #16233f; --verified: #34c38a; --verified-light: #10281f;
    --suspected: #e0a030; --suspected-light: #2b2212; --compromised: #f0616f; --compromised-light: #2d1419;
    --indigo: #8b8ff8; --indigo-light: #1c1d3d; --teal: #3cc4dc; --teal-light: #0f2a33;
    --dot: rgb(131 145 167 / 0.18); --shadow: 0 6px 24px -12px rgb(0 0 0 / 0.6); --focus: #7fb0ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #0b1120; --canvas-alt: #111827; --surface: #131a2b; --elevated: #182033;
  --line: #243049; --line-strong: #2e3b57; --ink: #f1f5f9; --ink-2: #b6c2d4; --ink-muted: #8391a7;
  --blue: #4c8dff; --blue-light: #16233f; --verified: #34c38a; --verified-light: #10281f;
  --suspected: #e0a030; --suspected-light: #2b2212; --compromised: #f0616f; --compromised-light: #2d1419;
  --indigo: #8b8ff8; --indigo-light: #1c1d3d; --teal: #3cc4dc; --teal-light: #0f2a33;
  --dot: rgb(131 145 167 / 0.18); --shadow: 0 6px 24px -12px rgb(0 0 0 / 0.6); --focus: #7fb0ff; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: 13.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11";
}
h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; margin: 0; letter-spacing: -0.005em; }
h1 { font-size: 20px; }
h2 { font-size: 13.5px; }
h3 { font-size: 13.5px; }
p { margin: 0 0 6px; }
a { color: var(--blue); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-muted); }
.small { font-size: 12px; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 60; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 64px minmax(0, 1fr); grid-template-rows: 48px auto; min-height: 100vh; }
body.anon .shell { grid-template-columns: minmax(0, 1fr); }
body.anon .rail { display: none; }
.rail {
  grid-row: 1 / 3; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border-right: 1px solid var(--line); padding: 6px 0; z-index: 6;
}
.rail .logo { height: 40px; display: grid; place-items: center; margin-bottom: 8px; color: var(--blue); font-weight: 700; font-size: 12px; letter-spacing: 0.04em; }
.rail .logo span { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--blue-light); border: 1px solid color-mix(in srgb, var(--blue) 25%, transparent); }
.rail-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 6px;
  margin: 0 6px; border-radius: var(--radius); color: var(--ink-muted); text-decoration: none; font-size: 10.5px;
  line-height: 1.15; text-align: center; border: 0; background: none; cursor: pointer; font-family: inherit; height: auto;
}
.rail-btn:hover { color: var(--ink); background: var(--canvas-alt); }
.rail-btn[aria-current="page"] { color: var(--blue); background: var(--blue-light); }
.rail-btn[aria-current="page"]::before { content: ""; position: absolute; left: -6px; top: 8px; bottom: 8px; width: 2px; border-radius: 0 2px 2px 0; background: var(--blue); }
.rail .spacer { flex: 1; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0;
}
.topbar .brand { font-weight: 600; font-size: 13.5px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topbar .sep { width: 1px; height: 18px; background: var(--line); flex: none; }
.topbar .crumb { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .grow { flex: 1; }
.topbar .search { width: min(320px, 32vw); position: relative; }
.topbar .search input { height: 30px; padding-left: 30px; }
.topbar .search .ic { position: absolute; left: 9px; top: 7px; width: 16px; height: 16px; color: var(--ink-muted); }
.userbox { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.userbox b { display: block; font-weight: 600; font-size: 12.5px; }
.userbox small { display: block; color: var(--ink-muted); font-size: 11px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--indigo-light); color: var(--indigo); font-weight: 600; font-size: 11.5px; flex: none; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; border-radius: 10px; }

.content { padding: 16px 18px 56px; min-width: 0; }
.canvas-grid { background-color: var(--canvas); background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 16px 16px; }
main.narrow { padding-left: max(18px, calc((100% - 760px) / 2)); padding-right: max(18px, calc((100% - 760px) / 2)); }

/* ------------------------------------------------------------------------------------------- panels */
section, .sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 12px; min-width: 0; }
section > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 9px 12px; border-bottom: 1px solid var(--line); }
section > header h2 { font-size: 13px; }
section > header a { font-size: 12.5px; text-decoration: none; }
section > .sheet { border: 0; border-radius: 0; margin: 0; }
section > .sheet + .sheet { border-top: 1px solid var(--line); }
.sheet { padding: 12px; }
section > .row, section > .actions { padding: 10px 12px 4px; }
section > div[id]:not(.sheet):not(.row) { padding: 10px 12px 12px; }
section.sheet > h2, .sheet > h2, .sheet > h3 { margin-bottom: 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 2px; }
.list > li:last-child { padding-bottom: 2px; }

/* ------------------------------------------------------------------------------------------- controls */
button, .btn {
  font: inherit; font-size: 12.5px; height: 30px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; text-decoration: none;
}
button:hover, .btn:hover { background: var(--canvas-alt); }
button.primary, .btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.primary:hover, .btn.primary:hover { filter: brightness(1.07); background: var(--blue); }
button.quiet, .btn.quiet { border-color: transparent; background: none; color: var(--ink-2); padding: 0 8px; }
button.quiet:hover, .btn.quiet:hover { background: var(--canvas-alt); color: var(--ink); }
button.danger, .btn.danger { color: var(--compromised); }
button:disabled { opacity: 0.55; cursor: default; }
input, select, textarea {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); height: 32px; padding: 0 9px; width: 100%; min-width: 0;
}
input[type="file"] { height: auto; padding: 6px; }
input[type="checkbox"], input[type="radio"] { height: auto; width: auto; accent-color: var(--blue); }
textarea { height: auto; min-height: 92px; padding: 7px 9px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--blue) 35%, transparent); outline-offset: 0; border-color: var(--blue); }
label { display: block; font-size: 11.5px; color: var(--ink-2); margin: 10px 0 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 150px; min-width: 0; }
.row > .auto { flex: 0 0 auto; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.error { color: var(--compromised); font-size: 12px; min-height: 1.2em; margin-top: 4px; }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--canvas-alt); padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; border-radius: 4px; height: 28px; background: none; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(23 32 42 / 0.08); }

/* ------------------------------------------------------------------------------------------- status: mark + word, never color alone */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; display: inline-block; flex: none; }
.status.urgent { color: var(--compromised); }
.status.urgent::before { background: var(--compromised); border-radius: 2px; }
.status.attention { color: var(--suspected); }
.status.attention::before { background: var(--suspected); clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 9px; height: 9px; }
.status.info { color: var(--ink-2); }
.status.info::before { border: 2px solid var(--ink-muted); border-radius: 50%; width: 8px; height: 8px; }
.status.ok { color: var(--verified); }
.status.ok::before { background: var(--verified); border-radius: 50%; }
.flag-low, .flag-high { font-weight: 600; color: var(--suspected); white-space: nowrap; }
.flag-low::after { content: " ▼ zem normas"; font-size: 0.85em; }
.flag-high::after { content: " ▲ virs normas"; font-size: 0.85em; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 11px; color: var(--ink-2); background: var(--elevated); white-space: nowrap; font-weight: 500;
}
button.chip { height: 26px; padding: 0 10px; }
.chip.on { border-color: color-mix(in srgb, var(--blue) 35%, var(--line)); color: var(--blue); background: var(--blue-light); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-muted); }
.chip.ok .dot { background: var(--verified); }
.chip.warn .dot { background: var(--suspected); }
.chip.bad .dot { background: var(--compromised); }

/* ------------------------------------------------------------------------------------------- alerts */
.alert {
  border: 1px solid color-mix(in srgb, var(--compromised) 30%, var(--line)); border-left: 3px solid var(--compromised);
  background: var(--compromised-light); padding: 10px 12px; border-radius: var(--radius); margin-bottom: 10px;
}
.alert.attention { border-color: color-mix(in srgb, var(--suspected) 30%, var(--line)); border-left-color: var(--suspected); background: var(--suspected-light); }
.alert p { margin: 0 0 6px; }

/* ------------------------------------------------------------------------------------------- gestation ruler */
.ruler-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 10px; margin-bottom: 12px; }
.ruler-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ruler-week { font-size: 40px; line-height: 1; font-weight: 650; color: var(--blue); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.ruler-week small { font-size: 14px; color: var(--ink-2); font-weight: 450; letter-spacing: 0; }
.ruler-meta { color: var(--ink-2); }
.ruler-meta b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
svg.ruler { width: 100%; max-width: 100%; height: auto; display: block; margin-top: 12px; overflow: visible; }
svg.ruler text { font-family: var(--font); fill: var(--ink-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.ruler text.tri { fill: var(--ink-2); font-size: 11px; font-weight: 500; }
svg.ruler .band1 { fill: var(--canvas-alt); }
svg.ruler .band2 { fill: color-mix(in srgb, var(--canvas-alt) 55%, var(--line)); }
svg.ruler .band3 { fill: var(--line); }
svg.ruler .tick { stroke: var(--ink-muted); stroke-width: 1; }
svg.ruler .now { stroke: var(--blue); stroke-width: 2; }
svg.ruler .nowdot { fill: var(--blue); stroke: var(--surface); stroke-width: 2; }
svg.ruler .win { stroke-width: 6; stroke-linecap: round; }
svg.ruler .win.due { stroke: var(--blue); }
svg.ruler .win.upcoming { stroke: var(--ink-muted); opacity: 0.5; }
svg.ruler .win.overdue { stroke: var(--suspected); }
svg.ruler .win.done { stroke: var(--verified); }
svg.ruler .win.norecord { stroke: var(--ink-muted); stroke-width: 3; stroke-dasharray: 1 5; }
.ruler-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-2); margin-top: 8px; }
.ruler-legend i { display: inline-block; width: 14px; height: 5px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.ruler-legend i.lg-now { width: 2px; height: 12px; border-radius: 0; background: var(--blue); }
.ruler-legend i.lg-due { background: var(--blue); }
.ruler-legend i.lg-planned { background: var(--ink-muted); opacity: 0.5; }
.ruler-legend i.lg-overdue { background: var(--suspected); }
.ruler-legend i.lg-norecord { background: none; border-top: 3px dotted var(--ink-muted); height: 0; }
.ruler-legend i.lg-done { background: var(--verified); }
.mini-ruler { display: block; width: 110px; height: 14px; }
.mini-ruler .track { fill: var(--line); }
.mini-ruler .fill { fill: var(--blue); }
.mini-ruler .dot { fill: var(--blue); stroke: var(--surface); stroke-width: 2; }

/* ------------------------------------------------------------------------------------------- mother */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.quick button {
  height: auto; padding: 12px 10px; flex-direction: column; gap: 4px; background: var(--surface); line-height: 1.25;
  white-space: normal; color: var(--ink-2); font-size: 12px; border-color: var(--line);
}
.quick button:hover { border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); background: var(--surface); }
.quick button .ic { width: 22px; height: 22px; color: var(--blue); }
.quick button b { display: block; font-size: 13.5px; color: var(--ink); font-weight: 600; }
#panel:empty { display: none; }
.wellbeing { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.wellbeing button { padding: 0 2px; font-size: 12px; }
.wellbeing button[aria-pressed="true"] { background: var(--blue-light); border-color: var(--blue); color: var(--blue); font-weight: 600; }

/* to confirm */
.confirm-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.confirm-item .what { font-weight: 600; }
.confirm-item .val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.confirm-item .val.long { font-size: 12.5px; font-weight: 500; max-width: 26ch; }
.confirm-item .val input.fix { width: 8rem; }
.confirm-item q { color: var(--ink-muted); font-size: 12px; display: block; }
.confirm-item .actions { margin-top: 2px; grid-column: 1 / -1; }

/* ------------------------------------------------------------------------------------------- timeline */
.week-head { font-weight: 600; color: var(--ink); margin: 14px 0 6px; display: flex; gap: 10px; align-items: baseline; }
.week-head:first-child { margin-top: 0; }
.week-head span { color: var(--ink-muted); font-weight: 400; font-size: 12px; }
.tl { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.tl > li { position: relative; padding: 3px 0 14px 14px; }
.tl > li::before { content: ""; position: absolute; left: -23px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink-muted); }
.tl > li.k-lab::before, .tl > li.k-ultrasound::before, .tl > li.k-document::before { border-color: var(--blue); }
.tl > li.k-diary::before { border-color: var(--indigo); border-radius: 3px; }
.tl > li.k-alert::before { background: var(--compromised); border-color: var(--compromised); }
.tl > li.k-decision::before { background: var(--verified); border-color: var(--verified); }
.tl > li.k-visit::before { background: var(--blue); border-color: var(--blue); }
.tl .when { font-size: 11.5px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.tl .title { font-weight: 600; }
.tl .values { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 3px; }
.tl .values span b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tl blockquote { margin: 6px 0 0; padding: 6px 10px; border-left: 3px solid var(--indigo-light); background: var(--elevated); color: var(--ink-2); border-radius: 0 4px 4px 0; }

/* ------------------------------------------------------------------------------------------- tables & charts */
table.params { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.params th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: 11px; background: var(--elevated); border-bottom: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
table.params td { border-bottom: 1px solid var(--line); padding: 7px 8px; vertical-align: middle; }
table.params tr:last-child td { border-bottom: 0; }
table.params td.v { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
table.params tr.click { cursor: pointer; }
table.params tr.click:hover td { background: var(--canvas-alt); }
table.params tr[aria-selected="true"] td { background: var(--blue-light); }
table.params.compact td { padding: 6px; }
table.params.compact svg.spark { width: 64px; }
svg.spark { width: 84px; height: 24px; display: block; }
svg.spark polyline { fill: none; stroke: var(--ink-muted); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
svg.spark circle { fill: var(--blue); }
.chart { position: relative; margin: 6px 0 10px; }
.chart svg { width: 100%; max-width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis text, .chart text.ax { font-family: var(--font); font-size: 11px; fill: var(--ink-muted); font-variant-numeric: tabular-nums; }
.chart .band { fill: var(--verified); opacity: 0.1; }
.chart .series { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--blue); stroke: var(--surface); stroke-width: 2; }
.chart .pt.out { fill: var(--suspected); }
.chart .pt.waiting { fill: var(--surface); stroke: var(--blue); stroke-dasharray: 2 2; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:focus-visible { outline: none; stroke: var(--focus); stroke-width: 2; }
#tooltip { position: fixed; z-index: 40; background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 6px 9px; border-radius: var(--radius); font-size: 12px; pointer-events: none; max-width: 280px; }

/* ------------------------------------------------------------------------------------------- doctor */
.split { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 12px; align-items: start; }
.patients { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: sticky; top: 60px; }
.patients .search { padding: 8px; border-bottom: 1px solid var(--line); }
.patients ul { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 140px); overflow: auto; }
.patients li a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 9px 10px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.patients li a:hover { background: var(--canvas-alt); }
.patients li a[aria-current="page"] { background: var(--blue-light); box-shadow: inset 2px 0 0 var(--blue); }
.patients .pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.patients .counts { display: flex; gap: 6px; font-size: 11px; grid-column: 1 / -1; flex-wrap: wrap; }
.patients .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pgrid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
.inspector { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); position: sticky; top: 60px; overflow: hidden; }
.insp-head { display: flex; gap: 10px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.insp-head h3 { font-size: 15px; }
.insp-head .ga { color: var(--blue); font-weight: 600; font-variant-numeric: tabular-nums; }
.insp-sec { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.insp-sec:last-child { border-bottom: 0; }
.insp-sec h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--ink); }
.kv { display: grid; grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); gap: 5px 12px; font-size: 12.5px; }
.kv .k { color: var(--ink-2); }
.kv > span:nth-child(even) { overflow-wrap: anywhere; }
.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.counters a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink-2); font-size: 12px; background: var(--elevated); }
.counters a b { min-width: 20px; height: 20px; padding: 0 5px; border-radius: 4px; display: grid; place-items: center; background: var(--canvas-alt); color: var(--ink); font-variant-numeric: tabular-nums; }
.counters a.urgent b { background: var(--compromised-light); color: var(--compromised); }
.counters a.attention b { background: var(--suspected-light); color: var(--suspected); }
.stack { display: grid; gap: 6px; }
.stack .btn, .stack button { width: 100%; }
.tabs { display: flex; gap: 2px; margin-bottom: 12px; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 6px; }
.tabs a { padding: 10px 10px 9px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--blue); border-bottom-color: var(--blue); }
.two { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.ind { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.ind .t { font-weight: 600; margin-top: 2px; }
.ind .note { grid-column: 1 / -1; }
.ind .note .actions { margin-top: 6px; }
.decided { color: var(--ink-muted); font-size: 12px; }
details summary { cursor: pointer; margin-top: 8px; }
.dash-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* ------------------------------------------------------------------------------------------- sign-in */
.login-wrap { min-height: calc(100vh - 48px); display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); }
.login-card h1 { margin-bottom: 4px; }
.login-card > p { color: var(--ink-2); margin-bottom: 14px; }
.login-card .sheet { box-shadow: var(--shadow); }
.btn.google { height: 36px; width: 100%; font-weight: 600; font-size: 13px; margin-top: 12px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-muted); font-size: 11.5px; margin: 14px 0 2px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-err { margin-top: 12px; padding: 9px 11px; border-radius: var(--radius); background: var(--compromised-light); color: var(--compromised); border: 1px solid color-mix(in srgb, var(--compromised) 30%, var(--line)); font-size: 12.5px; }
.login-err.info { background: var(--blue-light); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 30%, var(--line)); }

/* ------------------------------------------------------------------------------------------- toast */
#toast { position: fixed; right: 16px; bottom: 16px; max-width: min(460px, calc(100vw - 32px)); background: var(--ink); color: var(--surface); padding: 9px 12px; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12.5px; z-index: 50; opacity: 0; transform: translateY(6px); transition: opacity 0.15s, transform 0.15s; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* ------------------------------------------------------------------------------------------- helpers (no inline styles: strict CSP) */
input.inline { width: auto; }
.full { flex-basis: 100%; }
.gap-top { margin-top: 12px; }
.pad { padding: 12px; }
.actions.filters { margin: 0 0 12px; }
blockquote.tight { margin: 6px 0; }
pre.wrap { white-space: pre-wrap; font-size: 12px; }
.nowrap { white-space: nowrap; }
ul.plain { list-style: none; margin: 4px 0 0; padding: 0; }
ul.plain > li { padding: 2px 0; }
.st-due { color: var(--blue); font-weight: 600; }
.st-overdue { color: var(--suspected); font-weight: 600; }
.st-no_record { color: var(--ink-muted); }
.st-done { color: var(--verified); font-weight: 500; }
.v { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
label.search { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; min-width: 0; }
.kpi .label { font-size: 11.5px; color: var(--ink-2); }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.kpi .sub { font-size: 11px; color: var(--ink-muted); }

/* ------------------------------------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .pgrid { grid-template-columns: minmax(0, 1fr); }
  .inspector { position: static; order: -1; }
  .inspector .insp-sec.more { display: none; }
}
@media (max-width: 900px) {
  .split, .two { grid-template-columns: minmax(0, 1fr); }
  .patients { position: static; }
  .patients ul { max-height: 40vh; }
  .topbar .search { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 48px auto; }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around;
    border-right: 0; border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); grid-row: auto;
  }
  .rail .logo, .rail .spacer { display: none; }
  .rail-btn { flex: 1; margin: 0; }
  .rail-btn[aria-current="page"]::before { left: 20%; right: 20%; top: -4px; bottom: auto; width: auto; height: 2px; border-radius: 0 0 2px 2px; }
  .content { padding: 12px 12px 88px; }
  main.narrow { padding-left: 12px; padding-right: 12px; }
  .userbox span:not(.avatar) { display: none; }
  .topbar .crumb { display: none; }
  .ruler-week { font-size: 34px; }
  .quick button { font-size: 11.5px; padding: 10px 6px; }
  input, select, textarea, button, .btn { font-size: 14px; }
  button, .btn { height: 36px; }
  input, select { height: 38px; }
}

/* ------------------------------------------------------------------------------------------- advice mode, notice */
.guide { border-left: 3px solid var(--blue); background: var(--blue-light); padding: 10px 12px; border-radius: var(--radius); margin: 8px 0; }
.guide p { margin: 0 0 6px; }
.guide p:last-child { margin-bottom: 0; }
.guide ul.signs { margin: 0 0 8px; padding-left: 18px; columns: 2 220px; column-gap: 24px; }
.guide ul.signs li { break-inside: avoid; margin-bottom: 2px; }
label.mode { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 8px; cursor: pointer; font-weight: 400; color: var(--ink); }
label.mode:has(input:checked) { border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); background: var(--blue-light); }
label.mode input { margin-top: 3px; }
label.mode > span { display: flex; flex-direction: column; gap: 4px; }
label.mode, label.check { font-size: 14px; }
label.mode .mode-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
label.mode .small { font-size: 13px; line-height: 1.5; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; color: var(--ink); margin: 10px 0; }
label.check input { margin-top: 3px; }
.login-card.notice { width: min(560px, 100%); }
.login-card.notice .sheet p { color: var(--ink); line-height: 1.55; }
table.creds code { font-size: 14px; font-weight: 600; letter-spacing: 0.02em; user-select: all; }
table.creds td { vertical-align: middle; }
