/* Chuy v2 components and shell. Tokens come from theme.css (light/dark). No framework, no build.
   Classes other sections use: .card .card-title .kpi .chip(-success/-warning/-danger/-info/-muted)
   .btn(-primary/-secondary/-danger/-ghost) .table .form .field .label .hint .errors .alert(-*)
   .toast .menu dialog .empty .page-header .grid-2 .grid-3. Phase 1 classes (table.grid, form.stack,
   .flash, .narrow, .row, .list) keep working for the classic pages. */

/* ---- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--canvas); color: var(--fg);
  font: 400 var(--text-base)/var(--leading) var(--font-body); letter-spacing: var(--tracking-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-heading); letter-spacing: var(--tracking-heading); color: var(--fg); margin: 0 0 var(--sp-3); line-height: 1.2; }
h1 { font-size: var(--text-xl); font-weight: 600; }
h2 { font-size: var(--text-lg); font-weight: 600; }
h3 { font-size: var(--text-md); font-weight: 600; }
h4 { font-size: var(--text-base); font-weight: 600; margin: 0 0 var(--sp-2); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .small { font-size: var(--text-sm); }
code, .mono, .serial { font-family: var(--font-mono); font-size: 0.95em; letter-spacing: 0; }
.muted { color: var(--muted); }
.secondary { color: var(--fg-secondary); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -5px; }
.icon-sm { width: 16px; height: 16px; vertical-align: -3px; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
hr { border: 0; border-top: 1px solid var(--outline-variant); margin: var(--sp-4) 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* ---- shell: fixed 240px sidebar on the canvas at >= 900px; top bar plus drawer below */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 40;
  background: var(--canvas); border-right: 1px solid var(--outline-variant);
  display: flex; flex-direction: column; padding: var(--sp-4) var(--sp-3);
  overflow-y: auto; transition: transform var(--dur-4) var(--ease);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-1) var(--sp-2) var(--sp-4); }
.brand { display: inline-flex; align-items: center; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand .logo { height: 44px; width: auto; }
.brand .logo-light, .logo-light { display: var(--logo-light); }
.brand .logo-dark, .logo-dark { display: var(--logo-dark); }
.brand-small .logo { height: 28px; }
.sidebar-head .drawer-close { display: none; }
.nav { flex: 1; display: flex; flex-direction: column; gap: var(--sp-4); }
.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-section-label { font-size: 10px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); padding: var(--sp-2) var(--sp-3) var(--sp-1); }
.nav-row {
  position: relative; display: grid; grid-template-columns: 20px 1fr; align-items: center; gap: var(--sp-3);
  padding: 8px 12px; border-radius: var(--radius-md); color: var(--fg-secondary); font-weight: 500; text-decoration: none;
  transition: background var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
}
.nav-row:hover { background: var(--surface-high); color: var(--fg); text-decoration: none; }
.nav-row.active { color: var(--primary); background: var(--primary-bg); }
.nav-row.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--primary); }
.nav-row .icon { color: inherit; }
.nav-row-quiet { color: var(--muted); }
.sidebar-footer { border-top: 1px solid var(--outline-variant); margin-top: var(--sp-4); padding-top: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
.who { padding: var(--sp-1) var(--sp-3); min-width: 0; }
.who-name { font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-org { color: var(--muted); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { margin-left: var(--sidebar-w); padding: var(--sp-6) var(--sp-8) var(--sp-10); max-width: calc(var(--sidebar-w) + 1240px); min-width: 0; }
.topbar { display: none; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 39; background: var(--scrim); }

/* theme toggle: the mode shown follows html[data-theme] (no script needed for the first paint) */
.theme-toggle { display: inline-flex; align-items: center; gap: var(--sp-2); background: transparent; border: 1px solid transparent; color: var(--fg-secondary); font: inherit; font-weight: 500; cursor: pointer; border-radius: var(--radius-md); padding: 8px 12px; transition: background var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease); }
.theme-toggle:hover { background: var(--surface-high); color: var(--fg); }
.theme-toggle .tt-mode { display: none; align-items: center; gap: var(--sp-3); }
.theme-toggle .tt-mode .icon { width: 20px; height: 20px; }
.theme-toggle.compact .tt-label { display: none; }
.theme-toggle.compact { padding: 6px; border-radius: var(--radius-sm); }
.theme-toggle.wide { width: 100%; justify-content: flex-start; }
.theme-toggle.wide .tt-mode { display: none; grid-template-columns: 20px 1fr; }
.theme-toggle.wide .tt-mode .tt-label::before { content: "Colour mode: "; color: var(--muted); font-weight: 400; }
:root[data-theme="system"] .theme-toggle .tt-system, :root:not([data-theme]) .theme-toggle .tt-system { display: inline-flex; }
:root[data-theme="light"] .theme-toggle .tt-light { display: inline-flex; }
:root[data-theme="dark"] .theme-toggle .tt-dark { display: inline-flex; }
.theme-toggle.wide .tt-mode { display: none; }
:root[data-theme="system"] .theme-toggle.wide .tt-system, :root:not([data-theme]) .theme-toggle.wide .tt-system,
:root[data-theme="light"] .theme-toggle.wide .tt-light,
:root[data-theme="dark"] .theme-toggle.wide .tt-dark { display: grid; }
.theme-toggle:active .icon { transform: scale(.9) rotate(-12deg); transition: transform var(--dur-3) var(--ease-spring); }

@media (max-width: 899.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; border-right: 0; width: min(300px, 86vw); }
  .shell.drawer-open .sidebar { transform: none; box-shadow: var(--shadow-elevated); }
  .sidebar-head .drawer-close { display: inline-flex; }
  .topbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
    height: 52px; padding: 0 var(--sp-3) 0 var(--sp-2); background: var(--canvas); border-bottom: 1px solid var(--outline-variant);
  }
  .main { margin-left: 0; padding: var(--sp-4) var(--sp-4) var(--sp-8); }
}
@media (min-width: 900px) { .drawer-backdrop { display: none !important; } }

/* ---- auth / signed-out canvas: centred card with the logo */
.auth-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: var(--sp-6) var(--sp-4); }
.auth-top { width: 100%; max-width: 440px; display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-6); }
.auth-top .logo { height: 40px; }
.auth-main .flashes { width: 100%; max-width: 440px; }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--radius-lg); padding: var(--sp-6); box-shadow: var(--shadow-floating); }
.auth-card h1 { font-size: var(--text-xl); margin-bottom: var(--sp-2); }
.auth-card .lede { color: var(--muted); margin-bottom: var(--sp-5); }
.auth-card .form { margin-top: var(--sp-4); }
.auth-links { margin-top: var(--sp-4); color: var(--muted); font-size: var(--text-sm); display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.auth-foot { margin-top: auto; padding-top: var(--sp-8); color: var(--muted); font-size: var(--text-sm); }

/* ---- page header, grids */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-header h1 { margin-bottom: 2px; }
.page-sub { color: var(--muted); margin: 0; }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.section-title { font-size: var(--text-md); font-weight: 600; margin: var(--sp-6) 0 var(--sp-3); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-4); }
.functions { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } .kpis { gap: var(--sp-3); } }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

/* ---- cards and KPI tiles */
.card { background: var(--surface); border-radius: var(--radius-lg); padding: var(--card-pad); box-shadow: var(--ring); margin-bottom: var(--sp-4); min-width: 0; }
.card-title { font-size: var(--text-lg); font-weight: 600; margin: 0 0 var(--sp-1); }
.card-sub { color: var(--muted); margin: 0 0 var(--sp-4); font-size: var(--text-sm); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); flex-wrap: wrap; }
.card-head .card-sub { margin-bottom: var(--sp-3); }
.card-link { display: block; color: inherit; transition: transform var(--dur-hover) var(--ease), box-shadow var(--dur-hover) var(--ease); }
.card-link:hover { text-decoration: none; box-shadow: var(--shadow-floating); transform: translateY(-1px); }
.function { display: flex; flex-direction: column; gap: var(--sp-2); min-height: 150px; }
.function .fn-icon { width: 36px; height: 36px; border-radius: var(--radius-md); display: inline-flex; align-items: center; justify-content: center; background: var(--primary-bg); color: var(--primary); }
.function .fn-title { font-weight: 600; font-size: var(--text-md); font-family: var(--font-heading); letter-spacing: var(--tracking-heading); }
.function .fn-text { color: var(--muted); flex: 1; margin: 0; }
.function .fn-cta { color: var(--primary); font-weight: 500; display: inline-flex; align-items: center; gap: var(--sp-1); }
.kpi { background: var(--surface); border-radius: var(--radius-lg); padding: var(--sp-4) var(--card-pad); box-shadow: var(--ring); min-width: 0; }
.kpi-label { font-size: var(--text-sm); color: var(--muted); font-weight: 500; margin-bottom: var(--sp-1); }
.kpi-value { font-family: var(--font-heading); font-size: var(--text-2xl); font-weight: 600; letter-spacing: var(--tracking-heading); line-height: 1.1; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: var(--text-md); color: var(--muted); font-weight: 500; }
.kpi-delta { font-size: var(--text-sm); margin-top: var(--sp-1); color: var(--muted); }
.kpi-delta-success { color: var(--success); } .kpi-delta-danger { color: var(--danger); } .kpi-delta-warning { color: var(--warning); }

/* ---- chips (status triples: fg, 12% bg, 32% border) */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: var(--text-sm); font-weight: 500; line-height: 18px; white-space: nowrap; border: 1px solid var(--muted-border); background: var(--muted-bg); color: var(--fg-secondary); }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip-success { color: var(--success); background: var(--success-bg); border-color: var(--success-border); }
.chip-warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.chip-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.chip-info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.chip-muted { color: var(--muted); }
.chip-primary { color: var(--primary); background: var(--primary-bg); border-color: var(--primary-border); }

/* ---- buttons (bare <button> stays primary for the phase 1 pages) */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; min-height: 34px;
  border: 1px solid var(--outline); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg);
  font: inherit; font-weight: 500; letter-spacing: var(--tracking-body); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-hover) var(--ease), border-color var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease), transform var(--dur-2) var(--ease);
}
button:hover, .btn:hover { text-decoration: none; background: var(--surface-high); }
button:active, .btn:active { transform: scale(.985); transition-timing-function: var(--ease-spring); }
button:disabled, .btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
button:not([class]), button.btn-primary, .btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button:not([class]):hover, .btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: #ffffff; }
.btn-secondary { background: var(--surface); border-color: var(--outline); color: var(--fg); }
.btn-secondary:hover { background: var(--surface-high); }
.btn-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--on-status); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-secondary); }
.btn-ghost:hover { background: var(--surface-high); color: var(--fg); }
.btn-sm { padding: 4px 10px; min-height: 28px; font-size: var(--text-sm); }
.icon-btn { padding: 6px; min-height: 34px; width: 34px; }
.btn .icon { width: 18px; height: 18px; }

/* ---- forms */
.form { display: flex; flex-direction: column; gap: var(--sp-4); max-width: 520px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-3); }
.form-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; padding-top: var(--sp-1); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: var(--text-sm); font-weight: 600; color: var(--fg-secondary); }
.hint { font-size: var(--text-sm); color: var(--muted); margin: 0; }
.errors { color: var(--danger); font-size: var(--text-sm); margin: 0; padding-left: 0; list-style: none; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=tel], input[type=url],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; max-width: 100%; padding: 8px 10px; min-height: 36px; border: 1px solid var(--outline); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); font: inherit; letter-spacing: var(--tracking-body);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); border-radius: var(--radius-sm); }
textarea { min-height: 88px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; vertical-align: -3px; }
.check { display: flex; align-items: flex-start; gap: var(--sp-2); font-weight: 400; cursor: pointer; }
.check input { margin-top: 3px; }
.check.disabled { color: var(--muted); cursor: not-allowed; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--sp-2); }
.radio-card { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3); border: 1px solid var(--outline-variant); border-radius: var(--radius-md); cursor: pointer; background: var(--surface); transition: border-color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease); }
.radio-card:hover { background: var(--surface-high); }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-bg); color: var(--primary); }

/* ---- tables (hairline rows, no zebra, sortable headers via data-sort in app.js) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--outline-variant); vertical-align: middle; }
.table th { font-size: var(--text-sm); font-weight: 600; color: var(--muted); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-low); }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]::after { content: ""; display: inline-block; width: 0; height: 0; margin-left: 6px; border: 4px solid transparent; vertical-align: 1px; }
.table th[data-sort][aria-sort="ascending"]::after { border-bottom-color: currentColor; border-top: 0; }
.table th[data-sort][aria-sort="descending"]::after { border-top-color: currentColor; border-bottom: 0; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .serial { font-family: var(--font-mono); font-size: var(--text-sm); }
.table td.actions { text-align: right; white-space: nowrap; }
.table tr.row-link { cursor: pointer; }

/* ---- alerts (status triples) and the flash area that app.js turns into toasts */
.alert { display: flex; gap: var(--sp-2); align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--info-border); background: var(--info-bg); color: var(--fg); margin-bottom: var(--sp-3); }
.alert .icon { color: var(--info); margin-top: 1px; }
.alert-success { border-color: var(--success-border); background: var(--success-bg); } .alert-success .icon { color: var(--success); }
.alert-warning { border-color: var(--warning-border); background: var(--warning-bg); } .alert-warning .icon { color: var(--warning); }
.alert-danger { border-color: var(--danger-border); background: var(--danger-bg); } .alert-danger .icon { color: var(--danger); }
.alert a { color: inherit; text-decoration: underline; }
.flashes { margin-bottom: var(--sp-3); }

/* ---- toasts (bottom-right stack) */
.toasts { position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 60; display: flex; flex-direction: column; gap: var(--sp-2); width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--sp-2); padding: 10px 12px; border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-floating); border-left: 3px solid var(--info); color: var(--fg); transform: translateY(8px); opacity: 0; transition: transform var(--dur-4) var(--ease-spring), opacity var(--dur-3) var(--ease); }
.toast.show { transform: none; opacity: 1; }
.toast.hide { opacity: 0; transform: translateY(8px); }
.toast .icon { color: var(--info); margin-top: 1px; }
.toast-success { border-left-color: var(--success); } .toast-success .icon { color: var(--success); }
.toast-warning { border-left-color: var(--warning); } .toast-warning .icon { color: var(--warning); }
.toast-danger { border-left-color: var(--danger); } .toast-danger .icon { color: var(--danger); }
.toast .toast-text { flex: 1; }
.toast .toast-close { margin: -4px -6px -4px 0; }

/* ---- menus (native <details>) and dialogs */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; min-width: 180px; padding: var(--sp-1); background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-floating); display: flex; flex-direction: column; animation: menu-in var(--dur-2) var(--ease); }
.menu-item { display: flex; align-items: center; gap: var(--sp-2); padding: 7px 10px; border-radius: var(--radius-sm); color: var(--fg); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; min-height: 0; width: 100%; justify-content: flex-start; }
.menu-item:hover { background: var(--surface-high); text-decoration: none; }
.menu-item.danger { color: var(--danger); }
.menu-sep { border-top: 1px solid var(--outline-variant); margin: var(--sp-1) 0; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
dialog { border: 0; border-radius: var(--radius-lg); padding: var(--sp-6); background: var(--surface); color: var(--fg); box-shadow: var(--shadow-elevated); width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: var(--scrim); }
dialog[open] { animation: dialog-in var(--dur-3) var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-5); }

/* ---- empty states */
.empty { text-align: center; padding: var(--sp-8) var(--sp-4); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.empty-icon { width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-bg); color: var(--primary); margin-bottom: var(--sp-1); }
.empty-icon .icon { width: 24px; height: 24px; }
.empty-title { margin: 0; }
.empty-text { color: var(--muted); max-width: 420px; margin: 0 0 var(--sp-3); }

/* ---- charts (home activity; the classic page has its own dashboard.css) */
.chart-card .plot { position: relative; width: 100%; }
.chart-card .plot svg { display: block; width: 100%; height: auto; font: var(--text-sm) var(--font-body); overflow: visible; }
.chart-card .axis text { fill: var(--muted); }
.chart-card .axis line, .chart-card .axis path, .chart-card .gridline { stroke: var(--outline-variant); shape-rendering: crispEdges; }
.chart-card .axis .domain { display: none; }
.chart-card .line { fill: none; stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; }
.chart-card .area { opacity: .12; }
.chart-card .marker { stroke: var(--surface); stroke-width: 2px; }
.chart-card .hairline { stroke: var(--muted); stroke-width: 1px; pointer-events: none; }
.chart-card .overlay { fill: none; pointer-events: all; cursor: crosshair; outline: none; }
.chart-card .state { color: var(--muted); text-align: center; padding: var(--sp-6) 0; margin: 0; }
.chart-card .tooltip { position: absolute; top: 8px; left: 0; pointer-events: none; z-index: 2; min-width: 150px; background: var(--surface); border-radius: var(--radius-md); padding: 8px 10px; font-size: var(--text-sm); box-shadow: var(--shadow-floating); }
.chart-card .tooltip .time { color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.chart-card .tooltip .row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.chart-card .tooltip .val { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
.chart-card .tooltip .name { color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 0 0 var(--sp-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--fg-secondary); background: none; border: 0; padding: 2px 4px; min-height: 0; border-radius: 4px; }
.legend-item[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; flex: none; }
.tableview { margin-top: var(--sp-2); font-size: var(--text-sm); }
.tableview summary { cursor: pointer; color: var(--primary); }
.tablewrap { overflow: auto; margin-top: var(--sp-2); }

/* ---- settings page tabs (anchors) */
.tabs { display: flex; gap: var(--sp-1); flex-wrap: wrap; margin-bottom: var(--sp-5); border-bottom: 1px solid var(--outline-variant); padding-bottom: var(--sp-2); }
.tabs a { padding: 6px 12px; border-radius: var(--radius-pill); color: var(--fg-secondary); font-weight: 500; }
.tabs a:hover { background: var(--surface-high); text-decoration: none; color: var(--fg); }
section:target > .card, .card:target { box-shadow: 0 0 0 2px var(--primary-border); }
section[id] { scroll-margin-top: 64px; }

/* ---- lists */
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-rows > li { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: center; padding: 10px 0; border-bottom: 1px solid var(--outline-variant); }
.list-rows > li:last-child { border-bottom: 0; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-1) var(--sp-4); margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }

/* ---- B2: "how this is measured" icon beside chart titles (-> /home/methodology#anchor), and that page's contents list */
.info-link { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-left: 2px; vertical-align: middle; color: var(--muted); border-radius: 50%; transition: color var(--dur-hover) var(--ease); }
.info-link:hover, .info-link:focus-visible { color: var(--primary); text-decoration: none; }
.info-link .icon { width: 16px; height: 16px; vertical-align: 0; }
.toc { columns: 2; column-gap: var(--sp-5); margin: 0; padding-left: 20px; }
.toc li { break-inside: avoid; padding: 2px 0; }
@media (max-width: 640px) { .toc { columns: 1; } }

/* ---- legal pages (/privacy, /terms): one readable column in either shell */
.legal { width: 100%; max-width: 720px; }
.legal section + section { margin-top: var(--sp-5); }

/* ---- phase 1 classes (classic dashboard, staff and tenant pages) on the new tokens */
.container { max-width: 1200px; margin: 0 auto; }
.flash { padding: 10px 12px; border: 1px solid var(--info-border); background: var(--info-bg); border-radius: var(--radius-md); margin-bottom: var(--sp-3); }
.flash-error { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.flash-success { border-color: var(--success-border); background: var(--success-bg); color: var(--success); }
.flash-warning { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning); }
form.stack { display: block; }
form.stack label { display: block; margin: 10px 0 4px; font-weight: 500; font-size: var(--text-sm); color: var(--fg-secondary); }
form.stack input[type=text], form.stack input[type=email], form.stack input[type=password], form.stack select, form.stack textarea { max-width: 420px; }
form.stack .errors { padding-left: 0; margin-top: 4px; }
table.grid { border-collapse: collapse; width: 100%; margin: var(--sp-2) 0 var(--sp-4); }
table.grid th, table.grid td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--outline-variant); vertical-align: top; }
table.grid th { font-weight: 600; color: var(--muted); font-size: var(--text-sm); }
.list { padding-left: 18px; }
.row { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end; }
.narrow { max-width: 480px; }
.dash h1 { margin-bottom: var(--sp-4); }

/* ---- print and motion */
@media print {
  .sidebar, .topbar, .toasts, .theme-toggle, .page-actions { display: none !important; }
  .main { margin: 0; padding: 0; }
  .card, .kpi { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: #fff; color: #000; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
