/* ============================================================
   PracticeVue — Components
   ============================================================
   Every component reads from semantic tokens. No hardcoded
   colors, sizes, or spacing. Components automatically respond
   to [data-theme="dark"] via the tokens.

   Sections:
     - App shell (sidebar + main + topbar)
     - Buttons
     - Inputs & forms
     - Tabs
     - Filter chips
     - Badges & status pills
     - Cards & surfaces
     - Tables
     - KPI tiles
     - Charts (svg-based)
     - Sparklines
     - Insights card
     - Alerts
     - Modal
     - Dropdown
     - Tooltip
============================================================ */


/* ============================================================
   APP SHELL
============================================================ */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--text-primary);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: var(--space-3) 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4) var(--space-4);
  color: var(--text-primary);
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-tight);
}
.sidebar-brand-mark {
  width: 22px; height: 22px;
  border-radius: var(--radius-md);
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--text-inverse);
  font-size: 11px;
  font-weight: var(--weight-bold);
  letter-spacing: 0;
}
[data-theme="dark"] .sidebar-brand-mark { color: var(--gray-950); }

/* Wraps the workspace switcher so the popover can position absolutely
   without the sidebar's auto-overflow clipping it. */
.sidebar-workspace-wrap {
  position: relative;
  margin: 0 var(--space-3) var(--space-4);
}

.sidebar-workspace {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: transparent;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.sidebar-workspace:hover { background: var(--bg-subtle); border-color: var(--accent); }
.sidebar-workspace-avatar {
  width: 26px; height: 26px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  display: grid; place-items: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0;
  flex-shrink: 0;
}
.sidebar-workspace-text { flex: 1; min-width: 0; }
.sidebar-workspace-name {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-workspace-sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebar-section { padding: 0 var(--space-3); margin-bottom: var(--space-2); }
.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  padding: var(--space-3) var(--space-3) var(--space-1);
}

.sidebar-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--sidebar-item-fg);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.sidebar-item:hover { background: var(--sidebar-item-hover-bg); color: var(--text-primary); }
.sidebar-item.is-active {
  background: var(--accent-subtle-bg);
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}
/* Subtle 2px teal accent on the active item's leading edge. Sits inside
   the rounded background so it reads as part of the chip, not a gutter rail. */
.sidebar-item.is-active::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: var(--radius-sm);
  background: var(--accent);
}
.sidebar-item.is-active .sidebar-item-icon {
  color: var(--accent);
  opacity: 1;
}
.sidebar-item-icon { width: 16px; height: 16px; opacity: 0.85; }

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

/* --- User chip --- */
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  color: var(--text-primary);
  min-width: 0;
}
.user-chip-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  line-height: 1.2;
}
.user-chip-org {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.2;
}
.user-avatar {
  width: 26px; height: 26px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  color: var(--text-secondary);
  display: grid; place-items: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  flex-shrink: 0;
}
/* Accent variant: subtle teal gradient. Used in the sidebar footer user chip
   to add warmth to the most-anchored UI element. */
.user-avatar--accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
}

/* --- Main column --- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0; /* allow children to shrink */
}

/* --- Topbar --- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  color: var(--text-tertiary);
}
.topbar-breadcrumb a { color: var(--text-tertiary); }
.topbar-breadcrumb a:hover { color: var(--text-primary); }
.topbar-breadcrumb .crumb-sep { color: var(--text-disabled); }
.topbar-breadcrumb .crumb-current { color: var(--text-primary); font-weight: var(--weight-medium); }

.topbar-right { display: flex; align-items: center; gap: var(--space-2); }

/* --- Page wrapper --- */
.page {
  padding: var(--space-8) var(--space-10);
  max-width: var(--container-max);
  width: 100%;
  margin: 0 auto;
}

.page-header { margin-bottom: var(--space-6); }
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}
.page-title {
  font-size: var(--text-7xl);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-tighter);
  color: var(--text-primary);
  line-height: var(--leading-tight);
}
.page-subtitle {
  margin-top: var(--space-1);
  font-size: var(--text-md);
  color: var(--text-tertiary);
}
.page-actions { display: flex; align-items: center; gap: var(--space-2); }

/* One-line dot-separated meta strip rendered under a page H1.
   Example: "March 2026 actuals · Base forecast · Updated 2h ago". */
.page-meta-strip {
  margin-top: var(--space-1);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
  font-size: var(--text-md);
  color: var(--text-tertiary);
}
.page-meta-item { display: inline-flex; align-items: baseline; }
.page-meta-item + .page-meta-item::before {
  content: "·";
  margin-right: var(--space-2);
  color: var(--text-disabled);
}


/* ============================================================
   NAV RAIL — collapsed state, forecast chip visibility,
   practice chip, forecast switcher, rail toggle. PV-105.
============================================================ */

/* When collapsed, adjust shell grid and shrink the rail to icon-only width */
.shell[data-rail-state="collapsed"] {
  grid-template-columns: 56px 1fr;
}
.shell[data-rail-state="collapsed"] .sidebar {
  width: 56px;
  overflow: visible; /* allow tooltips / chip dropdowns to escape */
}
.shell[data-rail-state="collapsed"] .sidebar-brand span,
.shell[data-rail-state="collapsed"] .sidebar-section-label {
  display: none;
}
.shell[data-rail-state="collapsed"] .sidebar-item {
  justify-content: center;
  padding-inline: 0;
}
/* Hide label text when collapsed */
.shell[data-rail-state="collapsed"] .sidebar-item-label {
  display: none;
}
/* Hide the left-edge accent bar in icon-only mode; bg alone signals active state */
.shell[data-rail-state="collapsed"] .sidebar-item.is-active::before {
  display: none;
}

/* Forecast chip — dual-location visibility control */
/* By default the topbar chip is hidden (rail is expanded) */
.nav-forecast-chip[data-location="topbar"] {
  display: none;
}
/* When rail collapses: hide rail chip, reveal topbar chip */
.shell[data-rail-state="collapsed"] .nav-forecast-chip[data-location="rail"] {
  display: none;
}
.shell[data-rail-state="collapsed"] .nav-forecast-chip[data-location="topbar"] {
  display: flex;
}

/* Topbar left cluster (practice chip + topbar forecast chip) */
.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

/* Explicitly hide nav chip dropdowns when <details> is not open.
   Required because position:absolute on .nav-chip-dropdown can
   override the UA stylesheet's details:not([open])>:not(summary)
   hide rule in some rendering engines. */
.nav-practice-chip:not([open]) .nav-chip-dropdown,
.nav-forecast-chip:not([open]) .nav-chip-dropdown {
  display: none;
}

/* ---- Practice chip ---- */
.nav-practice-chip {
  position: relative;
}
.nav-practice-chip summary {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  list-style: none;
  user-select: none;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out);
}
.nav-practice-chip summary::-webkit-details-marker { display: none; }
.nav-practice-chip summary::marker { content: ''; }
.nav-practice-chip summary:hover {
  background: var(--bg-subtle);
}
.nav-practice-chip .nav-chip-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: var(--z-popover);
  min-width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
}

/* ---- Forecast chip ---- */
.nav-forecast-chip {
  position: relative;
}

/* Rail variant — full two-line chip with border below */
.nav-forecast-chip[data-location="rail"] {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: var(--space-2);
}
.nav-forecast-chip[data-location="rail"] summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-2);
  transition: background var(--duration-fast) var(--ease-out);
}
.nav-forecast-chip[data-location="rail"] summary::-webkit-details-marker { display: none; }
.nav-forecast-chip[data-location="rail"] summary::marker { content: ''; }
.nav-forecast-chip[data-location="rail"] summary:hover {
  background: var(--sidebar-item-hover-bg);
}

/* Topbar variant — compact single-line */
.nav-forecast-chip[data-location="topbar"] summary {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  list-style: none;
  user-select: none;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out);
}
.nav-forecast-chip[data-location="topbar"] summary::-webkit-details-marker { display: none; }
.nav-forecast-chip[data-location="topbar"] summary::marker { content: ''; }
.nav-forecast-chip[data-location="topbar"] summary:hover {
  background: var(--bg-subtle);
}

/* Chip text elements */
.nav-forecast-chip-name {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--sidebar-item-fg);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-forecast-chip-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.3;
  margin-top: 2px;
}
/* "Select forecast" prompt — muted vs active chip name */
.nav-forecast-chip-name--empty {
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
}
/* "+ New forecast" link — shown when client has no forecasts yet */
a.nav-forecast-chip--new {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  border-radius: var(--radius-md);
  white-space: nowrap;
}
a.nav-forecast-chip--new:hover {
  background: var(--accent-subtle-bg);
}

/* Dropdown panel — shared by both rail and topbar chip.
   Initial position is absolute as a fallback; JS overrides with
   position:fixed + computed coords on toggle to escape sidebar
   overflow:auto clipping (same pattern as .kebab-menu). */
.nav-forecast-chip .nav-chip-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: var(--z-popover);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  min-width: 260px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

/* ---- Forecast switcher dropdown rows ---- */
.nav-forecast-switcher {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-forecast-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
.nav-forecast-row:hover {
  background: var(--bg-subtle);
}
.nav-forecast-row.is-active {
  background: var(--accent-subtle-bg);
  color: var(--accent-subtle-fg);
}
.nav-forecast-row svg {
  flex-shrink: 0;
  color: var(--text-tertiary);
}
.nav-forecast-row.is-active svg {
  color: var(--accent-subtle-fg);
}
/* Scenario rows indented beneath their base */
.nav-forecast-row--scenario {
  padding-left: var(--space-6);
}
.nav-forecast-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.nav-forecast-row-name {
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.nav-forecast-row-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.3;
}
.nav-forecast-row.is-active .nav-forecast-row-meta {
  color: var(--accent-subtle-fg);
  opacity: 0.85;
}
.nav-forecast-switcher-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-1) 0;
}

/* ---- Rail collapse toggle ---- */
.nav-rail-toggle {
  margin-top: auto;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--sidebar-border);
}
.nav-rail-toggle button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.nav-rail-toggle button:hover {
  background: var(--sidebar-item-hover-bg);
  color: var(--text-primary);
}
/* When collapsed, center the toggle button in the 56px rail */
.shell[data-rail-state="collapsed"] .nav-rail-toggle {
  display: flex;
  justify-content: center;
  padding-inline: 0;
}


/* ============================================================
   BUTTONS
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 32px;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

/* sizes */
.btn-sm { height: 28px; padding: 0 var(--space-2); font-size: var(--text-sm); }
.btn-lg { height: 38px; padding: 0 var(--space-4); font-size: var(--text-lg); }
.btn-icon { width: 32px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }

/* variants */
.btn-primary {
  background: var(--action-primary-bg);
  color: var(--action-primary-fg);
  border-color: var(--action-primary-bg);
}
.btn-primary:hover { background: var(--action-primary-bg-hover); border-color: var(--action-primary-bg-hover); }

.btn-secondary {
  background: var(--action-secondary-bg);
  color: var(--action-secondary-fg);
  border-color: var(--action-secondary-border);
}
.btn-secondary:hover { background: var(--action-secondary-bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--action-ghost-fg);
}
.btn-ghost:hover { background: var(--action-ghost-bg-hover); color: var(--text-primary); }

.btn-destructive {
  background: var(--negative-fg);
  color: var(--gray-0);
  border-color: var(--negative-fg);
}
.btn-destructive:hover { filter: brightness(0.94); }

/* Small destructive (row-level Edit/Remove pairs): outlined to avoid visual weight.
   Full-size destructive (confirm dialog "Delete") keeps the filled red fill above. */
.btn-destructive.btn-sm {
  background: transparent;
  color: var(--negative-fg);
  border-color: var(--negative-fg);
}
.btn-destructive.btn-sm:hover {
  background: var(--negative-bg-subtle);
  filter: none;
}


/* ============================================================
   INPUTS & FORMS
============================================================ */
.input,
.select,
.textarea {
  width: 100%;
  height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.textarea { height: auto; padding: var(--space-2) var(--space-3); line-height: var(--leading-normal); }

/* `<textarea class="input">` is the convention across forms — but `.input` has
   zero vertical padding (correct for height-32 single-line fields, wrong for
   wrapped textareas which then jam text against the top edge). Treat any
   textarea wearing the `.input` class as a textarea for padding + line-height
   so the convention works as expected. Root-cause fix for a recurring pain
   point — saves every future form author from rediscovering this. */
textarea.input { height: auto; padding: var(--space-2) var(--space-3); line-height: var(--leading-normal); }

/* File input: inline-flex so the ::file-selector-button fills the input height
   and the filename text vertically centers next to it. Native file inputs add
   ~7px asymmetric top padding by default — we zero it and use flex centering. */
.input[type="file"] {
  display: inline-flex;
  align-items: center;
  /* !important is required to override Chrome's UA stylesheet for file inputs
     which sets an asymmetric ~7px top padding that resists normal author CSS. */
  padding: 0 var(--space-3) 0 0 !important;
  cursor: pointer;
}
.input[type="file"]::file-selector-button {
  appearance: none;
  background: var(--action-secondary-bg);
  color: var(--action-secondary-fg);
  border: 0;
  border-right: 1px solid var(--border-default);
  padding: 0 var(--space-3);
  height: 100%;
  margin-right: var(--space-3);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
.input[type="file"]::file-selector-button:hover {
  background: var(--action-secondary-bg-hover);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group .input-icon {
  position: absolute;
  left: var(--space-3);
  color: var(--text-tertiary);
  width: 14px; height: 14px;
  pointer-events: none;
}
.input-group .input { padding-left: var(--space-8); }
.input-group .input-kbd {
  position: absolute;
  right: var(--space-2);
}

.label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}
.help-text {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* Keyboard chip */
.kbd {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}


/* ============================================================
   TABS (underline)
============================================================ */
.tabs {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  border-bottom: 1px solid var(--border-default);
  margin-bottom: var(--space-6);
}
.tab {
  position: relative;
  padding: var(--space-3) 0;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}
.tab:hover { color: var(--text-primary); }
.tab.is-active { color: var(--text-primary); }
.tab.is-active::after {
  content: '';
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  background: var(--accent);
  border-radius: var(--radius-full);
}
.tab-count {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  margin-left: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
}


/* ============================================================
   SUBNAV SHELL (page-level secondary navigation, e.g. forecast subnav)
============================================================ */
.subnav-shell {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: 0 var(--space-10);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-canvas);
  flex-wrap: wrap;
}
.subnav-shell .tabs {
  border-bottom: 0;
  margin-bottom: 0;
  flex: 1 1 auto;
}
.subnav-shell .select-chip { flex-shrink: 0; }


/* ============================================================
   CHIPS — unified surface for filter, tag, and color chips.

   `variant='filter'` (default): button-style, interactive, with optional
   .is-active state. Used in subnav-style chip rows.
   `variant='tag'`: inline presentational pill, color-coded via the
   `data-tag-color` attribute. Non-interactive by default; macro can opt
   into a remove button via `removable=true`.
============================================================ */
.chip-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 28px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  /* Long labels stay on one line. The chip grows as needed; if the parent
     row is narrower than the chip, the table-wrap's horizontal scroll
     handles the overflow — far better than vertically broken pills. */
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.chip:hover { background: var(--bg-muted); color: var(--text-primary); }
.chip.is-active {
  background: var(--accent-subtle-bg);
  border-color: var(--accent-border);
  color: var(--accent-subtle-fg);
}
.chip.is-active .chip-count {
  color: var(--accent-subtle-fg);
  opacity: 0.7;
}
.chip-count {
  color: var(--text-tertiary);
  font-weight: var(--weight-regular);
  margin-left: var(--space-1);
}

/* Tag variant — presentational color-coded label, smaller than filter chips. */
.chip.is-tag {
  height: 22px;
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: default;
  background: var(--tag-slate-bg);
  color: var(--tag-slate-fg);
  border: 1px solid var(--tag-slate-border);
  transition: none;
}
.chip.is-tag:hover {
  /* Override .chip:hover — tag chips are static labels, not buttons */
  background: var(--tag-slate-bg);
  color: var(--tag-slate-fg);
}
.chip.is-tag .chip-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: currentColor;
  opacity: 0.55;
  flex-shrink: 0;
}

/* PV-99: allocation % suffix inside a location chip. Smaller, lighter weight,
   and partially transparent against the chip foreground so the location name
   stays the primary signal and the percent reads as secondary metadata. */
.chip-pct {
  font-size: 0.85em;
  font-weight: var(--weight-regular);
  opacity: 0.75;
}

/* PV-99 follow-up: standalone location color dot for surfaces that want a
   "this is the location color" signal alongside plain text — Locations list,
   allocation editor labels, P&L by location summary tables. Saturated
   foreground tokens match the chip dots used by filter chips. */
.location-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  vertical-align: middle;
  background: var(--tag-slate-fg);   /* default; per-color rules below override */
}
.location-dot[data-tag-color="slate"]   { background: var(--tag-slate-fg); }
.location-dot[data-tag-color="teal"]    { background: var(--tag-teal-fg); }
.location-dot[data-tag-color="amber"]   { background: var(--tag-amber-fg); }
.location-dot[data-tag-color="rose"]    { background: var(--tag-rose-fg); }
.location-dot[data-tag-color="violet"]  { background: var(--tag-violet-fg); }
.location-dot[data-tag-color="emerald"] { background: var(--tag-emerald-fg); }
.location-dot[data-tag-color="sky"]     { background: var(--tag-sky-fg); }
.location-dot[data-tag-color="stone"]   { background: var(--tag-stone-fg); }

/* Filter chips with a tag color get a leading color dot — at-a-glance signal
   of which tag each filter chip represents. The dot uses the tag's saturated
   foreground token. PV-90 PR 2: per-grid tag filter row. */
.chip:not(.is-tag)[data-tag-color] .chip-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.chip:not(.is-tag)[data-tag-color="slate"]   .chip-dot { background: var(--tag-slate-fg); }
.chip:not(.is-tag)[data-tag-color="teal"]    .chip-dot { background: var(--tag-teal-fg); }
.chip:not(.is-tag)[data-tag-color="amber"]   .chip-dot { background: var(--tag-amber-fg); }
.chip:not(.is-tag)[data-tag-color="rose"]    .chip-dot { background: var(--tag-rose-fg); }
.chip:not(.is-tag)[data-tag-color="violet"]  .chip-dot { background: var(--tag-violet-fg); }
.chip:not(.is-tag)[data-tag-color="emerald"] .chip-dot { background: var(--tag-emerald-fg); }
.chip:not(.is-tag)[data-tag-color="sky"]     .chip-dot { background: var(--tag-sky-fg); }
.chip:not(.is-tag)[data-tag-color="stone"]   .chip-dot { background: var(--tag-stone-fg); }

/* An active filter chip with a tag color tints to that palette, so the
   filter chip and the grid rows it pulls share an obvious color lock. */
.chip:not(.is-tag)[data-tag-color="slate"].is-active   { background: var(--tag-slate-bg);   color: var(--tag-slate-fg);   border-color: var(--tag-slate-border);   }
.chip:not(.is-tag)[data-tag-color="teal"].is-active    { background: var(--tag-teal-bg);    color: var(--tag-teal-fg);    border-color: var(--tag-teal-border);    }
.chip:not(.is-tag)[data-tag-color="amber"].is-active   { background: var(--tag-amber-bg);   color: var(--tag-amber-fg);   border-color: var(--tag-amber-border);   }
.chip:not(.is-tag)[data-tag-color="rose"].is-active    { background: var(--tag-rose-bg);    color: var(--tag-rose-fg);    border-color: var(--tag-rose-border);    }
.chip:not(.is-tag)[data-tag-color="violet"].is-active  { background: var(--tag-violet-bg);  color: var(--tag-violet-fg);  border-color: var(--tag-violet-border);  }
.chip:not(.is-tag)[data-tag-color="emerald"].is-active { background: var(--tag-emerald-bg); color: var(--tag-emerald-fg); border-color: var(--tag-emerald-border); }
.chip:not(.is-tag)[data-tag-color="sky"].is-active     { background: var(--tag-sky-bg);     color: var(--tag-sky-fg);     border-color: var(--tag-sky-border);     }
.chip:not(.is-tag)[data-tag-color="stone"].is-active   { background: var(--tag-stone-bg);   color: var(--tag-stone-fg);   border-color: var(--tag-stone-border);   }

/* Per-color tag rules. The data attribute is set by the chip macro from the
   tag.color column value. Keep this block in sync with TAG_COLOR_PALETTE in
   models.py and the --tag-* tokens in tokens.css. */
.chip.is-tag[data-tag-color="slate"]   { background: var(--tag-slate-bg);   color: var(--tag-slate-fg);   border-color: var(--tag-slate-border);   }
.chip.is-tag[data-tag-color="teal"]    { background: var(--tag-teal-bg);    color: var(--tag-teal-fg);    border-color: var(--tag-teal-border);    }
.chip.is-tag[data-tag-color="amber"]   { background: var(--tag-amber-bg);   color: var(--tag-amber-fg);   border-color: var(--tag-amber-border);   }
.chip.is-tag[data-tag-color="rose"]    { background: var(--tag-rose-bg);    color: var(--tag-rose-fg);    border-color: var(--tag-rose-border);    }
.chip.is-tag[data-tag-color="violet"]  { background: var(--tag-violet-bg);  color: var(--tag-violet-fg);  border-color: var(--tag-violet-border);  }
.chip.is-tag[data-tag-color="emerald"] { background: var(--tag-emerald-bg); color: var(--tag-emerald-fg); border-color: var(--tag-emerald-border); }
.chip.is-tag[data-tag-color="sky"]     { background: var(--tag-sky-bg);     color: var(--tag-sky-fg);     border-color: var(--tag-sky-border);     }
.chip.is-tag[data-tag-color="stone"]   { background: var(--tag-stone-bg);   color: var(--tag-stone-fg);   border-color: var(--tag-stone-border);   }

/* Tag color picker — palette swatches for the tag CRUD modal. Same color
   tokens as the rendered chip so the picker previews the actual result. */
.tag-palette {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.tag-palette__swatch {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
}
.tag-palette__swatch[data-tag-color="slate"]   { background: var(--tag-slate-fg);   }
.tag-palette__swatch[data-tag-color="teal"]    { background: var(--tag-teal-fg);    }
.tag-palette__swatch[data-tag-color="amber"]   { background: var(--tag-amber-fg);   }
.tag-palette__swatch[data-tag-color="rose"]    { background: var(--tag-rose-fg);    }
.tag-palette__swatch[data-tag-color="violet"]  { background: var(--tag-violet-fg);  }
.tag-palette__swatch[data-tag-color="emerald"] { background: var(--tag-emerald-fg); }
.tag-palette__swatch[data-tag-color="sky"]     { background: var(--tag-sky-fg);     }
.tag-palette__swatch[data-tag-color="stone"]   { background: var(--tag-stone-fg);   }
.tag-palette__swatch.is-selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-surface) inset;
}
.tag-palette__swatch:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Tag multiselect — checkbox list inside a popover, used in the location
   add/edit modal. */
.tag-select {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-height: 240px;
  overflow-y: auto;
  padding: var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}
.tag-select__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.tag-select__row:hover { background: var(--bg-subtle); }
.tag-select__row input[type="checkbox"] { margin: 0; }
.tag-select__empty {
  padding: var(--space-3);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  text-align: center;
}


/* ============================================================
   BADGES & STATUS PILLS
============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }

.badge-neutral  { color: var(--text-secondary); background: var(--bg-subtle); }
.badge-positive { color: var(--positive-fg);  background: var(--positive-bg-subtle); }
.badge-negative { color: var(--negative-fg);  background: var(--negative-bg-subtle); }
.badge-warning  { color: var(--warning-fg);   background: var(--warning-bg-subtle); }
.badge-info     { color: var(--info-fg);      background: var(--info-bg-subtle); }
.badge-accent   { color: var(--accent-subtle-fg); background: var(--accent-subtle-bg); }

/* Inline delta — used next to KPI values */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  margin-left: var(--space-2);
}
.delta-positive { color: var(--positive-fg); }
.delta-negative { color: var(--negative-fg); }
.delta-neutral  { color: var(--text-tertiary); }

/* Dot status (e.g. Ongoing) */
.status-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-tertiary);
}
.status-dot.is-positive { background: var(--positive-fg); }
.status-dot.is-negative { background: var(--negative-fg); }
.status-dot.is-warning  { background: var(--warning-fg); }


/* ============================================================
   CARDS
============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
/* Clickable card variant: full card surface is a link */
.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.card-link:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}
.card-link:active { transform: translateY(1px); }
.card-link-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.card-link .card-title { font-size: var(--text-xl); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.card-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}
.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: 2px;
}
.card-body { padding: var(--space-5); }
.card-body--flush { padding: 0; }
.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

/* "View" link inline-action (Galiant pattern) */
.link-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-link);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.link-action:hover { background: var(--bg-subtle); color: var(--text-primary); }
.link-action svg { width: 12px; height: 12px; }


/* ============================================================
   KPI TILES
============================================================ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.kpi {
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
}
.kpi-label {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  font-weight: var(--weight-regular);
  margin-bottom: var(--space-2);
}
.kpi-value {
  font-size: var(--text-5xl);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.kpi-meta {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}


/* ============================================================
   TABLES
============================================================ */
.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.table thead th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  white-space: nowrap;
}
.table tbody td,
.table tfoot td {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--bg-subtle); }

.table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.table .col-meta { color: var(--text-tertiary); font-size: var(--text-sm); }
.table .col-actions { text-align: right; width: 1px; white-space: nowrap; }

.table tbody td .cell-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cell-stack-primary { color: var(--text-primary); font-weight: var(--weight-medium); }
.cell-stack-secondary { color: var(--text-tertiary); font-size: var(--text-sm); }

/* Section subheader row inside a table (Galiant: "Behaviour / Adaptive living") */
.table .row-section td {
  padding-top: var(--space-4);
  padding-bottom: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  background: transparent;
  border-bottom: 1px solid var(--border-subtle);
}

/* PV-89: empty-state row inside an always-rendered tbody (see the
   data_table macro). Hidden the moment a real row lands beside it —
   no JS, so an HTMX beforeend OOB append hides it automatically. */
.table-empty-row:not(:only-child) { display: none; }
.table-empty-row td {
  padding: 0;
  border-bottom: 0;
}
.table-empty-row:hover td { background: transparent; }

/* ---- Controlled tables (table-controls.js: sort / search / filters) ---- */

/* Tighter cell padding on controlled tables — wide staffing tables need the
   horizontal room (14+ columns); --space-5 gutters alone cost >100px. */
[data-table-controls] thead th,
[data-table-controls] tbody td,
[data-table-controls] tfoot td {
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

/* Sort button inside a th — inherits the header's typography wholesale so a
   sortable header reads identically to a plain one, plus a subtle glyph. */
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.th-sort:hover { color: var(--text-secondary); }
.th-sort-icon { opacity: 0.45; flex-shrink: 0; }
.th-sort:hover .th-sort-icon { opacity: 0.8; }
/* Active sort column: accent the whole control so direction is scannable. */
th[aria-sort] .th-sort { color: var(--accent); }
th[aria-sort] .th-sort-icon { opacity: 1; }

/* Toolbar row above a controlled table (search box, right-aligned). Matches
   the .staff-filter row's padding/border so the two read as one family. */
.table-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.table-search .input {
  width: 220px;
  font-size: var(--text-sm);
}


/* ============================================================
   CHARTS (svg-based, no library)
============================================================ */
.chart {
  width: 100%;
  display: block;
}
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-label {
  fill: var(--chart-axis);
  font-size: 10px;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.chart .series-primary {
  fill: none;
  stroke: var(--chart-primary);
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .series-secondary {
  fill: none;
  stroke: var(--chart-secondary);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 4 4;
}
.chart .series-fill {
  fill: var(--chart-primary);
  opacity: 0.06;
}
.chart .series-point {
  fill: var(--bg-surface);
  stroke: var(--chart-primary);
  stroke-width: 1.5;
}

/* Chart legend */
.chart-legend {
  display: flex;
  gap: var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}
.chart-legend-item { display: inline-flex; align-items: center; gap: var(--space-2); }
.chart-legend-swatch {
  width: 10px; height: 2px;
  border-radius: 1px;
  background: var(--chart-primary);
}
.chart-legend-swatch.is-secondary { background: var(--chart-secondary); height: 2px; opacity: 0.7; }
.chart-legend-swatch.is-accent { background: var(--chart-accent); }
.chart-legend-swatch.is-positive { background: var(--chart-positive); }


/* ============================================================
   SPARKLINES (small inline chart in table cells)
============================================================ */
.sparkline { display: block; }
.sparkline .spark-line {
  fill: none;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.sparkline .spark-fill {
  opacity: 0.18;
}


/* ============================================================
   INSIGHTS CARD (AI-flavored, slightly different surface)
============================================================ */
.insight-card {
  background: linear-gradient(180deg, var(--accent-subtle-bg) 0%, var(--bg-surface) 70%);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
}
[data-theme="dark"] .insight-card {
  background: linear-gradient(180deg, var(--accent-subtle-bg) 0%, var(--bg-surface) 70%);
}
.insight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.insight-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
}
.insight-title svg { width: 14px; height: 14px; color: var(--accent); }
.insight-meta { font-size: var(--text-sm); color: var(--text-tertiary); margin-bottom: var(--space-2); }
.insight-body {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}
.insight-body p + p { margin-top: var(--space-3); }
.insight-body strong { color: var(--text-primary); font-weight: var(--weight-semi); }


/* ============================================================
   ALERTS
============================================================ */
.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid;
  font-size: var(--text-base);
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-title { font-weight: var(--weight-semi); margin-bottom: 2px; }
.alert-body { line-height: var(--leading-snug); }

.alert-info     { color: var(--info-fg);     background: var(--info-bg-subtle);     border-color: var(--info-border); }
.alert-positive { color: var(--positive-fg); background: var(--positive-bg-subtle); border-color: var(--positive-border); }
.alert-warning  { color: var(--warning-fg);  background: var(--warning-bg-subtle);  border-color: var(--warning-border); }
.alert-negative { color: var(--negative-fg); background: var(--negative-bg-subtle); border-color: var(--negative-border); }
.alert .alert-body { color: var(--text-secondary); }
[data-theme="dark"] .alert .alert-body { color: var(--text-secondary); }


/* ============================================================
   LOCKED BADGE (PV-107)
   Inline badge variant for frozen Budget / Reforecast snapshots.
   Extends .badge-neutral with a lock icon — no new color needed.
============================================================ */
.locked-badge {
  gap: var(--space-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-wide);
}
.locked-badge svg { width: 11px; height: 11px; }


/* ============================================================
   LOCKED BANNER (PV-107)
   Full-width informational strip shown at the top of read-only
   forecast pages. Muted neutral tone — not alarming, just clear.
   Sits flush above the page content, below the nav rail topbar.
============================================================ */
.locked-banner {
  --locked-banner-bg: var(--bg-muted);
  --locked-banner-fg: var(--text-secondary);
  --locked-banner-border: var(--border-default);

  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--locked-banner-bg);
  border: 1px solid var(--locked-banner-border);
  border-radius: var(--radius-md);
  color: var(--locked-banner-fg);
  font-size: var(--text-base);
  margin-bottom: var(--space-5);
}
.locked-banner svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.locked-banner-label {
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  margin-right: var(--space-2);
}
.locked-banner-body {
  color: var(--text-secondary);
}


/* ============================================================
   MODAL
============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-6);
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  /* cap height so tall modals scroll instead of overflowing the viewport */
  max-height: calc(100vh - var(--space-12));
  display: flex;
  flex-direction: column;
  overflow: hidden;  /* clips border-radius on children; scroll lives on .modal-body */
}
.modal-header {
  flex: 0 0 auto;
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.modal-title { font-size: var(--text-2xl); font-weight: var(--weight-semi); }
.modal-body {
  flex: 1 1 auto;
  min-height: 0;     /* required: allows flex child to shrink below content size */
  overflow-y: auto;
  padding: var(--space-5);
  color: var(--text-secondary);
}
.modal-footer {
  flex: 0 0 auto;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}


/* ============================================================
   DROPDOWN / POPOVER
============================================================ */
.popover {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  min-width: 200px;
}
.popover-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--text-primary);
  cursor: pointer;
}
.popover-item:hover { background: var(--bg-subtle); }
.popover-item svg { width: 14px; height: 14px; color: var(--text-tertiary); }
.popover-divider { height: 1px; background: var(--border-subtle); margin: var(--space-1) 0; }

/* Popover sub-structure: section label + per-item meta + active state +
   small avatar chip. Used by the workspace switcher; reusable elsewhere. */
.popover-section { display: flex; flex-direction: column; gap: 0; }
.popover-section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  padding: var(--space-2) var(--space-2) var(--space-1);
}
.popover-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover-meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  margin-left: auto;
}
.popover-avatar {
  width: 22px; height: 22px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  color: var(--text-secondary);
  display: grid; place-items: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  flex-shrink: 0;
}
.popover-item.is-active {
  background: var(--accent-subtle-bg);
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}
.popover-item.is-active .popover-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
}
.popover-item.is-active svg { color: var(--accent); }

/* Workspace switcher popover — anchored below the sidebar button, full
   sidebar width minus the section gutter, with a soft offset so it
   visually detaches from the button. */
.sidebar-workspace-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: var(--z-popover, 50);
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.sidebar-workspace-popover[hidden] { display: none; }


/* ============================================================
   TOOLTIP
============================================================ */
.tooltip {
  display: inline-block;
  position: relative;
}
.tooltip-content {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-inverse);
  color: var(--text-inverse);
  font-size: var(--text-xs);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
}


/* ============================================================
   LAYOUT HELPERS
============================================================ */
.row-2col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.row-2col--equal {
  grid-template-columns: 1fr 1fr;
}
.row-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--space-8) 0 var(--space-4);
}
.section-header:first-child { margin-top: 0; }
.section-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}
/* Actions slot — groups multiple buttons right-aligned without wrapping */
.section-header-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}


/* ============================================================
   FORM PRIMITIVES — checkbox, radio, toggle switch
============================================================ */
.form-check, .form-radio, .toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.form-check input[type="checkbox"],
.form-radio input[type="radio"] {
  accent-color: var(--accent);
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.form-check input[type="checkbox"] { border-radius: var(--radius-sm); }
.form-radio input[type="radio"]    { border-radius: var(--radius-full); }

.form-check input[type="checkbox"]:hover,
.form-radio input[type="radio"]:hover { border-color: var(--accent); }

.form-check input[type="checkbox"]:checked,
.form-radio input[type="radio"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

/* checkbox check mark */
.form-check input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  inset: 2px 3px;
  border: solid var(--gray-0);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
[data-theme="dark"] .form-check input[type="checkbox"]:checked::after { border-color: var(--gray-950); }

/* radio center dot */
.form-radio input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: var(--gray-0);
}
[data-theme="dark"] .form-radio input[type="radio"]:checked::after { background: var(--gray-950); }

.form-check input:disabled, .form-radio input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Selectable "radio card" — wide option tile (see radio_card macro).
   Whole card is the label; :has() toggles the checked look without JS. */
.radio-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}
.radio-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}
.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--bg-subtle);
}
.radio-card:has(input:focus-visible) {
  border-color: var(--border-strong);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.radio-card input[type="radio"] {
  accent-color: var(--accent);
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  margin-top: 2px;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.radio-card input[type="radio"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.radio-card input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-inverse);
}
.radio-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.radio-card-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
}
.radio-card-desc {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* Toggle switch */
.toggle-switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle-switch-track {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--gray-200);
  transition: background var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}
[data-theme="dark"] .toggle-switch-track { background: var(--gray-700); }

.toggle-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  background: var(--gray-0);
  box-shadow: 0 1px 2px rgba(11, 13, 15, 0.2);
  transition: transform var(--duration-fast) var(--ease-out);
}
.toggle-switch input:checked ~ .toggle-switch-track { background: var(--accent); }
.toggle-switch input:checked ~ .toggle-switch-track::after { transform: translateX(14px); }
.toggle-switch input:focus-visible ~ .toggle-switch-track {
  box-shadow: var(--focus-ring);
}
.toggle-switch-lead { display: inline-flex; color: var(--accent); flex-shrink: 0; }
.toggle-switch-lead svg { width: 14px; height: 14px; }


/* ============================================================
   FINANCIAL INPUTS — currency, percent
============================================================ */
.input-affix {
  position: relative;
  display: flex;
  align-items: center;
}
.input-affix::before,
.input-affix::after {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: var(--text-md);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.input-affix--currency::before {
  content: '$';
  left: var(--space-3);
}
.input-affix--percent::after {
  content: '%';
  right: var(--space-3);
}
.input--money {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.input-affix--currency .input--money { padding-left: var(--space-7); }
.input-affix--percent  .input--money { padding-right: var(--space-7); }


/* ============================================================
   EMPTY STATE
============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-secondary);
}
.empty-state-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  margin-bottom: var(--space-4);
}
.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-1);
}
.empty-state-body {
  font-size: var(--text-md);
  color: var(--text-tertiary);
  max-width: 360px;
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
}
.empty-state-action {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}


/* ============================================================
   DEFINITION ROW (label + value pair, used in detail panels)
============================================================ */
.def-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  align-items: baseline;
}
.def-row:last-child { border-bottom: 0; }
.def-label {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
}
.def-value {
  font-size: var(--text-md);
  color: var(--text-primary);
}


/* ============================================================
   MODAL WIDTH VARIANT
============================================================ */
.modal-wide { max-width: 640px; }


/* ============================================================
   CONFIRMATION DIALOG (extends .modal)
============================================================ */
.modal-backdrop.is-hidden { display: none; }
.modal-backdrop:not(.is-hidden) {
  animation: modalFadeIn var(--duration-fast) var(--ease-out);
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-backdrop:not(.is-hidden) .modal {
  animation: modalRiseIn var(--duration-normal) var(--ease-out);
}
@keyframes modalRiseIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-confirm .modal-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5);
  border-bottom: 0;
}
.modal-confirm .modal-title {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
}
.modal-confirm-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
}
.modal-confirm-icon.is-destructive {
  background: var(--negative-bg-subtle);
  color: var(--negative-fg);
}
.modal-confirm .modal-body {
  padding: 0 var(--space-5) var(--space-5);
  padding-left: calc(var(--space-5) + 36px + var(--space-3));
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}


/* ============================================================
   COLLAPSIBLE SECTION (native <details>, card-styled)
============================================================ */
.collapse-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-3);
  overflow: hidden;
}
.collapse-card > summary {
  list-style: none;
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  transition: background var(--duration-fast) var(--ease-out);
}
.collapse-card > summary::-webkit-details-marker { display: none; }
.collapse-card > summary::marker { content: ''; }
.collapse-card > summary::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform var(--duration-fast) var(--ease-out);
  color: var(--text-tertiary);
}
.collapse-card[open] > summary::before { transform: rotate(90deg); }
.collapse-card > summary:hover { background: var(--bg-subtle); }
.collapse-card[open] > summary { border-bottom: 1px solid var(--border-subtle); }
.collapse-card-body { padding: var(--space-5); }


/* ============================================================
   ALLOCATION EDITOR (location split with running sum)
============================================================ */
.allocation-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.alloc-section.is-hidden { display: none; }

.alloc-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.alloc-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: var(--space-2);
  align-items: center;
}
.alloc-pct-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.alloc-pct {
  width: 100%;
  text-align: right;
  padding-right: var(--space-7);
  font-variant-numeric: tabular-nums;
}
.alloc-pct-suffix {
  position: absolute;
  right: var(--space-3);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  pointer-events: none;
}

.alloc-sum {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.alloc-sum-label {
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  font-size: var(--text-xs);
}
.alloc-sum-value {
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  font-size: var(--text-base);
  flex-shrink: 0;
}
.alloc-sum-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-weight: var(--weight-medium);
}
.alloc-sum-status.is-ok      { color: var(--positive-fg); }
.alloc-sum-status.is-warn    { color: var(--warning-fg); }
.alloc-sum-status.is-error   { color: var(--negative-fg); }
.alloc-sum-flash {
  background: var(--negative-bg-subtle);
  border-color: var(--negative-border);
  transition: background 1.2s ease, border-color 1.2s ease;
}

.alloc-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.alloc-toggle input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.alloc-toggle input[type="checkbox"]:hover { border-color: var(--accent); }
.alloc-toggle input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.alloc-toggle input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  inset: 2px 3px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
[data-theme="dark"] .alloc-toggle input[type="checkbox"]:checked::after {
  border-color: var(--gray-950);
}


/* ============================================================
   LOCATION-MODE SPLIT ALLOCATION (legacy backend-compatible variant)
   Different naming from .allocation-editor; this matches the legacy
   form contract via location_mode + loc_<id> fields.
============================================================ */
.split-alloc-v1 {
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-top: var(--space-2);
}
.alloc-row-v1 {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-2);
}
.alloc-row-v1:last-of-type { margin-bottom: 0; }
.alloc-row-v1 > label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
}


/* ============================================================
   SELECT CHIP (native select styled as a chip-like button)
============================================================ */
.select-chip {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 6px var(--space-8) 6px var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  line-height: 1.2;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A4ADB7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.select-chip:hover { background-color: var(--bg-subtle); border-color: var(--border-strong); }
.select-chip:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }


/* ============================================================
   KEBAB MENU (native <details> with positioned popover)
============================================================ */
.kebab {
  position: relative;
  display: inline-block;
}
.kebab-trigger {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  color: var(--action-ghost-fg);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.kebab-trigger::-webkit-details-marker { display: none; }
.kebab-trigger::marker { display: none; content: ''; }
.kebab-trigger:hover { background: var(--action-ghost-bg-hover); color: var(--text-primary); }
.kebab[open] .kebab-trigger {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.kebab-menu {
  /* position/top/left set by JS (fixed) to escape overflow:hidden ancestors */
  z-index: var(--z-popover);
  min-width: 180px;
  animation: kebabFadeIn var(--duration-fast) var(--ease-out);
}
@keyframes kebabFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Destructive item color */
.popover-item.is-destructive { color: var(--negative-fg); }
.popover-item.is-destructive svg { color: var(--negative-fg); }
.popover-item.is-destructive:hover { background: var(--negative-bg-subtle); }


/* ============================================================
   P&L TABLE — sticky first column + row hierarchy + actuals tint
============================================================ */

/* Wrap any wide table in .table-wrap to enable horizontal scroll. */
.table-pnl {
  font-size: var(--text-base);
}
.table-pnl th, .table-pnl td {
  padding: var(--space-2) var(--space-3);
  white-space: nowrap;
}

/* --- Sticky first column --- */
.table-sticky-first thead th:first-child,
.table-sticky-first tbody td:first-child,
.table-sticky-first tfoot td:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-surface);
  z-index: 1;
  border-right: 1px solid var(--border-default);
}
.table-sticky-first thead th:first-child { z-index: 2; }
.table-sticky-first tbody tr:hover td:first-child { background: var(--bg-subtle); }

/* --- Actuals column tint (always-on, survives hover) --- */
.col-actual {
  background: rgba(20, 184, 166, 0.06);
}
[data-theme="dark"] .col-actual {
  background: rgba(45, 212, 191, 0.08);
}
.table tbody tr:hover .col-actual {
  background: rgba(20, 184, 166, 0.10);
}
[data-theme="dark"] .table tbody tr:hover .col-actual {
  background: rgba(45, 212, 191, 0.12);
}
/* Header tint slightly stronger so the column-group reads clearly */
.table thead .col-actual {
  background: rgba(20, 184, 166, 0.10);
  color: var(--accent-subtle-fg);
}
[data-theme="dark"] .table thead .col-actual {
  background: rgba(45, 212, 191, 0.14);
  color: var(--accent);
}

/* --- Row emphasis: section / subtotal / total --- */
.table .row-section td {
  /* Inherits existing .row-section styling from the base table rules */
  /* Adds an explicit top-border for visual separation */
  border-top: 1px solid var(--border-default);
  padding-top: var(--space-4);
}
.table .row-section td:first-child { font-weight: var(--weight-medium); }

.table .row-subtotal td {
  font-weight: var(--weight-semi);
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-default);
  border-bottom: 1px solid var(--border-default);
}
.table-sticky-first .row-subtotal td:first-child {
  background: var(--bg-subtle);
}

.table .row-total td {
  font-weight: var(--weight-semi);
  font-size: var(--text-md);
  background: var(--bg-muted);
  border-top: 2px solid var(--border-strong);
  border-bottom: 2px solid var(--border-strong);
  color: var(--text-primary);
}
.table-sticky-first .row-total td:first-child {
  background: var(--bg-muted);
}

/* --- Indent levels for nested rows --- */
.pnl-label { padding-left: var(--space-5); }
.pnl-label.depth-1 { padding-left: var(--space-8); }
.pnl-label.depth-2 { padding-left: var(--space-12); }

/* --- Drill-child rows (the rows inserted after a parent via HTMX afterend) --- */
.drill-child td {
  background: var(--bg-subtle);
}
/* Indent comes from .pnl-label.depth-* classes on the first cell, not from this rule */
.drill-child td:first-child {
  color: var(--text-secondary);
  font-weight: var(--weight-regular);
  border-left: 2px solid var(--accent);  /* a thin teal indicator marks drilled-from */
}
/* Fallback indent if a drill-child first-cell has no .depth-* class */
.drill-child td:first-child:not([class*="depth-"]) {
  padding-left: var(--space-8);
}
.table-sticky-first .drill-child td:first-child {
  background: var(--bg-subtle);
}
.drill-child.is-hidden { display: none; }

/* depth-2 drill rows sit one level deeper: lighter bg + muted border, no teal accent */
.drill-child:has(.pnl-label.depth-2) td {
  background: var(--bg-surface);
}
.drill-child:has(.pnl-label.depth-2) td:first-child {
  border-left: 2px solid var(--border-subtle);
  font-size: var(--text-sm);
}
.table-sticky-first .drill-child:has(.pnl-label.depth-2) td:first-child {
  background: var(--bg-surface);
}

/* Smooth entry animation when HTMX inserts drill-child rows */
.drill-child {
  animation: drillRowFadeIn var(--duration-normal) var(--ease-out);
}
@keyframes drillRowFadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Aria-expanded chevron rotation (replaces .is-open class for new buttons) --- */
.drill-trigger[aria-expanded="true"] .drill-chevron {
  transform: rotate(90deg);
  color: var(--accent);
}
.drill-trigger[aria-expanded="true"] {
  color: var(--accent);
}


/* ============================================================
   MEMO CARD (commentary with edit-in-place)
============================================================ */
.memo-card .memo-loading {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  font-style: italic;
}

.memo-view {
  font-size: var(--text-md);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}
.memo-view p + p { margin-top: var(--space-3); }
.memo-view strong { color: var(--text-primary); font-weight: var(--weight-semi); }

.memo-edit {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.memo-edit textarea {
  width: 100%;
  min-height: 140px;
  padding: var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  resize: vertical;
}
.memo-edit textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.memo-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}


/* ============================================================
   DRILL-DOWN ROW (expandable table row)
============================================================ */
.drill-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font: inherit;
  color: var(--text-primary);
  font-weight: var(--weight-medium);
  cursor: pointer;
  padding: 2px 0;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) var(--ease-out);
}
.drill-trigger:hover { color: var(--accent); }
.drill-trigger .drill-chevron {
  color: var(--text-tertiary);
  transition: transform var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.drill-trigger.is-open .drill-chevron {
  transform: rotate(90deg);
  color: var(--accent);
}
.drill-trigger:hover .drill-chevron { color: var(--accent); }

.drill-row { display: none; }
.drill-row.is-open { display: table-row; }
.drill-row > td {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-default);
  padding: 0;
}
.drill-content {
  padding: var(--space-4) var(--space-5);
  animation: drillFadeIn var(--duration-normal) var(--ease-out);
}
@keyframes drillFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Drill content layout: small grid of stats + a thin table */
.drill-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.drill-stat-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  font-weight: var(--weight-medium);
  margin-bottom: 2px;
}
.drill-stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tight);
}


/* ============================================================
   HTMX TRANSITIONS
   Smooth swaps without flash. View-transition-style fade.
============================================================ */
.htmx-swapping {
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}
.htmx-settling {
  opacity: 0;
}
.htmx-added {
  opacity: 0;
}
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-indicator {
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}

/* Subtle pulse for elements that are being fetched */
.htmx-request {
  cursor: progress;
}

/* Smooth content swap inside cards & table bodies */
[hx-target] {
  transition: opacity var(--duration-fast) var(--ease-out);
}


/* ============================================================
   TOAST
============================================================ */
#toast-region {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
#toast-region .toast { pointer-events: auto; }

.toast {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-2);
  min-width: 280px;
  max-width: 400px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  /* No fade-in animation — earlier attempts (`pv-toast-in` keyframes) stayed
     stuck at opacity:0 in this app's render path, making toasts invisible.
     Appear instantly; only the dismissal animates via .toast--leaving. */
}
/* Error/warning toasts can carry multi-line messages — allow them to be wider. */
.toast-negative,
.toast-warning  { max-width: 480px; }
.toast-positive { background: var(--toast-positive-fill); color: var(--toast-fg); }
.toast-positive svg { color: var(--toast-fg); }
.toast-negative { background: var(--toast-negative-fill); color: var(--toast-fg); }
.toast-negative svg { color: var(--toast-fg); }
.toast-warning  { background: var(--toast-warning-fill);  color: var(--toast-fg); }
.toast-warning svg  { color: var(--toast-fg); }
.toast-info     { background: var(--toast-info-fill);     color: var(--toast-fg); }
.toast-info svg     { color: var(--toast-fg); }
.toast-neutral  { background: var(--toast-neutral-fill);  color: var(--toast-neutral-fg); }
.toast-neutral svg  { color: var(--toast-neutral-fg); }
.toast .toast-message {
  flex: 1;
  /* Render \n line breaks in multi-line error messages. */
  white-space: pre-line;
}
/* Keep the icon and close button aligned to the top when message wraps. */
.toast svg { margin-top: 1px; flex-shrink: 0; }
.toast .toast-close {
  background: transparent;
  border: 0;
  padding: var(--space-1);
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  line-height: 0;
  flex-shrink: 0;
}
.toast .toast-close:hover { color: rgba(255, 255, 255, 1); }
.toast--leaving {
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}


/* ============================================================
   LEGACY-COMPAT
   ============================================================
   A small set of legacy class names from v0 that are still referenced
   in production templates. These are kept for two reasons:
     (1) inert semantic wrappers (.form-row, .form-group) that the v1
         macros / forms continue to use without trying to rename.
     (2) JS hooks (.staffing-table, .mapping-form, .pagination-*,
         .expandable, .toggle-cell, etc.) that the existing inline
         JS still queries by class.

   Styled with v1 tokens so they look consistent with the rest of the
   system. When a legacy class is no longer referenced anywhere in
   templates, its rule here can be deleted.
============================================================ */

/* Form layout */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.form-row > .form-group { flex: 1 1 0; min-width: 180px; }
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}
.form-group > label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary); }

.inline { display: inline-flex; }

/* Table action / column-width hints (used by staffing/overhead tables) */
.actions-cell {
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
  display: flex;
  gap: var(--space-1);
  justify-content: flex-end;
  align-items: center;
}
.staffing-table .col-name { min-width: 120px; }
.staffing-table .col-sl, .staffing-table .col-type, .staffing-table .col-worker, .staffing-table .col-comp, .staffing-table .col-rate { white-space: nowrap; }
.staffing-table .col-date, .overhead-table .col-date { white-space: nowrap; min-width: 96px; }
.staffing-table .col-location, .overhead-table .col-location { min-width: 120px; }
.staffing-table .col-actions, .overhead-table .col-actions { width: 1px; white-space: nowrap; }
.staffing-table .col-tags, .overhead-table .col-tags, .table .col-tags { min-width: 110px; }
.overhead-table .col-amount { min-width: 140px; }
.overhead-table .col-line-item { min-width: 200px; }

/* Drill-down expandable rows (used by results.html + variance.html JS) */
.expandable { cursor: pointer; }
.expandable:hover td { background: var(--bg-subtle); }
.expand-icon, .toggle-cell { color: var(--text-tertiary); }

/* Expand chevron used in expandable P&L / variance rows (▸ collapsed, ▾ expanded). */
.expand-icon {
  display: inline-block;
  width: 12px;
  color: var(--text-tertiary);
}
.expand-icon.is-open {
  color: var(--accent);
}

/* Inactive row (deactivated locations / clinicians / etc.) */
.row-inactive td { opacity: 0.55; }

/* Value cell — unified override/inherited treatment (PV-100).
   Use the `value_cell()` macro in _components.html; never write the markup raw.

   - .value-cell           → inherited value, muted text, no glyph
   - .value-cell.is-override → overridden value, normal text, leading accent dot

   The dot is a 6px filled circle rendered as a ::before so it doesn't take a
   text-baseline slot and stays aligned in numeric (right-aligned) cells. */
.value-cell {
  color: var(--text-secondary);
}
.value-cell.is-override {
  color: var(--text-primary);
}
.value-cell.is-override::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: var(--space-2);
  vertical-align: middle;
  /* Pull up slightly so the dot reads as mid-cap-height, not baseline-bottom */
  transform: translateY(-1px);
}
.default-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--weight-regular);
  margin-left: var(--space-1);
}

/* Modal `<details>` advanced-options disclosure */
.modal-details {
  margin: var(--space-3) 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
}
.modal-details > summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  list-style: none;
  user-select: none;
}
.modal-details > summary::-webkit-details-marker { display: none; }
.modal-details[open] > summary { color: var(--text-primary); margin-bottom: var(--space-3); }
.modal-details > summary::before {
  content: '▸';
  display: inline-block;
  width: 12px;
  color: var(--text-tertiary);
  transition: transform var(--duration-fast) var(--ease-out);
}
.modal-details[open] > summary::before { content: '▾'; color: var(--accent); }

/* Pagination controls (staffing-table JS pagination)
   Three-zone footer: count (left) · prev/page/next (center) · per-page (right).
   .pagination-controls is the outer flex row; .pagination-buttons holds the
   prev/page/next cluster; .pagination-per-page holds the selector. */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  gap: var(--space-3);
}
.pagination-buttons {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.pagination-info, .pagination-page {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}
.pagination-per-page {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  white-space: nowrap;
}
/* Compact select for per-page chooser — inherits .select-chip shape */
.select-chip--sm {
  font-size: var(--text-sm);
  padding: 3px var(--space-6) 3px var(--space-2);
  height: 28px;
  background-position: right 6px center;
  background-size: 12px;
}

/* Breadcrumb (legacy classes; new system uses .topbar-breadcrumb) */
.breadcrumb {
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: var(--text-sm);
}
.breadcrumb:hover { color: var(--text-primary); }
.breadcrumb-sep { color: var(--text-disabled); margin: 0 var(--space-1); }

/* Mobile sidebar overlay + toggle button */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 90;
}
.sidebar-overlay.visible { display: block; }
.sidebar-toggle {
  display: none;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--text-secondary);
}
@media (max-width: 720px) {
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out);
    z-index: 100; /* above sidebar-overlay (z-index: 90) so clicks aren't blocked */
  }
  .sidebar.open { transform: translateX(0); display: flex; }
}

/* Radio label (assumptions form) */
.radio-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  cursor: pointer;
  margin-right: var(--space-3);
}

/* Wide main column (used by P&L / variance / dashboard via {% block main_class %}wide{% endblock %}) */
.wide { max-width: 100%; }

/* Active link/menu state (used by sidebar/subnav legacy code paths) */
.active { color: var(--accent); }

/* Badge legacy aliases (badge-muted, badge-green, badge-amber, badge-active, badge-group) */
.badge-muted, .badge-group { color: var(--text-secondary); background: var(--bg-subtle); padding: 2px 6px; border-radius: var(--radius-sm); font-size: var(--text-xs); }
.badge-green, .badge-active { color: var(--positive-fg); background: var(--positive-bg-subtle); padding: 2px 6px; border-radius: var(--radius-sm); font-size: var(--text-xs); }
.badge-amber { color: var(--warning-fg); background: var(--warning-bg-subtle); padding: 2px 6px; border-radius: var(--radius-sm); font-size: var(--text-xs); }

/* Import.html JS-hook classes (no style needed — JS queries by class) */
.mapping-form, .mapping-edit-form, .mapping-gl-input, .mapping-sub-input,
.mapping-lineitem-input, .subcategory-select, .lineitem-select,
.seasonal-input { /* JS hooks only — styling comes from .input/.select */ }

/* Short descriptive paragraph below a section_header. Caps reading width.
   Use on the <p> directly under the header — not for body copy elsewhere. */
.section-intro {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
  max-width: 680px;
}

/* Mid-card heading for a sub-grouping of fields. Smaller emphasis than
   section_header (which sits OUTSIDE a card). Use inside body_flush cards. */
.subsection-heading {
  font-size: var(--text-md);
  font-weight: var(--weight-semi);
  margin: var(--space-4) 0 var(--space-2);
  color: var(--text-primary);
}

/* Small "Actual" sub-label that appears below a period header on the P&L
   when that period contains imported actuals (vs forecast). Pairs with
   .col-actual cell tint. */
.col-actual-tag {
  font-size: 9px;
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--accent-subtle-fg);
}


/* ============================================================
   COMPARE VIEW (PV-44)
============================================================ */

/* Block 1 — Compare strip: two picker buttons + range/swap controls.
   align-items: flex-end keeps the picker buttons' bottom edges aligned
   even though only the A/B sides carry the small label row above. */
.compare-strip {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.compare-strip-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1 1 240px;
  min-width: 0;
}
.compare-strip-side-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  font-weight: var(--weight-semi);
}
.compare-strip-vs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-subtle, var(--bg-surface));
  border: 1px solid var(--border-default);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin: 0 var(--space-2) 4px;
  flex-shrink: 0;
}
.compare-strip-controls {
  display: flex;
  align-items: stretch;
  gap: var(--space-2);
}
/* Range picker in the controls cluster should size to content, not
   flex-stretch like A/B's 240px-min picker wraps. */
.compare-strip-controls .compare-picker-wrap { flex: 0 0 auto; min-width: 160px; }
.compare-swap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
}
.compare-swap-btn:hover {
  background: var(--bg-subtle, var(--bg-surface));
  color: var(--text-primary);
}

/* compare_picker: popover-style picker button matching workspace switcher */
.compare-picker-wrap {
  position: relative;
}
.compare-picker-button {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  color: var(--text-primary);
  text-align: left;
}
.compare-picker-button:hover {
  background: var(--bg-subtle, var(--bg-surface));
  border-color: var(--border-strong, var(--border-default));
}
.compare-picker-name {
  flex: 1;
  font-weight: var(--weight-semi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compare-picker-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--accent-subtle-bg, color-mix(in srgb, var(--accent) 12%, transparent));
  color: var(--accent-subtle-fg, var(--accent));
  border-radius: var(--radius-full, 999px);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
}
.compare-picker-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 280px;
  z-index: 40;
}

/* Block 2 — KPI row: 4 equal columns of the standard .kpi tiles */
.compare-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

/* Block 4 compare table */
.table-compare {
  width: 100%;
  border-collapse: collapse;
}
.table-compare thead th {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-default);
}
.table-compare thead th.col-num { text-align: right; }
.compare-row td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle, var(--border-default));
}
.compare-cell-label { color: var(--text-primary); }
.compare-cell-num { text-align: right; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.compare-cell-delta.is-positive { color: var(--positive-fg); }
.compare-cell-delta.is-negative { color: var(--negative-fg); }
.compare-row-subtotal td {
  font-weight: var(--weight-semi);
  background: var(--bg-subtle, transparent);
}
.compare-row-total td {
  font-weight: var(--weight-semi);
  border-top: 1px solid var(--border-default);
  border-bottom: 1px solid var(--border-default);
}
.compare-row-parent:hover td { background: var(--bg-subtle, transparent); }
.compare-drill-caret {
  display: inline-block;
  width: 1em;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}
/* Two drill levels (PV-115): sub-group (depth-1) then leaf (depth-2),
   mirroring results.html's .depth-1 / .depth-2 indentation.
   PV-134 readability: three clear background tiers so deep line-item lists are
   scannable — parent (surface) < zebra leaves (surface/subtle) < group header
   (muted). Leaves alternate (compare-row-leaf-alt set every other leaf in the
   macro), and hovering any drill row tints it so you can track across columns. */
.compare-row-group td {
  background: var(--bg-muted);
}
.compare-cell-group {
  padding-left: var(--space-5) !important;
  color: var(--text-primary);
  font-weight: var(--weight-medium, 500);
}
.compare-row-child td { background: var(--bg-surface); }
.compare-row-child.compare-row-leaf-alt td { background: var(--bg-subtle); }
.compare-row-group:hover td,
.compare-row-child:hover td { background: var(--accent-subtle-bg); }
.compare-cell-leaf {
  padding-left: var(--space-7, 2.5rem) !important;
  color: var(--text-secondary);
}

/* Stubbed-block placeholder (Blocks 3 + 6 in v1) */
.compare-stub {
  padding: var(--space-6);
  text-align: center;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-xl);
  background: var(--bg-subtle, var(--bg-surface));
  color: var(--text-tertiary);
}
.compare-stub-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  margin-bottom: var(--space-1);
  color: var(--text-secondary);
}

/* Block 0 — Insights narrative card.
   Subtle mint→white left-to-right gradient so the insight surface
   reads as distinct without competing visually. Standard card border
   so it sits in the same chrome family as the rest of the page. */
.compare-narrative {
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--accent) 12%, var(--bg-surface)) 0%,
    var(--bg-surface) 100%
  );
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-5);
}
.compare-narrative-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.compare-narrative-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.compare-narrative-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
}
.compare-narrative-beta {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--accent);
  letter-spacing: var(--tracking-wide);
}
.compare-narrative-body {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.55;
}
.compare-narrative-body strong {
  font-weight: var(--weight-semi);
  color: var(--text-primary);
}


/* ============================================================
   COMPARE — BLOCK 6: RECONCILING CROSSWALK + INPUT AUDIT (PV-113)
   The crosswalk strip is the net-income bridge (precursor to a waterfall
   chart); the audit sections are the per-input "what changed" detail.
============================================================ */
.crosswalk {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
}
.crosswalk-node {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  min-width: 92px;
}
.crosswalk-node--anchor { background: var(--bg-subtle); }
.crosswalk-op {
  display: flex;
  align-items: center;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}
.crosswalk-node-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.crosswalk-node-value {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
}
/* Bars carry a colored top-edge (the "waterfall" hint) + a colored value. */
.crosswalk-bar { border-top: 3px solid var(--border-strong); }
.crosswalk-bar.is-favorable { border-top-color: var(--positive-fg); }
.crosswalk-bar.is-unfavorable { border-top-color: var(--negative-fg); }
.crosswalk-bar.is-zero { border-top-color: var(--border-default); }
.crosswalk-bar-value {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
}
.crosswalk-bar.is-favorable .crosswalk-bar-value { color: var(--positive-fg); }
.crosswalk-bar.is-unfavorable .crosswalk-bar-value { color: var(--negative-fg); }
.crosswalk-bar.is-zero .crosswalk-bar-value { color: var(--text-tertiary); }

/* Audit sections (inside a flush card) */
.audit-section { border-bottom: 1px solid var(--border-subtle, var(--border-default)); }
.audit-section:last-child { border-bottom: 0; }
.audit-section.is-empty { opacity: 0.55; }
.audit-section-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: none;
  border: 0;
  font: inherit;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}
.audit-section.is-empty .audit-section-head { cursor: default; }
.audit-chevron {
  display: inline-block;
  width: 1em;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}
.audit-section-title { font-weight: var(--weight-semi); }
.audit-section-impact {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semi);
}
.audit-section-impact.is-favorable { color: var(--positive-fg); }
.audit-section-impact.is-unfavorable { color: var(--negative-fg); }
.audit-section.is-collapsed .audit-section-body { display: none; }
.audit-section-body { padding: 0 var(--space-4) var(--space-3); }

.audit-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px dashed var(--border-subtle, var(--border-default));
}
.audit-row:first-child { border-top: 0; }
.audit-pill {
  flex: 0 0 auto;
  height: fit-content;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.audit-pill.is-added { color: var(--positive-fg); background: var(--positive-bg-subtle); }
.audit-pill.is-removed { color: var(--negative-fg); background: var(--negative-bg-subtle); }
.audit-pill.is-changed { color: var(--info-fg); background: var(--info-bg-subtle); }
.audit-row-main { flex: 1 1 auto; min-width: 0; }
.audit-row-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.audit-row-label { font-weight: var(--weight-medium); color: var(--text-primary); }
.audit-row-sub { font-size: var(--text-xs); color: var(--text-tertiary); }
.audit-row-summary {
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.audit-changes {
  margin-top: var(--space-1);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.audit-change {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--text-sm);
}
.audit-change-field { color: var(--text-tertiary); min-width: 140px; }
.audit-change-before { color: var(--text-secondary); }
.audit-change-arrow { color: var(--text-tertiary); }
.audit-change-after { color: var(--text-primary); font-weight: var(--weight-medium); }

.audit-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-default);
}
/* Per-section explanatory note (e.g. revenue-driver / assumption impact lives
   in the bars above, not as a line here). Sits below the section's rows. */
.audit-section-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-style: italic;
}
.audit-section-note svg { flex: 0 0 auto; margin-top: 2px; }
/* Bare text button — routed through the `button` macro (ghost variant), so these
   rules neutralize the .btn layout (padding/height/weight/hover-bg) to keep the
   borderless accent-text look. Use .btn-ghost.audit-expand-btn for hover so it
   beats .btn-ghost:hover on specificity, not just source order. */
.audit-expand-btn {
  background: none;
  border: 0;
  padding: 0;
  height: auto;
  color: var(--accent);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  cursor: pointer;
}
.btn-ghost.audit-expand-btn:hover {
  background: none;
  color: var(--accent);
  text-decoration: underline;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .row-2col, .row-2col--equal { grid-template-columns: 1fr; }
  .row-3col { grid-template-columns: 1fr; }
  .compare-kpi-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .audit-change { flex-wrap: wrap; }
  .audit-change-field { min-width: 100%; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .page { padding: var(--space-5) var(--space-4); }
  .page-title { font-size: var(--text-5xl); }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: var(--space-2); }
  .compare-kpi-row { grid-template-columns: 1fr; }
  .compare-strip { flex-direction: column; align-items: stretch; }
}


/* ============================================================
   MONTHLY REVIEW / TRACK & REVIEW (PV-111)
   Timeline of monthly reviews + per-month review page. Public API
   is the mr_* macros in _components.html; markup uses native
   <details> for disclosures (no JS). Semantic tokens only.
============================================================ */

/* --- Status indicator dots (timeline) --- */
.tr-status-dot {
  width: 14px; height: 14px;
  border-radius: var(--radius-full);
  flex: 0 0 14px;
  display: inline-flex;
  position: relative;
}
.tr-status-dot.is-reviewed {
  background: var(--positive-fg);
  box-shadow: 0 0 0 3px var(--positive-bg-subtle);
}
.tr-status-dot.is-inreview {
  background: var(--warning-fg);
  box-shadow: 0 0 0 3px var(--warning-bg-subtle);
}
.tr-status-dot.is-inreview::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  clip-path: inset(0 0 0 50%);
}
.tr-status-dot.is-awaiting {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  box-shadow: 0 0 0 3px var(--bg-subtle);
}

/* --- Timeline --- */
.tr-timeline {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 28px;
}
.tr-timeline::before {
  content: "";
  position: absolute;
  left: 14px; top: 22px; bottom: 22px;
  width: 1px;
  background: var(--border-default);
}

.tr-month {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-3);
  text-align: left;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3) var(--space-4);
  align-items: start;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.tr-month .tr-month-dot {
  position: absolute;
  left: -28px; top: 24px;
  background: var(--bg-canvas);
  padding: 2px;
  border-radius: var(--radius-full);
}
a.tr-month:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
a.tr-month:hover .tr-month-arrow {
  color: var(--text-primary);
  transform: translateX(2px);
}

.tr-month-body { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.tr-month-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.tr-month-label {
  font-size: var(--text-md);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  letter-spacing: -0.005em;
  text-decoration: none;
}
a.tr-month-label:hover { color: var(--accent); }

.tr-metrics { display: flex; flex-direction: column; gap: 6px; }
.tr-metric-row {
  display: grid;
  grid-template-columns: 96px 140px 1fr;
  align-items: baseline;
  gap: var(--space-3);
}
.tr-metric-label { color: var(--text-tertiary); font-size: var(--text-sm); }
.tr-metric-value {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  letter-spacing: -0.012em;
}
.tr-metric-var { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.tr-metric-var.tr-var-positive { color: var(--positive-fg); }
.tr-metric-var.tr-var-negative { color: var(--negative-fg); }
.tr-metric-var .tr-metric-vs { color: var(--text-tertiary); font-weight: var(--weight-regular); }

.tr-month-forecast { font-size: var(--text-md); color: var(--text-secondary); }
.tr-month-footer { font-size: var(--text-sm); color: var(--text-tertiary); }

.tr-month-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-3);
  justify-self: end;
  align-self: center;
}
.tr-month-arrow {
  color: var(--text-tertiary);
  transition: color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.tr-inline-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  text-decoration: none;
  white-space: nowrap;
}
.tr-inline-action:hover { border-color: var(--text-primary); background: var(--bg-surface); }

/* --- Future row + footer link --- */
.tr-future-row {
  margin-top: var(--space-3);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  border-top: 1px dashed var(--border-default);
  position: relative;
}
.tr-future-row::before {
  content: "";
  position: absolute;
  left: -22px; top: 50%;
  width: 8px; height: 8px;
  border-radius: var(--radius-full);
  border: 1px dashed var(--border-strong);
  background: var(--bg-canvas);
  transform: translateY(-50%);
}
.tr-future-label {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.tr-future-chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.tr-future-chip {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.tr-future-chip:hover { background: var(--bg-subtle); color: var(--text-primary); }

.tr-footer-link {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-default);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  color: var(--text-secondary);
  text-decoration: none;
  width: fit-content;
}
.tr-footer-link:hover { color: var(--accent); }

/* --- Per-month review: back link + sections --- */
.tr-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  text-decoration: none;
  margin-bottom: var(--space-4);
}
.tr-back:hover { color: var(--text-primary); }
.tr-back svg { transform: rotate(180deg); }

.tr-section { margin-bottom: var(--space-8); }
.tr-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  gap: var(--space-3);
}
.tr-section-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  letter-spacing: -0.005em;
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.tr-section-sub { font-size: var(--text-sm); color: var(--text-tertiary); margin-top: 2px; }
.tr-section-asof {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--weight-regular);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* --- Status strip --- */
.tr-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  overflow: hidden;
}
.tr-strip-cell {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--border-subtle);
}
.tr-strip-cell:last-child { border-right: 0; }
.tr-strip-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.tr-strip-value {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tr-strip-meta { font-size: var(--text-xs); color: var(--text-tertiary); }
.tr-check {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  flex: 0 0 14px;
}
.tr-check.is-ok { background: var(--positive-bg-subtle); color: var(--positive-fg); }
.tr-check.is-no { background: var(--bg-subtle); color: var(--text-tertiary); }
.tr-check.is-warn { background: var(--warning-bg-subtle); color: var(--warning-fg); }
.tr-check.is-neutral { background: var(--bg-subtle); color: var(--text-tertiary); }
.tr-check-dash { font-size: 11px; line-height: 1; color: var(--text-tertiary); }

/* --- Plan context disclosure (native <details>) --- */
.tr-plan-context {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: var(--space-4) var(--space-5);
}
.tr-plan-context-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--text-md);
  list-style: none;
}
.tr-plan-context-trigger::-webkit-details-marker { display: none; }
.tr-plan-context-trigger svg {
  color: var(--text-tertiary);
  transition: transform var(--duration-fast) var(--ease-out);
}
.tr-plan-context[open] .tr-plan-context-trigger svg { transform: rotate(90deg); }
.tr-plan-context-trigger:hover { color: var(--text-primary); }
.tr-plan-context-prefix { font-weight: var(--weight-medium); color: var(--text-primary); }
.tr-plan-context-quote { color: var(--text-tertiary); font-style: italic; }
.tr-plan-context-body {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  max-width: 70ch;
  white-space: pre-wrap;
}

/* --- Period-end balances --- */
.tr-balances {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  overflow: hidden;
}
.tr-balance-cash {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-5) var(--space-6);
}
.tr-balance-cash-left { display: flex; flex-direction: column; gap: 4px; }
.tr-balance-cash-value {
  font-size: var(--text-4xl);
  font-weight: var(--weight-semi);
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.05;
  margin-top: 4px;
}
.tr-balance-meta { font-size: var(--text-sm); color: var(--text-tertiary); }

.tr-balance-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(200px, 1fr) auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.tr-balance-row:last-child { border-bottom: 0; }
.tr-balance-label { font-size: var(--text-md); color: var(--text-primary); font-weight: var(--weight-medium); }
.tr-balance-value {
  font-size: var(--text-md);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.tr-balance-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  justify-self: end;
}
.tr-balance-toggle svg { transition: transform var(--duration-fast) var(--ease-out); }

/* AR disclosure (native <details>) */
.tr-ar-disclosure { border-top: 1px solid var(--border-subtle); }
.tr-ar-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
}
.tr-ar-trigger::-webkit-details-marker { display: none; }
.tr-ar-trigger:hover { background: var(--bg-subtle); color: var(--text-primary); }
.tr-ar-trigger svg { color: var(--text-tertiary); transition: transform var(--duration-fast) var(--ease-out); }
.tr-ar-disclosure[open] > .tr-ar-trigger svg { transform: rotate(90deg); color: var(--text-primary); }
.tr-ar-trigger-meta { margin-left: auto; font-size: var(--text-xs); color: var(--text-tertiary); }
.tr-ar-body { border-top: 1px solid var(--border-subtle); }

/* AR insurance row is itself a disclosure for the aging buckets */
.tr-ar-insurance > summary.tr-balance-row { cursor: pointer; list-style: none; }
.tr-ar-insurance > summary.tr-balance-row::-webkit-details-marker { display: none; }
.tr-ar-insurance[open] .tr-balance-toggle svg { transform: rotate(90deg); }

.tr-aging {
  padding: var(--space-3) var(--space-5) var(--space-5) var(--space-7);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}
.tr-aging-cell { display: flex; flex-direction: column; gap: 4px; }
.tr-aging-label {
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  font-weight: var(--weight-medium);
}
.tr-aging-value {
  font-size: var(--text-md);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.tr-aging-bar {
  margin-top: 4px;
  height: 3px;
  background: var(--border-default);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.tr-aging-bar > span { display: block; height: 100%; background: var(--text-secondary); }
.tr-aging-cell.is-old .tr-aging-value { color: var(--warning-fg); }
.tr-aging-cell.is-old .tr-aging-bar > span { background: var(--warning-fg); }

.tr-footnote-row {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-subtle);
}

/* --- Notes --- */
.tr-notes-wrap {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: var(--space-4) var(--space-5) var(--space-3);
}
.tr-textarea {
  width: 100%;
  min-height: 120px;
  border: 0;
  background: transparent;
  resize: vertical;
  font: inherit;
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  padding: 0;
  outline: 0;
}
.tr-textarea::placeholder { color: var(--text-tertiary); }
.tr-notes-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.tr-notes-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* --- Diagnostics --- */
.tr-diagnostics {
  border-top: 1px solid var(--border-default);
  padding-top: var(--space-5);
  margin-top: var(--space-10);
}
.tr-diagnostics-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}
.tr-diag-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
}
.tr-diag-link.is-disabled { color: var(--text-tertiary); cursor: not-allowed; pointer-events: none; }
.tr-diag-link:hover { color: var(--accent); }
.tr-diag-note { display: block; margin-top: 4px; font-size: var(--text-xs); color: var(--text-tertiary); }


/* ============================================================
   ONBOARDING WIZARD (PV-30)
   ============================================================
   The 5-step setup wizard. Chrome-less full-page layout with a
   step rail, per-step content, and a footer nav. Every value below
   reads a semantic token (translated from the approved design file).
============================================================ */

/* --- Shell --- */
.wz {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
  color: var(--text-primary);
}
.wz-top {
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
}
.wz-brand-mark {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--text-inverse);
  display: grid;
  place-items: center;
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
  flex: 0 0 auto;
}
.wz-top .wz-wm { font-size: var(--text-lg); font-weight: var(--weight-semi); letter-spacing: var(--tracking-tight); }
.wz-top .wz-div { width: 1px; height: 20px; background: var(--border-default); }
.wz-top .wz-ws { font-size: var(--text-base); color: var(--text-tertiary); }
.wz-top-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.wz-saved { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--text-tertiary); }
.wz-saved svg { width: 13px; height: 13px; color: var(--positive-fg); }
/* AI-assist header toggle (PR D) — only rendered when the overlay is available. */
.ai-ctl-form { margin: 0; }
.ai-ctl { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--text-secondary); cursor: pointer; user-select: none; }
.ai-ctl .sp { color: var(--accent); display: inline-flex; }
.ai-ctl .sp svg { width: 14px; height: 14px; }

.wz-main { flex: 1; overflow-y: auto; padding: 38px 24px 96px; }
.wz-inner { max-width: 960px; margin: 0 auto; }

/* --- Stepper --- */
.wz-stepper { display: flex; align-items: center; margin-bottom: 30px; }
.wz-step { display: flex; align-items: center; gap: 9px; }
.wz-step .conn { flex: 1; height: 1.5px; background: var(--border-default); margin: 0 12px; min-width: 20px; }
.wz-step.done .conn { background: var(--accent); }
.wz-dot {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  border: 1.5px solid var(--border-strong);
  color: var(--text-tertiary);
  background: var(--bg-surface);
  flex: 0 0 auto;
}
.wz-dot svg { width: 15px; height: 15px; }
.wz-step.done .wz-dot { background: var(--accent); border-color: var(--accent); color: var(--text-inverse); }
.wz-step.cur .wz-dot { border-color: var(--accent); color: var(--accent); box-shadow: var(--focus-ring); }
.wz-slabel { font-size: var(--text-base); color: var(--text-tertiary); white-space: nowrap; }
.wz-step.cur .wz-slabel { color: var(--text-primary); font-weight: var(--weight-semi); }
.wz-step.done .wz-slabel { color: var(--text-secondary); }

/* --- Step headings --- */
.wz-h1 { font-size: var(--text-4xl); font-weight: var(--weight-semi); letter-spacing: var(--tracking-tighter); color: var(--text-primary); line-height: var(--leading-tight); }
.wz-sub { font-size: var(--text-md); color: var(--text-tertiary); margin-top: 5px; margin-bottom: 24px; }
.wz-sec { font-size: var(--text-xs); font-weight: var(--weight-semi); letter-spacing: var(--tracking-widest); text-transform: uppercase; color: var(--text-tertiary); margin: 0 0 12px; }

/* --- Fields --- */
.wz-field { margin-bottom: 18px; }
.wz-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* --- Practice-type cards (Step 1) --- */
.type-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.type-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 15px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface);
  transition: border-color var(--duration-fast), background var(--duration-fast);
}
.type-card:hover { border-color: var(--border-strong); }
.type-card:has(input:checked) { border-color: var(--accent); background: var(--accent-subtle-bg); box-shadow: inset 0 0 0 1px var(--accent); }
.type-card:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.type-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.type-ic { width: 32px; height: 32px; border-radius: var(--radius-lg); background: var(--bg-subtle); display: grid; place-items: center; color: var(--accent); }
.type-card:has(input:checked) .type-ic { background: var(--bg-surface); }
.type-ic svg { width: 17px; height: 17px; }
.type-name { font-size: var(--text-base); font-weight: var(--weight-semi); color: var(--text-primary); }
.type-desc { font-size: var(--text-sm); color: var(--text-tertiary); line-height: var(--leading-snug); }

/* --- Path cards (Step 2) --- */
.path-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 16px; align-items: stretch; }
.path-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 18px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
}
.path-card.primary { border-color: var(--accent-border); box-shadow: inset 3px 0 0 var(--accent); }
.path-card.disabled { background: var(--bg-subtle); opacity: 0.9; }
.path-ic { width: 34px; height: 34px; border-radius: var(--radius-lg); background: var(--accent-subtle-bg); color: var(--accent); display: grid; place-items: center; margin-bottom: 12px; }
.path-ic.muted { background: var(--bg-muted); color: var(--text-tertiary); }
.path-ic svg { width: 18px; height: 18px; }
.path-h { font-size: var(--text-lg); font-weight: var(--weight-semi); color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.path-d { font-size: var(--text-base); color: var(--text-tertiary); line-height: var(--leading-normal); margin-top: 5px; flex: 1; }

/* --- Dropzone (Step 2) --- */
.drop {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px 18px;
  text-align: center;
  background: var(--bg-canvas);
  cursor: pointer;
  transition: border-color var(--duration-fast), background var(--duration-fast);
  margin-top: 14px;
}
.drop:hover, .drop.is-dragover { border-color: var(--accent); background: var(--accent-subtle-bg); }
.drop:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--accent); }
.drop--uploading { cursor: default; border-style: solid; border-color: var(--accent-border); background: var(--accent-subtle-bg); }
.drop-ic { width: 38px; height: 38px; border-radius: var(--radius-lg); background: var(--bg-surface); border: 1px solid var(--border-default); display: grid; place-items: center; color: var(--accent); margin: 0 auto 10px; }
.drop-ic svg { width: 19px; height: 19px; }
.drop-t { font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--text-primary); }
.drop-s { font-size: var(--text-sm); color: var(--text-tertiary); margin-top: 3px; }
.wz-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.prog { height: 6px; background: var(--bg-muted); border-radius: var(--radius-sm); overflow: hidden; margin-top: 10px; }
.prog-bar { height: 100%; background: var(--accent); border-radius: var(--radius-sm); transition: width 0.18s var(--ease-out); }
/* Honest indeterminate progress — no fake percentage, just motion. */
.prog-bar--indeterminate { width: 40%; animation: wz-indeterminate 1.1s var(--ease-in-out) infinite; }
@keyframes wz-indeterminate {
  0%   { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.filepill { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-base); color: var(--text-secondary); background: var(--bg-subtle); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: 7px 11px; }
.filepill svg { width: 14px; height: 14px; color: var(--text-tertiary); }

/* --- Detected mini-cards (Step 3) --- */
.mini-card { border: 1px solid var(--border-default); border-radius: var(--radius-xl); background: var(--bg-surface); overflow: hidden; margin-bottom: 16px; }
.mini-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border-subtle); }
.mini-title { font-size: var(--text-base); font-weight: var(--weight-semi); color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.mini-title svg { width: 15px; height: 15px; color: var(--text-tertiary); }
.mini-count { font-size: var(--text-sm); color: var(--text-tertiary); }

/* Static (non-interactive) icon + label row — read-only lists. */
.list-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; font-size: var(--text-base); color: var(--text-secondary); }
.list-row svg { width: 14px; height: 14px; color: var(--text-tertiary); flex-shrink: 0; }

/* --- Triage (Step 3) --- */
.tri-bar { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin: 2px 0 14px; padding: 11px 14px; background: var(--bg-subtle); border: 1px solid var(--border-default); border-radius: var(--radius-lg); }
.tri-left { font-size: var(--text-base); color: var(--text-secondary); display: flex; align-items: center; gap: 10px; }
.tri-count { font-weight: var(--weight-semi); color: var(--text-primary); }
.tri-sep { color: var(--text-disabled); }
.cls-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  margin-bottom: 8px;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
/* Dormant PR-D state — AI-suggested triage row. */
.cls-row.suggested { background: var(--accent-subtle-bg); border-color: var(--accent-border); }
.cls-name { font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--text-primary); }
.cls-amt { font-size: var(--text-sm); color: var(--text-tertiary); margin-top: 1px; }
.cls-badge-cell { text-align: right; }
.cseg-group { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.cseg {
  height: 28px;
  padding: 0 9px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background var(--duration-instant), color var(--duration-instant), border-color var(--duration-instant);
}
.cseg:hover { background: var(--bg-subtle); color: var(--text-primary); }
.cseg:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cseg svg { width: 11px; height: 11px; }
.cseg .cseg-check { display: none; }
.cseg.conf { background: var(--accent); border-color: var(--accent); color: var(--text-inverse); }
.cseg.conf .cseg-check { display: inline-flex; }
/* Dormant PR-D state — AI-suggested (dashed) segment. */
.cseg.sug { background: var(--bg-surface); border: 1px dashed var(--accent); color: var(--accent-subtle-fg); }
.cls-oh-select { height: 28px; font-size: var(--text-xs); max-width: 160px; padding: 0 24px 0 9px; }

/* --- Staffing (Step 4) --- */
.staff-layout { display: grid; grid-template-columns: 1fr 292px; gap: 24px; align-items: start; }
.staff-item { border: 1px solid var(--border-default); border-radius: var(--radius-xl); padding: 13px 15px; margin-bottom: 10px; background: var(--bg-surface); }
.staff-hd { display: flex; align-items: center; gap: 11px; }
.wz-avatar { width: 32px; height: 32px; border-radius: var(--radius-lg); display: grid; place-items: center; font-size: var(--text-sm); font-weight: var(--weight-semi); flex: 0 0 auto; }
.staff-name { font-size: var(--text-base); font-weight: var(--weight-semi); color: var(--text-primary); }
.staff-meta { font-size: var(--text-sm); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.staff-hrs { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.staff-hrs input[type=range] { flex: 1; accent-color: var(--accent); height: 4px; }
.staff-hrs input[type=range]:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-full); }
.staff-read { font-size: var(--text-sm); color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 132px; text-align: right; }
.staff-read b { color: var(--text-primary); font-weight: var(--weight-semi); }
.add-row { display: flex; gap: 10px; align-items: center; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 12px 15px; color: var(--text-secondary); font-size: var(--text-base); cursor: pointer; background: var(--bg-canvas); width: 100%; text-align: left; transition: border-color var(--duration-fast), color var(--duration-fast), background var(--duration-fast); }
.add-row:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-subtle-bg); }
.add-row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.add-row svg { width: 15px; height: 15px; }
/* Inline expanding add form — native <details>, works with or without JS. */
.wz-add-details { margin-bottom: 10px; }
.wz-add-details summary { list-style: none; }
.wz-add-details summary::-webkit-details-marker { display: none; }
.wz-add-details[open] summary.add-row { border-color: var(--accent); color: var(--accent); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.wz-addform { border: 1px solid var(--border-default); border-top: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); padding: 15px; background: var(--bg-surface); }
.wz-addform-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.live-card {
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-xl);
  padding: 18px;
  background: linear-gradient(180deg, var(--accent-subtle-bg), var(--bg-surface) 66%);
  position: sticky;
  top: 6px;
}
.live-k { font-size: var(--text-xs); font-weight: var(--weight-semi); letter-spacing: var(--tracking-widest); text-transform: uppercase; color: var(--text-tertiary); display: flex; align-items: center; gap: 6px; }
.live-k svg { width: 13px; height: 13px; color: var(--accent); }
.live-val { font-size: var(--text-5xl); font-weight: var(--weight-semi); letter-spacing: var(--tracking-tighter); color: var(--text-primary); font-variant-numeric: tabular-nums; margin-top: 8px; line-height: 1; }
.live-val .u { font-size: var(--text-base); font-weight: var(--weight-regular); color: var(--text-tertiary); }
.live-note { font-size: var(--text-sm); color: var(--text-tertiary); margin-top: 5px; }
.live-row { display: flex; justify-content: space-between; font-size: var(--text-base); padding: 8px 0; border-top: 1px solid var(--border-subtle); }
.live-row:first-of-type { margin-top: 14px; }
.live-row .l { color: var(--text-tertiary); }
.live-row .v { color: var(--text-primary); font-weight: var(--weight-semi); font-variant-numeric: tabular-nums; }

/* --- Review (Step 5) --- */
.rev-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.rev-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* --- AI explainer (DORMANT — PR D renders it) --- */
.explain { border: 1px solid var(--accent-border); border-radius: var(--radius-xl); background: linear-gradient(180deg, var(--accent-subtle-bg), var(--bg-surface) 72%); padding: 14px 16px; margin-bottom: 22px; display: flex; gap: 12px; align-items: flex-start; }
.explain .ic { width: 26px; height: 26px; border-radius: var(--radius-md); background: var(--bg-surface); display: grid; place-items: center; color: var(--accent); flex: 0 0 auto; }
.explain .ic svg { width: 15px; height: 15px; }
.explain-t { font-size: var(--text-base); font-weight: var(--weight-semi); color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.explain-b { font-size: var(--text-base); color: var(--text-secondary); line-height: var(--leading-normal); margin-top: 3px; }
.explain-x { margin-left: auto; color: var(--text-tertiary); cursor: pointer; background: none; border: 0; padding: 3px; }
.explain-x svg { width: 14px; height: 14px; }

/* --- Footer nav --- */
.wz-nav { display: flex; align-items: center; gap: 12px; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border-default); }
.wz-nav .spacer { flex: 1; }
.nav-hint { font-size: var(--text-sm); color: var(--text-tertiary); }

/* --- Editable definition row (assumptions step, PV-146) ---
   A def-row whose value IS an input: reads as a value at rest (transparent,
   right-aligned), reveals its editability on hover/focus (border + surface).
   One set of fields — no read-only recap + hidden <details> duplication. */
.def-row-input { align-items: center; }
.def-row-input .def-edit {
  justify-self: end;
  width: 100%;
  max-width: 220px;
  text-align: right;
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 4px 8px;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.def-row-input .def-edit:hover { border-color: var(--border-default); background: var(--bg-surface); }
.def-row-input .def-edit:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-surface);
  box-shadow: var(--focus-ring);
}
/* A trailing unit/help hint sitting under the row's value (e.g. "0.95 = 95%"). */
.def-edit-hint {
  grid-column: 2;
  justify-self: end;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
}
select.def-edit { text-align: left; }

/* --- Responsive --- */
@media (max-width: 720px) {
  .wz-field-grid { grid-template-columns: 1fr; }
  .type-row { grid-template-columns: 1fr; }
  .path-row { grid-template-columns: 1fr; }
  .staff-layout { grid-template-columns: 1fr; }
  .rev-kpis { grid-template-columns: 1fr 1fr; }
  .rev-sum { grid-template-columns: 1fr; }
  .live-card { position: static; }
}


/* ============================================================
   AUTH SCREENS (PV-30 — design "2a Horizon photographic" + "#join")
   ============================================================
   Chrome-less pre-login layouts: the split-panel sign-in (_auth_split.html)
   and the centered-card join (join.html). Bespoke on-photo wash/line colors
   are literals sourced VERBATIM from the design file
   "PracticeVue Onboarding - Flow & Sign-in.dc.html" (line numbers cited
   inline); everything structural uses semantic tokens. */

/* --- Brand lockup (shared by both auth layouts) --- */
.auth-brand { display: flex; align-items: center; gap: 10px; }
/* Binoculars mark in the brand accent — matches base.html's sidebar-brand. */
.auth-brand-icon {
  display: inline-flex;
  color: var(--accent);
  flex: 0 0 auto;
}
.auth-wordmark {
  font-size: var(--text-xl);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

/* --- Full-bleed sign-in stage (PV-146) ---
   The hero (photo + wash + forecast chart + overlays) is the background of the
   whole viewport; a solid floating card sits over it toward the left. */
.auth-stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}
/* Floating card column: card pinned ~8% from the left, vertically centered.
   The card itself reuses the shared .auth-card chrome (defined with the join
   layout below) — solid surface, hairline, radius, shadow. The sign-in card is
   a touch wider than the join card so the one-line headline has room; a
   descendant selector wins the width regardless of source order. */
.auth-float {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: var(--space-6) 8%;
}
.auth-float .auth-card { max-width: 480px; }
/* Wider variant for the join card — room for the 12-char segmented invite
   field (PV-146: it overflowed the standard card). */
.auth-float .auth-card--wide { max-width: 560px; }
.auth-kicker {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 22px 0 14px;
}
.auth-headline {
  /* One line at desktop widths: nowrap + a clamp()-sized type that degrades
     gracefully as the card narrows on small screens. Sized to fit the ~480px
     card without wrapping the "Your practice, in full view" headline. */
  font-size: clamp(18px, 4.6vw, 26px);
  line-height: 1.15;
  letter-spacing: var(--tracking-tighter);
  color: var(--text-primary);
  font-weight: var(--weight-semi);
  white-space: nowrap;
}
.auth-sub {
  font-size: var(--text-md);
  color: var(--text-secondary);
  margin-top: 12px;
  line-height: var(--leading-normal);
}
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
}
.auth-alt {
  text-align: center;
  font-size: var(--text-base);
  color: var(--text-tertiary);
}
/* Divider above the card footer row. */
.auth-card-divider {
  border-top: 1px solid var(--border-subtle);
  margin: 24px 0 15px;
}
.auth-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}
.auth-foot svg { color: var(--text-tertiary); }
.auth-foot-links { margin-left: auto; display: flex; gap: 16px; }
.auth-foot-links a { color: var(--text-tertiary); }

/* --- Hero (photo + teal wash + forecast line), now the full-bleed layer ---
   Positioned ancestor for every .auth-hero-* overlay below. */
.auth-hero {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--bg-subtle);
}
.auth-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.auth-hero-wash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Teal wash over a near-black vertical ramp; theme-swapped via the token. */
  background: var(--overlay-scrim);
}

/* Forecast trajectory (decorative). The SVG holds ONLY the area fill + the two
   stroked lines, in a 0-100 viewBox with preserveAspectRatio="none" so its
   coordinate space maps linearly to the pane (x -> % width, y -> % height).
   `vector-effect: non-scaling-stroke` keeps the stroke a constant 2.5px at any
   aspect ratio, so the line never looks fat/thin as the viewport resizes.
   Everything that WOULD distort under non-uniform scaling (the round dot, the
   dashed "Today" rule, all text, the KPI card, the month labels) lives in
   percentage-positioned HTML instead — HTML text/boxes never stretch. Because
   the SVG maps 0-100 linearly to the pane, an HTML element at left:X% top:Y%
   lands exactly on the SVG point (X, Y) at every width. */
.auth-hero-chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.auth-hero-area { fill: var(--hero-area); }
.auth-hero-path {
  fill: none;
  stroke: var(--hero-line);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.auth-hero-path.is-forecast {
  stroke-dasharray: 6 6;
  opacity: .85;
}

/* "Today" dashed vertical rule + label — HTML so it never distorts. */
.auth-hero-marker {
  position: absolute;
  left: 50%;
  top: 12%;
  height: 44%;          /* runs down to the dot at ~56% */
  border-left: 1px dashed var(--hero-marker);
  pointer-events: none;
}
.auth-hero-marker-label {
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  font-size: var(--text-sm);
  color: var(--hero-text-muted);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* Junction dot at the actuals -> forecast handoff (left:50%, top:56%). */
.auth-hero-dot {
  position: absolute;
  left: 50%;
  top: 56%;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--hero-dot-fill);
  border: 2px solid var(--hero-dot-stroke);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Frosted KPI callout — bespoke on-photo element (option 1). Semi-transparent
   fill + backdrop blur + hairline; floats top-right over the photo. */
.auth-hero-card {
  position: absolute;
  top: clamp(24px, 5%, 48px);
  right: clamp(24px, 5%, 48px);
  max-width: 260px;
  padding: 18px 20px;
  border-radius: var(--radius-xl);
  background: var(--hero-card-bg);
  border: 1px solid var(--hero-card-border);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  color: var(--hero-text);
}
.auth-hero-card-kicker {
  font-size: var(--text-sm);
  color: var(--hero-text-muted);
  margin-bottom: 8px;
}
.auth-hero-card-figure {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.auth-hero-card-value {
  font-size: clamp(28px, 3vw, 36px);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.auth-hero-card-delta {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--hero-delta);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.auth-hero-card-sub {
  font-size: var(--text-sm);
  color: var(--hero-text-muted);
  margin-top: 8px;
}

/* Month axis labels along the bottom — HTML, evenly distributed. */
.auth-hero-months {
  position: absolute;
  left: 44px;
  right: 44px;
  bottom: 76px;
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--hero-text-faint);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.auth-hero-legend {
  position: absolute;
  left: 44px;
  bottom: 44px;
  display: flex;
  gap: 20px;
}
.auth-hero-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--text-sm);
  color: var(--hero-text-muted);   /* on-photo legend text */
}
.auth-hero-swatch {
  width: 14px;
  height: 2px;
  border-radius: 1px;
  background: var(--hero-line);
}
.auth-hero-swatch.is-forecast { opacity: .6; }

/* --- Full-bleed → narrow: the card takes near-full width with margins and
   stays legible over the photo; the photo's fine overlays are hidden so the
   background reads as ambiance, not clutter. Nothing scrolls horizontally
   (the stage clips overflow). --- */
@media (max-width: 640px) {
  .auth-float { padding: var(--space-5) var(--space-4); align-items: center; }
  .auth-float .auth-card { max-width: none; padding: 28px 22px 22px; }
  .auth-hero-card, .auth-hero-months, .auth-hero-legend,
  .auth-hero-marker, .auth-hero-marker-label { display: none; }
}

/* --- Join: centered card over quiet geometry canvas --- */
.auth-canvas {
  position: relative;
  min-height: 100vh;
  background: var(--bg-canvas);
  display: grid;
  place-items: center;
  padding: var(--space-6);
  overflow: hidden;
}
.auth-canvas-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.auth-card {
  position: relative;
  width: 100%;
  max-width: 452px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);   /* floating card — shadow allowed */
  padding: 38px 40px 30px;
}
.auth-card-foot {
  border-top: 1px solid var(--border-subtle);
  margin-top: 22px;
  padding-top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}
.auth-card-foot svg { color: var(--text-tertiary); }
.auth-card-foot a { color: var(--text-tertiary); }
.auth-foot-sep { color: var(--border-strong); }

/* --- Invite code field (pv-invite-field) --- */
.invite-field {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Boxes flex down so 12 chars + separators always fit the card (they
   overflowed the fixed 38px width at 12 chars — PV-146). */
.invite-box {
  flex: 1 1 0;
  min-width: 0;
  max-width: 40px;
  height: 44px;
  padding: 0;
  text-align: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  background: var(--bg-surface);
  text-transform: uppercase;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.invite-box.filled { border-color: var(--border-strong); }
.invite-box:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.invite-sep {
  color: var(--text-disabled);
  font-weight: var(--weight-semi);
}
