/* ──────────────────────────────────────────────────────────────────────────
   Mantle theme — shared stylesheet for every page using base_mantle.html.

   Two themes (Linen / Graphite), driven by `html[data-theme="..."]`.
   Graphite (warm-dark) is the default; users can toggle in the sidebar.
   Active choice persists to localStorage + (when logged in) to User.theme
   via POST /api/theme.

   Source of truth: design_handoff_mantle_redesign/source/ui-primitives.jsx
   ────────────────────────────────────────────────────────────────────────── */

/* ── THEMES ──────────────────────────────────────────────────────────────── */
html[data-theme="graphite"] {
  color-scheme: dark;
  --bg:          #16140F;
  --surface:     #1C1A14;
  --surface2:    #23201A;
  --elev:        #2B2820;
  --rule:        rgba(245,235,215,0.08);
  --ruleStrong:  rgba(245,235,215,0.16);
  --ink:         #F2ECDD;
  --ink2:        #D8D0BC;
  /* --muted + --faint bumped 5 Jun 2026 after Lighthouse flagged 11 low-contrast
     elements (nav-group-title, tt-blurb, tt-stat, kbd, etc). Old values
     (#8C8676 / #5F5A4F) failed WCAG AA against the dark --bg. New values keep
     the same visual hierarchy (clearly muted vs primary) but cross 4.5:1. */
  --muted:       #A39C8A;
  --faint:       #8C8676;
  --accent:      #C9D6A8;    /* pale moss */
  --accentSoft:  #2A2E20;
  --accentInk:   #E6EED1;
  --warn:        #E6B86A;
  --warnSoft:    #33291A;
  --danger:      #E0846B;
  --dangerSoft:  #33201B;
  --good:        #9FC09F;
  --goodSoft:    #1F2A20;
  --info:        #A9BBD4;
  --infoSoft:    #1F2530;
  --plum:        #BBA9DC;
  --plumSoft:    #2A2436;
  --chipBg:      rgba(245,235,215,0.06);
  --chipInk:     #D8D0BC;
  --grid:        rgba(245,235,215,0.025);
}
html[data-theme="linen"] {
  color-scheme: light;
  --bg:          #F6F2EA;
  --surface:     #FBF8F2;
  --surface2:    #F1ECE1;
  --elev:        #FFFFFF;
  --rule:        rgba(46,36,24,0.35);
  --ruleStrong:  rgba(46,36,24,0.45);
  --ink:         #1B1A17;
  --ink2:        #3A372F;
  /* 19 Jun 2026 — WCAG AA contrast bump (audit 8). Previous Linen tokens
     failed AA at 4.5:1 across --muted, --faint, --warn on the warm beige
     surfaces. Graphite was bumped 5 Jun; Linen was missed. New values
     verified to clear 4.5:1 against --bg (#F6F2EA) and --surface (#FBF8F2). */
  --muted:       #6E6860;    /* was #7A746A — bumped for 4.5:1 on bg/surface */
  --faint:       #666058;    /* was #7A746A — bumped for 5.86:1, clears AA for small text */
  --accent:      #3F5A45;    /* sage */
  --accentSoft:  #E9EFE7;
  --accentInk:   #2A3D2E;
  --warn:        #8B5F19;    /* amber-ink — was #9B6B1F, bumped for 4.5:1 on bg */
  --warnSoft:    #F4EBD6;
  --danger:      #A24932;    /* terracotta */
  --dangerSoft:  #F2DFD7;
  --good:        #3D6B4A;
  --goodSoft:    #DEE8DE;
  --info:        #3F5878;
  --infoSoft:    #DBE3EB;
  --plum:        #7A5E96;
  --plumSoft:    #EDE6F4;
  --chipBg:      rgba(46,36,24,0.05);
  --chipInk:     #3A372F;
  --grid:        rgba(46,36,24,0.04);
}

/* ── RESET + BODY ────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: 'Inter Tight', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px; line-height: 1.5;
  font-feature-settings: "ss01", "ss02";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  transition: background .2s, color .2s;
}
a { color: inherit; }
button { font-family: inherit; }

/* ── Cursor hygiene ──────────────────────────────────────────────────────────
   Browsers default the mouse cursor to a text I-beam over selectable text,
   which on a read/click surface like Mantle looks like a stray caret sitting
   next to headings and body copy (Finn flagged 23 Jun 2026). Force the arrow
   cursor at the root and re-enable the I-beam only where typing actually
   happens. Buttons and links already set `cursor: pointer` explicitly across
   the codebase, so they're unaffected. */
html { cursor: default; }
/* Kill the caret browser-wide. Caret browsing (F7 on Chrome/Edge) was
   painting a vertical bar next to whatever text Finn was hovering over,
   on every page. We hide it on the document by default, then re-enable
   it only on real editable surfaces below. 24 Jun 2026. */
html, body { caret-color: transparent; }
input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="number"], input[type="date"],
input[type="tel"], input[type="url"], input[type="datetime-local"],
input[type="time"], input[type="month"], input[type="week"],
input:not([type]), textarea,
[contenteditable="true"], [contenteditable=""] {
  cursor: text;
  caret-color: auto;
}

/* ── Form inputs — global Mantle defaults ───────────────────────────────────
   Without these, raw <input> / <select> / <textarea> elements on pages we
   haven't fully redesigned fall through to browser-default chrome which
   looks awful on Mantle's warm-dark Graphite + sage palette. These base
   rules give every form field a sensible look even when the page-level
   styling hasn't been ported yet. Pages with their own input classes
   (login.html, new_client.html, client_profile_form.html) already win on
   specificity, so this doesn't disturb them. */
input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="number"], input[type="date"],
input[type="tel"], input[type="url"], input:not([type]),
select, textarea {
  /* surface2 sits a half-step above the card surface so the input always
     announces itself visually — regardless of whether it's on the page bg
     or inside a card. Was --bg, which made inputs invisible against any
     card surface (the caret appeared to float on an unmarked rectangle).
     19 Jun 2026. */
  background: var(--surface2);
  color: var(--ink);
  border: 1px solid var(--ruleStrong);
  border-radius: 6px;
  padding: 7px 11px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  outline: none;
  transition: border-color .12s, box-shadow .12s, background .12s;
  -webkit-appearance: none;
  appearance: none;
  /* Lock text + caret to the left edge (Finn saw blinking carets land
     on the right of empty inputs across the app — 22 Jun 2026). Some
     ancestor templates were leaking text-align: right / direction: rtl
     into inputs. Both ride defensively on every form field here. */
  text-align: left;
  direction: ltr;
}
/* Kill the residual right-edge decorations Chrome paints on
   <input type="search"> (the empty-state grey sliver + the
   results-button capsule). Applies to every search input across
   Mantle. 22 Jun 2026. */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="search"]:focus, input[type="number"]:focus, input[type="date"]:focus,
input[type="tel"]:focus, input[type="url"]:focus, input:not([type]):focus,
select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accentSoft);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%238C8676' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><path d='m3 6 5 5 5-5'/></svg>") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  padding-right: 30px;
}
/* Linen override — #5D5750 reads at 6.05:1 on Linen surface2 vs #8C8676 which
   is only 2.80:1 on the warm-beige background. */
html[data-theme="linen"] select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%235D5750' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><path d='m3 6 5 5 5-5'/></svg>") !important;
}
option {
  background-color: var(--surface);
  color: var(--ink);
}
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
input[type="file"] {
  background: transparent;
  color: var(--ink2);
  font-size: 12px;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
  cursor: pointer;
}

/* Scrollbars — thin, warm-toned, NO up/down arrow buttons.
   The OS-default scrollbar buttons look cheap on small textareas (visible
   stacked next to the mic in the Edit-with-AI chat). Hidden globally. */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.28);
  border-radius: 999px;
  transition: background 0.15s;
}
::-webkit-scrollbar-thumb:hover { background: rgba(128, 128, 128, 0.45); }
::-webkit-scrollbar-button { display: none; height: 0; width: 0; }
::-webkit-scrollbar-corner { background: transparent; }
/* Firefox */
* { scrollbar-width: thin; scrollbar-color: rgba(128, 128, 128, 0.28) transparent; }
label { color: var(--ink2); font-size: 12px; }
fieldset { border: 1px solid var(--rule); border-radius: 8px; padding: 12px 14px; }
legend { color: var(--muted); font-size: 11px; padding: 0 6px; }

/* Buttons without any class — give them Mantle look so legacy form buttons
   (Save Notes, Save Address, family-row edit, etc.) don't fall through to
   browser-default white-on-black chrome. Pages with .btn-primary /
   .btn-ghost / .checkin-btn / .signin-btn already win on specificity. */
button:not([class]):not([data-mantle-skip]) {
  background: var(--surface2);
  color: var(--ink2);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
button:not([class]):not([data-mantle-skip]):hover {
  background: var(--surface);
  border-color: var(--ruleStrong);
  color: var(--ink);
}
button:not([class]):not([data-mantle-skip]):disabled {
  opacity: 0.5; cursor: not-allowed;
}

/* Headings inside tab content that haven't been wrapped in a card —
   gives section labels like "People", "Family", "Policies" a Mantle look. */
.tab-content h2, .tab-content h3, .tab-content h4 {
  margin: 0 0 8px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.1px;
}
.tab-content h2 { font-size: 16px; }
.tab-content h3 { font-size: 14px; }
.tab-content h4 { font-size: 12.5px; color: var(--ink2); }

/* Unclassed links inside tab content — accent colour instead of browser blue. */
.tab-content a:not([class]):not([role="button"]) {
  color: var(--accent);
  text-decoration: none;
}
.tab-content a:not([class]):not([role="button"]):hover {
  text-decoration: underline;
}

/* Radio + checkbox bubbles — accent-coloured native widget on a sized box. */
input[type="radio"], input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px; height: 14px;
  vertical-align: middle;
  cursor: pointer;
}

/* ── Utility classes carried over from Tailwind ──────────────────────────
   Lots of legacy JS toggles these. Keeping them so ported pages don't
   silently break when scripts add/remove them. */
.hidden { display: none !important; }
.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;
}

/* Font helpers
   .mono used to be JetBrains Mono — switched 11 Jun 2026 (Variant 2 from the
   /font-preview page) to Inter Tight with tabular-nums so digit columns still
   line up but the page no longer mixes three typefaces in one strip. */
.serif { font-family: 'Newsreader', Georgia, serif; }
.mono  { font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "cv11"; }

/* ── APP FRAME ───────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

/* Global footer — Privacy / Terms / copyright. Lives inside .app-main so
   it scrolls with content (sidenav is fixed). 22 Jun 2026. */
.mantle-footer {
  margin-top: auto;
  padding: 22px 32px 26px;
  border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-size: 11.5px; color: var(--faint); line-height: 1.5;
}
.mantle-footer a {
  color: var(--muted); text-decoration: none; padding: 2px 0;
  border-bottom: 1px solid transparent;
  transition: color .12s, border-color .12s;
}
.mantle-footer a:hover { color: var(--ink); border-color: var(--accent); }
.mantle-footer-sep   { color: var(--faint); opacity: 0.6; }
.mantle-footer-brand { color: var(--muted); font-weight: 500; }
.mantle-footer-copy  { color: var(--faint); margin-left: auto; }

/* ── SIDE NAV ────────────────────────────────────────────────────────────── */
.sidenav {
  width: 200px; flex: 0 0 200px;
  border-right: 1px solid var(--rule);
  background: var(--surface);
  padding: 16px 12px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; align-self: flex-start;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-tile {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text .name {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 22px; font-weight: 400; color: var(--ink);
  letter-spacing: -0.6px;
}

.nav-group { margin-bottom: 14px; }
.nav-group-title {
  font-size: 9.5px; font-weight: 500; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--faint);
  padding: 6px 10px 4px;
}
.nav-list { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  border-radius: 6px; font-size: 12.5px; color: var(--ink2);
  font-weight: 450; cursor: pointer; text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--ink); }
.nav-item.active { color: var(--ink); background: var(--surface2); font-weight: 500; }
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px;
  width: 2px; background: var(--accent); border-radius: 1px;
}
.nav-item .nav-icon { color: var(--muted); flex-shrink: 0; }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-item .nav-label { flex: 1; }
.nav-item .nav-count {
  font-size: 10.5px; color: var(--muted);
  font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums;
}
.sidenav-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

/* Theme toggle (segmented control at bottom of sidebar) */
.theme-toggle {
  display: flex; align-items: center;
  background: var(--surface2); border: 1px solid var(--rule);
  border-radius: 6px; padding: 2px;
}
.theme-toggle button {
  flex: 1; padding: 6px 8px; border: none; cursor: pointer;
  background: transparent; color: var(--muted);
  font-family: inherit; font-size: 11.5px; font-weight: 450;
  border-radius: 4px; letter-spacing: 0.1px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: background .12s, color .12s;
}
.theme-toggle button.active {
  background: var(--elev); color: var(--ink); font-weight: 500;
  box-shadow: 0 1px 0 var(--ruleStrong);
}
.theme-toggle .swatch {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  border: 1px solid var(--ruleStrong);
}
.theme-toggle .swatch.linen    { background: #F6F2EA; }
.theme-toggle .swatch.graphite { background: #16140F; }
/* Audit 30 Jun 2026 — on Graphite theme the dark Graphite swatch sat on a
   dark elev background with a 16%-opacity border, rendering near-invisible
   so the active-theme dot looked missing. Bump the border opacity per-theme
   so both dots stay legible on whichever background they land on. */
html[data-theme="graphite"] .theme-toggle .swatch { border-color: rgba(245,235,215,0.55); }
html[data-theme="linen"]    .theme-toggle .swatch { border-color: rgba(46,36,24,0.55); }

/* Admin Centre link in sidenav footer — master-admin only (18 Jun 2026).
   Visual signal: subtler than a nav item, sits between the theme toggle
   and the user strip. */
.sidenav-admin-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 6px;
  font-family: inherit; font-size: 12px; color: var(--muted);
  text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
}
.sidenav-admin-link:hover { background: var(--surface2); color: var(--ink); border-color: var(--rule); }
.sidenav-admin-link.active { background: var(--accentSoft); color: var(--accentInk); border-color: var(--accent); }
.sidenav-admin-link svg { flex-shrink: 0; opacity: 0.85; }

/* Sign-out button (always-visible in sidenav footer, 22 Jun 2026)
   One-click logout from every authenticated page — see ruling §"Navigation
   & orientation". Form-POST under the hood so CSRF stays enforced. */
.sidenav-signout-form { margin: 0 0 8px; padding: 0; }
.sidenav-signout-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 7px 10px; border-radius: 6px;
  font-family: inherit; font-size: 12px; color: var(--muted);
  background: transparent; border: 1px solid transparent;
  text-align: left; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.sidenav-signout-btn:hover { background: var(--dangerSoft); color: var(--danger); border-color: var(--danger); }
.sidenav-signout-btn svg { flex-shrink: 0; opacity: 0.85; }

/* User strip (bottom of sidebar) — popover menu added 5 Jun 2026 */
.user-strip { border-top: 1px solid var(--rule); padding-top: 12px; position: relative; }
.user-strip-inner {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--rule);
  transition: background .15s, border-color .15s;
  /* button reset so the strip can act as a menu trigger */
  width: 100%; font-family: inherit; font-size: inherit; color: inherit;
  text-align: left; cursor: pointer;
}
.user-strip-inner:hover { background: var(--elev); border-color: var(--ruleStrong); }
.user-strip.open .user-strip-inner { background: var(--elev); border-color: var(--ruleStrong); }
.user-strip-chev {
  flex-shrink: 0; color: var(--muted);
  transition: transform .15s, color .12s;
}
.user-strip-inner:hover .user-strip-chev { color: var(--ink); }
.user-strip.open .user-strip-chev { transform: rotate(180deg); color: var(--ink); }

/* Popover menu — sits ABOVE the strip (anchors to .user-strip's bottom) */
.user-strip-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--ruleStrong);
  border-radius: 10px; box-shadow: 0 12px 28px -8px rgba(0,0,0,0.35);
  padding: 4px; display: none; flex-direction: column; gap: 2px; z-index: 50;
}
.user-strip.open .user-strip-menu { display: flex; }
.user-strip-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 12.5px; color: var(--ink); text-decoration: none;
  font-weight: 500; letter-spacing: -0.1px;
  transition: background .1s, color .1s;
}
.user-strip-menu-item:hover { background: var(--surface2); }
.user-strip-menu-item svg { color: var(--muted); flex-shrink: 0; }
.user-strip-menu-item:hover svg { color: var(--ink); }
.user-strip-menu-item-danger { color: var(--danger); }
.user-strip-menu-item-danger svg { color: var(--danger); opacity: 0.8; }
.user-strip-menu-item-danger:hover { background: var(--dangerSoft); }
.user-strip-menu-item-danger:hover svg { opacity: 1; }
.user-strip-inner .avatar {
  width: 30px; height: 30px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.4px;
  background: var(--accentSoft); color: var(--accentInk);
  border: 1px solid var(--ruleStrong);
}
.user-strip-name {
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.1px;
}
.user-strip-sub {
  font-size: 10.5px; color: var(--muted); font-weight: 450;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-strip-logout {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  color: var(--muted); text-decoration: none;
  border: 1px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
}
.user-strip-logout:hover {
  color: var(--ink); background: var(--surface);
  border-color: var(--rule);
}

/* ── AVATAR ──────────────────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 500; letter-spacing: 0.5px; flex: 0 0 auto;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10px; background: var(--accentSoft); color: var(--accentInk); }
.avatar-md { width: 28px; height: 28px; font-size: 10.5px; background: var(--chipBg); color: var(--ink2); }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn-ghost, .btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; font-size: 12px; border-radius: 5px;
  cursor: pointer; font-family: inherit; text-decoration: none;
  line-height: 1.4;
}
.btn-ghost {
  background: transparent; color: var(--ink2);
  border: 1px solid var(--rule); font-weight: 450;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ruleStrong); }
.btn-primary {
  background: var(--accent); color: var(--surface);
  border: 1px solid var(--accent); font-weight: 500;
}
.btn-primary:hover { opacity: 0.92; }

/* ── PILLS ───────────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 500; line-height: 1.4;
  letter-spacing: 0.1px;
}
.pill-neutral { background: var(--chipBg);    color: var(--chipInk);   }
.pill-accent  { background: var(--accentSoft); color: var(--accentInk); }
.pill-warn    { background: var(--warnSoft);   color: var(--warn);      }
.pill-danger  { background: var(--dangerSoft); color: var(--danger);    }
.pill-good    { background: var(--goodSoft);   color: var(--good);      }
.pill-info    { background: var(--infoSoft);   color: var(--info);      }
.pill-plum    { background: var(--plumSoft);   color: var(--plum);      }
.pill .disc { display: inline-block; width: 5px; height: 5px; border-radius: 50%; }
.pill .disc.good   { background: var(--good); }
.pill .disc.warn   { background: var(--warn); }
.pill .disc.danger { background: var(--danger); }
.pill .disc.info   { background: var(--info); }
.pill.mono { font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: 0; }

/* ── EYEBROW (small all-caps label) ─────────────────────────────────────── */
.eyebrow {
  font-size: 10px; font-weight: 500; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: baseline; justify-content: space-between;
}
.eyebrow > span:last-child { color: var(--faint); letter-spacing: 0.4px; }

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px;
}

/* Card variants used by the client detail page (referenced in client.html) */
.mantle-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
}
.mantle-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mantle-card-header h2, .mantle-card-header h3 {
  margin: 0;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.2px;
}
.mantle-card-body { padding: 14px 18px; }

/* ── TOP UTILITY BAR (search + actions, used on Home) ───────────────────── */
.top-util {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 40px; border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.search-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--rule); border-radius: 6px;
  padding: 6px 10px; width: 320px; color: var(--muted); font-size: 12px;
}
.search-pill .grow { flex: 1; }
.kbd {
  font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums;
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
  background: var(--chipBg); color: var(--faint);
}

/* ── HOME HEADER (greeting + date) ──────────────────────────────────────── */
.home-header { padding: 32px 40px 0; display: flex; flex-direction: column; gap: 4px; }
.home-date {
  font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums;
  font-size: 10.5px; color: var(--muted);
  letter-spacing: 1.4px; text-transform: uppercase;
}
.home-greeting { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.home-greeting .pre { font-size: 28px; color: var(--ink2); font-weight: 300; letter-spacing: -0.5px; }
.home-greeting h1 {
  margin: 0; font-family: 'Newsreader', Georgia, serif;
  font-size: 34px; font-weight: 400; color: var(--ink);
  letter-spacing: -0.7px; line-height: 1;
}
.home-blurb {
  margin: 10px 0 0; font-size: 13.5px; color: var(--muted);
  max-width: 560px; line-height: 1.55;
}

/* ── TOOL GRID + TILES ──────────────────────────────────────────────────── */
.tool-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
.tool-tile {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
  padding: 20px 22px 18px;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 168px; cursor: pointer; position: relative;
  transition: border-color .12s, background .12s;
  text-decoration: none; color: inherit;
}
.tool-tile:hover { border-color: var(--ruleStrong); }
.tool-tile.muted { opacity: 0.78; cursor: default; }
.tool-tile.muted:hover { border-color: var(--rule); }

.tool-tile .tt-head { display: flex; align-items: flex-start; justify-content: space-between; }
.tool-tile .tt-icon {
  width: 38px; height: 38px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.tool-tile .tt-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--warn); margin-top: 4px;
}

.tool-tile .tt-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.tool-tile .tt-title { font-size: 15px; font-weight: 500; color: var(--ink); letter-spacing: -0.15px; }
.tool-tile .tt-blurb { font-size: 12px; color: var(--muted); line-height: 1.45; }

.tool-tile .tt-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid var(--rule);
}
.tool-tile .tt-stat {
  font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums;
  font-size: 11px; color: var(--ink2); letter-spacing: 0.1px;
}
.tool-tile.muted .tt-stat { color: var(--faint); }
.tool-tile .tt-soon {
  font-size: 9.5px; color: var(--faint); letter-spacing: 1.2px;
  text-transform: uppercase;
}

/* Tool-tile icon-box tone variants — must match `tone` value passed in */
.tt-icon.tone-accent { background: var(--accentSoft); color: var(--accent); }
.tt-icon.tone-warn   { background: var(--warnSoft);   color: var(--warn);   }
.tt-icon.tone-danger { background: var(--dangerSoft); color: var(--danger); }
.tt-icon.tone-good   { background: var(--goodSoft);   color: var(--good);   }
.tt-icon.tone-info   { background: var(--infoSoft);   color: var(--info);   }
.tt-icon.tone-plum   { background: var(--plumSoft);   color: var(--plum);   }

/* ── RECENT STRIP (Last viewed bar at bottom of Home) ───────────────────── */
.recent-strip {
  padding: 0 40px; display: flex; align-items: stretch; gap: 0;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.recent-strip .rs-label {
  flex: 0 0 auto; padding: 14px 18px 14px 0;
  display: flex; align-items: center; gap: 8px;
  border-right: 1px solid var(--rule); margin-right: 8px;
  font-size: 9.5px; font-weight: 500; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--faint);
}
.recent-strip .rs-item {
  flex: 1; padding: 12px 18px; display: flex; align-items: center; gap: 12px;
  border-right: 1px solid var(--rule);
  cursor: pointer; min-width: 0; text-decoration: none; color: inherit;
}
.recent-strip .rs-item:last-of-type { border-right: none; }
.recent-strip .rs-item:hover { background: var(--surface2); }
.recent-strip .rs-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.recent-strip .rs-name {
  font-size: 12.5px; color: var(--ink); font-weight: 500; letter-spacing: -0.1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent-strip .rs-sub {
  font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent-strip .rs-all {
  flex: 0 0 auto; padding: 12px 0 12px 18px;
  display: flex; align-items: center;
  border-left: 1px solid var(--rule);
}
.recent-strip .rs-all a {
  color: var(--muted); font-size: 11.5px; letter-spacing: 0.2px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.recent-strip .rs-all a:hover { color: var(--ink); }

/* ── FOOTER META LINE ───────────────────────────────────────────────────── */
.meta-line {
  padding: 14px 40px; display: flex; align-items: center; gap: 18px;
  font-size: 11px; color: var(--muted);
}
.meta-line .spacer { flex: 1; }
.meta-line .ok-dot {
  display: inline-flex; align-items: center; gap: 5px;
}
.meta-line .ok-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good);
}

/* ── CLIENTS LIST — top header ──────────────────────────────────────────── */
.page-header {
  padding: 22px 40px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--rule); background: var(--surface);
}
.page-header h1 {
  margin: 0; font-family: 'Newsreader', Georgia, serif;
  font-size: 30px; font-weight: 400; color: var(--ink);
  letter-spacing: -0.6px; line-height: 1;
}
.page-header .sub {
  font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--muted); letter-spacing: 0.2px;
}
.page-header .title-row { display: flex; align-items: baseline; gap: 14px; }
.page-header .actions { display: flex; align-items: center; gap: 8px; }

/* ── ATTENTION RAIL (3 stacks above the clients table) ──────────────────── */
.attention-rail { padding: 20px 40px 4px; }
.attention-rail .ar-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.attention-stack {
  display: flex; flex-direction: column; min-width: 0; gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.attention-stack.tone-danger { border-top: 2px solid var(--danger); }
.attention-stack.tone-warn   { border-top: 2px solid var(--warn);   }
.attention-stack.tone-info   { border-top: 2px solid var(--info);   }
.attention-stack.tone-good   { border-top: 2px solid var(--good);   }
.attention-stack .as-head {
  display: flex; align-items: baseline; justify-content: space-between;
}
.attention-stack .as-eyebrow {
  font-size: 10px; font-weight: 500; letter-spacing: 1.2px;
  text-transform: uppercase;
}
.attention-stack.tone-danger .as-eyebrow { color: var(--danger); }
.attention-stack.tone-warn   .as-eyebrow { color: var(--warn);   }
.attention-stack.tone-info   .as-eyebrow { color: var(--info);   }
.attention-stack.tone-good   .as-eyebrow { color: var(--good);   }
.attention-stack .as-sub { font-size: 10.5px; color: var(--muted); margin-left: 10px; }
.attention-stack .as-count {
  font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums;
  font-size: 18px; color: var(--ink); font-weight: 500;
}
.attention-stack .as-items { display: flex; flex-direction: column; gap: 7px; }
.attention-stack .as-item {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; min-width: 0;
  text-decoration: none; color: inherit;
}
.attention-stack .as-name {
  font-size: 12.5px; color: var(--ink); font-weight: 500; letter-spacing: -0.1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attention-stack .as-meta {
  font-size: 11px; color: var(--muted); flex-shrink: 0;
  max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attention-stack .as-viewall {
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 11px; letter-spacing: 0.2px;
  padding: 0; align-self: flex-start;
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: auto; text-decoration: none;
}
.attention-stack.tone-danger .as-viewall { color: var(--danger); }
.attention-stack.tone-warn   .as-viewall { color: var(--warn);   }
.attention-stack.tone-info   .as-viewall { color: var(--info);   }
.attention-stack.tone-good   .as-viewall { color: var(--good);   }
.attention-stack .as-empty {
  font-size: 11.5px; color: var(--faint); font-style: italic;
}

/* ── SAVED VIEWS PILL BAR ───────────────────────────────────────────────── */
.saved-views {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.saved-views .sv {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  background: transparent; color: var(--ink2);
  border: 1px solid var(--rule);
  font-family: inherit; font-size: 12px; font-weight: 450; cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.05px;
}
.saved-views .sv:hover { border-color: var(--ruleStrong); color: var(--ink); }
.saved-views .sv.active {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.saved-views .sv .dot {
  width: 6px; height: 6px; border-radius: 50%;
}
.saved-views .sv .count {
  font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums;
  font-size: 10.5px; color: var(--muted);
}
.saved-views .sv.active .count { color: var(--bg); opacity: 0.7; }
.saved-views .sv.tone-danger .dot { background: var(--danger); }
.saved-views .sv.tone-warn   .dot { background: var(--warn);   }
.saved-views .sv.tone-info   .dot { background: var(--info);   }
.saved-views .sv.tone-good   .dot { background: var(--good);   }
.saved-views .sv.active.tone-danger .dot,
.saved-views .sv.active.tone-warn   .dot,
.saved-views .sv.active.tone-info   .dot,
.saved-views .sv.active.tone-good   .dot { background: var(--bg); }

/* ── SERVICE LETTER CHIPS (L T I Tr) ────────────────────────────────────── */
.svc-chips { display: inline-flex; gap: 3px; }
.svc-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 4px;
  font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.2px;
  background: transparent; color: var(--faint);
  border: 1px solid var(--rule);
}
.svc-chip.on.svc-life   { background: var(--accentSoft); color: var(--accent); border-color: var(--accentSoft); }
.svc-chip.on.svc-tpd    { background: var(--infoSoft);   color: var(--info);   border-color: var(--infoSoft);   }
.svc-chip.on.svc-ip     { background: var(--warnSoft);   color: var(--warn);   border-color: var(--warnSoft);   }
.svc-chip.on.svc-trauma { background: var(--dangerSoft); color: var(--danger); border-color: var(--dangerSoft); }

/* ── CLIENTS TABLE ──────────────────────────────────────────────────────── */
.clients-table-wrap {
  margin: 0 40px 32px;
  border: 1px solid var(--rule); border-radius: 10px;
  overflow-x: auto; background: var(--surface);
}
.clients-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg); font-family: inherit;
}
.clients-table thead th {
  text-align: left; padding: 10px 12px;
  font-size: 11px; font-weight: 500; color: var(--muted);
  background: var(--surface); border-bottom: 1px solid var(--rule);
  letter-spacing: 0.3px; text-transform: uppercase;
}
.clients-table thead th.right { text-align: right; }
.clients-table tbody td {
  padding: 12px; border-bottom: 1px solid var(--rule);
  vertical-align: middle; font-size: 13px; color: var(--ink2);
}
.clients-table tbody tr:hover td { background: var(--surface2); }
.clients-table tbody tr.flag-row td.flag-col {
  background: var(--danger); opacity: 0.7;
  width: 4px; padding: 0;
}
.clients-table tbody td.flag-col { width: 4px; padding: 0; background: transparent; }

.client-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-cell .name-row {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.client-cell .name-row .name {
  font-size: 13px; color: var(--ink); font-weight: 500; letter-spacing: -0.1px;
}
.client-cell .name-row .age {
  font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums;
  font-size: 10.5px; color: var(--muted);
}
.client-cell .partner {
  font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.1px;
}
.status-badge.tone-info   { background: var(--infoSoft);   color: var(--info);   }
.status-badge.tone-warn   { background: var(--warnSoft);   color: var(--warn);   }
.status-badge.tone-danger { background: var(--dangerSoft); color: var(--danger); }
.status-badge.tone-good   { background: var(--goodSoft);   color: var(--good);   }
.status-badge.tone-neutral{ background: var(--chipBg);     color: var(--chipInk);}
.status-badge .dot { width: 5px; height: 5px; border-radius: 50%; }
.status-badge.tone-info   .dot { background: var(--info);   }
.status-badge.tone-warn   .dot { background: var(--warn);   }
.status-badge.tone-danger .dot { background: var(--danger); }
.status-badge.tone-good   .dot { background: var(--good);   }
.status-badge.tone-neutral .dot{ background: var(--chipInk);}

.last-touch { display: flex; flex-direction: column; line-height: 1.3; }
.last-touch .what { font-size: 12px; color: var(--ink2); }
.last-touch .when { font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums; font-size: 11px; color: var(--muted); }

.stories-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: 4px;
  background: var(--warnSoft); color: var(--warn); font-weight: 500;
}
.stories-badge .num { font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums; font-size: 11px; }

.clients-table-foot {
  padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2); font-size: 11.5px; color: var(--muted);
  border-top: 1px solid var(--rule);
}
.clients-table-foot .legend {
  display: inline-flex; align-items: center; gap: 10px;
}
.clients-table-foot .legend .lg {
  display: inline-flex; align-items: center; gap: 4px;
}
.clients-table-foot .legend .lg .sq {
  width: 8px; height: 8px; border-radius: 2px;
}
.clients-table-foot .legend .sq.life   { background: var(--accent); }
.clients-table-foot .legend .sq.tpd    { background: var(--info);   }
.clients-table-foot .legend .sq.ip     { background: var(--warn);   }
.clients-table-foot .legend .sq.trauma { background: var(--danger); }

/* Sortable column headers */
.clients-table .sort-th { cursor: pointer; user-select: none; }
.clients-table .sort-th:hover { color: var(--ink); }
.clients-table .sort-th .sort-arrow {
  display: inline-block; width: 8px; margin-left: 4px;
  font-family: 'Inter Tight', system-ui, sans-serif; font-variant-numeric: tabular-nums; color: var(--faint);
}
.clients-table .sort-th.asc  .sort-arrow::before { content: '↑'; color: var(--accent); }
.clients-table .sort-th.desc .sort-arrow::before { content: '↓'; color: var(--accent); }

/* ── SEARCH ROW (between attention rail and table) ──────────────────────── */
.controls-row {
  padding: 20px 40px 12px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.search-pill.compact { width: 400px; }

/* ── FLINT TOAST (carried over from legacy base.html so toasts keep working) */
.flint-toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  background: var(--elev); color: var(--ink);
  border: 1px solid var(--ruleStrong); border-radius: 8px;
  padding: 10px 14px; font-size: 12.5px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0; transform: translateY(8px); transition: opacity .15s, transform .15s;
}
.flint-toast.show { opacity: 1; transform: translateY(0); }
.flint-toast.error { border-color: var(--danger); color: var(--danger); }
.flint-toast.success { border-color: var(--good); color: var(--good); }

/* Mantle confirm-modal styles live in static/js/mantle-confirm.js (self-injected
   on first use). Loaded from both base.html and base_mantle.html. */

/* ── GOOGLE PLACES AUTOCOMPLETE (pac-container) ──────────────────────────────
   Google's Places dropdown is injected at the bottom of <body>, so it picks
   up our theme variables. Default Google styling is uppercase-ish and clashes
   hard with Mantle — these rules normalise it to Inter Tight + theme colours.
   The "powered by Google" badge stays (ToS requirement) but is restyled to
   sit quietly in the dropdown footer. */
.pac-container {
  background: var(--elev) !important;
  border: 1px solid var(--ruleStrong) !important;
  border-radius: 10px !important;
  box-shadow: 0 10px 32px rgba(0,0,0,0.25) !important;
  font-family: 'Inter Tight', system-ui, sans-serif !important;
  margin-top: 4px;
  padding: 4px 0;
  overflow: hidden;
}
.pac-container:after {
  /* "powered by Google" attribution — keep visible (Google ToS) but tone down */
  background-color: var(--surface2) !important;
  padding: 6px 12px !important;
  margin-top: 4px;
  opacity: 0.55;
  filter: grayscale(1);
  height: 22px !important;
  background-size: 90px auto !important;
  background-position: right 10px center !important;
}
.pac-item {
  border-top: 1px solid var(--rule) !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  color: var(--ink2) !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  cursor: pointer;
  line-height: 1.4 !important;
}
.pac-item:first-child { border-top: 0 !important; }
.pac-item:hover,
.pac-item-selected,
.pac-item.pac-item-selected {
  background: var(--accentSoft) !important;
  color: var(--ink) !important;
}
.pac-item-query {
  font-size: 13px !important;
  color: var(--ink) !important;
  font-weight: 500 !important;
  padding-right: 4px;
}
.pac-matched { font-weight: 600 !important; color: var(--ink) !important; }
.pac-icon,
.pac-icon-marker {
  /* swap Google's default pink pin for a neutral mono mark */
  background-image: none !important;
  background: var(--chipBg) !important;
  border-radius: 50%;
  width: 14px !important;
  height: 14px !important;
  margin-top: 4px !important;
  margin-right: 8px !important;
  position: relative;
}
.pac-icon:after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--muted);
}

/* ── Input validation error state (mantle-validate.js) ─────────────────── */
input.mantle-valid-error,
input.mantle-valid-error:focus {
  border-color: var(--danger) !important;
  background: var(--dangerSoft) !important;
  box-shadow: 0 0 0 1px var(--danger) !important;
}
input.mantle-valid-error::placeholder { color: var(--danger); opacity: 0.65; }


/* ── HAMBURGER + NAV BACKDROP (hidden by default at desktop widths) ─────── */
/* Both are positioned + visually inert until the @media block below kicks
   in at < 768px. The hamburger sits in the top-left corner of the viewport;
   the backdrop covers the screen behind the slide-out sidenav. */
.nav-toggle {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 60;
  width: 36px; height: 36px;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.nav-toggle:hover { background: var(--surface2); }
.nav-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,0.35); backdrop-filter: blur(2px);
}


/* ── MOBILE / NARROW VIEWPORT ───────────────────────────────────────────── */
/* Below 768px the sticky 200px sidenav consumes too much width, so we slide
   it off-screen and reveal via the hamburger button. The main content then
   reflows to full width. This is the only @media query in the file as of
   11 Jun 2026 — kept conservative to minimise regression risk pre-launch. */
@media (max-width: 768px) {

  /* Show hamburger button (was display:none above) */
  .nav-toggle { display: flex; }

  /* Sidenav: fixed slide-out drawer (was sticky 200px column) */
  .sidenav {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 240px; height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    box-shadow: 4px 0 12px rgba(0,0,0,0.18);
  }
  body.nav-open .sidenav { transform: translateX(0); }
  body.nav-open .nav-backdrop { display: block; }

  /* Main content reclaims full width when sidenav is hidden */
  .app-main { padding-left: 0; padding-right: 0; min-width: 0; }
  .app { display: block; }

  /* Page-level horizontal padding shrinks at narrow widths */
  .clients-table-wrap,
  .page-pad,
  .home-hero,
  .home-grid { margin-left: 12px !important; margin-right: 12px !important; }

  /* Tables: always scroll horizontally rather than blowing out the layout */
  .clients-table-wrap { overflow-x: auto; }
  table { min-width: 100%; }

  /* Modals: never wider than the viewport */
  .modal, [class*="-modal"], .modal-card, .modal-content {
    max-width: calc(100vw - 24px);
    margin-left: 12px; margin-right: 12px;
  }

  /* Headings shrink a touch so titles don't wrap awkwardly */
  h1, .page-title { font-size: 24px !important; }

  /* Push main content down to clear the fixed hamburger button */
  .app-main { padding-top: 56px; }
}

/* ── Insurer-logo theme switching ──────────────────────────────────────────
   When the Jinja `insurer_logo` filter finds a `{slug}_dark.{svg|png}` on
   disk it emits BOTH the light and dark variants. CSS shows whichever one
   matches the active theme. Logos without a dark variant render with class
   `insurer-logo` only and show on both themes.
   `display` lives here (not in the inline style) so these rules can win
   over the filter's inline `style="..."` attribute.                        */
.insurer-logo,
.insurer-logo-light,
.insurer-logo-dark              { display: inline-block; }
.insurer-logo-dark              { display: none; }
html[data-theme="graphite"] .insurer-logo-light { display: none; }
html[data-theme="graphite"] .insurer-logo-dark  { display: inline-block; }

/* ── Error pages — shared chrome (26 Jun 2026, #50 audit) ──────────────────
   Was duplicated ~150 lines across 5 templates (403/404/429/500/503). Extracted
   here so all five share one source of truth. Per-page tone of the icon tile
   is set via .err-icon.tone-{accent|info|warn|danger}. */
.err-wrap {
  max-width: 520px; margin: 12vh auto 0; padding: 0 24px;
  text-align: center; position: relative; z-index: 1;
}
.err-icon {
  width: 56px; height: 56px; margin: 0 auto 24px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}
.err-icon.tone-accent { background: var(--accentSoft); color: var(--accentInk); }
.err-icon.tone-info   { background: var(--infoSoft);   color: var(--info);      }
.err-icon.tone-warn   { background: var(--warnSoft);   color: var(--warn);      }
.err-icon.tone-danger { background: var(--dangerSoft); color: var(--danger);    }
.err-wrap h1 {
  font-family: 'Newsreader', serif; font-weight: 500;
  font-size: 32px; letter-spacing: -0.5px;
  color: var(--ink); margin: 0 0 12px;
}
.err-wrap p {
  color: var(--ink2); font-size: 14.5px; line-height: 1.55;
  margin: 0 0 28px;
}
.err-wrap .err-code {
  display: inline-block; font-size: 11px;
  color: var(--muted); letter-spacing: 0.6px; text-transform: uppercase;
  margin-bottom: 12px;
}
.err-wrap .err-detail {
  margin: 16px auto 0; padding: 8px 12px;
  background: var(--surface2); border-radius: 6px;
  font-size: 12px; color: var(--ink2); max-width: 380px;
}
.err-wrap .err-id-row {
  margin: 16px auto 0; padding: 8px 12px;
  background: var(--surface2); border-radius: 6px;
  font-size: 11px; color: var(--muted); max-width: 360px;
  display: inline-flex; align-items: center; gap: 8px; word-break: break-all;
}
.err-wrap .err-id-copy-btn {
  background: transparent; border: 1px solid var(--rule); color: var(--ink2);
  padding: 2px 8px; border-radius: 4px; font-size: 10.5px; cursor: pointer;
  font-family: inherit; line-height: 1.4; flex-shrink: 0;
}
.err-wrap .err-id-copy-btn:hover { background: var(--surface); }
.err-actions {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
/* Pre-auth wordmark watermark — same treatment as login.html / forgot_password.html
   so error pages feel like part of the brand chrome even when the user has
   no session. */
.err-bg-wordmark {
  position: fixed; bottom: 24px; right: 36px;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 180px; color: var(--ink); opacity: 0.06;
  letter-spacing: -6px; line-height: 1; font-weight: 400;
  user-select: none; pointer-events: none;
  max-width: 92vw; overflow: hidden; z-index: 0;
}
html[data-theme="linen"] .err-bg-wordmark { opacity: 0.03; }
@media (max-width: 880px) {
  .err-bg-wordmark { font-size: 100px; bottom: 12px; right: 16px; }
}
