/* Sestante design system imported from https://claude.ai/artifact/2qSNB9Cbh1yCv9oU5JSgeX (version c2)
   by scripts/import_design_system.py. Generated: do not edit. App-specific rules live in app.css. */

/* Sestante Design System — generated from tokens.json */
:root, [data-theme="dark"] {
  --bg: #0d0d0f;
  --surface: #151517;
  --surface-2: #1c1c20;
  --surface-3: #26262c;
  --surface-inset: #111113;
  --surface-ink: #1a1626;
  --on-ink: #ffffff;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.36);
  --border-card: rgba(255, 255, 255, 0.09);
  --border-emphasis: rgba(255, 106, 31, 0.5);
  --highlight: rgba(255, 255, 255, 0.06);
  --dot: rgba(255, 255, 255, 0.06);
  --text: #e8e8ea;
  --text-strong: #ffffff;
  --text-secondary: #b4b4ba;
  --text-muted: #909098;
  --text-faint: #909098;
  --brand: #ff6a1f;
  --brand-hover: #ff7f3d;
  --brand-text: #ffa36b;
  --on-brand: #1a0b04;
  --brand-tint: rgba(255, 106, 31, 0.12);
  --brand-tint-text: #ffa36b;
  --sunset-1: #ff8a1f;
  --sunset-2: #ff4f6d;
  --sunset-3: #b04dff;
  --accent: #36eaba;
  --accent-tint: rgba(54, 234, 186, 0.12);
  --accent-tint-text: #36eaba;
  --ok: #36eaba;
  --warn: #ffb347;
  --danger: #ff6b7a;
  --info: #8fb4ff;
  --sev-critical: #ff6b7a;
  --sev-high: #ffb347;
  --sev-medium: #c9a2ff;
  --sev-low: #8fb4ff;
  --sev-info: #a0a0a8;
  --backdrop: rgba(8, 8, 10, 0.7);
  --surface-page: var(--bg);
  --surface-card: var(--surface);
  --surface-raised: var(--surface-2);
  --surface-sunken: var(--surface-3);
  --text-body: var(--text);
  --text-meta: var(--text-faint);
  --text-label: var(--text-muted);
  --action-primary: var(--brand);
  --action-primary-hover: var(--brand-hover);
  --action-on-primary: var(--on-brand);
  --live: var(--accent);
  --control-border: var(--border-strong);
  --divider: var(--border);
  --shadow-raised: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 0 rgba(0, 0, 0, 0.6), 0 16px 32px -18px rgba(0, 0, 0, 0.85);
  --shadow-panel: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 28px 60px -16px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(0, 0, 0, 0.4);
  --shadow-control: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 10px -6px rgba(0, 0, 0, 0.8);
  --glow-hot: 0 14px 30px -18px rgba(255, 79, 109, 0.55);
  --shadow-float: 0 24px 60px rgba(0, 0, 0, 0.5);
  --shadow-overlay: 0 30px 80px rgba(0, 0, 0, 0.55);
}
[data-theme="light"] {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f7f6f2;
  --surface-3: #ebe9e3;
  --surface-inset: #fafaf8;
  --surface-ink: #191a24;
  --on-ink: #ffffff;
  --border: #ebe8e1;
  --border-strong: #8e93a2;
  --border-card: #e6e2da;
  --border-emphasis: #191a24;
  --highlight: rgba(255, 255, 255, 0.9);
  --dot: rgba(23, 25, 35, 0.08);
  --text: #17181f;
  --text-strong: #0e0f14;
  --text-secondary: #4a4d5a;
  --text-muted: #62657a;
  --text-faint: #62657a;
  --brand: #ff6a1f;
  --brand-hover: #e85a12;
  --brand-text: #b8400c;
  --on-brand: #1a0b04;
  --brand-tint: #fff0e7;
  --brand-tint-text: #8a2e06;
  --sunset-1: #e8700c;
  --sunset-2: #d93a5a;
  --sunset-3: #8a3fd9;
  --accent: #0a7356;
  --accent-tint: #ddf5ec;
  --accent-tint-text: #0a5c45;
  --ok: #0a7356;
  --warn: #8a5a00;
  --danger: #c42746;
  --info: #3555c8;
  --sev-critical: #c42746;
  --sev-high: #8a5a00;
  --sev-medium: #6a3fc1;
  --sev-low: #3555c8;
  --sev-info: #62657a;
  --surface-page: var(--bg);
  --surface-card: var(--surface);
  --surface-raised: var(--surface-2);
  --surface-sunken: var(--surface-3);
  --text-body: var(--text);
  --text-meta: var(--text-faint);
  --text-label: var(--text-muted);
  --action-primary: var(--brand);
  --action-primary-hover: var(--brand-hover);
  --action-on-primary: var(--on-brand);
  --live: var(--accent);
  --control-border: var(--border-strong);
  --divider: var(--border);
  --shadow-raised: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(23, 25, 35, 0.06), 0 12px 28px -16px rgba(23, 25, 35, 0.18);
  --shadow-panel: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 24px 50px -20px rgba(23, 25, 35, 0.22);
  --shadow-control: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 2px 6px -3px rgba(23, 25, 35, 0.2);
  --glow-hot: 0 12px 26px -16px rgba(217, 58, 90, 0.35);
  --shadow-float: 0 24px 60px rgba(23, 25, 35, 0.18);
  --shadow-overlay: 0 30px 80px rgba(23, 25, 35, 0.22);
}
:root {
  --size-1: 0.25rem;
  --size-2: 0.5rem;
  --size-3: 0.75rem;
  --size-4: 1rem;
  --size-5: 1.25rem;
  --size-6: 1.5rem;
  --size-7: 2rem;
  --size-8: 3rem;
  --size-9: 4.5rem;
  --radius-sm: 3px;
  --radius: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-2xl: 28px;
  --radius-round: 100000px;
  --border-width: 1px;
  --hairline: 1px;
  --sidebar-w: 244px;
  --topbar-h: 66px;
  --content-max: 1360px;
  --font-size-0: 0.6875rem;
  --font-size-1: 0.8125rem;
  --font-size-2: 0.875rem;
  --font-size-3: 0.9375rem;
  --font-size-4: 1.375rem;
  --font-size-5: 1.875rem;
  --font-size-6: 3.5rem;
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Space Mono", ui-monospace, Menlo, Consolas, monospace;
}
.type-hero { font-family: var(--font-display); font-size: 56px; line-height: 1.05; font-weight: 600; letter-spacing: -0.025em; }
.type-h1 { font-family: var(--font-display); font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
.type-h2 { font-family: var(--font-display); font-size: 22px; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; }
.type-title { font-family: var(--font-display); font-size: 15px; line-height: 1.3; font-weight: 600; letter-spacing: -0.005em; }
.type-kpi-xl { font-family: var(--font-display); font-size: 56px; line-height: 1; font-weight: 500; letter-spacing: -0.03em; }
.type-kpi { font-family: var(--font-display); font-size: 28px; line-height: 1.05; font-weight: 500; letter-spacing: -0.02em; }
.type-lead { font-family: var(--font-sans); font-size: 16px; line-height: 1.6; font-weight: 400; }
.type-body { font-family: var(--font-sans); font-size: 14px; line-height: 1.55; font-weight: 400; }
.type-small { font-family: var(--font-sans); font-size: 12px; line-height: 1.5; font-weight: 400; }
.type-label { font-family: var(--font-sans); font-size: 11px; line-height: 1.4; font-weight: 500; letter-spacing: 0.12em; }
.type-control { font-family: var(--font-sans); font-size: 13px; line-height: 1.2; font-weight: 500; }
.type-chip { font-family: var(--font-sans); font-size: 11px; line-height: 1.33; font-weight: 600; letter-spacing: 0.04em; }
.type-eyebrow { font-family: var(--font-mono); font-size: 11px; line-height: 1.4; font-weight: 400; letter-spacing: 0.18em; }
.type-data { font-family: var(--font-mono); font-size: 13px; line-height: 1.5; font-weight: 400; }
.type-data-sm { font-family: var(--font-mono); font-size: 11px; line-height: 1.5; font-weight: 400; }

/* Sestante UI, "dot matrix": base, shell, components, utilities, responsive rules.
   Every colour, size, radius, shadow and font comes from tokens.json (compiled to tokens.css, loaded first).
   Declared here only: what tokens.json cannot hold (gradients, dot patterns, motion). */

:root, [data-theme="dark"] { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
:root {
  --sunset: linear-gradient(90deg, var(--sunset-1) 0%, var(--sunset-2) 55%, var(--sunset-3) 100%);
  --sunset-diag: linear-gradient(135deg, var(--sunset-1), var(--sunset-2));
  --dots-4: radial-gradient(circle at center, #000 1.35px, transparent 1.75px) 0 0 / 4px 4px;
  --dots-5: radial-gradient(circle at center, #000 1.6px, transparent 2px) 0 0 / 5px 5px;
  --dots-6: radial-gradient(circle at center, #000 1.8px, transparent 2.2px) 0 0 / 6px 6px;
  --ease-2: cubic-bezier(.25,0,.4,1);
  --ease-3: cubic-bezier(.25,0,.3,1);
  --ease-out-3: cubic-bezier(0,0,.3,1);
  --duration-control: 0.15s;
  --duration-panel: 0.25s;
  --animation-spin: spin 2s linear infinite;
  --font-body: var(--font-sans);
  --font-data: var(--font-mono);
  --font-label: var(--font-sans);
  /* kept for older markup */
  --brand-soft: var(--brand-tint);
  --accent-soft: var(--accent-tint);
  --accent-glow: 0 0 0 3px var(--accent);
  --focus-ring: var(--accent-glow);
}

@keyframes spin{to{transform:rotate(1turn)}}

/* Icons: Phosphor light is the house weight. Components write `ph ph-<name>`; this draws them with the light font
   (same code points). Use `ph-fill` for "on" states. */
.ph { font-family: "Phosphor-Light" !important; }

/* --- Base ------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: var(--font-size-2);
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.5px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { color: var(--text-strong); }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; line-height: 1.2; letter-spacing: -0.015em; color: var(--text-strong); }
h1 { font-size: var(--font-size-5); line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: var(--font-size-4); }
h3 { font-size: var(--font-size-3); letter-spacing: -0.005em; }
h4 { font-size: var(--font-size-2); letter-spacing: 0; }
p { margin: 0; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--font-size-0); }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-muted); }
.prompt::before { content: "> "; color: var(--brand-text); font-family: var(--font-mono); font-weight: 700; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Raised surface: lit from above, resting on the page. */
.raised, .card, .sidebar, .page-hero { background-image: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0) 40%); }
[data-theme="light"] .card, [data-theme="light"] .sidebar, [data-theme="light"] .page-hero { background-image: none; }

/* Dot-matrix fill: any element with .dots paints its background through a dot mask. */
.dots { -webkit-mask: var(--dots-5); mask: var(--dots-5); }

/* --- App layout: floating sidebar ------------------------------------ */

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; gap: 0; align-items: start; min-height: 100vh; padding: 14px 0 0 14px; }

.sidebar {
  position: sticky; top: 14px;
  max-height: calc(100vh - 28px); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column;
  padding: 10px 10px 12px;
  background-color: var(--surface);
  border: var(--hairline) solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
}
.sidebar__brand {
  display: flex; flex-shrink: 0; align-items: center; justify-content: center;
  padding: 10px 8px 14px;
}
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text-strong); }
.logo-icon { height: 30px; width: auto; flex-shrink: 0; }
.wordmark { font-family: var(--font-sans); font-weight: 400; font-size: 20px; letter-spacing: 0.01em; line-height: 1; color: var(--text-strong); }
.logo--lg { justify-content: center; gap: var(--size-3); }
.logo--lg .logo-icon { height: 52px; }
.logo--lg .wordmark { font-size: 32px; }

.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px color-mix(in oklab, var(--accent) 70%, transparent);
  display: inline-block; flex-shrink: 0;
}

/* Tenant switch: a rounded block at the top of the sidebar. */
.sidebar__tenant {
  flex-shrink: 0; margin-bottom: 6px; padding: 9px 12px;
  border-radius: var(--radius); background: var(--surface-2);
  border: var(--hairline) solid var(--border-card);
}
.sidebar__tenant .label { font-size: 10px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }
.sidebar__tenant .name { display: flex; align-items: center; justify-content: space-between; gap: var(--size-2); font-size: var(--font-size-2); font-weight: 600; color: var(--text-strong); }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar__section { padding: 12px 12px 5px; font-size: 10px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }

.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: 34px; padding: 0 12px;
  border-radius: var(--radius);
  color: var(--text-secondary); font-size: var(--font-size-1); font-weight: 500;
  transition: background var(--duration-control) var(--ease-2), color var(--duration-control) var(--ease-2);
}
.nav-link i { font-size: 18px; color: var(--text-muted); transition: color var(--duration-control) var(--ease-2); }
.nav-link:hover { background: var(--surface-2); color: var(--text-strong); }
.nav-link:hover i { color: var(--text-secondary); }
.nav-link.active {
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
  color: var(--text-strong);
  box-shadow: var(--shadow-control);
}
[data-theme="light"] .nav-link.active { background: var(--surface-2); }
.nav-link.active i { color: var(--brand); }
.nav-link span:first-of-type { flex: 1; }
.nav-badge { font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 0 7px; line-height: 17px; border-radius: var(--radius-round); background: var(--surface-2); color: var(--text-secondary); }
.nav-link.active .nav-badge { background: var(--brand-tint); color: var(--brand-tint-text); }

/* The user lives in the top bar now; a sidebar footer, if present, is quiet. */
.sidebar__footer { flex-shrink: 0; margin-top: 8px; padding: 10px 12px 2px; border-top: var(--hairline) solid var(--border); display: flex; flex-direction: column; gap: var(--size-2); }

.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--sunset-diag); color: var(--on-brand);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em; flex-shrink: 0;
}
.user-chip .meta { min-width: 0; line-height: 1.25; text-align: left; }
.user-chip .meta strong { display: block; font-size: 12px; font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta span { font-size: 10px; color: var(--text-muted); }

/* Profile button: a pill in the top bar holding the user chip and a caret. */
.profile {
  display: inline-flex; align-items: center; gap: 10px;
  height: 42px; padding: 0 12px 0 5px;
  border-radius: var(--radius-round);
  border: var(--hairline) solid var(--border-card);
  background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer;
  box-shadow: var(--shadow-control);
}
.profile > i { color: var(--text-muted); font-size: 14px; }
.profile:hover { background: var(--surface-2); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 260px;
  padding: 8px; border-radius: var(--radius-md);
  background: var(--surface); border: var(--hairline) solid var(--border-card);
  box-shadow: var(--shadow-float);
}
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border-radius: 10px; font: inherit; font-size: var(--font-size-1); color: var(--text-secondary); background: none; border: 0; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-2); color: var(--text-strong); }
.menu i { font-size: 17px; color: var(--text-muted); }
.menu hr { border: 0; border-top: var(--hairline) solid var(--border); margin: 6px 0; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: relative; z-index: 10;
  min-height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--size-4);
  margin: 0 28px 0 32px;
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--sunset); opacity: .55; }
/* Crumbs: no slash separators; spacing alone separates them, "> " marks the current page. */
.topbar__title { display: flex; align-items: center; gap: 14px; font-family: var(--font-mono); font-size: 12px; color: var(--text-strong); }
.topbar__title .crumb { color: var(--text-muted); }
.topbar__title .crumb:nth-child(even) { display: none; }
.topbar__actions { position: relative; display: flex; align-items: center; gap: 10px; }

.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 22px 28px 40px 32px; display: flex; flex-direction: column; gap: var(--size-4); flex: 1; }

.footer { padding: var(--size-3) 32px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); display: flex; justify-content: space-between; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--size-4); flex-wrap: wrap; }
.page-head p { color: var(--text-secondary); margin-top: 6px; font-size: var(--font-size-2); }
.page-head .actions { display: flex; flex-wrap: wrap; gap: var(--size-2); }

/* Page hero: the dashboard header panel, with a dot-matrix motif on the right. */
.page-hero {
  position: relative; overflow: hidden;
  padding: 26px 28px 24px;
  background-color: var(--surface);
  border: var(--hairline) solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}
.page-hero > *:not(.page-hero__art) { position: relative; }
.page-hero__art { position: absolute; right: 0; top: 0; height: 100%; width: auto; max-width: 62%; pointer-events: none; }
.page-hero h1 { font-size: var(--font-size-5); }
.page-hero p { margin-top: 6px; color: var(--text-secondary); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px;
  border-radius: var(--radius-round); font-size: 12px; color: var(--text);
  background: color-mix(in oklab, var(--bg) 60%, transparent);
  border: var(--hairline) solid var(--border-card);
}
.chip i { font-size: 14px; color: var(--text-muted); }
.chip--hot { color: color-mix(in oklab, var(--sev-critical) 70%, var(--text-strong)); border-color: color-mix(in oklab, var(--sev-critical) 45%, transparent); }
.chip--hot i { color: var(--sev-critical); }

/* --- Centered (auth) layout ------------------------------------------ */

.centered { min-height: 100vh; display: grid; place-items: center; padding: var(--size-5); }
.auth-card { width: min(100%, 400px); }
.auth-card .logo { align-self: center; margin-bottom: var(--size-4); }

.tenant-grid { width: min(100%, 880px); display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--size-4); }
.tenant-card {
  display: flex; flex-direction: row; align-items: center; gap: var(--size-3);
  padding: var(--size-4); border-radius: var(--radius-md);
  text-align: left; cursor: pointer;
  transition: transform var(--duration-control) var(--ease-2), border-color var(--duration-control) var(--ease-2);
}
.tenant-card:hover { transform: translateY(-2px); border-color: var(--border-emphasis); box-shadow: var(--shadow-raised), var(--glow-hot); }
.tenant-card .icon { width: 38px; height: 38px; border-radius: var(--radius); background: var(--brand-tint); color: var(--brand-text); display: grid; place-items: center; font-size: 19px; flex-shrink: 0; }
.tenant-card strong { font-size: var(--font-size-2); font-weight: 600; color: var(--text-strong); }

/* --- Cards ----------------------------------------------------------- */

.card {
  background-color: var(--surface);
  border: var(--hairline) solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}
.accent-line { position: relative; overflow: hidden; border-color: var(--border-emphasis); }
.accent-line::before { content: ""; position: absolute; left: 20px; right: 20px; top: 0; height: 2px; border-radius: 0 0 2px 2px; background: var(--sunset); }
.accent-line > * { position: relative; }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--size-3);
  padding: 18px 20px 0;
}
.card__head h3 { font-size: var(--font-size-3); display: flex; align-items: center; gap: var(--size-2); }
.card__head h3 i { color: var(--text-muted); font-size: 18px; }
.card__body { padding: 18px 20px; }
.card__head + .card__body { padding-top: 12px; }
.card__body--flush, .card__head + .card__body--flush { padding: 0; }
.card__head + .card__body--flush { margin-top: var(--size-3); }

.grid { display: grid; gap: var(--size-4); }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--3-2 { grid-template-columns: 3fr 2fr; }
@media (max-width: 1100px) { .grid--2, .grid--3-2 { grid-template-columns: 1fr; } }

/* KPI tile: raised, a dot-matrix strip along the bottom in its colour; critical tiles glow underneath. */
.kpi {
  padding: 16px 16px 26px; border-radius: var(--radius-md);
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 22px; pointer-events: none;
  background: linear-gradient(90deg, color-mix(in oklab, var(--kpi-accent, var(--text-muted)) 60%, transparent), transparent 70%);
  -webkit-mask: var(--dots-6); mask: var(--dots-6);
}
.kpi[style*="--kpi-accent"]::after { background: linear-gradient(90deg, var(--kpi-accent), transparent 75%); }
.kpi--hot::after, .kpi[style*="sev-critical"]::after, .kpi[style*="brand"]::after { background: linear-gradient(90deg, var(--sunset-1), var(--sunset-2) 45%, transparent 100%); }
.kpi--hot, .kpi[style*="sev-critical"], .kpi[style*="brand"] { box-shadow: var(--shadow-raised), var(--glow-hot); }
.kpi .label { position: relative; font-size: 11px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.kpi .label i { font-size: 15px; }
.kpi .value { position: relative; font-family: var(--font-display); font-size: 28px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.05; color: var(--kpi-accent, var(--text-strong)); font-variant-numeric: tabular-nums; }
.kpi--hot .value, .kpi[style*="sev-critical"] .value, .kpi[style*="brand"] .value { background: var(--sunset-diag); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 10px color-mix(in oklab, var(--sunset-2) 35%, transparent)); }
.kpi .hint { position: relative; font-size: 12px; color: var(--text-secondary); }

/* --- Buttons --------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border-radius: var(--radius);
  border: var(--hairline) solid var(--border-strong);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,0)); color: var(--text);
  box-shadow: var(--shadow-control);
  font: inherit; font-size: var(--font-size-1); font-weight: 500; line-height: 1.2;
  cursor: pointer; white-space: nowrap;
  transition: background var(--duration-control) var(--ease-2), border-color var(--duration-control) var(--ease-2), color var(--duration-control) var(--ease-2);
}
[data-theme="light"] .btn { background: var(--surface); }
.btn:hover { background: var(--surface-2); color: var(--text-strong); }
.btn--primary { background: var(--sunset-diag); border-color: transparent; color: var(--on-brand); font-weight: 600; }
[data-theme="light"] .btn--primary { background: var(--brand); }
.btn--primary:hover { background: var(--brand-hover); border-color: transparent; color: var(--on-brand); }
.btn--ghost { border-color: transparent; background: none; box-shadow: none; color: var(--text-secondary); }
[data-theme="light"] .btn--ghost { background: none; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 55%, transparent); }
.btn--danger:hover { background: color-mix(in oklab, var(--danger) 12%, transparent); color: var(--danger); }
.btn--sm { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: 10px; }
.btn--icon { padding: 0; width: 36px; height: 36px; }
.btn--sm.btn--icon { width: 30px; height: 30px; }
.btn--block { width: 100%; }
.btn i { font-size: 16px; }
.btn--sm i { font-size: 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* --- Badges, risk, flags --------------------------------------------- */

.badge {
  --tone: var(--text-muted);
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px;
  border-radius: var(--radius-round);
  font-family: var(--font-sans); font-size: 10px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; line-height: 17px;
  white-space: nowrap;
  color: var(--tone);
  background: color-mix(in oklab, var(--tone) 10%, transparent);
  border: var(--hairline) solid color-mix(in oklab, var(--tone) 42%, transparent);
}
.badge i { font-size: 12px; }
.badge--compact { letter-spacing: 0.02em; padding-inline: 6px; }
.badge--critical { --tone: var(--sev-critical); }
.badge--high { --tone: var(--sev-high); }
.badge--medium { --tone: var(--sev-medium); }
.badge--low { --tone: var(--sev-low); }
.badge--info { --tone: var(--sev-info); }
.badge--ok { --tone: var(--ok); }
.badge--neutral { --tone: var(--text-secondary); background: transparent; border-color: var(--border-card); }
.badge--accent { --tone: var(--accent); }
.badge--brand { --tone: var(--brand-text); }

/* Risk pill: a dot-matrix bar in the sunset gradient. */
.risk-pill { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-weight: 700; font-size: 12px; color: var(--text-strong); }
.risk-pill .bar { position: relative; width: 44px; height: 8px; overflow: hidden; }
.risk-pill .bar::before { content: ""; position: absolute; inset: 0; background: var(--text-muted); opacity: .35; -webkit-mask: var(--dots-4); mask: var(--dots-4); }
.risk-pill .bar span { position: relative; display: block; height: 100%; background: var(--sunset); background-size: 44px 100%; -webkit-mask: var(--dots-4); mask: var(--dots-4); }
.risk-high .bar span { background: var(--sev-high); }
.risk-medium .bar span { background: var(--sev-medium); }
.risk-low .bar span { background: var(--sev-low); }

.flag { color: var(--text-muted); font-size: 16px; }
.flag--on { color: var(--brand-text); }
.flags { display: inline-flex; gap: 6px; }

/* --- Tables ---------------------------------------------------------- */

.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; max-width: 100%; }
.content > *, .grid > *, .card { min-width: 0; }

.table { width: 100%; border-collapse: collapse; font-size: var(--font-size-1); }
.table th {
  text-align: left; padding: 8px 12px;
  font-size: 10px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: var(--hairline) solid var(--border);
  white-space: nowrap;
}
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover, .table th a.sorted { color: var(--brand-text); }
.table td { padding: 11px 12px; border-bottom: var(--hairline) solid var(--border); vertical-align: middle; color: var(--text); }
.card__body--flush .table th:first-child, .card__body--flush .table td:first-child { padding-left: 20px; }
.card__body--flush .table th:last-child, .card__body--flush .table td:last-child { padding-right: 20px; }
.table .cell-badge { padding-inline: var(--size-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table .title { font-weight: 500; color: var(--text-strong); }
.table a.title:hover { color: var(--brand-text); }
.table .sub { display: block; font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.table td.num, .table th.num { text-align: right; font-family: var(--font-mono); font-size: 12px; }
.table td.mono { color: var(--text-secondary); font-size: 11px; white-space: nowrap; }
.table .empty { text-align: center; padding: var(--size-8); color: var(--text-muted); }
.table input[type="checkbox"] { accent-color: var(--brand); width: 15px; height: 15px; }
.table .checkbox-cell { width: 36px; }

/* --- Forms ----------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.field .help { font-size: 12px; color: var(--text-muted); }
.field .error { font-size: 12px; font-weight: 500; color: var(--danger); }

.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: 0 14px;
  border-radius: var(--radius);
  border: var(--hairline) solid var(--border-strong);
  background: var(--surface-inset); color: var(--text-strong);
  font: inherit; font-size: var(--font-size-1);
  transition: border-color var(--duration-control) var(--ease-2);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.textarea { padding: 10px 14px; border-radius: var(--radius-md); line-height: 1.5; resize: vertical; }
.select { padding-right: 10px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.select--sm { min-height: 30px; padding: 0 8px 0 10px; font-size: 12px; width: auto; border-radius: 10px; }
.select--inline { width: auto; display: inline-block; }

.checkbox { display: flex; align-items: center; gap: var(--size-2); font-size: var(--font-size-1); color: var(--text-secondary); }
.checkbox input { accent-color: var(--brand); width: 15px; height: 15px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checklist li { display: flex; align-items: center; gap: var(--size-2); font-size: var(--font-size-1); }
.checklist input { accent-color: var(--brand); width: 15px; height: 15px; }

.form-grid { display: grid; gap: var(--size-4); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--size-2); margin-top: var(--size-4); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--size-2); }
.filters .input { width: 260px; }
.filters .select { width: auto; }

/* --- Feedback -------------------------------------------------------- */

.flashes { display: flex; flex-direction: column; gap: var(--size-2); }
.alert {
  --tone: var(--text-muted);
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: var(--radius-md);
  border: var(--hairline) solid color-mix(in oklab, var(--tone) 35%, transparent);
  background: color-mix(in oklab, var(--tone) 8%, var(--surface));
  color: var(--text); font-size: var(--font-size-1);
}
.alert i { font-size: 18px; color: var(--tone); }
.alert--ok, .alert--success { --tone: var(--ok); }
.alert--warn, .alert--warning { --tone: var(--warn); }
.alert--danger { --tone: var(--danger); }
.alert--info { --tone: var(--info); }

.drawer {
  position: fixed; top: 14px; bottom: 14px; right: 14px; width: min(calc(100% - 28px), 520px); z-index: 40;
  background: var(--surface);
  border: var(--hairline) solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  overflow-y: auto;
  transform: translateX(calc(100% + 20px));
  transition: transform var(--duration-panel) var(--ease-3);
}
.drawer.open { transform: translateX(0); }
.backdrop { position: fixed; inset: 0; z-index: 30; background: var(--backdrop); backdrop-filter: blur(4px); }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--size-5); }
.modal .backdrop { position: absolute; z-index: 0; }
.modal__panel { position: relative; z-index: 1; width: min(100%, 520px); max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-overlay); }

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--size-4); padding: 20px; border-bottom: var(--hairline) solid var(--border); }
.detail-head h2 { font-size: 18px; line-height: 1.25; }
.detail-body { padding: 20px; display: flex; flex-direction: column; gap: var(--size-5); }

/* --- Data display ---------------------------------------------------- */

.dl { display: grid; grid-template-columns: 1fr 1fr; gap: var(--size-4); margin: 0; }
.dl div { display: flex; flex-direction: column; gap: 3px; }
.dl dt { font-size: 10px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.dl dd { margin: 0; font-size: var(--font-size-1); color: var(--text-strong); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--size-2) var(--size-5); font-size: var(--font-size-1); }
.kv dt { color: var(--text-muted); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; padding-top: 3px; }
.kv dd { margin: 0; color: var(--text-strong); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--size-3); padding: 12px 20px; border-top: var(--hairline) solid var(--border); font-size: 12px; color: var(--text-muted); }
.pagination .pages { display: flex; gap: var(--size-1); }

.dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 20; min-width: 260px;
  border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--shadow-float);
}
.dropdown__list { list-style: none; margin: 0; padding: 12px 16px; border-bottom: var(--hairline) solid var(--border); display: grid; gap: var(--size-2); font-size: var(--font-size-1); }

.empty-state { text-align: center; padding: var(--size-8) var(--size-5); color: var(--text-secondary); font-size: var(--font-size-1); }
.empty-state i { font-size: 32px; display: block; margin-bottom: var(--size-3); color: var(--text-muted); }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--size-3); }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: var(--size-3); font-size: var(--font-size-1); }
.timeline strong { color: var(--text-strong); font-weight: 500; }
.timeline .dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--sunset-2); box-shadow: 0 0 0 3px color-mix(in oklab, var(--sunset-2) 18%, transparent); }
.timeline .dot--system { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.timeline .when { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* Dot-matrix bars: the track and the fill are both drawn as dots. */
.factor { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: var(--size-3); font-size: var(--font-size-1); color: var(--text-secondary); }
.factor .track, .progress { position: relative; height: 10px; overflow: hidden; }
.factor .track::before, .progress::before { content: ""; position: absolute; inset: 0; background: var(--text-muted); opacity: .3; -webkit-mask: var(--dots-5); mask: var(--dots-5); }
.factor .track span { position: relative; display: block; height: 100%; background: var(--sunset); -webkit-mask: var(--dots-5); mask: var(--dots-5); }
.factor .mono { text-align: right; color: var(--text-strong); font-size: 12px; }
.progress { min-width: 80px; flex: 1 1 auto; }
.progress span { position: relative; display: block; height: 100%; background: var(--ok); -webkit-mask: var(--dots-5); mask: var(--dots-5); }

.tabs { display: flex; gap: var(--size-1); border-bottom: var(--hairline) solid var(--border); }
.tab { padding: 8px 10px; color: var(--text-secondary); font-size: var(--font-size-1); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text-strong); }
.tab.active { color: var(--text-strong); border-image: var(--sunset) 1; border-bottom: 2px solid; }

pre.raw { font-family: var(--font-mono); font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; color: var(--text); background: var(--surface-inset); border: var(--hairline) solid var(--border); border-radius: var(--radius); padding: 12px 16px; max-height: 360px; overflow: auto; margin: 0; }

.bulk-bar { display: flex; align-items: center; gap: var(--size-2); flex-wrap: wrap; padding: 8px 20px; border-bottom: var(--hairline) solid var(--border); background: var(--brand-tint); color: var(--brand-tint-text); font-size: var(--font-size-1); }
.bulk-bar strong { color: var(--brand-tint-text); }

/* --- Utilities ------------------------------------------------------- */

.chart-box { position: relative; height: 240px; }
.row { display: flex; align-items: center; gap: var(--size-2); }
.row--between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--size-4); }
.actions { display: flex; flex-wrap: wrap; gap: var(--size-2); }
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spin { animation: var(--animation-spin); }
[x-cloak] { display: none !important; }

/* --- Responsive ------------------------------------------------------ */

.topbar__menu, .sidebar__close { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; padding: 0; }
  .sidebar {
    position: fixed; top: 10px; bottom: auto; left: 10px; z-index: 60;
    width: min(86vw, 300px); max-height: calc(100dvh - 20px);
    transform: translateX(calc(-100% - 20px)); visibility: hidden;
    box-shadow: var(--shadow-overlay);
    transition: transform var(--duration-panel) var(--ease-3), visibility var(--duration-panel) var(--ease-3);
  }
  .sidebar.is-open { transform: none; visibility: visible; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 50; background: var(--backdrop); backdrop-filter: blur(4px); }
  body.nav-lock { overflow: hidden; }
  .topbar__menu, .sidebar__close { display: inline-flex; }
  .sidebar__brand { justify-content: space-between; }
  .topbar { margin: 0 16px; gap: var(--size-2); }
  .topbar__title { flex: 1; min-width: 0; }
  .topbar__title .prompt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .profile .meta { display: none; }
  .content { padding: 16px; gap: var(--size-4); }
  .footer { padding-inline: 16px; flex-direction: column; gap: 2px; }
  h1, .page-hero h1 { font-size: 24px; }
  .page-hero__art { opacity: .35; max-width: 100%; }
  .page-head { align-items: flex-start; }
  .card__head { padding: 16px 16px 0; flex-wrap: wrap; }
  .card__body { padding: 16px; }
  .card__body--flush .table th:first-child, .card__body--flush .table td:first-child { padding-left: 16px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .filters .input, .filters .select { width: 100%; }
  .filters .input, .filters .checkbox { grid-column: 1 / -1; }
  .col-optional { display: none; }
  .chart-box { height: 200px; }
  .modal { padding: var(--size-3); }
  .modal__panel { max-height: 85dvh; }
}
@media (max-width: 480px) {
  .topbar__title .crumb { display: none; }
}
