/* ============================================================================
   שרה 360 · עמדת עבודה קלינית — עיצוב
   Light-first clinical theme with dark counterpart via light-dark().
   Typography: IBM Plex Sans Hebrew (UI/data) + Frank Ruhl Libre (identity).
   ============================================================================ */

:root {
  color-scheme: light dark;

  /* ---- surfaces ---- */
  --bg:            light-dark(#eef1f5, #0a1220);
  --bg-deep:       light-dark(#e4e9ef, #060c16);
  --surface:       light-dark(#ffffff, #111c2d);
  --surface-2:     light-dark(#f6f8fa, #172438);
  --surface-3:     light-dark(#eef2f6, #1d2c44);
  --line:          light-dark(#e2e7ee, #24344b);
  --line-2:        light-dark(#cbd4e0, #2f4160);

  /* ---- ink ---- */
  --ink:           light-dark(#0f1c2e, #e8eef7);
  --ink-2:         light-dark(#3a4a60, #b7c4d6);
  --muted:         light-dark(#6a7a91, #8595ad);
  --muted-2:       light-dark(#8d9bb0, #66768f);

  /* ---- brand ---- */
  --brand:         light-dark(#0f766e, #2dd4bf);
  --brand-strong:  light-dark(#115e59, #5eead4);
  --brand-soft:    light-dark(#e3f3f1, rgba(45, 212, 191, 0.14));
  --brand-line:    light-dark(#a7dcd6, rgba(45, 212, 191, 0.35));
  --on-brand:      light-dark(#ffffff, #04332e);

  /* ---- navigation rail (always deep) ---- */
  --rail:          light-dark(#0b1f3a, #07101e);
  --rail-2:        light-dark(#122a4b, #0d1a2e);
  --rail-ink:      #d6e0ee;
  --rail-muted:    #8fa3c0;
  --rail-active:   #2dd4bf;

  /* ---- clinical severity (never decorative) ---- */
  --urgent:        light-dark(#c0262c, #f87171);
  --urgent-ink:    light-dark(#9f1f24, #fca5a5);
  --urgent-soft:   light-dark(#fbe9ea, rgba(220, 38, 38, 0.18));
  --watch:         light-dark(#b45309, #fb923c);
  --watch-ink:     light-dark(#92400e, #fdba74);
  --watch-soft:    light-dark(#fdf1df, rgba(234, 88, 12, 0.18));
  --stable:        light-dark(#15803d, #4ade80);
  --stable-ink:    light-dark(#166534, #86efac);
  --stable-soft:   light-dark(#e3f5e8, rgba(22, 163, 74, 0.18));
  --offline:       light-dark(#5b6b80, #94a3b8);
  --offline-ink:   light-dark(#475569, #cbd5e1);
  --offline-soft:  light-dark(#e9edf2, rgba(100, 116, 139, 0.2));
  --info:          light-dark(#1d4ed8, #60a5fa);
  --info-ink:      light-dark(#1e40af, #93c5fd);
  --info-soft:     light-dark(#e6eefc, rgba(96, 165, 250, 0.16));

  --focus:         light-dark(#0369a1, #38bdf8);

  /* ---- shape, depth, motion ---- */
  --r-xs: 6px; --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(15, 28, 46, 0.06), 0 1px 1px rgba(15, 28, 46, 0.04);
  --shadow:    0 2px 6px rgba(15, 28, 46, 0.07), 0 8px 24px -12px rgba(15, 28, 46, 0.18);
  --shadow-lg: 0 24px 60px -24px rgba(15, 28, 46, 0.35);
  --fast: 120ms; --base: 200ms; --ease: cubic-bezier(.2, .7, .2, 1);

  /* ---- type ---- */
  --font-ui: 'IBM Plex Sans Hebrew', 'Heebo', 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Frank Ruhl Libre', 'Heebo', 'Segoe UI', serif;
  --fs-xs: 0.78rem; --fs-sm: 0.86rem; --fs: 0.95rem; --fs-md: 1.05rem; --fs-lg: 1.25rem; --fs-xl: 1.6rem; --fs-2xl: 2.1rem;

  --rail-w: 232px; --top-h: 60px;
}
:root[data-theme="dark"]  { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root {
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 2px 8px rgba(0,0,0,.45), 0 12px 32px -12px rgba(0,0,0,.6);
    --shadow-lg: 0 30px 80px -30px rgba(0,0,0,.85);
  }
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  font-family: var(--font-ui); font-size: var(--fs); line-height: 1.5;
  color: var(--ink); background: var(--bg);
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--brand); }
svg.i { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.18em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap; }
[hidden] { display: none !important; }
::selection { background: var(--brand-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* ------------------------------------------------------------- app frame */
.app {
  display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); grid-template-rows: var(--top-h) minmax(0, 1fr);
  grid-template-areas: "rail top" "rail main"; height: 100dvh;
}
.rail { grid-area: rail; background: linear-gradient(180deg, var(--rail) 0%, var(--rail-2) 100%); color: var(--rail-ink); display: flex; flex-direction: column; min-height: 0; position: relative; }
.rail::after { content: ""; position: absolute; inset-block: 0; inset-inline-end: 0; width: 1px; background: rgba(255,255,255,.06); }
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--rail-active); color: #04332e; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; box-shadow: 0 6px 18px -6px rgba(45, 212, 191, .7); }
.brand-name { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; letter-spacing: .01em; color: #fff; }
.brand-sub { font-size: var(--fs-xs); color: var(--rail-muted); margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; }
.nav-label { font-size: 0.7rem; letter-spacing: .08em; color: var(--rail-muted); padding: 14px 10px 6px; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--rail-ink); text-decoration: none; font-weight: 500; font-size: var(--fs); transition: background var(--fast) var(--ease), color var(--fast); position: relative; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a[aria-current="page"] { background: rgba(45, 212, 191, .14); color: #fff; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -12px; inset-block: 8px; width: 3px; border-radius: 3px; background: var(--rail-active); }
.nav a .i { opacity: .85; }
.nav .count { margin-inline-start: auto; font-size: var(--fs-xs); font-weight: 600; padding: 1px 8px; border-radius: 999px; background: rgba(255,255,255,.1); color: #fff; }
.nav .count.urgent { background: var(--urgent); }
.rail-foot { margin-top: auto; padding: 14px 16px 16px; border-top: 1px solid rgba(255,255,255,.07); display: flex; flex-direction: column; gap: 10px; }
.unit-pulse { display: flex; align-items: center; gap: 10px; font-size: var(--fs-xs); color: var(--rail-muted); }
.unit-pulse b { color: #fff; font-weight: 600; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 4px rgba(74, 222, 128, .18); }

.topbar { grid-area: top; display: flex; align-items: center; gap: 16px; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; flex: 1 1 auto; }
.crumbs a, .crumbs .sep { flex: none; }
.crumbs .cur { flex: 0 1 auto; min-width: 0; }
.crumbs .sep { color: var(--muted-2); }
.crumbs .cur { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); }
.search { margin-inline-start: auto; position: relative; width: min(340px, 26vw); flex: none; }
.search input { width: 100%; height: 38px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 0 38px 0 12px; font-size: var(--fs-sm); transition: border-color var(--fast), box-shadow var(--fast); }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search .i { position: absolute; inset-inline-start: 12px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.search input { padding-inline-start: 36px; padding-inline-end: 12px; }
.search-results { position: absolute; top: calc(100% + 6px); inset-inline: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; max-height: 360px; overflow: auto; }
.search-results button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; text-align: start; }
.search-results button:hover, .search-results button:focus-visible { background: var(--surface-2); }
.search-results .meta { color: var(--muted); font-size: var(--fs-xs); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); position: relative; transition: background var(--fast); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn .badge { position: absolute; top: 5px; inset-inline-end: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--urgent); color: #fff; font-size: 0.66rem; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; padding-inline: 6px; }
.clock .time { font-weight: 600; font-size: var(--fs-md); }
.clock .date { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
@media (max-width: 1240px) { .topbar .me .who, .topbar .clock .date { display: none; } .topbar { gap: 10px; } }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 10px; border-radius: 12px; }
.me:hover { background: var(--surface-2); }
.me .who { display: flex; flex-direction: column; line-height: 1.15; text-align: start; }
.me .who b { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; }
.me .who span { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 0.85rem; color: #fff; background: hsl(var(--h, 200) 45% 42%); flex: none; letter-spacing: .02em; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.35rem; border-radius: 18px; }
.avatar.sm { width: 28px; height: 28px; font-size: 0.7rem; }

.view { grid-area: main; min-height: 0; overflow: auto; padding: 22px 24px 40px; scroll-behavior: smooth; container: main / inline-size; }
.view:focus { outline: none; }
.view > * { animation: rise var(--base) var(--ease) both; }
@keyframes rise { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }

/* -------------------------------------------------------------- generic */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -.005em; }
.page-sub { color: var(--muted); margin-top: 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px 12px; border-bottom: 1px solid var(--line); }
.card-h h2, .card-h h3 { font-size: var(--fs-md); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-h .hint { color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.card-b { padding: 16px 18px; }
.card-b.tight { padding: 8px 10px; }
.card-b.flush { padding: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.b { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.end { margin-inline-start: auto; }
.divider { height: 1px; background: var(--line); margin: 6px 0; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .i { width: 28px; height: 28px; opacity: .5; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: var(--fs-sm); }
.kv dd { margin: 0; font-weight: 500; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 500; background: var(--surface-3); color: var(--ink-2); border: 1px solid transparent; line-height: 1.3; }
.chip.brand { background: var(--brand-soft); color: var(--brand-strong); }
.chip.urgent { background: var(--urgent-soft); color: var(--urgent-ink); }
.chip.watch { background: var(--watch-soft); color: var(--watch-ink); }
.chip.stable { background: var(--stable-soft); color: var(--stable-ink); }
.chip.info { background: var(--info-soft); color: var(--info-ink); }
.chip.offline { background: var(--offline-soft); color: var(--offline-ink); }
.chip.outline { background: transparent; border-color: var(--line-2); }
.chip.toggle { cursor: pointer; user-select: none; }
.chip.toggle:hover { border-color: var(--brand-line); }
.chip.toggle[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }

/* status pill: icon + word + color (never color alone) */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; line-height: 1.2; }
.pill .i { width: 0.95em; height: 0.95em; }
.pill.urgent { background: var(--urgent-soft); color: var(--urgent-ink); }
.pill.watch { background: var(--watch-soft); color: var(--watch-ink); }
.pill.stable { background: var(--stable-soft); color: var(--stable-ink); }
.pill.offline { background: var(--offline-soft); color: var(--offline-ink); }
.pill.info { background: var(--info-soft); color: var(--info-ink); }
.pill.near { background: var(--watch-soft); color: var(--watch-ink); }
.pill.alert { background: var(--urgent-soft); color: var(--urgent-ink); }
.pill.ok { background: var(--stable-soft); color: var(--stable-ink); }

/* buttons: 4 classes */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px; font-weight: 600; font-size: var(--fs-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); transition: background var(--fast), border-color var(--fast), box-shadow var(--fast), translate var(--fast); white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: var(--muted-2); }
.btn:active { translate: 0 1px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: 0 6px 16px -8px var(--brand); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.danger { background: var(--urgent); border-color: var(--urgent); color: #fff; }
.btn.danger:hover { filter: brightness(.94); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { height: 32px; padding: 0 10px; font-size: var(--fs-xs); border-radius: 8px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: var(--fs); border-radius: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: start; font-weight: 600; color: var(--muted); font-size: var(--fs-xs); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table.clickable tbody tr { cursor: pointer; }
.table .flag-high, .table .flag-low, .table .flag-crit { font-weight: 700; }
.flag-high, .flag-low { color: var(--watch-ink); }
.flag-crit { color: var(--urgent-ink); }
.flag-tag { display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; margin-inline-start: 6px; vertical-align: middle; }
.flag-tag.high, .flag-tag.low { background: var(--watch-soft); color: var(--watch-ink); }
.flag-tag.crit { background: var(--urgent-soft); color: var(--urgent-ink); }
.table-wrap { overflow-x: auto; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; padding: 0 4px; position: relative; }
@container main (inline-size < 1300px) { .tab .i { display: none; } .tab { padding-inline: 10px; } }
.tab { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 12px 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 6px 6px 0 0; transition: color var(--fast), background var(--fast); font-size: var(--fs-sm); }
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--brand-strong); border-bottom-color: var(--brand); font-weight: 600; }
.tab .n { font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); }
.tab .n.urgent { background: var(--urgent-soft); color: var(--urgent-ink); }
.tab .n.watch { background: var(--watch-soft); color: var(--watch-ink); }
.tab-panel { padding-top: 18px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.field .help { font-size: var(--fs-xs); color: var(--muted); }
.req::after { content: " *"; color: var(--urgent); }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 9px 12px; font-size: var(--fs); transition: border-color var(--fast), box-shadow var(--fast); min-height: 40px; }
.textarea { min-height: 88px; resize: vertical; line-height: 1.5; field-sizing: content; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input.sm { min-height: 34px; padding: 5px 10px; font-size: var(--fs-sm); }
.input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.input:user-invalid { border-color: var(--urgent); }
.f-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.f-grid.c2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: border-color var(--fast), background var(--fast); }
.check:hover { border-color: var(--brand-line); }
.check:has(input:checked) { background: var(--brand-soft); border-color: var(--brand-line); }
.check input { accent-color: var(--brand); width: 18px; height: 18px; margin: 2px 0 0; flex: none; }
.check .t { font-weight: 500; font-size: var(--fs-sm); }
.check .d { font-size: var(--fs-xs); color: var(--muted); }
.check-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: 10px; }
.seg button { padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: var(--fs-sm); color: var(--ink-2); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow-sm); }

/* pain scale */
.pain { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; }
.pain button { height: 44px; border-radius: 8px; font-weight: 700; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); transition: background var(--fast), color var(--fast), border-color var(--fast); }
.pain button:hover { border-color: var(--muted-2); }
.pain button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pain-labels { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }

/* -------------------------------------------------------------- dashboard */
.dash { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "alert alert" "kpi kpi" "census side"; }
.dash > .visit-alert { grid-area: alert; }
.dash > .kpis { grid-area: kpi; }
.dash > .census { grid-area: census; }
.dash > .side { grid-area: side; display: flex; flex-direction: column; gap: 18px; }
@container main (inline-size < 980px) { .dash { grid-template-columns: 1fr; grid-template-areas: "alert" "kpi" "census" "side"; } }

.visit-alert { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; padding: 16px 20px; border-radius: var(--r-lg); background: linear-gradient(135deg, var(--brand-soft), var(--surface) 60%); border: 1px solid var(--brand-line); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.visit-alert::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 5px; background: var(--brand); }
.visit-alert .when { display: flex; flex-direction: column; align-items: center; padding: 8px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--brand-line); min-width: 92px; }
.visit-alert .when b { font-size: 1.5rem; font-weight: 700; line-height: 1.1; color: var(--brand-strong); }
.visit-alert .when span { font-size: var(--fs-xs); color: var(--muted); }
.visit-alert .who { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.visit-alert .who .t { font-size: var(--fs-xs); color: var(--brand-strong); font-weight: 600; letter-spacing: .04em; }
.visit-alert .who h2 { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 600; }
.visit-alert .who p { color: var(--ink-2); font-size: var(--fs-sm); }
.visit-alert .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@container main (inline-size < 700px) { .visit-alert { grid-template-columns: 1fr; } .visit-alert .acts { justify-content: flex-start; } }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi .l { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.kpi .s { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 4px; }
.kpi.urgent .v { color: var(--urgent-ink); }
.kpi.watch .v { color: var(--watch-ink); }
.kpi.brand .v { color: var(--brand-strong); }
.kpi::after { content: ""; position: absolute; inset-inline-end: -20px; top: -20px; width: 70px; height: 70px; border-radius: 50%; background: var(--surface-3); opacity: .6; }

.census { container: census / inline-size; }
.census .card-h { flex-wrap: wrap; }
.census-row { display: grid; grid-template-columns: 28px minmax(190px, 1.4fr) minmax(110px, 1fr) repeat(4, 78px) 100px 92px; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background var(--fast); text-decoration: none; color: inherit; border-inline-start: 3px solid transparent; }
.census-row:hover { background: var(--surface-2); }
.census-row:last-child { border-bottom: 0; }
.census-row.head { cursor: default; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; background: var(--surface-2); padding-block: 8px; }
.census-row.head:hover { background: var(--surface-2); }
.census-row.tri-urgent { background: color-mix(in srgb, var(--urgent-soft) 55%, transparent); border-inline-start-color: var(--urgent); }
.census-row.tri-watch { border-inline-start-color: var(--watch); }
.census-row.tri-stable { border-inline-start-color: var(--stable); }
.census-row.tri-offline { border-inline-start-color: var(--offline); }
.census-row .rank { font-size: var(--fs-xs); color: var(--muted-2); font-weight: 600; text-align: center; }
.census-row .id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.census-row .id .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.census-row .id .m { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.census-row .dx { font-size: var(--fs-sm); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.census-row .dx small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.vcell { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.vcell b { font-weight: 700; font-size: var(--fs); }
.vcell b.sev-urgent { color: var(--urgent-ink); }
.vcell b.sev-watch { color: var(--watch-ink); }
.vcell small { font-size: 0.68rem; color: var(--muted); }
.vcell svg { width: 64px; height: 18px; margin-top: 2px; }
.census-row .age { font-size: var(--fs-xs); color: var(--muted); display: flex; flex-direction: column; }
.census-row .age b { color: var(--ink-2); font-weight: 600; }
@container census (inline-size < 960px) { .census-row { grid-template-columns: 28px minmax(180px, 1.4fr) minmax(110px, 1fr) repeat(2, 78px) 100px 92px; } .census-row > .hide-md { display: none; } }
@container census (inline-size < 640px) { .census-row { grid-template-columns: 28px 1fr 92px; } .census-row > .hide-sm { display: none; } }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 52px 14px 1fr; gap: 10px; padding: 8px 0; align-items: start; }
.timeline .t { font-weight: 600; font-size: var(--fs-sm); color: var(--ink-2); padding-top: 2px; }
.timeline .rail-dot { position: relative; height: 100%; }
.timeline .rail-dot::before { content: ""; position: absolute; top: 8px; inset-inline-start: 5px; width: 3px; height: calc(100% + 8px); background: var(--line); }
.timeline li:last-child .rail-dot::before { display: none; }
.timeline .rail-dot::after { content: ""; position: absolute; top: 6px; inset-inline-start: 2px; width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.timeline li.done .rail-dot::after { background: var(--stable); box-shadow: 0 0 0 1px var(--stable); }
.timeline li.now .rail-dot::after { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.timeline li.urgent .rail-dot::after { background: var(--urgent); box-shadow: 0 0 0 1px var(--urgent); }
.timeline li.hl .body { background: var(--brand-soft); border-color: var(--brand-line); }
.timeline .body { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); }
.timeline .body b { font-weight: 600; font-size: var(--fs-sm); }
.timeline .body span { font-size: var(--fs-xs); color: var(--muted); }
.timeline li.done .body { opacity: .7; }

.alert-item { display: grid; grid-template-columns: 4px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.alert-item:last-child { border-bottom: 0; }
.alert-item .bar { border-radius: 4px; background: var(--offline); }
.alert-item.urgent .bar { background: var(--urgent); }
.alert-item.watch .bar { background: var(--watch); }
.alert-item.info .bar { background: var(--info); }
.alert-item .h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.alert-item .h b { font-weight: 600; font-size: var(--fs-sm); }
.alert-item .h time { font-size: var(--fs-xs); color: var(--muted); margin-inline-start: auto; }
.alert-item p { font-size: var(--fs-xs); color: var(--ink-2); margin-top: 2px; }
.alert-item .acts { display: flex; gap: 6px; margin-top: 6px; }
.alert-item.acked { opacity: .65; }

.task { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task input { accent-color: var(--brand); width: 18px; height: 18px; margin-top: 3px; flex: none; cursor: pointer; }
.task .t { font-weight: 500; font-size: var(--fs-sm); }
.task .m { font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task .m .over { color: var(--urgent-ink); font-weight: 600; }
.task .m .soon { color: var(--watch-ink); font-weight: 600; }
.task .pri { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); margin-top: 8px; flex: none; }
.task .pri.high { background: var(--urgent); }

/* --------------------------------------------------------------- patient */
.p-head { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: start; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; margin-bottom: 16px; }
.p-head::before { content: ""; position: absolute; inset-inline-start: 0; inset-block: 0; width: 6px; background: var(--offline); }
.p-head.tri-urgent::before { background: var(--urgent); }
.p-head.tri-watch::before { background: var(--watch); }
.p-head.tri-stable::before { background: var(--stable); }
.p-head .ident { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.p-head .name { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.p-head h1 { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -.005em; }
.p-head .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: var(--fs-sm); }
.p-head .meta b { color: var(--ink-2); font-weight: 500; }
.p-head .dx { font-size: var(--fs-md); font-weight: 500; color: var(--ink); }
.p-head .flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.p-head .acts { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 180px; }
.p-head .acts .btn-group { justify-content: flex-end; }
.p-head .day-ring { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.p-head .day-ring b { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.p-head .day-ring span { font-size: var(--fs-xs); color: var(--muted); display: block; }
.allergy-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px; background: var(--urgent-soft); color: var(--urgent-ink); border: 1px solid color-mix(in srgb, var(--urgent) 35%, transparent); font-weight: 600; font-size: var(--fs-xs); }
.allergy-chip.none { background: var(--stable-soft); color: var(--stable-ink); border-color: transparent; }
@media (max-width: 1240px) { .p-head { grid-template-columns: auto 1fr; } .p-head .acts { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; } .p-head .acts .btn-group { justify-content: flex-start; } }

.p-grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
@container main (inline-size < 1100px) { .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 6; } }
@container main (inline-size < 720px) { .p-grid > * { grid-column: span 12; } }

.vitals-now { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.vt { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; min-width: 0; position: relative; }
.vt .l { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); font-weight: 500; min-width: 0; }
.vt .l > span:first-of-type { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vt .v { font-size: 1.5rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 4px; }
.vt .v small { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.vt > svg { width: 100%; height: 28px; }
.vt .sev { display: inline-flex; align-items: center; gap: 3px; font-size: 0.68rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; margin-inline-start: auto; flex: none; }
.vt.sev-urgent { border-color: color-mix(in srgb, var(--urgent) 50%, var(--line)); }
.vt.sev-urgent .sev { background: var(--urgent-soft); color: var(--urgent-ink); }
.vt.sev-watch { border-color: color-mix(in srgb, var(--watch) 50%, var(--line)); }
.vt.sev-watch .sev { background: var(--watch-soft); color: var(--watch-ink); }
.vt.sev-ok .sev { background: var(--stable-soft); color: var(--stable-ink); }
.spark-ok { color: var(--brand); } .spark-watch { color: var(--watch); } .spark-urgent { color: var(--urgent); }

.chart { width: 100%; height: auto; display: block; font-family: var(--font-ui); }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .band { fill: var(--stable-soft); opacity: .7; }
.chart .line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.a { stroke: var(--brand); }
.chart .line.b { stroke: var(--info); }
.chart .line.c { stroke: var(--watch); }
.chart .pt { fill: var(--surface); stroke-width: 2; }
.chart .pt.a { stroke: var(--brand); } .chart .pt.b { stroke: var(--info); } .chart .pt.c { stroke: var(--watch); }
.chart .pt.flag { fill: var(--watch); stroke: var(--watch); }
.chart .target { stroke: var(--urgent); stroke-dasharray: 4 4; stroke-width: 1.5; }
.chart .lbl { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-inline-end: 6px; }
.legend i.a { background: var(--brand); } .legend i.b { background: var(--info); } .legend i.c { background: var(--watch); } .legend i.t { background: var(--urgent); }

.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.progress.warn > i { background: var(--watch); }
.goal { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.goal:last-child { border-bottom: 0; }
.goal .h { display: flex; justify-content: space-between; gap: 10px; font-size: var(--fs-sm); }
.goal .h b { font-weight: 600; }
.goal .h span { color: var(--muted); font-size: var(--fs-xs); }

.med { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.med:last-child { border-bottom: 0; }
.med .n { font-weight: 600; }
.med .n small { font-weight: 400; color: var(--muted); margin-inline-start: 6px; }
.med .d { font-size: var(--fs-sm); color: var(--ink-2); }
.med .note { font-size: var(--fs-xs); color: var(--muted); }
.med .route { font-size: 0.7rem; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); }
.med .route.IV { background: var(--info-soft); color: var(--info-ink); }
.med.held { opacity: .6; }
.mar-cell { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; font-size: var(--fs-xs); font-weight: 600; }
.mar-cell.given { background: var(--stable-soft); color: var(--stable-ink); }
.mar-cell.due { background: var(--info-soft); color: var(--info-ink); }
.mar-cell.missed { background: var(--urgent-soft); color: var(--urgent-ink); }
.mar-cell.held { background: var(--offline-soft); color: var(--offline-ink); }

.bg-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.bg-item:last-child { border-bottom: 0; }
.bg-item b { font-weight: 600; }
.bg-item span { font-size: var(--fs-sm); color: var(--ink-2); grid-column: 1; }
.bg-item time { font-size: var(--fs-xs); color: var(--muted); grid-row: 1 / span 2; align-self: start; }

.score { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.score b { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.score b small { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.score span { font-size: var(--fs-xs); color: var(--muted); }
.score-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.contact { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.contact:last-child { border-bottom: 0; }
.contact .w { flex: 1; min-width: 0; }
.contact .w b { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.contact .w span { font-size: var(--fs-xs); color: var(--muted); display: block; }
.contact .w p { font-size: var(--fs-xs); color: var(--ink-2); margin-top: 2px; }

.suit { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.suit-item { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.suit-item .st { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.suit-item .st.ok { background: var(--stable-soft); color: var(--stable-ink); }
.suit-item .st.warn { background: var(--watch-soft); color: var(--watch-ink); }
.suit-item .st.no { background: var(--urgent-soft); color: var(--urgent-ink); }
.suit-item b { font-weight: 600; display: block; }
.suit-item p { font-size: var(--fs-sm); color: var(--ink-2); }

.esc-row { display: grid; grid-template-columns: 1.3fr 100px 110px 1.3fr; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.esc-row:last-child { border-bottom: 0; }
.esc-row.head { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.esc-row .cur { font-weight: 700; }
.esc-row.alert { background: color-mix(in srgb, var(--urgent-soft) 50%, transparent); margin-inline: -18px; padding-inline: 18px; }
@media (max-width: 720px) { .esc-row { grid-template-columns: 1fr 100px; } .esc-row > :nth-child(3), .esc-row > :nth-child(4) { display: none; } }

.consult { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.consult .h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.consult .h b { font-weight: 600; }
.consult .q { font-size: var(--fs-sm); color: var(--ink-2); padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border-inline-start: 3px solid var(--line-2); }
.consult .a { font-size: var(--fs-sm); padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); border-inline-start: 3px solid var(--brand); }
.consult .a ul { margin: 6px 0 0; padding-inline-start: 18px; }
.consult .a li { margin: 2px 0; }
.consult .att { display: flex; flex-wrap: wrap; gap: 6px; }

.nurse-log { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.nurse-log:last-child { border-bottom: 0; }
.nurse-log time { font-size: var(--fs-xs); color: var(--muted); display: flex; flex-direction: column; }
.nurse-log time b { color: var(--ink-2); font-weight: 600; font-size: var(--fs-sm); }
.nurse-log .type { font-size: 0.7rem; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); display: inline-block; margin-inline-end: 6px; }
.nurse-log p { font-size: var(--fs-sm); }
.nurse-log .resp { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }

.visit-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.visit-card summary { list-style: none; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; cursor: pointer; }
.visit-card summary::-webkit-details-marker { display: none; }
.visit-card summary:hover { background: var(--surface-2); }
.visit-card summary .d { display: flex; flex-direction: column; align-items: center; min-width: 54px; padding: 6px 8px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); line-height: 1.1; }
.visit-card summary .d b { font-size: var(--fs-md); font-weight: 700; }
.visit-card summary .d span { font-size: 0.68rem; color: var(--muted); }
.visit-card summary .w b { font-weight: 600; display: block; }
.visit-card summary .w span { font-size: var(--fs-xs); color: var(--muted); }
.visit-card .body { padding: 4px 16px 16px; display: grid; gap: 10px 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); border-top: 1px solid var(--line); }
.visit-card .body dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; margin-top: 8px; }
.visit-card .body dd { margin: 2px 0 0; font-size: var(--fs-sm); }
.visit-card.signed summary .w b::after { content: " · חתום"; color: var(--stable-ink); font-weight: 500; font-size: var(--fs-xs); }

/* ---------------------------------------------------------- visit summary */
.visit { display: grid; grid-template-columns: 200px minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.visit .steps { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.visit .steps a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; font-size: var(--fs-xs); color: var(--muted); text-decoration: none; font-weight: 500; }
.visit .steps a:hover { background: var(--surface-2); color: var(--ink); }
.visit .steps a .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 0.7rem; font-weight: 700; background: var(--surface-3); color: var(--ink-2); flex: none; }
.visit .steps a.done .n { background: var(--stable-soft); color: var(--stable-ink); }
.visit .steps a[aria-current] { color: var(--brand-strong); background: var(--brand-soft); font-weight: 600; }
.visit .steps a[aria-current] .n { background: var(--brand); color: var(--on-brand); }
.visit .steps .prog { padding: 10px 10px 4px; font-size: var(--fs-xs); color: var(--muted); }
.visit .form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.visit .ctx { position: sticky; top: 0; display: flex; flex-direction: column; gap: 14px; }
.sec { scroll-margin-top: 12px; }
.sec .card-h .n { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--surface); display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; }
.sec .card-h .auto { font-size: var(--fs-xs); color: var(--brand-strong); display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.soap { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.soap .field > label b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-3); font-size: 0.75rem; }
.vit-in { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.vit-in .field .input { font-weight: 700; font-size: var(--fs-md); text-align: center; }
.vit-in .field .help { text-align: center; }
.meds-given { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.meds-given th { text-align: start; font-size: var(--fs-xs); color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.meds-given td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.meds-given .input { min-height: 34px; padding: 4px 8px; font-size: var(--fs-sm); }
.visit-foot { position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); flex-wrap: wrap; }
.visit-foot .st { font-size: var(--fs-xs); color: var(--muted); }
.ctx .mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ctx .mini div { padding: 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); text-align: center; }
.ctx .mini b { display: block; font-weight: 700; font-size: var(--fs-md); line-height: 1.1; }
.ctx .mini span { font-size: 0.68rem; color: var(--muted); }
.ctx .mini b.sev-watch { color: var(--watch-ink); } .ctx .mini b.sev-urgent { color: var(--urgent-ink); }
.redflag { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--urgent-soft); border: 1px solid color-mix(in srgb, var(--urgent) 25%, transparent); font-size: var(--fs-sm); }
.redflag .i { color: var(--urgent-ink); margin-top: 2px; }
.redflag b { color: var(--urgent-ink); font-weight: 600; }
.redflag span { color: var(--ink-2); font-size: var(--fs-xs); display: block; }
@container main (inline-size < 1180px) { .visit { grid-template-columns: minmax(0, 1fr) 300px; } .visit .steps { display: none; } }
@container main (inline-size < 820px) { .visit { grid-template-columns: 1fr; } .visit .ctx { position: static; } }

/* ------------------------------------------------------------ dialogs etc */
dialog.dialog { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); }
dialog.dialog::backdrop { background: rgba(6, 12, 22, .55); backdrop-filter: blur(3px); }
dialog.dialog .d-h { display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; }
dialog.dialog .d-h h2 { font-size: var(--fs-lg); font-weight: 600; flex: 1; }
dialog.dialog .d-b { padding: 4px 20px 18px; display: flex; flex-direction: column; gap: 14px; }
dialog.dialog .d-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
dialog.dialog.wide { width: min(760px, calc(100vw - 32px)); }
.opt-list { display: grid; gap: 8px; }
.opt { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; text-align: start; transition: border-color var(--fast), background var(--fast); }
.opt:hover { border-color: var(--brand-line); background: var(--surface-2); }
.opt .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.opt.urgent .ic { background: var(--urgent-soft); color: var(--urgent-ink); }
.opt.watch .ic { background: var(--watch-soft); color: var(--watch-ink); }
.opt.brand .ic { background: var(--brand-soft); color: var(--brand-strong); }
.opt b { font-weight: 600; display: block; }
.opt span { font-size: var(--fs-xs); color: var(--muted); }

.toasts { position: fixed; inset-block-end: 20px; inset-inline-start: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); font-weight: 500; animation: rise var(--base) var(--ease) both; max-width: 380px; }
.toast .i { color: var(--rail-active); }
.toast.urgent .i { color: #fca5a5; }

.panel { position: fixed; top: calc(var(--top-h) + 6px); inset-inline-end: 16px; width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - var(--top-h) - 24px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 40; animation: rise var(--fast) var(--ease) both; }
.panel .card-h { position: sticky; top: 0; background: var(--surface); z-index: 1; }

/* --------------------------------------------------------------- lists */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.big-task { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.big-task:last-child { border-bottom: 0; }
.big-task input { accent-color: var(--brand); width: 20px; height: 20px; cursor: pointer; }
.big-task .t { font-weight: 500; }
.big-task .m { font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.big-task .m a { color: var(--brand); text-decoration: none; font-weight: 500; }
.big-task.done .t { text-decoration: line-through; color: var(--muted); }
.sched-row { display: grid; grid-template-columns: 70px 1fr auto; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sched-row:last-child { border-bottom: 0; }
.sched-row .t { font-weight: 700; font-size: var(--fs-md); }
.sched-row .t small { display: block; font-weight: 400; color: var(--muted); font-size: var(--fs-xs); }
.sched-row.hl { background: var(--brand-soft); }
.sched-row.urgent .t { color: var(--urgent-ink); }
.sched-row.done { opacity: .6; }

/* --------------------------------------------------------- responsive */
@media (max-width: 900px) {
  :root { --rail-w: 0px; }
  .app { grid-template-columns: 1fr; grid-template-areas: "top" "main"; }
  .rail { display: none; }
  .view { padding: 14px 14px 30px; }
  .search { width: 100%; }
  .clock { display: none; }
}

/* --------------------------------------------------------- print */
@media print {
  :root { color-scheme: light; }
  .rail, .topbar, .visit .steps, .visit .ctx, .visit-foot, .toasts, .panel, .no-print { display: none !important; }
  .app { display: block; height: auto; }
  .view { overflow: visible; padding: 0; }
  .visit { display: block; }
  .card { box-shadow: none; break-inside: avoid; border-color: #bbb; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .print-head { display: block !important; margin-bottom: 12px; }
}
.print-head { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
