:root {
  color-scheme: light;
  --font-ui: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --bg: oklch(95% 0.01 150);
  --surface: oklch(100% 0 0);
  --surface-2: oklch(97% 0.008 150);
  --surface-3: oklch(92% 0.012 150);
  --border: oklch(87% 0.012 150);
  --border-strong: oklch(72% 0.02 150);
  --text: oklch(22% 0.025 150);
  --text-2: oklch(43% 0.02 150);
  --text-3: oklch(39% 0.018 150);
  --brand: oklch(52% 0.15 145);
  --brand-hover: oklch(44% 0.14 145);
  --brand-soft: oklch(93% 0.055 145);
  --on-brand: oklch(100% 0 0);
  --success: oklch(47% 0.14 145);
  --success-soft: oklch(94% 0.045 145);
  --warning: oklch(48% 0.12 75);
  --warning-text: oklch(34% 0.09 75);
  --warning-soft: oklch(95% 0.065 85);
  --danger: oklch(48% 0.18 28);
  --danger-soft: oklch(94% 0.045 28);
  --info: oklch(49% 0.13 240);
  --info-soft: oklch(94% 0.035 240);
  --focus: oklch(52% 0.15 145);
  --shadow-float: 0 8px 24px color-mix(in oklch, var(--text) 12%, transparent);
  --shadow-dialog: 0 20px 56px color-mix(in oklch, var(--text) 24%, transparent);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --sidebar-width: 232px;
  --topbar-height: 64px;
  --z-dropdown: 30;
  --z-sticky: 40;
  --z-modal-backdrop: 50;
  --z-modal: 60;
  --z-toast: 70;
  --z-tooltip: 80;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(14% 0.018 150);
  --surface: oklch(18% 0.018 150);
  --surface-2: oklch(22% 0.019 150);
  --surface-3: oklch(27% 0.02 150);
  --border: oklch(30% 0.018 150);
  --border-strong: oklch(44% 0.022 150);
  --text: oklch(94% 0.008 150);
  --text-2: oklch(75% 0.015 150);
  --text-3: oklch(70% 0.015 150);
  --brand: oklch(72% 0.17 145);
  --brand-hover: oklch(78% 0.15 145);
  --brand-soft: oklch(26% 0.06 145);
  --on-brand: oklch(16% 0.025 145);
  --success: oklch(72% 0.15 145);
  --success-soft: oklch(25% 0.055 145);
  --warning: oklch(78% 0.13 80);
  --warning-text: oklch(88% 0.09 80);
  --warning-soft: oklch(28% 0.055 80);
  --danger: oklch(72% 0.15 28);
  --danger-soft: oklch(27% 0.055 28);
  --info: oklch(75% 0.11 240);
  --info-soft: oklch(27% 0.045 240);
  --focus: oklch(75% 0.17 145);
  --shadow-float: none;
  --shadow-dialog: none;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-family: var(--font-ui); background: var(--bg); color: var(--text); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-size: 1rem; line-height: 1.5; font-weight: 500; font-kerning: normal; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary, select { cursor: pointer; }
a { color: var(--brand-hover); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand); }
img, svg { display: block; max-width: 100%; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { text-wrap: pretty; }
h1, h2, h3 { margin: 0; color: var(--text); }
h1 { font-size: 2rem; line-height: 1.2; letter-spacing: -0.02em; font-weight: 800; }
h2 { font-size: 1.35rem; line-height: 1.25; letter-spacing: -0.01em; font-weight: 700; }
h3 { font-size: 1rem; line-height: 1.4; font-weight: 700; }
p { margin: 0; }
code, .numeric { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
code { font-size: .82rem; }
small { font-size: .78rem; line-height: 1.4; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--brand-soft); color: var(--text); }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.skip-link { position: fixed; top: var(--space-3); left: var(--space-3); z-index: var(--z-tooltip); padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); background: var(--text); color: var(--surface); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.connection-banner { position: fixed; inset: 0 0 auto; z-index: var(--z-tooltip); padding: var(--space-2) var(--space-4); background: var(--warning-soft); color: var(--warning-text); text-align: center; font-size: .8rem; font-weight: 700; }
.mobile-only { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-4) var(--space-3); background: var(--surface); border-inline-end: 1px solid var(--border); overflow-y: auto; z-index: var(--z-sticky); }
.brand-lockup { display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: 0 var(--space-2); }
.brand-lockup > span:last-child { display: grid; line-height: 1.2; }
.brand-lockup strong { font-size: .95rem; font-weight: 800; }
.brand-lockup small { color: var(--text-2); }
.brand-lockup.is-large { padding: 0; }
.brand-lockup.is-large strong { font-size: 1.1rem; }
.brand-mark { display: flex; align-items: end; gap: 2px; width: 32px; height: 32px; padding: 7px; border-radius: 9px; background: var(--brand); color: var(--on-brand); flex: 0 0 auto; }
.brand-mark i { display: block; width: 5px; border-radius: 1px; background: currentColor; }
.brand-mark i:nth-child(1) { height: 38%; }
.brand-mark i:nth-child(2) { height: 68%; }
.brand-mark i:nth-child(3) { height: 100%; }
.primary-nav { display: grid; gap: var(--space-5); }
.nav-group { display: grid; gap: 2px; }
.nav-group-label { padding: 0 var(--space-3) var(--space-2); color: var(--text-3); font-size: .75rem; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); color: var(--text-2); font-size: .875rem; font-weight: 600; text-decoration: none; transition: background-color 150ms cubic-bezier(.22,1,.36,1), color 150ms cubic-bezier(.22,1,.36,1); }
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--brand-soft); color: var(--text); font-weight: 700; }
.sidebar-footer { margin-top: auto; display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3); border-top: 1px solid var(--border); }
.sidebar-footer > span:last-child { display: grid; }
.sidebar-footer strong { font-size: .78rem; }
.sidebar-footer small { color: var(--text-2); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); }
.status-dot.is-good { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }

.shell-content { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: var(--z-sticky); min-height: var(--topbar-height); display: flex; align-items: center; gap: var(--space-4); padding: 0 var(--space-5); background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-context { min-width: 0; display: flex; align-items: center; gap: var(--space-2); color: var(--text-2); font-size: .875rem; }
.topbar-context a { color: var(--text-2); }
.context-label { color: var(--text); font-weight: 700; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--space-2); }
.project-switcher select { min-height: 40px; max-width: 280px; padding: var(--space-2) 36px var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text-2); }
.icon-button:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 3px var(--space-2) 3px 3px; border-radius: var(--radius-md); color: var(--text); font-size: .85rem; font-weight: 600; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-2); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-hover); font-weight: 800; }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--z-dropdown); min-width: 220px; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-float); }
.user-menu-panel a, .user-menu-panel button { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; text-decoration: none; font-size: .875rem; }
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--surface-2); }

.main-content { width: 100%; max-width: 1600px; margin: 0 auto; padding: var(--space-6) var(--space-6) 80px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-5); margin-bottom: var(--space-6); }
.page-header > div:first-child { display: grid; gap: var(--space-2); min-width: 0; }
.page-context { color: var(--text-2); font-size: .82rem; font-weight: 600; }
.page-lead { max-width: 68ch; color: var(--text-2); }
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 40px; padding: 9px var(--space-4); border: 1px solid transparent; border-radius: var(--radius-md); font-size: .875rem; font-weight: 700; text-decoration: none; white-space: nowrap; transition: background-color 150ms cubic-bezier(.22,1,.36,1), border-color 150ms cubic-bezier(.22,1,.36,1), color 150ms cubic-bezier(.22,1,.36,1); }
.button-primary { border-color: var(--brand); background: var(--brand); color: var(--on-brand); }
.button-primary:hover { border-color: var(--brand-hover); background: var(--brand-hover); color: var(--on-brand); }
.button-secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.button-secondary:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.button-danger { border-color: var(--danger); background: var(--danger); color: var(--on-brand); }
.button-danger:hover { filter: brightness(.92); color: var(--on-brand); }
.button-block { width: 100%; }
.button:disabled, .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.toast-region { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: var(--z-toast); display: grid; gap: var(--space-2); width: min(380px, calc(100vw - 32px)); }
.toast { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-float); }
.toast svg { color: var(--brand); }
.toast-error svg { color: var(--danger); }
.toast-warning svg { color: var(--warning); }
.toast button { border: 0; background: transparent; color: var(--text-2); font-size: 1.25rem; }

.data-notice, .form-alert { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-6); padding: var(--space-3) var(--space-4); border: 1px solid color-mix(in oklch, var(--warning) 35%, var(--border)); border-radius: var(--radius-lg); background: var(--warning-soft); }
.data-notice svg { color: var(--warning); flex: 0 0 auto; }
.data-notice > div { flex: 1; }
.data-notice p, .form-alert { color: color-mix(in oklch, var(--warning) 70%, var(--text)); font-size: .85rem; }

.decision-section, .portfolio-section, .dashboard-split, .financial-strip, .health-list, .system-status-grid, .danger-zone { margin-bottom: var(--space-7); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.section-heading > div { display: grid; gap: var(--space-1); }
.section-heading p { color: var(--text-2); font-size: .875rem; }
.section-heading > a { font-size: .875rem; font-weight: 700; }
.action-list { display: grid; gap: var(--space-2); }
.action-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-4); min-height: 82px; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.action-row.status-critical { border-color: color-mix(in oklch, var(--danger) 35%, var(--border)); background: var(--danger-soft); }
.action-row.status-warning { border-color: color-mix(in oklch, var(--warning) 35%, var(--border)); background: var(--warning-soft); }
.severity-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface); color: var(--danger); border: 1px solid currentColor; font-weight: 800; }
.status-warning .severity-icon { color: var(--warning); }
.action-copy { min-width: 0; display: grid; gap: var(--space-1); }
.action-title { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.action-copy > p { color: var(--text-2); font-size: .875rem; }
.action-meta { display: flex; gap: var(--space-4); flex-wrap: wrap; color: var(--text-2); font-size: .76rem; }
.status-label, .status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text); font-size: .72rem; font-weight: 700; }
.status-critical .status-label { background: var(--danger); color: var(--on-brand); }
.status-warning .status-label { background: var(--warning); color: var(--on-brand); }

.financial-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-block: 1px solid var(--border); background: var(--surface); }
.financial-cell { min-width: 0; display: grid; gap: var(--space-2); padding: var(--space-4); border-inline-end: 1px solid var(--border); }
.financial-cell:last-child { border-inline-end: 0; }
.financial-cell > span { color: var(--text-2); font-size: .78rem; }
.financial-cell > strong { font-size: 1.12rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.financial-cell > small { color: var(--text-2); }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-success { color: var(--success) !important; }

.eyebrow { color: var(--text-2); font-size: .75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.panel { min-width: 0; }
.panel > h2 { margin-bottom: var(--space-4); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 var(--space-7); border-block: 1px solid var(--border); background: var(--surface); }
.metric-grid > div { min-width: 0; display: grid; gap: var(--space-2); padding: var(--space-4); border-inline-end: 1px solid var(--border); }
.metric-grid > div:last-child { border-inline-end: 0; }
.metric-grid dt { color: var(--text-2); font-size: .78rem; }
.metric-grid dd { margin: 0; font: 700 1.12rem/1.3 var(--font-mono); font-variant-numeric: tabular-nums; }
.metric-grid dd small { display: block; color: var(--text-2); font-family: var(--font-ui); font-weight: 500; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); margin-bottom: var(--space-7); }
.dashboard-grid--wide { grid-template-columns: minmax(0, 2fr) minmax(280px, .8fr); }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0 0 var(--space-6); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.detail-list > div { display: grid; grid-template-columns: minmax(130px, .7fr) minmax(0, 1.3fr); gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.detail-list dt { color: var(--text-2); font-size: .8rem; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.item-list, .alert-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.item-list li, .alert-list li > a, .alert-list > li:not(:has(> a)) { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.item-list li:last-child, .alert-list li:last-child > a, .alert-list > li:last-child:not(:has(> a)) { border-bottom: 0; }
.alert-list li > a { display: grid; }
.alert-list span, .alert-list small, .item-list span { color: var(--text-2); }
.subnav { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-6); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.subnav a { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text); font-size: .82rem; font-weight: 700; text-decoration: none; }
.subnav a:hover { background: var(--brand-soft); }
.table-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.table-actions form { margin: 0; }
.link-button { padding: 0; border: 0; background: transparent; color: var(--brand-hover); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.responsive-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); }
.responsive-form-grid--wide { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.role-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-2) var(--space-4); margin: 0; padding: 0; border: 0; }
.role-checks label { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 32px; color: var(--text-muted); font-size: .86rem; cursor: pointer; }
.role-checks label:has(input:checked) { color: var(--text); font-weight: 650; }
.details-grid { padding-top: var(--space-4); }
.data-table { width: 100%; }

.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th, td, .action-copy, .page-header, .item-list li, .alert-list li { min-width: 0; overflow-wrap: anywhere; }
thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--text-2); font-size: .76rem; font-weight: 700; white-space: nowrap; }
tbody th { font-weight: 700; }
tbody th small { display: block; color: var(--text-2); font-weight: 500; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
th.numeric, td.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.numeric small { display: block; color: currentColor; }
.table-action { font-weight: 700; }
.risk-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.risk-red { background: var(--danger-soft); color: var(--danger); }
.risk-yellow { background: var(--warning-soft); color: var(--warning); }
.risk-green { background: var(--success-soft); color: var(--success); }

.dashboard-split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .85fr); gap: var(--space-6); }
.cash-chart { display: grid; grid-template-columns: 70px 1fr; min-height: 280px; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.chart-axis { display: flex; flex-direction: column; justify-content: space-between; padding-block: var(--space-1) var(--space-5); color: var(--text-2); font: 500 .7rem var(--font-mono); }
.chart-bars { display: flex; align-items: stretch; gap: 3px; min-width: 0; position: relative; border-bottom: 1px solid var(--border); }
.chart-bars::before { content: ""; position: absolute; inset-inline: 0; top: 50%; border-top: 1px solid var(--border); }
.chart-bars .bar { flex: 1; min-width: 5px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: var(--space-1); }
.chart-bars .bar i { width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--brand); }
.bar-height-1 i { height: 10%; }
.bar-height-2 i { height: 20%; }
.bar-height-3 i { height: 30%; }
.bar-height-4 i { height: 40%; }
.bar-height-5 i { height: 50%; }
.bar-height-6 i { height: 60%; }
.bar-height-7 i { height: 70%; }
.bar-height-8 i { height: 80%; }
.bar-height-9 i { height: 90%; }
.bar-height-10 i { height: 100%; }
.chart-bars .bar.is-negative i { background: var(--danger); }
.chart-bars small { min-height: 20px; color: var(--text-3); font-size: .62rem; }
.ranked-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.ranked-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-3); min-height: 64px; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.ranked-list li:last-child { border-bottom: 0; }
.ranked-list li > div { display: grid; }
.ranked-list small { color: var(--text-2); }
.rank { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); font: 600 .75rem var(--font-mono); }

.empty-state { display: flex; align-items: center; justify-content: center; gap: var(--space-3); min-height: 120px; padding: var(--space-5); color: var(--text-2); text-align: left; }
.empty-state svg { color: var(--success); }
.empty-state > div, .empty-state:not(:has(> div)) { display: grid; gap: var(--space-1); }

.filter-bar, .form-surface { display: flex; align-items: end; gap: var(--space-3); margin-bottom: var(--space-5); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.filter-bar { flex-wrap: wrap; }
.filter-bar label, .field { display: grid; gap: 6px; min-width: 180px; }
.filter-bar label span, .field label { font-size: .8rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 44px; padding: 9px var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--text); }
textarea { min-height: 104px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-2); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--brand); outline-color: var(--focus); }
input[type="checkbox"], input[type="radio"] { width: 20px; min-height: 20px; accent-color: var(--brand); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .8rem; }
.field-help { color: var(--text-2); font-size: .82rem; }
.draft-status { min-height: 1.4em; color: var(--text-2); font-size: .8rem; }
.form-surface { display: grid; align-items: stretch; gap: var(--space-4); }
.narrow-form { max-width: 680px; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); padding: var(--space-5); border: 1px solid color-mix(in oklch, var(--danger) 35%, var(--border)); border-radius: var(--radius-lg); background: var(--danger-soft); }
.danger-zone > div { display: grid; gap: var(--space-2); }
.danger-zone p { max-width: 70ch; color: var(--text-2); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); color: var(--text-2); font-size: .8rem; }
.pagination-meta, .pagination-size { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.pagination-meta { min-width: 0; }
.pagination-size select { width: auto; min-height: 36px; padding-block: 4px; }
.pagination-size .button { min-height: 36px; padding-block: 6px; }
.pagination-controls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pagination-controls a, .pagination-controls span { min-width: 36px; min-height: 36px; display: inline-grid; place-items: center; padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; }
.pagination-controls a:hover { border-color: var(--brand); background: var(--brand-soft); }
.pagination-controls .is-current { border-color: var(--brand); background: var(--brand); color: var(--on-brand); }
.pagination-controls [aria-disabled="true"] { opacity: .5; }
.pagination-controls .pagination-ellipsis { border-color: transparent; background: transparent; }

.system-status-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.system-status-grid > div { display: grid; gap: var(--space-2); padding: var(--space-5); border-inline-end: 1px solid var(--border); }
.system-status-grid > div:last-child { border-inline-end: 0; }
.system-status-grid span, .system-status-grid small { color: var(--text-2); }
.health-list { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.health-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-4); min-height: 72px; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.health-row:last-child { border-bottom: 0; }
.health-row p { color: var(--text-2); font-size: .85rem; }
.health-indicator { width: 12px; height: 12px; border-radius: 50%; background: var(--text-3); }
.health-indicator.is-good { background: var(--success); }
.health-indicator.is-warning { background: var(--warning); }
.health-indicator.is-danger { background: var(--danger); }

.blueprint-header { margin-bottom: var(--space-4); }
.blueprint-meta { display: flex; gap: var(--space-2) var(--space-5); flex-wrap: wrap; margin: 0 0 var(--space-5); }
.blueprint-meta div { display: flex; gap: var(--space-2); }
.blueprint-meta dt { color: var(--text-2); }
.blueprint-meta dd { margin: 0; font-weight: 700; }
.blueprint-toolbar { position: sticky; top: var(--topbar-height); z-index: calc(var(--z-sticky) - 1); display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-6); padding: var(--space-3) 0; background: var(--bg); border-bottom: 1px solid var(--border); }
.blueprint-search { display: flex; align-items: end; gap: var(--space-2); flex: 1; max-width: 620px; }
.blueprint-toolbar .search-field { flex: 1; }
.blueprint-toolbar > span { color: var(--text-2); font-size: .8rem; }
.blueprint-section-jump { display: none; }
.blueprint-layout { display: grid; grid-template-columns: 220px minmax(0, 920px); justify-content: center; align-items: start; gap: var(--space-7); }
.blueprint-toc { position: sticky; top: calc(var(--topbar-height) + 80px); display: grid; gap: var(--space-3); max-height: calc(100vh - 170px); overflow-y: auto; }
.blueprint-toc > strong { font-size: .82rem; }
.blueprint-toc nav { display: grid; gap: 2px; }
.blueprint-toc a { padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-size: .78rem; text-decoration: none; }
.blueprint-toc a:hover, .blueprint-toc a.is-current { background: var(--brand-soft); color: var(--text); }
.prd-content { min-width: 0; max-width: 920px; }
.prd-content > h1 { margin-bottom: var(--space-5); }
.prd-content h2 { scroll-margin-top: 150px; margin: var(--space-7) 0 var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.prd-content h3 { scroll-margin-top: 150px; margin: var(--space-5) 0 var(--space-3); }
.prd-content p, .prd-content ul, .prd-content ol, .prd-content blockquote { max-width: 75ch; margin-block: var(--space-3); }
.prd-content li { margin-block: var(--space-1); }
.prd-content blockquote { margin-inline: 0; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); font-weight: 700; }
.prd-content pre { max-width: 100%; overflow-x: auto; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); }
.prd-content table { margin-block: var(--space-4); border: 1px solid var(--border); background: var(--surface); }
.prd-content .search-match { border-radius: 4px; background: var(--warning-soft); box-shadow: 0 0 0 3px var(--warning-soft); }
.no-search-results { max-width: 920px; margin: 0 auto; padding: var(--space-6); text-align: center; }
.no-search-results p { margin-bottom: var(--space-3); }

.date-range-control { display: flex; align-items: end; gap: var(--space-3); flex-wrap: wrap; }
.date-range-custom { display: flex; align-items: end; gap: var(--space-3); flex-wrap: wrap; }
.date-range-control.is-enhanced:not(.is-custom) .date-range-custom { display: none; }
.date-range-error { flex-basis: 100%; margin: 0; color: var(--danger); font-size: .8rem; }

.segmented-control { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.segmented-control a { min-height: 36px; display: inline-grid; place-items: center; padding: 6px 11px; border-radius: 7px; color: var(--text-2); font-size: .78rem; font-weight: 700; text-decoration: none; }
.segmented-control a:hover, .segmented-control a[aria-current="page"] { background: var(--surface); color: var(--text); }
.chart-data { margin-top: var(--space-3); }
.chart-data summary { width: fit-content; color: var(--brand-hover); font-size: .82rem; font-weight: 700; }
.chart-data .table-wrap { margin-top: var(--space-3); max-height: 320px; }

.secret-block { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2); align-items: center; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.secret-block span { grid-column: 1 / -1; color: var(--text-2); font-size: .8rem; }
.secret-block code { overflow-wrap: anywhere; }

.auth-page { min-height: 100vh; background: var(--bg); }
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, .9fr) minmax(460px, 1.1fr); }
.auth-context { display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-7); padding: clamp(32px, 6vw, 88px); background: oklch(18% 0.04 150); color: oklch(94% 0.01 150); }
.auth-context h1 { max-width: 13ch; color: inherit; font-size: 2.5rem; }
.auth-context p { max-width: 52ch; margin-top: var(--space-4); color: oklch(78% 0.02 150); }
.auth-context blockquote { max-width: 52ch; margin: 0; color: oklch(78% 0.02 150); font-size: .9rem; }
.auth-context .brand-mark { color: var(--on-brand); }
.auth-context .brand-lockup small { color: oklch(78% 0.02 150); }
.auth-form-wrap { display: grid; place-items: center; padding: var(--space-6); background: var(--surface); }
.auth-form { width: min(420px, 100%); display: grid; gap: var(--space-5); }
.auth-form > div:first-child { display: grid; gap: var(--space-2); }
.auth-form > div:first-child p, .auth-help { color: var(--text-2); }
.auth-help { font-size: .78rem; }
.auth-card { width: min(520px, calc(100vw - 32px)); display: grid; gap: var(--space-4); padding: var(--space-6); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.auth-layout > .auth-card:only-child { grid-column: 1 / -1; place-self: center; }

.error-page { min-height: 60vh; display: grid; place-content: center; justify-items: start; gap: var(--space-4); max-width: 600px; margin: 0 auto; }
.error-code { font: 600 1rem var(--font-mono); color: var(--danger); }
.error-page p { color: var(--text-2); }
.nav-scrim { display: none; }

@media (max-width: 1200px) {
  .financial-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .financial-cell:nth-child(3n) { border-inline-end: 0; }
  .financial-cell:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
  .blueprint-layout { grid-template-columns: 190px minmax(0, 1fr); gap: var(--space-5); }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  .mobile-only { display: inline-grid !important; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, calc(100vw - 48px)); visibility: hidden; transform: translateX(-105%); transition: transform 220ms cubic-bezier(.22,1,.36,1), visibility 0s linear 220ms; box-shadow: var(--shadow-dialog); }
  [data-shell].nav-open .sidebar { visibility: visible; transform: translateX(0); transition-delay: 0s; }
  .nav-scrim { position: fixed; inset: 0; z-index: calc(var(--z-sticky) - 1); border: 0; background: color-mix(in oklch, var(--text) 44%, transparent); }
  [data-shell].nav-open .nav-scrim { display: block; }
  .main-content { padding-inline: var(--space-5); }
  .dashboard-split { grid-template-columns: 1fr; }
  .dashboard-grid, .dashboard-grid--wide { grid-template-columns: 1fr; }
  .blueprint-layout { grid-template-columns: 1fr; }
  .blueprint-toc { display: none; }
  .blueprint-section-jump { display: grid; gap: 6px; margin-bottom: var(--space-5); }
  .blueprint-section-jump span { font-size: .8rem; font-weight: 700; }
}

@media (max-width: 767px) {
  .desktop-only { display: none !important; }
  .topbar { padding-inline: var(--space-3); }
  .project-switcher { display: none; }
  .main-content { padding: var(--space-5) var(--space-4) 72px; }
  h1 { font-size: 1.65rem; }
  .page-header, .section-heading, .danger-zone, .pagination { align-items: stretch; flex-direction: column; }
  .page-actions { justify-content: flex-start; }
  .page-actions .button { flex: 1; }
  .metric-grid, .detail-list, .form-grid { grid-template-columns: 1fr; }
  .metric-grid > div { border-inline-end: 0; border-bottom: 1px solid var(--border); }
  .metric-grid > div:last-child { border-bottom: 0; }
  .action-row { grid-template-columns: auto 1fr; }
  .action-row > .button { grid-column: 1 / -1; width: 100%; }
  .action-meta { gap: var(--space-2) var(--space-3); }
  .financial-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .financial-cell { border-bottom: 1px solid var(--border); }
  .financial-cell:nth-child(2n) { border-inline-end: 0; }
  .financial-cell:nth-last-child(-n+2) { border-bottom: 0; }
  .cash-chart { grid-template-columns: 54px 1fr; min-height: 230px; padding: var(--space-3); }
  .ranked-list li { grid-template-columns: auto minmax(0,1fr) auto; }
  .ranked-list li > a { grid-column: 2 / -1; }
  .filter-bar { display: grid; grid-template-columns: 1fr; align-items: stretch; }
  .filter-bar label { min-width: 0; }
  .system-status-grid { grid-template-columns: 1fr; }
  .system-status-grid > div { border-inline-end: 0; border-bottom: 1px solid var(--border); }
  .system-status-grid > div:last-child { border-bottom: 0; }
  .pagination-controls { justify-content: flex-start; }
  .pagination-meta { align-items: flex-start; flex-direction: column; }
  .blueprint-toolbar { align-items: stretch; flex-direction: column; }
  .blueprint-search { max-width: none; }
  .date-range-control, .date-range-custom { display: grid; grid-template-columns: 1fr; align-items: stretch; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-context { min-height: 360px; padding: var(--space-6) var(--space-5); }
  .auth-context h1 { font-size: 2rem; }
  .auth-form-wrap { padding: var(--space-7) var(--space-4); }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
}

@media (max-width: 479px) {
  .financial-strip { grid-template-columns: 1fr; }
  .financial-cell { border-inline-end: 0; border-bottom: 1px solid var(--border) !important; }
  .financial-cell:last-child { border-bottom: 0 !important; }
  .blueprint-search { align-items: stretch; flex-direction: column; }
  .health-row { grid-template-columns: auto 1fr; }
  .health-row > .status-chip { grid-column: 2; justify-self: start; }
  .toast-region { right: var(--space-4); bottom: var(--space-4); }
}

@media (pointer: coarse) {
  .button, .icon-button, .nav-item, .pagination-controls a, .pagination-controls span, .user-menu summary, .toast button, .segmented-control a { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
  .risk-chip, .status-chip, .status-label, .brand-mark, .health-indicator, .status-dot { border: 1px solid ButtonText; forced-color-adjust: auto; }
  .nav-item.is-active, .pagination-controls .is-current { outline: 2px solid Highlight; outline-offset: -2px; }
}

@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --surface-2: #f6f6f6; --text: #111; --text-2: #444; --border: #bbb; }
  .sidebar, .topbar, .blueprint-toolbar, .blueprint-toc, .page-actions, .toast-region, .nav-scrim { display: none !important; }
  .app-shell { display: block; }
  .main-content { max-width: none; padding: 0; }
  .blueprint-layout { display: block; }
  .prd-content { max-width: none; }
  .prd-content h2, .prd-content h3 { break-after: avoid; }
  .prd-content table, .prd-content pre, .prd-content blockquote { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
