/* Northstar theme — indigo primary, teal accent */
:root {
  --primary: #3B4A9F;
  --primary-dark: #2E3A80;
  --primary-light: #EEF0FA;
  --accent: #0FA3A3;
  --accent-light: #E4F6F6;
  --ok: #1E9E5A;
  --ok-bg: #E4F5EC;
  --warn: #C77D08;
  --warn-bg: #FDF2DD;
  --danger: #C93B3B;
  --danger-bg: #FBE9E9;
  --info: #4A7CC9;
  --info-bg: #E9F0FB;
  --muted: #6B7280;
  --ink: #1E2432;
  --line: #E4E7EE;
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --radius: 10px;
  /* Floating bottom-right cluster (Assistant bubble + Gmail/Drive/Chat FABs)
     safe zone.
     .ai-shell sits at right:24px; .notification-fabs start at right:60px inside it
     and are 2 x 42px + 8px gap wide, so the cluster reaches ~176px in from the
     viewport's right edge. Any bottom-anchored/sticky bar must reserve this much
     room on the right (--fab-gutter) and this much room underneath
     (--fab-safe-bottom) or its controls disappear behind the cluster (z-index 9000). */
  /* v0.4.542 — was 190px for a 2-FAB cluster; the Drive bubble adds one more
     42px circle + one 8px gap. 24 + 60 + 3x42 + 2x8 = 226 → round to 240 so a
     sticky bar's own padding still has slack. Under-sizing this is what the
     v0.4.138 collision note warns about. */
  --fab-gutter: 240px;
  --fab-safe-bottom: 88px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; min-height: 100vh; }
/* v0.4.642 — STAGING banner (rendered only when STAGING=1; see staging.js). */
.staging-banner { position: sticky; top: 0; z-index: 1000; background: #f97316; color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .02em; text-align: center; padding: 6px 14px; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
body:has(> .staging-banner) .topbar { top: 31px; }

/* Sidebar */
.sidebar { width: 220px; background: var(--primary-dark); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { background: var(--accent); color: #fff; font-weight: 800; border-radius: 8px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand-name span { display: block; font-weight: 400; font-size: 11px; color: rgba(255,255,255,.65); }
.sidebar nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.82); padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; font-size: 13.5px; }
.nav-item:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; opacity: .9; }
.nav-label { flex: 1; }
.nav-badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.nav-group-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,.38); padding: 14px 14px 4px; margin-top: 2px; }
.nav-separator { height: 1px; background: rgba(255,255,255,.10); margin: 10px 14px 8px; }
.sidebar-foot { padding: 12px 16px; font-size: 11px; color: rgba(255,255,255,.45); border-top: 1px solid rgba(255,255,255,.12); }

/* Topbar */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; position: sticky; top: 0; z-index: 20; }
.global-search input { width: 380px; max-width: 45vw; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font-size: 13px; }
.global-search input:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.bell { position: relative; background: none; border: none; font-size: 18px; cursor: pointer; }
.bell-badge { position: absolute; top: -4px; right: -8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar { background: var(--primary); color: #fff; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.user-meta { line-height: 1.15; }
.user-meta small { color: var(--muted); display: block; }

/* Content */
.content { padding: 24px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { font-size: 20px; }
.breadcrumb { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

/* Active/Inactive/All segmented filter (authorizations, outcomes) */
.seg-filter { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.subtitle { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* Cards & KPI tiles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h2 { font-size: 14px; margin-bottom: 10px; color: var(--ink); }
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: block; color: inherit; }
.kpi:hover { border-color: var(--primary); text-decoration: none; }
.kpi .kpi-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .kpi-value { font-size: 24px; font-weight: 800; margin: 4px 0 2px; color: var(--primary); }
.kpi .kpi-sub { font-size: 12px; color: var(--muted); }
.kpi.kpi-alert .kpi-value { color: var(--danger); }
.kpi.kpi-warn .kpi-value { color: var(--warn); }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; font-size: 13px; }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #FAFBFD; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable:hover { background: var(--primary-light); cursor: pointer; }
tbody tr.row-late td { background: var(--danger-bg); }
tbody tr.row-late:first-child td { border-top: 1px solid #F0C9C9; }

/* Chips / status pills */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-muted { background: #EEF0F4; color: var(--muted); }
.chip-accent { background: var(--accent-light); color: var(--accent); }
.chip-primary { background: var(--primary-light); color: var(--primary); }
/* v0.4.648 — visit billing 'voided': paid claim later voided in PROMISe (re-billable). Distinct from 'void' (deleted visit, danger). */
.chip-voided { background: #FCE7F3; color: #9D174D; }

/* Filter bar & tabs */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar label { font-size: 12px; color: var(--muted); font-weight: 600; }
.filter-bar select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 13px; }
/* v0.4.694 — "Show demo data" toggle (partials/demo-toggle.ejs): last item of
   every list page's filter bar, pushed to the right edge. */
.demo-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; background: var(--card); white-space: nowrap; text-decoration: none; }
.demo-toggle:hover { text-decoration: none; color: var(--primary); border-color: var(--primary); }
.demo-toggle.on { color: #9a3412; background: #fff7ed; border-color: #fdba74; }
.demo-toggle-box { font-size: 13px; line-height: 1; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tab { padding: 9px 16px; font-size: 13.5px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab:hover { text-decoration: none; color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { background: var(--danger); color: #fff; border-radius: 999px; font-size: 10.5px; padding: 1px 6px; margin-left: 5px; }

/* Buttons */
.btn { display: inline-block; padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; border: 1px solid transparent; cursor: pointer; }
/* Document Sign-Off (my-day-acknowledgements): desktop keeps the classic
   right-aligned action column; .ack-view-mobile only exists on phones —
   both are overridden inside the ≤768px block. */
.ack-wrap td.ack-action { text-align: right; }
.ack-view-mobile { display: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-outline { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Alerts feed (legacy) */
.alert-row { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.alert-row:last-child { border-bottom: none; }
.alert-icon { font-size: 16px; }
.alert-body { flex: 1; font-size: 13px; }
.alert-time { font-size: 11.5px; color: var(--muted); }
.alert-assign { font-size: 11.5px; }

/* Dashboard To-Do */

/* ---- To-Do HERO card (v0.4.157) ----------------------------------------
   The To-Do card is the dashboard's daily-duty anchor: full-width, directly
   under the KPI strip, larger type than the rest of the page. Two columns at
   >=1100px so a wide card isn't a column of stubs. Deliberately NOT sticky —
   see the .fab-safe-* note below; a sticky hero would collide with the
   floating Assistant/Gmail cluster (z-index 9000). */
.todo-hero { margin-bottom: 16px; padding: 18px 20px; border-width: 2px; }
.todo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; /* v0.4.694 — room for the demo toggle at 390px */ }
.todo-hero .todo-head h2 { font-size: 20px; margin: 0; letter-spacing: -.2px; }
.todo-count { font-weight: 600; color: var(--muted); font-size: 16px; }
.todo-expander { background: none; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font: inherit; font-size: 12px; color: var(--muted); padding: 4px 10px; }
.todo-expander:hover { color: var(--ink); border-color: var(--muted); }
.todo-caught-up { font-size: 14px; color: var(--ok, #22a06b); padding: 6px 0 2px; }
/* Empty state shrinks so a clear list doesn't push the Live Board down. */
.todo-hero-empty { padding: 14px 20px; }
.todo-hero-empty .todo-head { margin-bottom: 4px; }
.todo-done-wrap { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
/* v0.4.219 — one merged completed drawer for the whole card. */
.todo-done-summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); list-style: none; padding: 2px 0; user-select: none; }
.todo-done-summary::-webkit-details-marker { display: none; }
.todo-done-summary:hover { color: var(--ink); text-decoration: underline; }
.todo-done-grouplabel { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 6px 0 2px; }
.todo-add-wrap { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.todo-add-toggle { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent, #3b82f6); list-style: none; padding: 4px 0; user-select: none; }
.todo-add-toggle::-webkit-details-marker { display: none; }
.todo-add-toggle:hover { text-decoration: underline; }

.todo-list { margin-bottom: 10px; }
/* Cap the hero at 10 rows; the expander removes the cap. v0.4.691: rows past
   the cap are hidden instead of scrolled — the old 460px inner scroll box left
   clipped row links sitting under the Live board links (UI gate overlap). */
.todo-list.todo-capped > .todo-row:nth-child(n+11) { display: none; }
/* v0.4.831 — a grouped auto item (<details>) obeys the same 10-row card cap. */
.todo-list.todo-capped > .todo-auto-group:nth-child(n+11) { display: none; }
@media (min-width: 1100px) {
  .todo-hero .todo-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-content: start; }
  .todo-hero .todo-list > .todo-auto-group[open] { grid-column: 1 / -1; } /* v0.4.831 */
  .todo-hero .todo-caught-up { grid-column: 1 / -1; }
}
.todo-row { display: flex; align-items: flex-start; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.todo-row:last-child { border-bottom: none; }
.todo-check { background: none; border: none; cursor: pointer; font-size: 16px; padding: 0; line-height: 1; color: var(--ink); }
.todo-body { flex: 1; font-size: 13px; }
/* Hero rows get bigger type + padding + a real checkbox hit area. */
.todo-hero .todo-row { padding: 13px 8px; gap: 10px; border-radius: 6px; }
.todo-hero .todo-body { font-size: 15px; }
.todo-hero .todo-check { font-size: 20px; min-width: 24px; min-height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.todo-hero .todo-meta { font-size: 12px; }
.todo-hero .todo-del { font-size: 20px; min-width: 24px; min-height: 24px; }
.todo-title { line-height: 1.3; }
.todo-meta { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; }
.todo-from { font-style: italic; }
.todo-del { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--muted); padding: 0 2px; line-height: 1; }
.todo-del:hover { color: var(--danger, #e74c3c); }
.todo-overdue { background: rgba(231,76,60,.06); }
.todo-overdue-text { color: var(--danger, #e74c3c); font-weight: 600; }
.todo-hero .todo-overdue { border-left: 3px solid var(--danger, #e74c3c); padding-left: 9px; }
.todo-hero .todo-overdue .todo-title { font-weight: 600; }
.todo-done { opacity: 0.6; }

/* ---- Today-tab To-Dos card (v0.4.309) ------------------------------------
   Collapsible sections on /my-day. Rows reuse the dashboard To-Do hero
   vocabulary (.todo-row/.todo-check/.todo-meta/.todo-badge-auto); only the
   section chrome below is new. Native <details> — no JS, works on
   tablets/phones. */
.todo-sec { border-top: 1px solid var(--line); }
.todo-sec:first-of-type { border-top: none; }
.todo-sec-toggle { cursor: pointer; list-style: none; user-select: none; display: flex; align-items: center; gap: 8px; padding: 10px 2px; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.todo-sec-toggle::-webkit-details-marker { display: none; }
.todo-sec-toggle::before { content: '\25B8'; color: var(--muted); font-size: 11px; transition: transform .15s; }
.todo-sec[open] > .todo-sec-toggle::before { transform: rotate(90deg); }
.todo-sec-count { background: #EEF0F4; color: var(--muted); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 8px; }
.todo-sec-count.todo-sec-alert { background: var(--danger-bg); color: var(--danger); }
.todo-sec-list { padding: 0 2px 10px; }
.todo-sec .todo-row:last-child { border-bottom: none; }
@media (max-width: 768px) {
  /* Real tap target for the section header on tablets/phones. */
  .todo-sec-toggle { min-height: 40px; }
}

.todo-auto { background: var(--bg); }
.todo-check-disabled { cursor: default; opacity: 0.35; pointer-events: none; }
.todo-auto-link { color: var(--accent, #3b82f6); text-decoration: none; font-weight: 500; }
.todo-auto-link:hover { text-decoration: underline; }
.todo-badge-auto { display: inline-block; font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; background: var(--line); color: var(--muted); padding: 1px 5px; border-radius: 3px; margin-left: 6px; vertical-align: middle; }
/* Delegated to-dos (v0.4.168) — informational rows for work I assigned out. */
.todo-deleg-wrap { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.todo-deleg-toggle { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted); list-style: none; padding: 2px 0; }
.todo-deleg-toggle::-webkit-details-marker { display: none; }
.todo-deleg-toggle::before { content: '\25B8'; display: inline-block; margin-right: 6px; transition: transform .15s; }
.todo-deleg-wrap[open] .todo-deleg-toggle::before { transform: rotate(90deg); }
.todo-deleg-toggle:hover { color: var(--ink); }
.todo-deleg-list { margin-top: 4px; }
.todo-deleg-list.todo-capped { max-height: 340px; overflow-y: auto; }
.todo-hero .todo-row.todo-deleg { padding: 11px 8px; }
.todo-deleg-done { background: var(--ok-bg); }
.todo-deleg-donetext { color: #14713F; font-weight: 600; }
.todo-deleg-act { padding: 3px 9px; font-size: 11.5px; }
/* Bulk fan-out grouping (v0.4.184): one summary line per batch, collapsed by
   default, so a 14-person department assign doesn't flatten the section. */
.todo-deleg-group { border-left: 2px solid var(--line); margin: 2px 0; }
.todo-deleg-groupline { cursor: pointer; list-style: none; }
.todo-deleg-groupline::-webkit-details-marker { display: none; }
.todo-deleg-groupline::after { content: '\25B8'; margin-left: auto; color: var(--muted); font-size: 11px; transition: transform .15s; }
.todo-deleg-group[open] > .todo-deleg-groupline::after { transform: rotate(90deg); }
.todo-deleg-child { padding-left: 20px !important; }
@media (max-width: 768px) {
  /* Assignee chip wraps under the title rather than squeezing the row. */
  .todo-deleg .todo-badge-auto { display: block; margin-left: 0; margin-top: 4px; width: fit-content; }
  .todo-deleg-act { min-height: 36px; }
}

.todo-add-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.todo-input { flex: 1; min-width: 120px; padding: 5px 8px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--ink); }
.todo-date-input { width: 130px; padding: 5px 6px; font-size: 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--ink); }
.todo-assignee-picker { position: relative; width: 180px; }
/* Bulk target (v0.4.184) — hidden until "A department" is picked, so the
   common title + Enter flow stays a single line. */
.todo-target-modes { display: flex; gap: 12px; align-items: center; font-size: 12px; font-weight: 600; }
.todo-target-modes label { display: flex; align-items: center; gap: 5px; font-weight: 600; cursor: pointer; }
.todo-dept-target { flex: 1 0 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.todo-dept-target select { font-size: 12px; padding: 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--ink); }
.todo-assignee-search { width: 100%; padding: 5px 8px; font-size: 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--ink); box-sizing: border-box; }
.todo-assignee-options { display: none; position: absolute; z-index: 100; top: calc(100% + 2px); left: 0; right: 0; max-height: 210px; overflow-y: auto; background: var(--card-bg, #fff); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.todo-assignee-picker.open .todo-assignee-options { display: block; }
.todo-assignee-options button { display: block; width: 100%; padding: 7px 9px; border: 0; background: transparent; color: var(--ink); text-align: left; font: inherit; font-size: 12px; cursor: pointer; }
.todo-assignee-options button:hover, .todo-assignee-options button:focus { background: var(--bg); outline: none; }
.todo-assignee-options button[hidden] { display: none; }

/* Timeline */
.timeline { list-style: none; }
.timeline li { position: relative; padding: 0 0 16px 24px; border-left: 2px solid var(--line); margin-left: 8px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }
.timeline .t-time { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.timeline .t-event { font-size: 13px; margin-top: 1px; }

/* Detail layout */
.detail-header { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.detail-header h1 { font-size: 19px; margin-bottom: 4px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.section { margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-weight: 600; }
.flag-banner { background: var(--danger-bg); color: var(--danger); border: 1px solid #F1C7C7; border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.callout { border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.callout-warn { background: var(--warn-bg); border: 1px solid #EBD3A6; color: #7A5104; }
.callout-info { background: var(--info-bg); border: 1px solid #C4D6F0; color: #2C5493; }
.callout-ok, .callout-success { background: var(--ok-bg); border: 1px solid #B7E3CB; color: #14713F; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare .box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.compare .box.entered { border-color: var(--warn); background: var(--warn-bg); }
.compare .box small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }

/* Settings sub-nav */
/* 🩸 minmax(0, 1fr) — NOT plain `1fr`. A grid item defaults to min-width:auto,
   so the content column was sized by the MIN-CONTENT width of whatever it held.
   Every Settings page puts a wide table in that column; even though the table
   sits in a `.table-wrap` (overflow-x:auto), Chrome still grew the track to the
   table's intrinsic width — 1745px on /settings and 2103px on
   /settings/service-codes inside a 1172px page — so the WINDOW scrolled
   sideways instead of the wrap, and the sub-nav (same single column on mobile)
   was dragged out to 1737px at 390px wide. minmax(0, …) lets the track shrink
   to the container and hands the horizontal scrolling back to `.table-wrap`
   where it belongs. `min-width: 0` on the children is the same guard for any
   future non-table child (flex rows, `<pre>`, long unbroken strings). */
.settings-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; }
.settings-layout > * { min-width: 0; }
@media (max-width: 900px) { .settings-layout { grid-template-columns: minmax(0, 1fr); } }
/* Cluster is still desktop-sized down to 769px, so only trim the gutter to the
   measured 176px + a little breathing room — going narrower re-creates the bug. */
@media (max-width: 900px) { :root { --fab-gutter: 230px; --fab-safe-bottom: 80px; } }
.subnav { display: flex; flex-direction: column; gap: 2px; }
.subnav a { padding: 8px 12px; border-radius: 8px; font-size: 13px; color: var(--ink); }
.subnav a:hover { background: var(--primary-light); text-decoration: none; }
.subnav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.subnav .subnav-group { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px 4px; }

/* Note rendering */
.goal-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.goal-card .goal-name { font-weight: 700; font-size: 13px; }
.goal-card .goal-data { margin: 4px 0; }
.goal-card .goal-narrative { color: var(--ink); font-size: 13px; }

.stub { text-align: center; padding: 70px 20px; color: var(--muted); }
.stub h1 { font-size: 22px; color: var(--ink); margin-bottom: 10px; }
.stub p { max-width: 520px; margin: 0 auto 18px; line-height: 1.5; }
.stub .stub-badge { display: inline-block; background: var(--accent-light); color: var(--accent); font-weight: 700; font-size: 12px; border-radius: 999px; padding: 4px 14px; margin-bottom: 16px; }

.muted { color: var(--muted); }
.mb { margin-bottom: 16px; }
.right { text-align: right; }

/* View-as switcher */
.view-as { display: flex; align-items: center; gap: 7px; background: var(--primary-light); border: 1px solid #D6DBF2; border-radius: 999px; padding: 4px 10px 4px 14px; }
.view-as label { font-size: 11px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .05em; }
.view-as select { border: none; background: transparent; font-size: 12.5px; font-weight: 600; color: var(--primary-dark); padding: 4px 2px; cursor: pointer; }
.view-as select:focus { outline: none; }
/* v0.4.144 — searchable persona picker replaces the <select> (every staff member
   is now a target, so a flat dropdown no longer scales). */
.view-as-trigger { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; border: none; background: transparent; cursor: pointer; padding: 2px 4px; font-family: inherit; max-width: 190px; }
.view-as-trigger span { font-size: 12.5px; font-weight: 700; color: var(--primary-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.view-as-trigger small { font-size: 10.5px; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.view-as-trigger:hover span { text-decoration: underline; }
.view-as-dialog { max-width: 520px; }
.va-search { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; font-family: inherit; }
.va-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; }
.va-row { display: flex; flex-direction: column; gap: 1px; padding: 9px 12px; text-decoration: none; border-bottom: 1px solid var(--line); background: var(--card); }
.va-row:last-child { border-bottom: none; }
.va-row:hover { background: var(--primary-light); }
.va-row.va-hidden { display: none; }
.va-row .va-name { font-size: 13.5px; font-weight: 650; color: var(--ink); }
.va-row .va-name em { font-style: normal; font-weight: 600; color: var(--primary); font-size: 12px; }
.va-row .va-meta { font-size: 11.5px; color: var(--muted); }
.va-row.va-current { background: var(--primary-light); }
.va-self { background: var(--accent-light); }
.va-self:hover { background: #D3EFEF; }
.va-self .va-name { color: var(--accent); }
.va-empty { padding: 14px 12px; font-size: 12.5px; color: var(--muted); text-align: center; }
.va-toggle { display: flex !important; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 !important; cursor: pointer; }
.va-toggle input { width: auto !important; }

/* v0.4.144 — impersonation banner. Sticky at the TOP on purpose: a bottom bar
   would collide with the floating Assistant/Gmail FAB cluster (see v0.4.138 and
   the .fab-safe-* utilities). */
.impersonation-banner { position: sticky; top: 0; z-index: 19; display: flex; align-items: center; gap: 10px; padding: 9px 24px; background: var(--warn-bg); border-bottom: 1px solid #F0D79B; color: #7A4E05; font-size: 13px; }
.impersonation-banner .imp-icon { font-size: 14px; flex: 0 0 auto; }
.impersonation-banner .imp-text { flex: 1 1 auto; }
.impersonation-banner strong { font-weight: 800; }
.impersonation-banner small { display: inline-block; margin-left: 6px; color: #96703A; font-size: 11.5px; }
.impersonation-banner .imp-exit { flex: 0 0 auto; background: #7A4E05; color: #fff; border-radius: 999px; padding: 5px 14px; font-size: 12px; font-weight: 700; text-decoration: none; }
.impersonation-banner .imp-exit:hover { background: #5E3C04; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 200; opacity: 0; transition: opacity .18s, transform .18s; max-width: 80vw; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Dialogs (action forms) */
/* v0.4.804: margin:auto re-centres every modal — the `* { margin: 0 }` reset above was
   overriding the UA sheet's `dialog { margin: auto }` and pinning dialogs top-left (Nick, #evv 2026-11-11). */
dialog { border: none; border-radius: 12px; padding: 0; margin: auto; max-width: 460px; width: 92vw; box-shadow: 0 12px 48px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20,25,40,.45); }
.dialog-head { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.dialog-head button { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.dialog-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.dialog-body label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 4px; }
.dialog-body input[type="text"], .dialog-body input[type="number"], .dialog-body input[type="date"], .dialog-body input[type="email"], .dialog-body input[type="tel"], .dialog-body select, .dialog-body textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit; }
.dialog-body textarea { min-height: 64px; resize: vertical; }
.dialog-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.dialog-hint { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 8px 10px; }

/* Punch panel (visit detail) */
.punch-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 700px) { .punch-panel { grid-template-columns: 1fr; } }
.punch-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.punch-card.punch-missing { border-color: var(--danger); background: var(--danger-bg); }
.punch-card .punch-label { font-size: 11px; font-weight: 800; letter-spacing: .07em; color: var(--muted); text-transform: uppercase; }
.punch-card .punch-time { font-size: 26px; font-weight: 800; color: var(--ink); margin: 4px 0 2px; }
.punch-card.punch-missing .punch-time { color: var(--danger); font-size: 20px; }
.punch-card .punch-meta { font-size: 12.5px; color: var(--muted); }
.punch-duration { grid-column: 1 / -1; text-align: center; font-size: 13px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 8px; padding: 8px; }
.callout-danger { background: var(--danger-bg); border: 1px solid #F1C7C7; color: var(--danger); font-weight: 700; }

/* Tooltip */
.tip { position: relative; display: inline-block; cursor: help; color: var(--info); font-weight: 700; border-bottom: 1px dotted var(--info); }
.tip .tip-text { visibility: hidden; opacity: 0; position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; font-weight: 400; line-height: 1.45; border-radius: 8px; padding: 9px 12px; width: 280px; z-index: 100; transition: opacity .15s; }
.tip:hover .tip-text { visibility: visible; opacity: 1; }

/* Pickup badge */
.chip-pickup { background: #F3E8FD; color: #7C3AED; }

/* Department tree (settings) */
.tree-cell { white-space: nowrap; }
.tree-cell .tree-line { color: var(--muted); }

/* Intake kanban */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
@media (max-width: 1000px) { .kanban { grid-template-columns: repeat(2, 1fr); } }
.kanban-col { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.kanban-col h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 4px 6px 10px; }
.kanban-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; font-size: 13px; }
.kanban-card strong { display: block; margin-bottom: 2px; }
.kanban-card .muted { font-size: 12px; }

/* Report gallery */
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1000px) { .report-grid { grid-template-columns: 1fr 1fr; } }
.report-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: block; color: inherit; }
.report-card:hover { border-color: var(--primary); text-decoration: none; }
.report-card h3 { font-size: 14px; margin-bottom: 6px; }
.report-card p { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.report-card .chip { margin-top: 10px; }

/* Health & safety panel */
.hs-panel { background: #FFF8F0; border: 1px solid #F0DCC0; border-radius: 8px; padding: 12px 14px; }
.hs-panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #9A6108; margin-bottom: 8px; }
.hs-panel ul { list-style: none; }
.hs-panel li { font-size: 13px; padding: 3px 0; }

/* Sort headers */
.sort-header { color: inherit; text-decoration: none; white-space: nowrap; cursor: pointer; }
.sort-header:hover { color: var(--accent); text-decoration: underline; }

/* Non-billable badge */
.chip-nonbill { background: #F3E8FF; color: #6B21A8; }

/* 2:1 badge */
.chip-21 { background: #DBEAFE; color: #1E40AF; font-weight: 700; }
.chip-12 { background: #FEF3C7; color: #92400E; font-weight: 700; }

/* Intake badge */
.chip-intake { background: #FEF3C7; color: #92400E; }

/* Notification bell tray */
.bell-wrap { position: relative; }
.bell-tray { display: none; position: absolute; right: 0; top: 100%; margin-top: 6px; width: 340px; max-height: 400px; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 1000; }
.bell-open .bell-tray { display: block; }
.bell-tray-head { padding: 10px 14px; font-weight: 700; font-size: 13px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
.bell-empty { padding: 24px 14px; text-align: center; color: var(--muted); font-size: 13px; }
.bell-item { display: flex; align-items: flex-start; gap: 8px; padding: 10px 14px; text-decoration: none; color: inherit; border-bottom: 1px solid #f0f0f0; transition: background .1s; }
.bell-item:hover { background: #f8f9ff; }
.bell-item-icon { flex-shrink: 0; font-size: 16px; }
/* v0.4.433 — the body is now the link and the row is a flex container so a
   Dismiss form can sit beside it (the same dismiss the dashboard card has). */
.bell-item-body { min-width: 0; flex: 1; text-decoration: none; color: inherit; }
.bell-item-dismiss { flex-shrink: 0; margin: 0; }
.bell-dismiss-btn { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 11px; padding: 2px 8px; cursor: pointer; white-space: nowrap; }
.bell-dismiss-btn:hover { background: #fff; color: var(--text, #222); border-color: #bbb; }
.bell-item-body strong { display: block; font-size: 12px; }
.bell-item-body small { color: var(--muted); font-size: 11px; }

/* Link-styled button (for inline forms) */
.link-btn { background: none; border: none; padding: 0; color: var(--accent); font: inherit; font-size: inherit; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--primary); }

/* Searchable picker (filter box + select) */
.searchable-picker { display: flex; flex-direction: column; gap: 4px; }
.searchable-picker .picker-search { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px 8px 0 0; font-size: 13px; background: var(--bg); }
.searchable-picker .picker-search:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.searchable-picker select { border: 1px solid var(--line); border-top: none; border-radius: 0 0 8px 8px; font-size: 13px; padding: 2px; }
.searchable-picker select option { padding: 4px 8px; }
.searchable-picker select option.picker-hidden { display: none; }

/* ================================================================
   AI Assistant — floating bubble + chat panel
   ================================================================ */
/* Utilities: keep bottom-anchored UI clear of the floating cluster above.
   Use .fab-safe-right on any sticky/fixed bottom action bar, and drop a
   <div class="fab-safe-bottom"></div> as the LAST child of the bar's sticky
   container so the bar lifts off the very bottom edge at full scroll.
   Never raise a bar's z-index above .ai-shell (9000) to win this fight —
   that just hides the global Assistant instead. */
.fab-safe-right { padding-right: var(--fab-gutter); }
.fab-safe-bottom { height: var(--fab-safe-bottom); flex: 0 0 auto; pointer-events: none; }

/* v0.4.498 — Visits bulk-nudge bar (partials/bulk-nudge-bar.ejs, both tabs).
   Sticky bottom bar => needs the gutter above. z-index stays 20; see the
   warning in the comment block above before "fixing" any overlap with it. */
.bulk-nudge-bar {
  position: sticky; bottom: 0; z-index: 20; margin: 12px 0 0;
  background: var(--card, #fff); border: 1px solid var(--line, #ddd);
  border-radius: 10px; box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  padding: 10px 14px; padding-right: var(--fab-gutter);
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; justify-content: space-between;
}
.bulk-nudge-info { font-size: 14px; }
.bulk-nudge-actions { display: flex; gap: 10px; align-items: center; }

.ai-shell { position: fixed; bottom: 24px; right: 24px; z-index: 9000; font-family: inherit; }
.notification-fabs { position: absolute; right: 60px; bottom: 4px; display: flex; gap: 8px; }
.notification-fab {
  position: relative; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--primary); font-size: 19px; cursor: pointer;
  box-shadow: 0 3px 12px rgba(0,0,0,.16); display: flex; align-items: center; justify-content: center;
}
.notification-fab:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(0,0,0,.2); }
.notification-fab--gmail { color: #c5221f; }
.notification-fab--chat { color: #137333; }
/* v0.4.542 — Google Drive. It is an <a>, not a <button>, so it needs the
   text-decoration reset a button got for free (otherwise the mark is
   underlined on hover). The icon is a multi-colour inline SVG, so unlike its
   two siblings it sets no `color` — nothing here inherits currentColor. */
.notification-fab--drive { text-decoration: none; }
.notification-fab--drive:hover { text-decoration: none; }
.notification-fab-svg { width: 20px; height: 20px; display: block; }
.notification-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 18px; }
.notification-panel { display: none; flex-direction: column; position: fixed; bottom: 24px; right: 24px; width: 390px; max-width: calc(100vw - 48px); max-height: 500px; background: var(--card); border-radius: 14px; box-shadow: 0 8px 40px rgba(0,0,0,.18); overflow: hidden; }
.notification-panel.is-open { display: flex; }
.notification-panel-header { padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--primary-light); display: flex; justify-content: space-between; gap: 12px; }
.notification-panel-header h2 { margin: 0; font-size: 15px; color: var(--primary-dark); }
.notification-panel-header p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.notification-list { overflow-y: auto; min-height: 100px; }
.notification-item { display: block; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.notification-item:hover { background: var(--bg); }
.notification-item-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.notification-item-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-item time { color: var(--muted); flex-shrink: 0; font-size: 10px; }
.notification-item-title { font-weight: 700; font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-item-snippet { color: var(--muted); font-size: 11.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-empty { color: var(--muted); text-align: center; padding: 30px 16px; font-size: 13px; }
.notification-open { padding: 12px 16px; border-top: 1px solid var(--line); text-align: center; color: var(--primary); font-weight: 700; text-decoration: none; font-size: 13px; }

/* Floating action button */
.ai-fab {
  width: 52px; height: 52px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 22px;
  cursor: pointer; box-shadow: 0 4px 16px rgba(59,74,159,.35);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
}
.ai-fab:hover { transform: scale(1.08); box-shadow: 0 6px 22px rgba(59,74,159,.45); }
.ai-fab-icon { line-height: 1; }

/* Panel */
.ai-panel {
  display: none; flex-direction: column;
  position: fixed; bottom: 24px; right: 24px;
  width: 400px; max-width: calc(100vw - 48px);
  height: 560px; max-height: calc(100vh - 48px);
  background: var(--card); border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  overflow: hidden;
}
.ai-open .ai-panel { display: flex; }

/* Header */
.ai-panel-header {
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line);
  background: var(--primary-light);
}
.ai-panel-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ai-panel-header h2 { font-size: 15px; font-weight: 700; color: var(--primary-dark); margin: 0; }
.ai-panel-subtitle { font-size: 11.5px; color: var(--muted); margin: 2px 0 0; }
.ai-panel-header-actions { display: flex; gap: 4px; flex-shrink: 0; }
.ai-btn-icon {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-size: 15px; color: var(--muted);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.ai-btn-icon:hover { background: var(--bg); color: var(--ink); }
.ai-btn-sm { width: 24px; height: 24px; font-size: 13px; }

/* Body / messages area */
.ai-body { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.ai-messages { display: flex; flex-direction: column; gap: 6px; }
.ai-status { font-size: 12px; color: var(--muted); text-align: center; padding: 6px 0; }
.ai-status:empty, .ai-status[hidden] { display: none; }
.ai-status--error { color: var(--danger); }

/* Messages */
.ai-msg { display: flex; flex-direction: column; gap: 2px; }
.ai-msg--user { align-items: flex-end; }
.ai-msg--assistant { align-items: flex-start; }
.ai-msg-meta { font-size: 10.5px; color: var(--muted); padding: 0 4px; }
.ai-msg-bubble {
  max-width: 92%; padding: 8px 12px; border-radius: 12px;
  font-size: 13.5px; line-height: 1.45; word-break: break-word;
}
.ai-msg--user .ai-msg-bubble {
  background: var(--primary); color: #fff; border-bottom-right-radius: 4px;
}
.ai-msg--assistant .ai-msg-bubble {
  background: var(--bg); color: var(--ink); border-bottom-left-radius: 4px;
}
.ai-msg-bubble strong { font-weight: 600; }
.ai-msg-bubble code { background: rgba(0,0,0,.07); padding: 1px 4px; border-radius: 3px; font-size: 12.5px; }
.ai-msg-bubble pre.ai-code {
  background: #1e2432; color: #e4e7ee; padding: 8px 10px; border-radius: 6px;
  font-size: 12px; overflow-x: auto; margin: 4px 0; white-space: pre-wrap;
}
.ai-msg-bubble ul, .ai-msg-bubble ol { margin: 4px 0 4px 18px; }
.ai-msg-bubble li { margin-bottom: 2px; }

/* Thinking animation */
.ai-dots span { display: inline-block; animation: aiBounce .6s infinite; font-size: 20px; line-height: 1; }
.ai-dots span:nth-child(2) { animation-delay: .15s; }
.ai-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes aiBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

/* Composer */
.ai-composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 10px 12px; border-top: 1px solid var(--line); background: var(--card);
}
.ai-composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 13.5px; font-family: inherit;
  max-height: 120px; line-height: 1.4; background: var(--bg);
}
.ai-composer textarea:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.ai-send {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 17px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ai-send:disabled { opacity: .5; cursor: not-allowed; }
.ai-send:hover:not(:disabled) { background: var(--primary-dark); }

/* Composer: attach button + chips (v0.4.177) */
.ai-composer { flex-direction: column; align-items: stretch; gap: 8px; }
.ai-composer-input { display: flex; align-items: flex-end; gap: 6px; }
.ai-attach-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ai-attach-btn:hover { background: var(--card); border-color: var(--primary); }
/* Cap at ~2 rows and scroll instead of growing: the composer must never get
   pushed under the mobile keyboard by a pile of chips. */
.ai-attach-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 64px; overflow-y: auto; overflow-x: hidden;
}
.ai-attach-row[hidden] { display: none; }
.ai-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  padding: 4px 6px 4px 8px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg); font-size: 12px; line-height: 1.2;
}
.ai-chip-icon { font-size: 13px; flex-shrink: 0; }
.ai-chip-name {
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-chip-size { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.ai-chip-rm {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 0; flex-shrink: 0;
  /* Real touch target, not a hover-only 10px glyph (the v0.4.162 lesson). */
  min-width: 22px; min-height: 22px; display: flex; align-items: center; justify-content: center;
}
.ai-chip-rm:hover { color: var(--danger); }
.ai-chip--busy { color: var(--muted); font-style: italic; }
.ai-chip--static { background: rgba(0,0,0,.04); }
.ai-msg-atts { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px 2px; max-width: 92%; }

/* Drop state across the whole panel */
.ai-panel.ai-dropping { outline: 2px dashed var(--primary); outline-offset: -6px; }
.ai-panel.ai-dropping::after {
  content: 'Drop to attach'; position: absolute; inset: auto 0 76px 0;
  text-align: center; font-size: 12px; color: var(--primary); pointer-events: none;
}

/* Copy / download on assistant messages */
.ai-msg-tools { display: flex; gap: 6px; padding: 2px 4px 0; opacity: 0; transition: opacity .12s; }
.ai-msg:hover .ai-msg-tools, .ai-msg-tools:focus-within { opacity: 1; }
.ai-msg-tool {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 10px; font-size: 11px; padding: 2px 8px; cursor: pointer; line-height: 1.5;
}
.ai-msg-tool:hover { color: var(--ink); border-color: var(--primary); }
/* Hover-only controls are invisible on touch (the v0.4.162 lesson) — always show. */
@media (hover: none) {
  .ai-msg-tools { opacity: 1; }
  .ai-msg-tool { padding: 5px 10px; font-size: 12px; }
}


/* Conversation list overlay */
.ai-convs {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--card); z-index: 2; display: flex; flex-direction: column;
}
.ai-convs[hidden] { display: none; }
.ai-convs-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line); background: var(--primary-light);
  font-size: 14px;
}
.ai-convs-list { flex: 1; overflow-y: auto; padding: 8px; }
.ai-convs-empty { text-align: center; color: var(--muted); padding: 20px; font-size: 13px; }
.ai-conv-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
  gap: 6px;
}
.ai-conv-item:hover { background: var(--bg); }
.ai-conv-item.ai-conv-active { background: var(--primary-light); font-weight: 600; }
.ai-conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-conv-del {
  width: 22px; height: 22px; border-radius: 4px; border: none;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ai-conv-del:hover { background: var(--danger-bg); color: var(--danger); }

/* ═══ Forms (AI-designed) ═══ */
/* Designer layout */
.fd-layout { display: grid; grid-template-columns: minmax(340px, 5fr) minmax(380px, 7fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .fd-layout { grid-template-columns: 1fr; } }
.fd-chat { display: flex; flex-direction: column; position: sticky; top: 76px; max-height: calc(100vh - 100px); }
.fd-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 10px; min-height: 180px; }
.fd-msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.fd-msg-ai { background: var(--primary-light); color: var(--ink); align-self: flex-start; border-bottom-left-radius: 4px; }
.fd-msg-user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.fd-msg-thinking { opacity: .6; font-style: italic; }
.fd-input-row { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 10px; }
.fd-input-row textarea { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit; resize: vertical; }
.fd-error { background: var(--danger-bg); color: var(--danger); border-radius: 8px; padding: 8px 12px; font-size: 12.5px; margin-bottom: 8px; }
.fd-save-bar { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.fd-save-fields { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fd-save-fields label { font-size: 11.5px; font-weight: 700; color: var(--muted); display: block; }
.fd-save-fields input { width: 100%; margin-top: 3px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.fd-preview { border: 1px dashed var(--line); border-radius: 8px; padding: 16px; background: #FCFCFE; }
.fd-json { margin-top: 12px; }
.fd-json summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.fd-json textarea { width: 100%; margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.fd-json-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

/* Rendered form fields (shared renderer) */
.ff-head { margin-bottom: 14px; }
.ff-title { font-size: 17px; font-weight: 700; }
.ff-desc { color: var(--muted); font-size: 13px; margin-top: 3px; }
.ff-section { margin: 20px 0 10px; padding-bottom: 5px; border-bottom: 2px solid var(--primary-light); }
.ff-section:first-child { margin-top: 4px; }
.ff-section-title { font-size: 14px; font-weight: 700; color: var(--primary-dark); }
.ff-section-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.ff-field { margin-bottom: 14px; }
.ff-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.ff-req { color: var(--danger); }
.ff-help { font-size: 12px; color: var(--muted); margin: -2px 0 5px; }
.ff-input { width: 100%; max-width: 460px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit; background: #fff; }
.ff-input:disabled { background: #F4F5F8; color: #8a8f9c; }
.ff-textarea { max-width: 100%; }
.ff-number, .ff-date, .ff-time { max-width: 200px; }
.ff-choices { display: flex; flex-direction: column; gap: 5px; }
.ff-choices.ff-inline { flex-direction: row; gap: 18px; }
.ff-choice { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.ff-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.ff-signature { font-family: 'Brush Script MT', 'Segoe Script', 'Apple Chancery', cursive; font-size: 19px; }
.ff-has-error .ff-input, .ff-has-error .ff-choices { outline: 2px solid var(--danger-bg); border-color: var(--danger); border-radius: 8px; }
.ff-error { color: var(--danger); font-size: 12px; font-weight: 600; margin-top: 4px; }
/* Read-only (view/print) values */
.ff-value { font-size: 13.5px; }
.ff-empty { color: var(--muted); }
.ff-narrative { white-space: pre-wrap; background: #FAFAFC; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.ff-list { margin: 0; padding-left: 18px; }
.ff-signature-view { display: flex; flex-direction: column; gap: 2px; }
.ff-sig-name { font-family: 'Brush Script MT', 'Segoe Script', 'Apple Chancery', cursive; font-size: 24px; color: #1a202c; }
.ff-sig-ts { font-size: 11.5px; color: var(--muted); }

/* Assign form on template detail */
.fa-assign-form label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 10px; }
.fa-assign-form select, .fa-assign-form input { display: block; width: 100%; max-width: 320px; margin-top: 3px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; }
/* v0.4.250 — the bare `input` above is meant for text/date/number boxes, but it
   also matched the checkboxes and radios in this form: the "Include
   sub-departments" box (and the assign_target / show_mode radios) became
   320px-wide blocks stranded away from their own label text, and the stretched
   box was a giant accidental click target that could silently toggle the
   option off. Restore native sizing for those two types ONLY — scoped to
   .fa-assign-form, native appearance kept, no custom control. */
.fa-assign-form input[type="checkbox"], .fa-assign-form input[type="radio"] { display: inline-block; width: 16px; height: 16px; max-width: none; flex: 0 0 auto; margin-top: 0; padding: 0; border: 0; border-radius: 0; background: none; }
.fa-assign-row { display: flex; gap: 14px; }
.fa-assign-row label { flex: 1; }

/* Submission sheet + print */
.fs-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; font-size: 13px; }
.fs-meta-label { display: inline-block; min-width: 84px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
@media print {
  /* v0.4.542 — `.notification-fabs` and `.notification-panel` were MISSING here:
     the Gmail/Chat bubbles have always printed on every form and visit record.
     Pre-existing, but adding a third bubble to that cluster made it worse, so
     the whole cluster is suppressed rather than just the new one. */
  .sidebar, .topbar, .no-print, .toast, .ai-fab, .ai-panel,
  .notification-fabs, .notification-panel { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: 100%; }
  .card { border: none; box-shadow: none; padding: 0; }
  .fs-sheet { max-width: 100% !important; }
}

/* ═══ eMAR month grid (mirrors the paper MAR sheet; printable) ═══ */
.emar-sheet { padding: 18px; }
.emar-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; border-bottom: 2px solid #333; padding-bottom: 10px; margin-bottom: 12px; }
.emar-title { text-align: left; }
.emar-meta { display: grid; grid-template-columns: 130px 1fr; gap: 2px 10px; font-size: 12px; margin: 0; max-width: 560px; flex: 1; }
.emar-meta dt { font-weight: 700; }
.emar-meta dd { margin: 0; }
.emar-table-wrap { overflow-x: auto; }
.emar-table { border-collapse: collapse; width: 100%; font-size: 10.5px; }
.emar-table th, .emar-table td { border: 1px solid #bbb; padding: 2px 3px; text-align: center; vertical-align: middle; }
.emar-table thead th { background: #f0f1f5; font-size: 10px; }
.emar-med-cell { text-align: left !important; min-width: 215px; max-width: 250px; vertical-align: top !important; padding: 6px 8px !important; }
.emar-med-name { font-weight: 700; font-size: 11.5px; }
.emar-med-sub { color: #555; font-size: 10px; margin-top: 2px; }
.emar-med-instr { font-size: 9.5px; color: #333; margin-top: 3px; text-transform: uppercase; }
.emar-time-cell { font-weight: 700; white-space: nowrap; font-size: 10.5px; }
.emar-day { min-width: 24px; height: 26px; font-weight: 600; }
.emar-day[data-cell] { cursor: pointer; }
.emar-day[data-cell]:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.emar-day-h { min-width: 24px; }
.emar-today { background: #fff3cd !important; }
.emar-cell-given { background: #e6f7ec; color: #1a7f45; }
.emar-cell-refused { background: #fff4e0; color: #b76e00; }
.emar-cell-held { background: #e8f1fd; color: #2b6cb0; }
.emar-cell-hospital { background: #e8f1fd; color: #2b6cb0; }
.emar-cell-error { background: #fde8f3; color: #a3195b; }
.emar-cell-respite { background: #efe9fb; color: #5b3fa6; }
.emar-cell-dc { color: #c53030; font-weight: 700; font-size: 9px; }
.emar-cell-missed { background: #fde8e8; color: #c53030; }
.emar-cell-x { color: #a7abb8; font-weight: 400; }
.emar-cell-pending { color: #8a8f9c; }
.emar-late { color: #b76e00; font-weight: 700; }
.emar-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: 11.5px; margin-top: 12px; border: 1px solid #ddd; border-radius: 6px; padding: 8px 12px; }
.emar-key { display: inline-block; min-width: 22px; text-align: center; border: 1px solid #ccc; border-radius: 3px; padding: 1px 3px; font-weight: 700; margin-right: 4px; font-size: 10.5px; }
.emar-remarks { margin-top: 14px; font-size: 12.5px; }
.emar-sign-line { border-bottom: 1px solid #999; height: 26px; max-width: 640px; }
.emar-signatures { margin-top: 16px; font-size: 12.5px; }
.emar-mini-table { border-collapse: collapse; width: 100%; max-width: 720px; font-size: 11.5px; margin-top: 6px; }
.emar-mini-table th, .emar-mini-table td { border: 1px solid #ccc; padding: 4px 8px; text-align: left; }
.emar-sign-cell { height: 26px; }
.emar-footnote { margin-top: 16px; font-size: 9.5px; color: #666; border-top: 1px solid #ddd; padding-top: 6px; }
@media print {
  .emar-controls { display: none !important; }
  .emar-sheet { padding: 0; }
  .emar-table { font-size: 8.5px; }
  .emar-table th, .emar-table td { padding: 1px 2px; }
  .emar-med-cell { min-width: 170px; }
  .emar-day[data-cell]:hover { outline: none; }
  .emar-today { background: transparent !important; }
  @page { size: letter landscape; margin: 10mm; }
}

/* Service-code scoping checkbox lists (departments / waivers multi-select)
   v0.4.370 — the 160px cap showed ~6 of 9 departments with NO scroll hint, the
   v0.4.320 clipped-picker shape: a list that looks complete but isn't. Taller
   cap + a persistent scrollbar gutter so the fold is always visible. */
.svc-check-list { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-height: 260px; overflow-y: auto; scrollbar-gutter: stable; display: flex; flex-direction: column; gap: 4px; background: #fff; }
.svc-check { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 400 !important; color: var(--ink) !important; margin: 0 !important; cursor: pointer; }

/* Currency input ($ prefix) */
.rate-input-wrap { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; max-width: 200px; }
.rate-input-wrap .rate-prefix { padding: 8px 0 8px 10px; color: var(--muted); font-weight: 600; }
.rate-input-wrap input { border: none !important; outline: none; flex: 1; padding: 8px 10px 8px 4px; font-size: 13px; min-width: 0; }

/* ================================================================
   Responsive / Mobile (≤768px)
   ================================================================ */

/* Hamburger toggle — hidden on desktop */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--ink);
  padding: 6px;
  line-height: 1;
  flex-shrink: 0;
}

/* Mobile sidebar close control — hidden on desktop */
.sidebar-close { display: none; }

/* Sidebar overlay backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20,25,40,.45);
  z-index: 49;
}

@media (max-width: 768px) {
  /* Show hamburger */
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }

  /* Columns hidden on small screens (e.g. Visits AI Review column) */
  .hide-mobile { display: none; }

  /* Hide sidebar by default on mobile */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }

  /* Show backdrop when sidebar open */
  .sidebar-backdrop.sidebar-backdrop-show {
    display: block;
  }

  /* Main takes full width */
  .main { width: 100%; }

  /* Topbar adjustments */
  .topbar { padding: 8px 12px; gap: 8px; }
  .global-search input { width: 100%; max-width: none; font-size: 14px; padding: 10px 14px; }
  .topbar-right { gap: 10px; }

  /* Hide view-as text on narrow screens — show icon only */
  .view-as label { display: none; }
  .view-as select { font-size: 11.5px; max-width: 120px; }
  .view-as-trigger { max-width: 110px; }
  .view-as-trigger span { font-size: 11.5px; }
  .view-as-trigger small { display: none; }
  .view-as-dialog { max-width: 100vw; }
  .va-list { max-height: 50vh; }
  /* Banner collapses to name + Exit on phones */
  .impersonation-banner { padding: 8px 12px; font-size: 12px; }
  .impersonation-banner small { display: none; }

  /* Hide user name, keep avatar */
  .user-meta { display: none; }

  /* Content padding */
  .content { padding: 14px 12px; }

  /* KPI row: 2 cols */
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* Grid-2: stack */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > * { min-width: 0; }

  /* Page head stack */
  .page-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-head h1 { font-size: 18px; }

  /* Tables: ensure horizontal scroll */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }

  /* =====================================================================
     Document Sign-Off — mobile card layout (v0.4.332)
     The acknowledgement tables (my-day-acknowledgements.ejs) become
     stacked cards on phones: doc name, individual as muted subtext, then
     View (outline) + Sign Off (primary) side by side. Type/Added and the
     doc-cell View/Download links are desktop-only; .ack-view-mobile is
     the phone-side View button (hidden outside this block, see below).
     Everything here is scoped to .ack-wrap — no other table changes.
     The min-width:0 override below is the actual fix for the sideways
     scroll: the global rule above forces 560px on every table.
     ===================================================================== */
  .ack-wrap { overflow-x: visible; }
  .ack-wrap table { min-width: 0; display: block; }
  .ack-wrap thead { display: none; }
  .ack-wrap tbody { display: block; }
  .ack-wrap tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .ack-wrap tr:last-child { border-bottom: none; }
  .ack-wrap td { display: block; padding: 0; border-bottom: none; }
  .ack-wrap td.ack-type, .ack-wrap td.ack-added { display: none; }
  .ack-wrap td.ack-doc strong { font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
  .ack-wrap .ack-file-links { display: none; } /* View becomes a button in the action row */
  .ack-wrap .ack-nofile { margin-top: 4px; }
  .ack-wrap td.ack-ind { margin-top: 2px; font-size: 12.5px; }
  .ack-wrap td.ack-ind a { color: var(--muted); }
  .ack-wrap td.ack-action { margin-top: 12px; text-align: left; display: flex; align-items: stretch; gap: 12px; }
  .ack-wrap td.ack-action form { display: inline-flex; }
  .ack-wrap td.ack-action .btn,
  .ack-view-mobile { display: inline-flex; align-items: center; justify-content: center; }
  /* Recently signed: reference-only — doc name + signed chip */
  .ack-wrap-signed td.ack-ind { display: none; }
  .ack-wrap-signed td.ack-signed { margin-top: 6px; }

  /* Cards */
  .card { padding: 12px; }

  /* Touch targets: bigger buttons/links */
  .btn { padding: 10px 16px; font-size: 14px; min-height: 44px; }
  .nav-item { padding: 12px 14px; font-size: 14px; min-height: 44px; }

  /* Segmented Active/Inactive/All filter: full-width 3-up row so it's obvious on a phone */
  .seg-filter { display: flex; width: 100%; gap: 6px; flex-wrap: nowrap; }
  .seg-filter .btn { flex: 1 1 0; min-width: 0; padding: 10px 6px; white-space: nowrap; }

  /* Filter bar: wrap nicely */
  .filter-bar { gap: 6px; }
  .filter-bar select { font-size: 14px; padding: 8px 10px; min-height: 44px; }

  /* Tabs: scrollable */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; gap: 0; }
  .tab { white-space: nowrap; padding: 10px 14px; flex-shrink: 0; }

  /* Settings layout — minmax(0, …) for the same reason as the base rule above:
     a plain 1fr track is min-content sized and a wide table blows the page out. */
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .subnav { flex-direction: row; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
  .subnav a { padding: 8px 12px; font-size: 12px; }

  /* Kanban: 1 col */
  .kanban { grid-template-columns: 1fr; }

  /* Report grid: 1 col */
  .report-grid { grid-template-columns: 1fr; }

  /* Dialogs: full-width mobile */
  dialog { max-width: 100vw; width: 100vw; margin: 0; border-radius: 12px 12px 0 0; position: fixed; bottom: 0; }

  /* Punch panel: stack */
  .punch-panel { grid-template-columns: 1fr; }

  /* KV detail grid: stack on very narrow */
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 6px; }

  /* Compare boxes: stack */
  .compare { grid-template-columns: 1fr; }

  /* Form designer: stack */
  .fd-layout { grid-template-columns: 1fr; }
  .fd-chat { position: static; max-height: 50vh; }

  /* Bell tray: full-width on mobile */
  .bell-tray { width: calc(100vw - 24px); right: -12px; }

  /* AI panel: full-screen on mobile */
  .ai-panel {
    width: 100vw; height: 100vh;
    max-width: 100vw; max-height: 100vh;
    bottom: 0; right: 0;
    border-radius: 0;
  }
  .notification-fabs { right: 56px; gap: 6px; }
  .notification-fab { width: 38px; height: 38px; }
  .notification-fab-svg { width: 18px; height: 18px; }
  /* Smaller FABs at this width: 24 + 56 + 3x38 + 2x6 = 206px cluster footprint
     (v0.4.542 — 3 FABs now, was 2 at 162px). */
  :root { --fab-gutter: 212px; --fab-safe-bottom: 76px; }

  /* v0.4.498 — a 168px right gutter on a 390px phone leaves ~200px for the
     whole bar and squeezes the Nudge button off-screen. Stack instead: the
     actions get their own full-width row ABOVE the corner cluster, so the
     button stays finger-sized and still never sits under the FABs. The
     bottom spacer below the bar is what keeps this row clear vertically. */
  .bulk-nudge-bar { flex-direction: column; align-items: stretch; padding-right: 14px; }
  .bulk-nudge-actions { justify-content: flex-end; }
  .notification-panel { width: 100vw; max-width: 100vw; max-height: 70vh; bottom: 0; right: 0; border-radius: 14px 14px 0 0; }

  /* eMAR: allow scroll */
  .emar-head { flex-direction: column; gap: 8px; }

  /* To-do add form: stack */
  .todo-add-form { flex-direction: column; align-items: stretch; }
  .todo-input { min-width: auto; }
  .todo-date-input, .todo-assignee-picker { width: 100%; }
  /* Bulk target controls go full width; a native multi-select is fine on iOS. */
  .todo-target-modes, .todo-dept-target { width: 100%; }
  .todo-dept-target select { width: 100%; }

  /* To-Do hero on mobile: first card after the KPIs, single column,
     full-width rows with 44px touch targets. */
  .todo-hero { padding: 14px; }
  .todo-hero .todo-head h2 { font-size: 18px; }
  .todo-count { font-size: 15px; }
  .todo-hero .todo-row { padding: 12px 6px; }
  .todo-hero .todo-check, .todo-hero .todo-del { min-width: 44px; min-height: 44px; }
  .todo-hero .todo-body { font-size: 15px; }

  /* Searchable picker */
  .searchable-picker select { max-height: 150px; }

  /* Sidebar close button */
  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    background: rgba(255,255,255,.15);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    z-index: 51;
  }
  .sidebar-close:hover { background: rgba(255,255,255,.25); }
}

/* Extra narrow: single-column KPIs */
@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr; }
  .kpi .kpi-value { font-size: 20px; }
  .topbar { flex-wrap: wrap; }
  .global-search { order: 2; width: 100%; }
  .fa-assign-row { flex-direction: column; }
  .fd-save-fields { grid-template-columns: 1fr; }
  .fs-meta { grid-template-columns: 1fr; }
}

/* ═══ Schedule Quick Entry (desktop-only bulk grid) ═══ */
.qe-wrap { max-height: 62vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.qe-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.qe-table thead th { position: sticky; top: 0; background: #f7f8fb; z-index: 2; padding: 7px 8px; text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: #667; border-bottom: 1px solid var(--line); }
.qe-table td { border-bottom: 1px solid #eef0f4; padding: 2px 4px; vertical-align: middle; height: 32px; }
.qe-rownum { color: #99a; font-size: 11px; text-align: right; padding-right: 8px !important; }
.qe-cell input { width: 100%; border: 1px solid transparent; border-radius: 6px; padding: 5px 6px; font-size: 12.5px; font-family: inherit; background: transparent; }
.qe-cell input:focus { border-color: var(--primary); background: #fff; outline: none; }
.qe-cell-bad input { background: #fde8e8; border-color: #f5b5b5; }
.qe-cell-multi input { background: #fdf3dc; }
.qe-chip { display: inline-block; font-size: 10.5px; background: #e6f4ea; color: #1e7b34; border-radius: 10px; padding: 1px 7px; margin-top: 1px; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
/* v0.4.653 — a DERIVED date (blank Date cell + a Repeat pattern naming
   weekdays) must never look like a typed one: amber, dashed, and labelled
   "(assumed)" in the chip text itself. */
/* max-width is raised above .qe-chip's 150px on purpose: at 150px the
   ellipsis eats the "(assumed)" suffix — i.e. exactly the marker this chip
   exists to show. */
.qe-chip-assumed { background: #fdf3d7; color: #8a6d0b; border: 1px dashed #d69e2e; max-width: 200px; }
.qe-cellwarn { color: #d69e2e; font-size: 12px; margin-left: 3px; cursor: help; }
.qe-pick { display: block; width: 100%; font-size: 11.5px; margin-top: 2px; padding: 2px; border: 1px solid #EBD3A6; border-radius: 6px; background: #fffbeb; }
/* v0.4.657 — this select is showing ONLY the individual's active
   authorizations. Visible without a hover tooltip, which touch devices never
   show, and it still reads as a pick after one is chosen. */
.qe-pick-auth { border-color: #c7d0f5; background: #f4f6ff; color: #33408f; }
tr.qe-err td { background: #fff5f5; }
tr.qe-warn td { background: #fffcf2; }
tr.qe-locked td { background: #f2faf4; }
tr.qe-locked input { color: #789; }
.qe-result { font-size: 11px; max-width: 260px; }
.qe-msg { display: block; line-height: 1.35; }
.qe-msg-err { color: #c53030; }
.qe-msg-warn { color: #975a16; }
.qe-actionbar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; padding-right: var(--fab-gutter); margin-top: 12px; box-shadow: 0 -2px 10px rgba(0,0,0,.04); flex-wrap: wrap; }
@media (max-width: 768px) {
  .qe-mobile-card { display: block !important; }
  #quick-entry-root { display: none; }
}

/* --- Outcome data points (v0.4.152): three counts + N/A ------------------- */
/* Replaces the old data-point dropdown + frequency + two checkboxes. Inputs
   stay >=44px tall so they are usable on a phone in the field. */
.oc-datarow { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin: 8px 0; }
.oc-numlabel { font-size: 12px; font-weight: 600; color: var(--muted); display: block; }
.oc-numlabel input { display: block; margin-top: 3px; width: 78px; min-height: 44px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; font-family: inherit; }
.oc-numlabel input:disabled { background: #f2f3f6; color: #9aa3af; }
.oc-nalabel { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; min-height: 44px; margin-left: auto; padding: 0 4px; white-space: nowrap; }
.oc-nalabel input { width: 18px; height: 18px; }
.doc-outcome.oc-na-on .oc-numlabel { opacity: .55; }
@media (max-width: 768px) {
  .oc-datarow { gap: 10px; }
  .oc-numlabel { flex: 1 1 30%; }
  .oc-numlabel input { width: 100%; }
  .oc-nalabel { margin-left: 0; flex: 1 1 100%; }
}

/* ═══ Multi-party form signatures (v0.4.163) ═══
   Global (not scoped to the fill/sign pages) because the status chips also
   render on the form template detail submissions list. */
  /* Multi-party signature surfaces (v0.4.163) */
  .ff-sig-pending {
    background: var(--bg-subtle, #f3f4f6);
    border: 1px dashed var(--line, #cbd5e1);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-muted, #555);
  }
  .ff-field.ff-sign-target {
    background: var(--ok-bg, #f0fdf4);
    border: 1px solid var(--ok, #16a34a);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 10px 0;
  }
  .sig-strip { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0; }
  .sig-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
  .sig-row .sig-what { font-weight: 600; }
  .sig-chip { font-size: 11px; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--line, #e5e7eb); }
  .sig-chip-signed { background: var(--ok-bg, #f0fdf4); border-color: var(--ok, #16a34a); }
  .sig-chip-pending { background: #fffbeb; border-color: #f59e0b; }
  .sig-chip-declined { background: var(--danger-bg, #fef2f2); border-color: var(--danger, #dc2626); }
  .sig-unsigned-banner {
    border: 2px solid var(--danger, #dc2626);
    background: var(--danger-bg, #fef2f2);
    color: var(--danger, #b91c1c);
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
  }
  @media (max-width: 768px) {
    .ff-sig-canvas { width: 100%; height: 180px; }
    .sig-actionbar .btn { flex: 1 1 auto; min-height: 44px; }
  }
  .sig-actionbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }

/* ═══════════════════════════════════════════════════════════════════════════
   Sticky table headers + client-side table search  (v0.4.535, Todoist 6hWcchjmJR6FJH9H)
   Nick: "Freeze the header row for when I scroll so i can see what I am looking
   at when scrolling. And add a search bar to filter services."
   Answers: 1. "The whole headers."  2. freeze the Code column too — "Sure!"
            3. match departments/waivers/modifiers too — "Sure!"

   🩸 THE THREE THINGS THAT MAKE position:sticky SILENTLY DO NOTHING HERE, and
   why each line below exists. Do not "simplify" any of them.

   1. `table { overflow: hidden }` (line ~95, for the rounded corners) is an
      ANCESTOR overflow on the sticky element's scroll container. Any ancestor
      with overflow other than `visible` clips a sticky child, so the header
      would simply never pin. `.table-sticky-head` resets it to `visible` and
      restores the rounded corners on `.table-wrap` instead (which needs its own
      `overflow: hidden` to clip — but it is ALSO the horizontal scroller, so it
      must stay `auto`; the radius is therefore carried by the wrap's border and
      the first/last header cells).
   2. 🩸 `.table-wrap { overflow-x: auto }` MAKES THE WRAP THE SCROLL CONTAINER
      IN BOTH AXES. Per spec, any non-`visible` overflow on one axis computes
      the other axis to `auto` too, so the wrap — not the window — is the
      nearest scrollport for the sticky header. v0.4.535 assumed the page
      scrolled in the window and set `top: <topbar height>`: the wrap never
      scrolls vertically (its height is its content), so the header NEVER
      pinned, and the 53px offset shoved the header row DOWN over the first
      data row (Nick, 2026-09-17: "the header is blocking the 1st service …
      the header isn't sticking when I scroll"). The fix (v0.4.563) makes the
      wrap a REAL vertical scroller — `.table-wrap-sticky` caps it at the
      viewport minus the chrome (`--sticky-table-top`, measured by
      table-tools.js from the topbar + impersonation banner) — and pins the
      header at `top: 0` OF THE WRAP. Both sticky axes now share one scroll
      container, which is the only configuration in which both can work. Same
      shape as `.qe-wrap` / `.qe-table thead th` above, which has always worked.
      table-tools.js adds `.table-wrap-sticky` to the wrap around any
      `.table-sticky-head` table, so other tables still opt in with markup only;
      the `:has()` rule is the no-JS twin.
   3. `border-collapse: collapse` drops the borders on a sticky row in WebKit
      and Chrome (the border belongs to the collapsed grid, which does not move
      with the cell). Hence `separate` + `border-spacing: 0` and borders drawn
      with box-shadow on the sticky cells.

   z-index ladder inside the table: sticky corner cell (3) > sticky header row
   and sticky first column (2) > ordinary cells (auto). All BELOW .topbar (20).
   ═══════════════════════════════════════════════════════════════════════════ */
.table-sticky-head { border-collapse: separate; border-spacing: 0; overflow: visible; }
/* The wrap is the scroll container for BOTH axes (see 2. above). Cap it so it
   actually scrolls vertically; 40px of slack keeps its bottom edge + horizontal
   scrollbar on screen once the page is scrolled to it. */
.table-wrap-sticky,
.table-wrap:has(> .table-sticky-head) {
  overflow: auto;
  max-height: calc(100vh - var(--sticky-table-top, 0px) - 40px);
}
.table-sticky-head th,
.table-sticky-head td { border-bottom: none; box-shadow: inset 0 -1px 0 var(--line); }
.table-sticky-head tr:last-child td { box-shadow: none; }
.table-sticky-head thead th {
  position: -webkit-sticky;
  position: sticky;
  top: 0;                           /* of the WRAP, which is the scrollport — never the topbar offset */
  z-index: 2;
  background: #FAFBFD;              /* MUST be solid — rows scroll underneath */
  box-shadow: inset 0 -1px 0 var(--line), 0 2px 4px rgba(16, 24, 40, .06);
}
/* Freeze the identity column while scrolling right (Nick answer 2). Opt-in per
   table via `.table-sticky-first` so a table whose first column is a checkbox
   or an avatar does not get it by accident. */
.table-sticky-first tbody td:first-child,
.table-sticky-first thead th:first-child {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  background: var(--card);
  box-shadow: inset 0 -1px 0 var(--line), 2px 0 4px rgba(16, 24, 40, .06);
}
.table-sticky-first thead th:first-child {
  z-index: 3;                        /* the corner outranks both sticky axes */
  background: #FAFBFD;
  box-shadow: inset 0 -1px 0 var(--line), 2px 0 4px rgba(16, 24, 40, .06), 0 2px 4px rgba(16, 24, 40, .06);
}
.table-sticky-first tbody tr:last-child td:first-child { box-shadow: 2px 0 4px rgba(16, 24, 40, .06); }

/* Visually-hidden label text (the search box shows a placeholder + icon only). */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Search bar above a filterable table */
.table-search { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.table-search-box { position: relative; display: flex; align-items: center; }
.table-search-box .table-search-icon { position: absolute; left: 11px; font-size: 13px; color: var(--muted); pointer-events: none; }
.table-search-box input {
  padding: 8px 12px 8px 30px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); font-size: 13px; width: 300px; max-width: 60vw;
}
.table-search-box input:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.table-search-count { font-size: 12.5px; color: var(--muted); }
.table-search-clear { font-size: 12.5px; background: none; border: none; color: var(--primary); cursor: pointer; padding: 2px 4px; }
.table-search-clear[hidden] { display: none; }
.table-search-empty td { text-align: center; color: var(--muted); padding: 22px 12px; font-style: italic; }

/* A printed table must NOT pin anything: a sticky row repeats or clips on paper. */
@media print {
  .table-search { display: none !important; }
  .table-sticky-head thead th,
  .table-sticky-first tbody td:first-child,
  .table-sticky-first thead th:first-child { position: static !important; box-shadow: none !important; }
  .table-sticky-head th, .table-sticky-head td { border-bottom: 1px solid var(--line); box-shadow: none !important; }
}
