/* ==========================================================================
   Care Platform design system v3 — "clinical calm"
   Research basis (see README → Interface):
   - Typeface: Atkinson Hyperlegible Next (Braille Institute, SIL OFL), designed so similar characters
     (I l 1, O 0, rn m, B 8) can't be confused. That matters for medication names, doses, IDs and times,
     and for low-vision family members and older adults.
   - 16px minimum body text, 1.55 line height, sentence case (no all-caps labels), 44px touch targets.
   - Restrained palette: white surfaces, one brand colour per app, colour never used alone for status
     (always paired with an icon or text). WCAG 2.2 AA contrast in light and dark themes.
   - Visible privacy & security cues (PHI notice, idle logoff warning, privacy screen, masked identifiers).
   No inline styles anywhere (strict CSP).
   ========================================================================== */
@font-face { font-family: 'Atkinson Hyperlegible Next'; src: url('/shared/fonts/atkinson-next.woff2') format('woff2'); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible Next'; src: url('/shared/fonts/atkinson-next-italic.woff2') format('woff2'); font-weight: 200 800; font-style: italic; font-display: swap; }

:root {
  color-scheme: light;
  --font: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs: 16px;
  /* brand (each app overrides in theme.css) */
  --brand: #175cd3; --brand-hover: #1849a9; --brand-ink: #fff; --brand-text: #1849a9; --brand-soft: #eff4ff; --brand-soft-2: #d1e0ff; --brand-line: #b2ccff;
  --accent: #0e7c72; --accent-soft: #e6f6f4;
  /* neutrals */
  --bg: #f5f7fa; --surface: #fff; --surface-2: #f9fafb; --surface-3: #f0f2f5;
  --ink: #101828; --ink-2: #344054; --muted: #556275; --line: #e4e7ec; --line-2: #d0d5dd; --input-line: #98a2b3;
  /* status: background / text / solid */
  --ok: #067647; --ok-bg: #ecfdf3; --ok-ink: #05603a; --ok-line: #abefc6;
  --warn: #b54708; --warn-bg: #fffaeb; --warn-ink: #93370d; --warn-line: #fedf89;
  --bad: #d92d20; --bad-bg: #fef3f2; --bad-ink: #b42318; --bad-line: #fecdca;
  --med-bg: #fefbe8; --med-ink: #854a0e; --low-bg: #f0f9ff; --low-ink: #026aa2;
  --ai: #4e46dc; --ai-bg: #f4f3ff; --ai-ink: #3e1c96; --ai-line: #d9d6fe;
  --focus: #f79009; --focus-ring: 0 0 0 3px var(--surface), 0 0 0 6px var(--focus);
  --radius: 12px; --r-sm: 8px; --r-xs: 6px;
  --sh-xs: 0 1px 2px rgb(16 24 40 / 5%);
  --sh-sm: 0 1px 3px rgb(16 24 40 / 8%), 0 1px 2px rgb(16 24 40 / 4%);
  --sh-md: 0 8px 16px -4px rgb(16 24 40 / 8%), 0 3px 6px -2px rgb(16 24 40 / 4%);
  --sh-lg: 0 20px 24px -4px rgb(16 24 40 / 10%), 0 8px 8px -4px rgb(16 24 40 / 4%);
  --t: .16s ease;
  font-family: var(--font); font-size: var(--fs); color: var(--ink); background: var(--bg);
}
/* Text size preference (family members and older adults). */
:root[data-size="lg"] { --fs: 18px; }
:root[data-size="xl"] { --fs: 20px; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #528bff; --brand-hover: #84adff; --brand-ink: #0b1220; --brand-text: #84adff; --brand-soft: #102a56; --brand-soft-2: #1a3a72; --brand-line: #2c4f8f;
  --accent: #2ed3b7; --accent-soft: #0b2e2a;
  --bg: #0c111d; --surface: #161b26; --surface-2: #1b2130; --surface-3: #222938;
  --ink: #f5f5f6; --ink-2: #cecfd2; --muted: #a2a8b4; --line: #2a3242; --line-2: #333c4f; --input-line: #5d6679;
  --ok: #47cd89; --ok-bg: #053321; --ok-ink: #75e0a7; --ok-line: #085d3a;
  --warn: #fdb022; --warn-bg: #4e1d09; --warn-ink: #fec84b; --warn-line: #7a2e0e;
  --bad: #f97066; --bad-bg: #55160c; --bad-ink: #fda29b; --bad-line: #912018;
  --med-bg: #3a2a07; --med-ink: #fde272; --low-bg: #0b2a42; --low-ink: #7cd4fd;
  --ai: #9b8afb; --ai-bg: #1f1650; --ai-ink: #d9d6fe; --ai-line: #3e1c96;
  --sh-xs: none; --sh-sm: 0 1px 2px rgb(0 0 0 / 40%); --sh-md: 0 8px 20px rgb(0 0 0 / 45%); --sh-lg: 0 24px 48px rgb(0 0 0 / 55%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: #528bff; --brand-hover: #84adff; --brand-ink: #0b1220; --brand-text: #84adff; --brand-soft: #102a56; --brand-soft-2: #1a3a72; --brand-line: #2c4f8f;
    --accent: #2ed3b7; --accent-soft: #0b2e2a;
    --bg: #0c111d; --surface: #161b26; --surface-2: #1b2130; --surface-3: #222938;
    --ink: #f5f5f6; --ink-2: #cecfd2; --muted: #a2a8b4; --line: #2a3242; --line-2: #333c4f; --input-line: #5d6679;
    --ok: #47cd89; --ok-bg: #053321; --ok-ink: #75e0a7; --ok-line: #085d3a;
    --warn: #fdb022; --warn-bg: #4e1d09; --warn-ink: #fec84b; --warn-line: #7a2e0e;
    --bad: #f97066; --bad-bg: #55160c; --bad-ink: #fda29b; --bad-line: #912018;
    --med-bg: #3a2a07; --med-ink: #fde272; --low-bg: #0b2a42; --low-ink: #7cd4fd;
    --ai: #9b8afb; --ai-bg: #1f1650; --ai-ink: #d9d6fe; --ai-line: #3e1c96;
    --sh-xs: none; --sh-sm: 0 1px 2px rgb(0 0 0 / 40%); --sh-md: 0 8px 20px rgb(0 0 0 / 45%); --sh-lg: 0 24px 48px rgb(0 0 0 / 55%);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { background: var(--bg); }
body { margin: 0; font-size: 1rem; line-height: 1.55; color: var(--ink); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-variant-numeric: tabular-nums; }
a { color: var(--brand-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 6px; line-height: 1.25; }
h2 { font-size: 1.125rem; font-weight: 700; margin: 0 0 12px; line-height: 1.35; }
h3 { font-size: 1rem; font-weight: 700; margin: 16px 0 8px; }
h4 { font-size: 1rem; margin: 0 0 6px; }
p { margin: 0 0 10px; }
ul, ol { padding-left: 1.25rem; }
li { margin: 2px 0; }
small { font-size: .875rem; }
strong, b { font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code { background: var(--surface-3); color: var(--ink); padding: 2px 6px; border-radius: 5px; word-break: break-all; font-size: .9em; letter-spacing: .04em; }
abbr[title] { text-decoration: underline dotted; cursor: help; }
::selection { background: var(--brand-soft-2); color: var(--ink); }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--surface); padding: 12px 16px; z-index: 100; border-radius: 0 0 8px 0; font-weight: 700; }
.skip:focus { left: 0; }
.muted { color: var(--muted); }
.wide { grid-column: 1 / -1; }
.grow { flex: 1; min-width: 240px; }
.full { width: 100%; }
.nowrap { white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.icon.sm { width: 16px; height: 16px; vertical-align: -3px; }
.icon.lg { width: 24px; height: 24px; }

/* ---------- App shell ----------
   Light sidebar (white, like clinical EHRs). A dark navy sidebar reads as "dev tool"; white chrome with
   one brand accent reads as calm and clinical. */
.shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); z-index: 30; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px 16px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.logo { width: 40px; height: 40px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; flex: none; }
.logo .icon { stroke: #fff; width: 22px; height: 22px; }
:root[data-theme="dark"] .logo .icon { stroke: var(--brand-ink); }
#brand { margin: 0; font-weight: 700; font-size: 1rem; line-height: 1.25; color: var(--ink); }
#brand small { display: block; font-weight: 400; font-size: .8125rem; color: var(--muted); margin-top: 1px; }
.side-org { margin: 12px 16px 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); display: flex; gap: 10px; align-items: center; font-size: .875rem; }
.side-org b { display: block; font-size: .875rem; }
.side-org span { color: var(--muted); font-size: .8125rem; }
nav#nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; scrollbar-width: thin; }
nav#nav details { margin: 2px 0; }
nav#nav summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 9px 12px; min-height: 44px; border-radius: var(--r-sm); cursor: pointer; color: var(--ink-2); font-weight: 700; font-size: .9375rem; user-select: none; }
nav#nav summary::-webkit-details-marker { display: none; }
nav#nav summary::after { content: ''; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform var(--t); }
nav#nav details[open] > summary::after { transform: rotate(45deg); }
nav#nav summary:hover { background: var(--surface-3); color: var(--ink); }
nav#nav summary .icon { color: var(--muted); }
nav#nav details.has-current > summary { color: var(--brand-text); }
nav#nav details.has-current > summary .icon { color: var(--brand); }
nav#nav ul { list-style: none; margin: 2px 0 8px 22px; padding: 0 0 0 14px; border-left: 1px solid var(--line); }
nav#nav li { margin: 1px 0; }
nav#nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; min-height: 40px; border-radius: var(--r-sm); text-decoration: none; color: var(--ink-2); font-size: .9375rem; }
nav#nav a:hover { background: var(--surface-3); color: var(--ink); }
nav#nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; box-shadow: inset 3px 0 0 var(--brand); }
nav#nav .count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; font-weight: 700; display: inline-grid; place-items: center; }
nav#nav .count:empty { display: none; }
nav#nav .nav-vigil { margin: 6px 0 10px; border: 1px solid var(--ai-line); background: var(--ai-bg); color: var(--ai-ink); justify-content: flex-start; gap: 10px; font-weight: 700; min-height: 44px; }
nav#nav .nav-vigil:hover { background: var(--ai-bg); border-color: var(--ai); color: var(--ai-ink); }
.side-foot { padding: 12px 16px 16px; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--muted); display: grid; gap: 6px; }
.side-foot .row { display: flex; align-items: center; gap: 8px; }
.side-foot .icon { color: var(--ok); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.phi-strip { display: flex; align-items: center; gap: 10px; padding: 6px 24px; font-size: .8125rem; color: var(--ink-2); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.phi-strip .icon { color: var(--ok); }
.phi-strip .sep { color: var(--line-2); }
.phi-strip button { margin-left: auto; }
header.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 68px; }
.gsearch { flex: 1; max-width: 520px; position: relative; display: flex; align-items: center; }
.gsearch .icon { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.gsearch input { width: 100%; padding: 10px 52px 10px 44px; border-radius: var(--r-sm); background: var(--surface-2); min-height: 44px; }
.gsearch kbd { position: absolute; right: 12px; font: 700 .75rem/1 var(--font); color: var(--muted); border: 1px solid var(--line-2); border-radius: 5px; padding: 4px 7px; background: var(--surface); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; text-decoration: none; transition: background var(--t); }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-text); }
.icon-btn .dot { position: absolute; top: 3px; right: 2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .6875rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.icon-btn .dot:empty { display: none; }
.theme-dark-icon { display: none; }
:root[data-theme="dark"] .theme-dark-icon { display: block; }
:root[data-theme="dark"] .theme-light-icon { display: none; }
.vsep { width: 1px; height: 28px; background: var(--line); margin: 0 6px; }
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; min-height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; }
.user-btn:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; font-weight: 700; font-size: .875rem; flex: none; border: 1px solid var(--brand-line); }
.who { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.who b { font-size: .875rem; }
.who span { font-size: .8125rem; color: var(--muted); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 300px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--sh-lg); padding: 6px; z-index: 40; }
.menu-pop .menu-id { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-size: .875rem; }
.menu-pop .menu-id b { display: block; font-size: 1rem; }
.menu-pop .menu-id span { color: var(--muted); display: block; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; min-height: 44px; border: 0; background: none; color: var(--ink); font: inherit; font-size: .9375rem; text-decoration: none; border-radius: var(--r-sm); cursor: pointer; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-3); }
.menu-pop .sep { height: 1px; background: var(--line); margin: 6px 0; }
.menu-pop .size-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px 8px; font-size: .875rem; color: var(--ink-2); }
.menu-pop .size-row .seg { margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; }
.seg button { width: auto; min-height: 36px; padding: 4px 12px; border: 0; border-radius: 0; background: var(--surface); color: var(--ink-2); font-weight: 700; justify-content: center; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-text); }
main { padding: 28px 32px 72px; width: 100%; max-width: 1400px; margin: 0 auto; }
main:focus { outline: none; }
.mobile-only { display: none; }
.scrim { position: fixed; inset: 0; background: rgb(16 24 40 / 50%); z-index: 25; }

/* Privacy screen: blurs the page when the user steps away or switches tabs (shoulder-surfing). */
:root.privacy main, :root.privacy .vigil-panel { filter: blur(14px); pointer-events: none; user-select: none; }
.privacy-veil { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgb(16 24 40 / 35%); }
.privacy-veil .card { max-width: 420px; text-align: center; box-shadow: var(--sh-lg); }
.privacy-veil .icon { width: 36px; height: 36px; color: var(--brand); display: block; margin: 0 auto 10px; }

/* ---------- Page header & breadcrumbs ---------- */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head h1 { margin: 0; }
.eyebrow { font-size: .875rem; font-weight: 700; color: var(--brand-text); margin: 0 0 4px; }
.eyebrow a { text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
.lede { color: var(--muted); margin: 6px 0 0; max-width: 72ch; }
main > p.muted { max-width: 90ch; }

/* ---------- Cards ---------- */
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--sh-xs); }
.card > h2:first-child { display: flex; align-items: center; gap: 10px; }
.card .card { box-shadow: none; background: var(--surface-2); }
.card.error { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad-ink); }
a.card { text-decoration: none; color: inherit; display: block; transition: box-shadow var(--t), border-color var(--t); }
a.card:hover { box-shadow: var(--sh-md); border-color: var(--line-2); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 20px; }
.grid > .card { margin-bottom: 0; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); margin-bottom: 20px; align-items: start; }
.grid-2 > .card, .grid-2 > section { margin-bottom: 0; }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 20px; }
.grid-3 > .card { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
.card-head a { font-size: .9375rem; font-weight: 700; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.card-head a:hover { text-decoration: underline; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 12px; }
.section-title h2 { margin: 0; font-size: 1.25rem; }
.card-icon { width: 36px; height: 36px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); flex: none; }
.tone-ok .card-icon, .card-icon.tone-ok { background: var(--ok-bg); color: var(--ok); }
.tone-warn .card-icon, .card-icon.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-bad .card-icon, .card-icon.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-ai .card-icon, .card-icon.tone-ai { background: var(--ai-bg); color: var(--ai); }

/* KPI cards. Status is shown with an icon + words, not colour alone. */
.kpi-card { display: flex; flex-direction: column; gap: 8px; min-height: 168px; overflow: hidden; }
.kpi-card.tone-bad { border-top: 3px solid var(--bad); }
.kpi-card.tone-warn { border-top: 3px solid var(--warn); }
.kpi-card.tone-ok { border-top: 3px solid var(--ok); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { color: var(--ink-2); margin: 0; font-weight: 700; font-size: .9375rem; }
.kpi { font-size: 2.25rem; font-weight: 700; margin: 0; letter-spacing: -.02em; line-height: 1.1; }
.kpi small { font-size: 1rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.kpi-status { display: inline-flex; align-items: center; gap: 6px; font-size: .875rem; font-weight: 700; }
.tone-ok .kpi-status { color: var(--ok-ink); } .tone-warn .kpi-status { color: var(--warn-ink); } .tone-bad .kpi-status { color: var(--bad-ink); }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.trend { font-size: .8125rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); }
.trend.up-bad, .trend.down-bad { background: var(--bad-bg); color: var(--bad-ink); }
.trend.up-good, .trend.down-good { background: var(--ok-bg); color: var(--ok-ink); }
.spark { width: 100%; max-width: 132px; height: 34px; display: block; }
.spark path.line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark path.area { fill: var(--brand); opacity: .1; stroke: none; }
.tone-bad .spark path.line { stroke: var(--bad); } .tone-bad .spark path.area { fill: var(--bad); }
.tone-ok .spark path.line { stroke: var(--ok); } .tone-ok .spark path.area { fill: var(--ok); }
.tone-warn .spark path.line { stroke: var(--warn); } .tone-warn .spark path.area { fill: var(--warn); }

/* Hover / focus reveal. Keyboard: focus-within. Touch: tap toggles .open. */
.hover-card { position: relative; }
.hover-card .reveal { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 18px 16px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -12px 24px rgb(16 24 40 / 8%); transform: translateY(101%); opacity: 0; transition: transform var(--t), opacity var(--t); font-size: .9375rem; z-index: 2; border-radius: 0 0 var(--radius) var(--radius); }
.hover-card:hover .reveal, .hover-card:focus-within .reveal, .hover-card.open .reveal { transform: translateY(0); opacity: 1; }
.hover-card .reveal dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.hover-card .reveal dt { color: var(--muted); }
.hover-card .reveal dd { margin: 0; text-align: right; font-weight: 700; }
.hover-card .reveal p { margin: 0 0 6px; }
.hover-card .hint { position: absolute; top: 14px; right: 14px; font-size: .75rem; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.kpi-card .hint { display: none; }
.hover-card:hover .hint, .hover-card:focus-within .hint { opacity: 0; }

/* Tiles: homes, branches, visits, records */
.tile-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-bottom: 20px; }
.tile { display: flex; flex-direction: column; gap: 12px; min-height: 200px; margin: 0; overflow: hidden; }
.tile.tone-bad { border-left: 4px solid var(--bad); }
.tile.tone-warn { border-left: 4px solid var(--warn); }
.tile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tile-title { margin: 0; font-size: 1.0625rem; font-weight: 700; line-height: 1.3; }
.tile-title a { color: var(--ink); text-decoration: none; }
.tile-title a:hover { color: var(--brand-text); text-decoration: underline; }
.tile-sub { margin: 3px 0 0; color: var(--muted); font-size: .875rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; }
.stat b { display: block; font-size: 1.125rem; }
.stat span { font-size: .8125rem; color: var(--muted); }
.meter-label { display: flex; justify-content: space-between; font-size: .8125rem; color: var(--muted); margin-bottom: 4px; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.meter.tone-bad > span { background: var(--bad); } .meter.tone-warn > span { background: var(--warn); } .meter.tone-ok > span { background: var(--ok); }
.tile .reveal { z-index: 3; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; min-height: 38px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: inherit; font-size: .875rem; font-weight: 700; cursor: pointer; text-decoration: none; transition: background var(--t), border-color var(--t), color var(--t); }
.chip:hover { border-color: var(--brand); color: var(--brand-text); background: var(--brand-soft); }
.view-toggle { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.view-toggle button { border: 0; background: none; padding: 8px 12px; color: var(--muted); cursor: pointer; display: grid; place-items: center; min-height: 44px; min-width: 44px; }
.view-toggle button + button { border-left: 1px solid var(--line-2); }
.view-toggle button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-text); }
.rec-card .fields { display: grid; grid-template-columns: minmax(90px, auto) 1fr; gap: 5px 14px; margin: 0; font-size: .9375rem; }
.rec-card .fields dt { color: var(--muted); }
.rec-card .fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.person { display: flex; align-items: center; gap: 12px; }
.person .avatar { width: 40px; height: 40px; font-size: .9375rem; }

/* Welcome banner: calm, not loud. White card with a brand rule, not a full gradient. */
.hero { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 28px; align-items: center; padding: 24px 28px; border-left: 4px solid var(--brand); }
.hero h1 { font-size: 1.875rem; }
.hero-stats { display: flex; gap: 0; flex-wrap: wrap; margin: 18px 0 16px; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; width: fit-content; max-width: 100%; }
.hero-stats div { padding: 10px 18px; border-right: 1px solid var(--line); background: var(--surface-2); }
.hero-stats div:last-child { border-right: 0; }
.hero-stats div b { display: block; font-size: 1.375rem; font-weight: 700; }
.hero-stats div span { font-size: .8125rem; color: var(--muted); }
.gauge-wrap { text-align: center; text-decoration: none; color: var(--ink); }
.gauge-wrap p { margin: 6px 0 0; font-weight: 700; font-size: .875rem; color: var(--ink-2); }
.gauge { width: 136px; height: 136px; display: block; }
.gauge .track { fill: none; stroke: var(--surface-3); stroke-width: 11; }
.gauge .val { fill: none; stroke: var(--brand); stroke-width: 11; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.gauge.tone-bad .val { stroke: var(--bad); } .gauge.tone-warn .val { stroke: var(--warn); } .gauge.tone-ok .val { stroke: var(--ok); }
.gauge text { fill: var(--ink); font-weight: 700; font-size: 30px; text-anchor: middle; dominant-baseline: central; font-family: var(--font); }
.gauge text.sub { font-size: 11px; font-weight: 700; fill: var(--muted); }

/* Feed lists */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 2px; border-bottom: 1px solid var(--line); margin: 0; }
.feed li:last-child { border-bottom: 0; }
.feed .sev-ic { flex: none; margin-top: 1px; }
.feed .sev-ic.sev-critical { color: var(--bad); background: none; }
.feed .sev-ic.sev-high { color: var(--warn); background: none; }
.feed .sev-ic.sev-medium { color: var(--med-ink); background: none; }
.feed .sev-ic.sev-low { color: var(--brand); background: none; }
.feed .body { min-width: 0; flex: 1; }
.feed .body a { color: var(--ink); text-decoration: none; font-weight: 700; font-size: .9375rem; }
.feed .body a:hover { color: var(--brand-text); text-decoration: underline; }
.feed .meta { display: block; color: var(--muted); font-size: .875rem; margin-top: 2px; }
.feed .when { margin-left: auto; font-size: .875rem; color: var(--muted); white-space: nowrap; padding-left: 8px; }
.empty { text-align: center; padding: 24px 12px; color: var(--muted); }
.empty .icon { width: 32px; height: 32px; color: var(--ok); display: block; margin: 0 auto 8px; }

/* ---------- Buttons (44px targets) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); padding: 9px 16px; border-radius: var(--r-sm); font: inherit; font-weight: 700; font-size: .9375rem; cursor: pointer; text-decoration: none; min-height: 44px; box-shadow: var(--sh-xs); transition: background var(--t), border-color var(--t); }
.btn:hover { background: var(--surface-2); border-color: var(--input-line); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
:root[data-theme="dark"] .btn.danger { color: #1a0605; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--brand-text); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.small { padding: 5px 12px; min-height: 36px; font-size: .875rem; }
.btn.vigil { background: var(--ai-bg); border-color: var(--ai-line); color: var(--ai-ink); }
.btn.vigil:hover { border-color: var(--ai); background: var(--ai-bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.big-actions { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 20px; }
.big-actions .btn { min-height: 84px; flex-direction: column; text-align: center; font-size: 1rem; border-radius: var(--radius); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--sh-xs); margin-bottom: 20px; }
.card .table-wrap { box-shadow: none; margin-bottom: 0; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9375rem; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); color: var(--ink-2); font-weight: 700; font-size: .875rem; position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td a { font-weight: 700; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 16px 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > span, fieldset > legend { font-weight: 700; font-size: .9375rem; color: var(--ink); }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field small { color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.req { color: var(--bad); }
input, select, textarea { font: inherit; font-size: 1rem; color: var(--ink); padding: 10px 12px; border: 1px solid var(--input-line); border-radius: var(--r-sm); background: var(--surface); min-height: 44px; transition: border-color var(--t), box-shadow var(--t); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent); outline: none; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--ink-2); border-color: var(--line-2); }
input[type="checkbox"], input[type="radio"] { min-height: auto; width: 20px; height: 20px; accent-color: var(--brand); padding: 0; }
input[type="range"] { accent-color: var(--brand); padding: 0; border: 0; min-height: auto; }
textarea { min-height: 104px; resize: vertical; line-height: 1.55; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px; margin: 0 0 12px; }
.actions { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search { display: flex; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; align-items: center; }
.search input { flex: 1; max-width: 440px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { margin: 0; flex: 1; }
.error-text { color: var(--bad-ink); margin: 0; grid-column: 1 / -1; font-weight: 700; }
.error-text:empty { display: none; }

/* PHI identifiers masked by default: "•••• 4821" with Reveal (audited). */
.phi-mask { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font); letter-spacing: .06em; }
.phi-mask button { font-size: .8125rem; min-height: 32px; }
input.phi-hidden { -webkit-text-security: disc; text-security: disc; letter-spacing: .12em; }

/* ---------- Badges (status always has a dot + word, never colour alone) ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 700; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; line-height: 1.6; border: 1px solid var(--line-2); }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ai::before, .badge.plain::before { display: none; }
.sev-critical { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad-line); }
.sev-high { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.sev-medium { background: var(--med-bg); color: var(--med-ink); border-color: var(--warn-line); }
.sev-low { background: var(--low-bg); color: var(--low-ink); border-color: var(--brand-line); }
.st-done, .st-given, .st-completed, .st-active, .st-approved, .st-paid, .st-verified, .st-closed, .st-pass, .st-taken, .st-observed, .st-enrolled, .st-signed, .st-filled, .st-present, .st-current, .st-valid, .st-submitted, .st-accepted { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok-line); }
.st-missed, .st-refused, .st-overdue, .st-denied, .st-fail, .st-open, .st-exception, .st-expired, .st-rejected, .st-call-off, .st-held, .st-declined { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad-line); }
.st-scheduled, .st-in_progress, .st-pending, .st-ready, .st-sent, .st-exported, .st-draft, .st-requested, .st-planned { background: var(--low-bg); color: var(--low-ink); border-color: var(--brand-line); }
.ai { background: var(--ai-bg); color: var(--ai-ink); border-color: var(--ai-line); }
.flags { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.flag { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-sm); padding: 6px 12px; font-size: .9375rem; font-weight: 700; background: var(--med-bg); color: var(--med-ink); border: 1px solid var(--warn-line); }
.flag.allergy { background: var(--bad-bg); color: var(--bad-ink); border: 2px solid var(--bad); }
.flag.diet { background: var(--low-bg); color: var(--low-ink); border-color: var(--brand-line); }

/* Notices */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-sm); border: 1px solid var(--brand-line); background: var(--brand-soft); color: var(--ink); margin-bottom: 16px; font-size: .9375rem; }
.notice .icon { color: var(--brand); margin-top: 1px; }
.checklist { list-style: none; padding: 0; margin: 0; } .checklist li { padding: 8px 0; border-bottom: 1px solid var(--line, rgba(0,0,0,.08)); }
/* Agency setup (onboarding) */
.setup-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 32px; background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); color: var(--ink); font-size: .9375rem; }
.setup-banner .icon { color: var(--warn); }
.setup-wrap { display: grid; grid-template-columns: minmax(200px, 260px) 1fr; gap: 20px; align-items: start; }
.setup-steps ol { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.setup-steps a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-weight: 700; }
.setup-steps a[aria-current="step"] { background: var(--brand-soft); color: var(--brand-text); }
.setup-steps .step-n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 999px; border: 1px solid var(--line-2); font-size: .75rem; }
.state-choice { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; cursor: pointer; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 12px; } .kv dt { color: var(--ink-2); } .kv dd { margin: 0; font-weight: 700; }
.field-error { color: var(--bad-ink); font-weight: 700; }
.field-error:empty { display: none; }
@media (max-width: 900px) { .setup-wrap { grid-template-columns: 1fr; } .setup-banner { padding: 10px 16px; } }
/* AristoIQ team: "View as" persona menu (header) and banner, team sign-in (login page) */
.persona { display: inline-flex; align-items: center; gap: 6px; margin: 0 6px; font-size: .8125rem; color: var(--muted); font-weight: 700; }
.persona select { max-width: 240px; min-height: 36px; padding: 4px 8px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; }
.persona-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 32px; background: var(--brand-soft); border-bottom: 1px solid var(--line); color: var(--ink); font-size: .9375rem; }
.persona-banner .icon { color: var(--brand); }
.staff-login { margin-top: 24px; }
.staff-login .sep-or { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; color: var(--ink-2); font-weight: 700; font-size: .875rem; }
.staff-login .sep-or::before, .staff-login .sep-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
@media (max-width: 900px) { .persona .lbl { display: none; } .persona select { max-width: 150px; } .persona-banner { padding: 10px 16px; } }
.notice.warn { border-color: var(--warn-line); background: var(--warn-bg); } .notice.warn .icon { color: var(--warn); }
.notice.bad { border-color: var(--bad-line); background: var(--bad-bg); } .notice.bad .icon { color: var(--bad); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); color: var(--ink); padding: 14px 16px; border-radius: var(--radius); max-width: 400px; box-shadow: var(--sh-lg); font-weight: 700; font-size: .9375rem; border: 1px solid var(--line); border-left: 4px solid var(--ok); animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--bad); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Skeleton ---------- */
.skeleton { display: grid; gap: 16px; }
.skeleton .sk { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
.sk.h1 { height: 32px; width: 36%; } .sk.row { height: 128px; } .sk.line { height: 14px; width: 64%; }
.sk-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Sign in ----------
   First impression for staff, families and surveyors: who runs this, that it's private, and how to get help. */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, 560px); background: var(--surface); }
.auth-art { position: relative; overflow: hidden; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; background: var(--brand-soft); border-right: 1px solid var(--brand-line); color: var(--ink); }
.auth-art::after { content: ''; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 56px solid color-mix(in srgb, var(--brand) 9%, transparent); pointer-events: none; }
.auth-art h2 { font-size: 2.25rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; max-width: 18ch; margin: 0 0 16px; }
.auth-art p { color: var(--ink-2); max-width: 48ch; font-size: 1.0625rem; }
.auth-art .feat { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; max-width: 46ch; }
.auth-art .feat li { display: flex; gap: 14px; align-items: flex-start; }
.auth-art .feat li b { display: block; }
.auth-art .feat li span { color: var(--ink-2); font-size: .9375rem; }
.auth-art .feat .icon { width: 40px; height: 40px; padding: 9px; border-radius: 10px; background: var(--surface); color: var(--brand); border: 1px solid var(--brand-line); flex: none; }
.auth-art .brandline { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.125rem; }
.auth-art .trust { display: flex; gap: 8px; flex-wrap: wrap; font-size: .875rem; position: relative; z-index: 1; }
.auth-art .trust span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--brand-line); font-weight: 700; color: var(--ink-2); }
.auth-art .trust .icon { color: var(--ok); }
.auth-panel { position: relative; display: grid; place-items: center; padding: 48px 32px; background: var(--surface); }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h1 { font-size: 1.875rem; }
.auth-box form { display: grid; gap: 16px; margin-top: 24px; }
.auth-box .btn.primary { min-height: 50px; font-size: 1.0625rem; }
.auth-box .legal { margin-top: 24px; padding: 14px 16px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: .875rem; color: var(--ink-2); display: flex; gap: 10px; align-items: flex-start; }
.auth-box .legal .icon { color: var(--brand); margin-top: 1px; }
.auth-box .help { margin-top: 14px; font-size: .875rem; color: var(--muted); }
.auth-box ol { padding-left: 1.25rem; }
.auth-tools { position: absolute; top: 16px; right: 16px; display: flex; gap: 4px; }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 92px; }
.pw-wrap button { position: absolute; right: 4px; top: 4px; bottom: 4px; min-height: 0; }
.caps { color: var(--warn-ink); font-size: .875rem; font-weight: 700; }
#login, #mfa-setup { position: relative; }

/* ---------- Idle-logoff dialog (HIPAA §164.312(a)(2)(iii)) ---------- */
.modal-veil { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: rgb(16 24 40 / 55%); padding: 16px; }
.modal { width: min(460px, 100%); background: var(--surface); border-radius: 16px; box-shadow: var(--sh-lg); padding: 26px; border: 1px solid var(--line); }
.modal h2 { font-size: 1.25rem; display: flex; gap: 10px; align-items: center; }
.modal .count-big { font-size: 2.5rem; font-weight: 700; margin: 6px 0 8px; color: var(--warn-ink); }
.modal .actions { justify-content: flex-end; margin-top: 16px; }

/* ---------- Vigil assistant ----------
   Indigo is reserved for AI everywhere, so AI content is always recognisable as AI (review before use). */
.vigil-fab { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px 10px 10px; min-height: 52px; border: 1px solid var(--ai-line); border-radius: 999px; cursor: pointer; color: var(--ai-ink); background: var(--surface); font: inherit; font-weight: 700; font-size: .9375rem; box-shadow: var(--sh-lg); transition: box-shadow var(--t), border-color var(--t); }
.vigil-fab:hover { border-color: var(--ai); }
.vigil-orb { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--ai); color: #fff; flex: none; }
.vigil-orb .icon { stroke: #fff; }
:root[data-theme="dark"] .vigil-orb .icon { stroke: #0c111d; }
.vigil-panel { position: fixed; right: 24px; bottom: 24px; top: 92px; width: min(440px, calc(100vw - 24px)); z-index: 70; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-lg); overflow: hidden; animation: panel-in .18s ease-out; }
@keyframes panel-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.vigil-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.vigil-head h2 { margin: 0; font-size: 1.0625rem; }
.vigil-head p { margin: 0; font-size: .8125rem; color: var(--muted); }
.vigil-head .icon-btn:first-of-type { margin-left: auto; }
.vigil-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.vmsg { max-width: 94%; padding: 12px 14px; border-radius: 14px; font-size: .9375rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.vmsg.me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.vmsg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.vmsg.bot .vsrc { display: block; margin-bottom: 8px; }
.vmsg ul.vitems { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; white-space: normal; }
.vmsg ul.vitems li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: .875rem; margin: 0; }
.vmsg ul.vitems li .badge { flex: none; }
.vmsg ul.vitems small { display: block; color: var(--muted); }
.vmsg .vtable { margin-top: 10px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); white-space: normal; }
.vmsg .vtable table { font-size: .8125rem; }
.vmsg .vtable th, .vmsg .vtable td { padding: 7px 9px; }
.vmsg .vlinks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; white-space: normal; }
.vtyping { display: inline-flex; gap: 5px; padding: 14px 16px; }
.vtyping span { width: 8px; height: 8px; border-radius: 50%; background: var(--ai); animation: blink 1.2s infinite; }
.vtyping span:nth-child(2) { animation-delay: .2s; } .vtyping span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.vigil-chips { padding: 12px 16px 4px; border-top: 1px solid var(--line); background: var(--surface); }
.vigil-ctx { margin: 8px 16px 0; padding: 8px 12px; border-radius: var(--r-sm); background: var(--ai-bg); color: var(--ai-ink); font-size: .875rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.vigil-form { display: flex; gap: 8px; padding: 12px 16px 14px; background: var(--surface); }
.vigil-form input { flex: 1; }
.vigil-form .btn { width: 48px; padding: 0; }
.vigil-note { padding: 0 16px 12px; font-size: .8125rem; color: var(--muted); background: var(--surface); margin: 0; display: flex; gap: 6px; }
.vigil-card { border-color: var(--ai-line); background: linear-gradient(180deg, var(--ai-bg), var(--surface) 70%); }
.vigil-card .card-icon { background: var(--ai); color: #fff; }
:root[data-theme="dark"] .vigil-card .card-icon { color: #0c111d; }
.vigil-card .vbrief { white-space: pre-wrap; font-size: 1rem; line-height: 1.6; margin: 0 0 14px; }
.vigil-card .vitems { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.vigil-card .vitems li { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); font-size: .9375rem; margin: 0; }
.vigil-card .vitems a { text-decoration: none; font-weight: 700; color: var(--ink); }
.vigil-card .vitems a:hover { text-decoration: underline; color: var(--brand-text); }
.vigil-card .vitems .badge { flex: none; }
.ask-hero { border-color: var(--ai-line); background: linear-gradient(180deg, var(--ai-bg), var(--surface)); }
.ask-hero .vigil-form { padding: 0; background: transparent; margin: 16px 0 10px; max-width: 680px; }

/* ---------- Existing components (restyled) ---------- */
pre.out { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 16px; margin: 12px 0 0; font: inherit; font-size: .9375rem; line-height: 1.6; }
.photo { max-width: 220px; max-height: 160px; border-radius: var(--r-sm); border: 1px solid var(--line); object-fit: cover; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.photo-grid figure { margin: 0; font-size: .8125rem; color: var(--muted); }
.sigpad { width: 100%; max-width: 600px; height: 180px; border: 2px dashed var(--input-line); border-radius: var(--radius); background: #fff; touch-action: none; }
.sigimg { max-height: 60px; border-bottom: 1px solid var(--line); background: #fff; border-radius: 6px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 18px; padding: 4px; background: var(--surface-3); border-radius: var(--radius); width: fit-content; max-width: 100%; }
.tabs .btn { box-shadow: none; border-color: transparent; background: transparent; }
.tabs .btn[aria-selected="true"], .tabs .btn.primary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--sh-sm); }
.mar-cell button { min-width: 88px; }
.task { border-left: 4px solid var(--line-2); }
.task.urgent { border-left-color: var(--bad); }
.task.st-done-l { border-left-color: var(--ok); }
.kanban { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.kanban > section { background: var(--surface-3); border-radius: var(--radius); padding: 12px; }
.chart { margin: 8px 0; }
.bar-row { display: grid; grid-template-columns: minmax(130px, 30%) 1fr 76px; align-items: center; gap: 12px; margin: 6px 0; font-size: .9375rem; }
.bar-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { display: block; height: 12px; background: var(--brand); border-radius: 999px; min-width: 3px; }
.bar-val { text-align: right; color: var(--ink-2); font-weight: 700; }
.w0{width:0}.w5{width:5%}.w10{width:10%}.w15{width:15%}.w20{width:20%}.w25{width:25%}.w30{width:30%}.w35{width:35%}.w40{width:40%}.w45{width:45%}.w50{width:50%}.w55{width:55%}.w60{width:60%}.w65{width:65%}.w70{width:70%}.w75{width:75%}.w80{width:80%}.w85{width:85%}.w90{width:90%}.w95{width:95%}.w100{width:100%}
.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 80%; padding: 12px 14px; border-radius: 14px; background: var(--surface-3); }
.msg.mine { align-self: flex-end; background: var(--brand-soft); }
.msg small { display: block; color: var(--muted); }
.agent h2 { display: flex; justify-content: space-between; align-items: center; }
.agent details { margin: 6px 0; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); }
.agent summary { cursor: pointer; font-weight: 700; }
.quiz fieldset { border: 1px solid var(--line); border-radius: var(--r-sm); margin: 8px 0; }
details > summary { cursor: pointer; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 300px; transform: translateX(-100%); transition: transform var(--t); }
  .shell.nav-open .side { transform: none; box-shadow: var(--sh-lg); }
  .mobile-only { display: inline-grid; }
  header.top { padding: 8px 12px; }
  .who, .gsearch kbd, .vsep, #vigil-top .lbl { display: none; }
  .phi-strip { padding: 6px 12px; }
  .phi-strip .long { display: none; }
  main { padding: 18px 14px 104px; }
  .hero { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 24px; border-right: 0; border-bottom: 1px solid var(--brand-line); }
  .auth-art .feat, .auth-art p, .auth-art::after { display: none; }
  .auth-art h2 { font-size: 1.375rem; margin: 8px 0 0; }
  .bar-row { grid-template-columns: 1fr 1fr 56px; }
  .vigil-panel { top: 8px; right: 8px; left: 8px; bottom: 8px; width: auto; }
  .vigil-fab { right: 16px; bottom: 16px; padding: 9px; }
  .vigil-fab .lbl { display: none; }
  .hover-card .reveal { position: static; transform: none; opacity: 1; box-shadow: none; border-radius: var(--r-sm); margin-top: 8px; display: none; border: 1px solid var(--line); }
  .hover-card.open .reveal { display: block; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (forced-colors: active) { .badge, .flag, .btn, .card { border: 1px solid CanvasText; } }
@media print {
  .side, header.top, .phi-strip, .btn, .search, #toasts, .vigil-fab, .vigil-panel, .toolbar, .view-toggle { display: none !important; }
  .shell { display: block; }
  body, html { background: #fff; }
  .card, .table-wrap { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  .hover-card .reveal { position: static; transform: none; opacity: 1; box-shadow: none; }
  main::after { content: 'CONFIDENTIAL — contains protected health information. Do not leave unattended.'; display: block; margin-top: 24px; font-size: 10pt; border-top: 1px solid #999; padding-top: 6px; }
}
.consent-page { max-width: 720px; margin: 4vh auto; padding: 0 16px; }
