/* Nexus Portfolio Lab — one stylesheet, design tokens on :root, light + dark. */
:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --surface-3: #f1f1ed;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7873;
  --line: #e4e3dc;
  --line-strong: #cfcdc4;
  --accent: #4f46e5;
  --accent-ink: #3730a3;
  --accent-soft: #eef2ff;
  --pos: #0a7a0a;
  --neg: #c9302c;
  --warn: #9a6400;
  --warn-soft: #fff4dc;
  --neg-soft: #fdecea;
  --ok-soft: #e7f5e7;
  --info-soft: #eaf2fc;
  --sidebar: #0f1720;
  --sidebar-ink: #c9d1da;
  --sidebar-muted: #7d8894;
  --sidebar-active: #1d2a38;
  --shadow: 0 1px 2px rgba(15, 23, 32, 0.05), 0 2px 8px rgba(15, 23, 32, 0.04);
  --radius: 10px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --glass: var(--surface);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #06060b; --surface: #0e0e17; --surface-2: #13131e; --surface-3: #1a1a28;
    --ink: #f1f5f9; --ink-2: #cbd5e1; --muted: #7c8aa0; --line: rgba(255, 255, 255, 0.07); --line-strong: rgba(255, 255, 255, 0.13);
    --accent: #6366f1; --accent-ink: #a5b4fc; --accent-soft: rgba(99, 102, 241, 0.14);
    --pos: #34d399; --neg: #fb7185; --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, 0.1); --neg-soft: rgba(251, 113, 133, 0.1); --ok-soft: rgba(52, 211, 153, 0.1); --info-soft: rgba(99, 102, 241, 0.1);
    --sidebar: #08080f; --sidebar-ink: #c9d1da; --sidebar-muted: #6b7686; --sidebar-active: rgba(99, 102, 241, 0.16);
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.02), 0 12px 40px rgba(0, 0, 0, 0.35);
    --glass: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #06060b; --surface: #0e0e17; --surface-2: #13131e; --surface-3: #1a1a28;
  --ink: #f1f5f9; --ink-2: #cbd5e1; --muted: #7c8aa0; --line: rgba(255, 255, 255, 0.07); --line-strong: rgba(255, 255, 255, 0.13);
  --accent: #6366f1; --accent-ink: #a5b4fc; --accent-soft: rgba(99, 102, 241, 0.14);
  --pos: #34d399; --neg: #fb7185; --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, 0.1); --neg-soft: rgba(251, 113, 133, 0.1); --ok-soft: rgba(52, 211, 153, 0.1); --info-soft: rgba(99, 102, 241, 0.1);
  --sidebar: #08080f; --sidebar-ink: #c9d1da; --sidebar-muted: #6b7686; --sidebar-active: rgba(99, 102, 241, 0.16);
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.02), 0 12px 40px rgba(0, 0, 0, 0.35);
  --glass: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
}

*, *::before, *::after { box-sizing: border-box; }
/* Dark mode borrows the Options Lab look: deep radial backdrop, glass cards, indigo accent. */
:root[data-resolved-theme="dark"] body { background: radial-gradient(ellipse 140% 80% at 50% -20%, #17172e 0%, #08080f 45%, #030306 100%) fixed; }
:root[data-resolved-theme="dark"] .card, :root[data-resolved-theme="dark"] .kpi, :root[data-resolved-theme="dark"] .feature { background: var(--glass), var(--surface); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
:root[data-resolved-theme="dark"] .kpi-value { text-shadow: 0 0 24px rgba(129, 140, 248, 0.25); }
:root[data-resolved-theme="dark"] #topbar { background: rgba(8, 8, 15, 0.8); }
:root[data-resolved-theme="dark"] .btn-primary { background: linear-gradient(135deg, #6366f1, #4f46e5); border-color: #6366f1; }
:root[data-resolved-theme="dark"] .btn-primary:hover { box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35); }
:root[data-resolved-theme="dark"] .nav-item.active { box-shadow: inset 2px 0 0 #818cf8; }
:root[data-resolved-theme="dark"] .chart .scatterlayer .js-line { filter: drop-shadow(0 0 5px rgba(129, 140, 248, 0.35)); }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, .tbl td.num, .kpi-value { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn-text { color: var(--warn); }
.upper { text-transform: uppercase; }
.w-80 { width: 80px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- layout ------------------------------------------------------------------------------------ */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
#sidebar { background: var(--sidebar); color: var(--sidebar-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 16px 12px; z-index: 40; }
.content { display: flex; flex-direction: column; min-width: 0; }
#topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--page); background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#main { padding: 24px; max-width: 1480px; width: 100%; margin: 0 auto; outline: none; }
.disclaimer-bar { font-size: 11.5px; color: var(--muted); padding: 12px 24px 20px; max-width: 1480px; margin: 0 auto; width: 100%; }

.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px 8px 16px; text-decoration: none !important; }
.brand strong { font-weight: 700; }
.brand span:last-child { font-size: 15px; line-height: 1.2; }
.brand small { display: block; font-size: 11px; color: var(--sidebar-muted); font-weight: 400; margin-top: 2px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #6366f1, #8b5cf6 55%, #22d3ee); box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 20px; height: 20px; color: #fff; }
.nav-group { margin-top: 14px; }
.nav-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--sidebar-muted); padding: 0 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--sidebar-ink); font-size: 13.5px; text-decoration: none !important; }
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 2px 0 0 #818cf8; }
.nav-badge { margin-left: auto; background: #d03b3b; color: #fff; font-size: 11px; font-weight: 600; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.nav-badge.warn { background: #b07800; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; font-size: 11.5px; color: var(--sidebar-muted); }
.sidebar-foot a { color: var(--sidebar-muted); }
.privacy-note { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; line-height: 1.4; }
.privacy-note svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }

.pf-switch { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pf-switch select { max-width: 280px; font-weight: 600; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.valdate { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.valdate input { padding: 5px 8px; }
.base-chip { font-size: 12px; font-weight: 600; background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.menu-btn { display: none; }

/* ---- controls ---------------------------------------------------------------------------------- */
input, select, textarea { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
input[type=range] { padding: 0; border: 0; accent-color: var(--accent); width: 100%; background: transparent; box-shadow: none; }
textarea { width: 100%; resize: vertical; line-height: 1.5; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none !important; line-height: 1.3; }
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

.btn-danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 45%, var(--line)); }
.btn-danger:hover { background: var(--neg-soft); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-lg { padding: 10px 18px; font-size: 15px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-row.end { justify-content: flex-end; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--ink-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.sm { width: 26px; height: 26px; font-size: 12px; }
.linkish { background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; text-align: left; font-weight: 500; }
.linkish:hover { color: var(--accent); text-decoration: underline; }
.link { font-size: 12.5px; font-weight: 500; }
.seg { display: inline-flex; background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

/* ---- page structure ----------------------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card.flush .card-body { padding: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 0; }
.card-head h2 { font-size: 14.5px; font-weight: 650; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; max-width: 720px; }
.card-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.card-body { padding: 14px 16px 16px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 16px; }
.grid-2.tight { gap: 16px; }
.h3 { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin: 6px 0 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.chart { width: 100%; min-height: 160px; }
.card-body > .chart:first-child { margin-top: 2px; }
.chart-fallback { padding: 24px; color: var(--muted); font-size: 13px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 8px; }
.footnote { color: var(--muted); font-size: 12px; margin: 4px 2px 16px; max-width: 900px; }
.bullets { margin: 0 0 12px; padding-left: 18px; color: var(--ink-2); }
.bullets li { margin-bottom: 4px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); margin-bottom: 16px; }
.empty .btn-row { justify-content: center; }
.empty .btn { margin-top: 12px; }

/* ---- KPI tiles ---------------------------------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-grid.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.kpi-value { font-size: 22px; font-weight: 650; margin-top: 2px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value.sm { font-size: 14px; white-space: normal; }
.kpi-value select { font-size: 13px; width: 100%; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.kpi-breach { border-color: color-mix(in srgb, var(--neg) 45%, var(--line)); box-shadow: inset 3px 0 0 var(--neg); }
.kpi-warn { box-shadow: inset 3px 0 0 var(--warn); }
.kpi-ok { box-shadow: inset 3px 0 0 var(--pos); }
.help { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line-strong); font-size: 10px; color: var(--muted); cursor: help; position: relative; }
.help:hover::after, .help:focus::after { content: attr(data-tip); position: absolute; left: 50%; top: 20px; transform: translateX(-50%); width: 280px; background: var(--ink); color: var(--page); padding: 8px 10px; border-radius: 7px; font-size: 12px; line-height: 1.45; z-index: 60; white-space: normal; font-weight: 400; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }

/* ---- alerts & chips ------------------------------------------------------------------------------ */
.alerts { display: grid; gap: 8px; margin-bottom: 16px; }
.alert { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 9px 14px; border-radius: 8px; font-size: 13px; border: 1px solid var(--line); margin-bottom: 12px; }
.alerts .alert { margin: 0; }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.alert-breach { background: var(--neg-soft); border-color: color-mix(in srgb, var(--neg) 35%, var(--line)); }
.alert a { font-weight: 600; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.chip-ok { background: var(--ok-soft); color: var(--pos); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-breach { background: var(--neg-soft); color: var(--neg); }
.type-tag { display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: 0.03em; padding: 1px 5px; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); border: 1px solid var(--line); font-family: var(--mono); vertical-align: 1px; }
.type-pill { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 20px; background: var(--surface-3); border: 1px solid var(--line); margin: 2px 4px 2px 0; color: var(--ink-2); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }

/* ---- tables ---------------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 11.5px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover, .tbl th.sorted { color: var(--ink); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl.dense td { padding: 6px 10px; }
.tbl.dense th { padding: 6px 10px; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tfoot td { font-weight: 650; border-top: 2px solid var(--line-strong); border-bottom: 0; }
.tbl tr.row-error td { background: color-mix(in srgb, var(--neg-soft) 60%, transparent); }
.tbl tr.row-sel td { background: var(--accent-soft); }
.tbl .cell-name { font-weight: 550; }
.tbl .cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.strategy-tag { display: inline-block; margin-left: 6px; font-size: 10.5px; padding: 0 6px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); }
.tbl.monthly td.heat { min-width: 58px; }
.tbl.monthly th[scope=row] { color: var(--ink); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=search] { width: 320px; max-width: 100%; }
.toolbar.wrap { row-gap: 8px; }
.settings-strip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; font-size: 12.5px; color: var(--ink-2); }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

/* ---- lists ------------------------------------------------------------------------------------------ */
.rule-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 4px 20px; }
.rule-list li { display: grid; grid-template-columns: 96px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.rule-list .num { color: var(--muted); font-size: 12px; }
.rule-list .chip { justify-self: start; }
.tbl td.nowrap { white-space: nowrap; }

/* ---- welcome ---------------------------------------------------------------------------------------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 32px; align-items: center; padding: 24px 0 8px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
.hero h1 { font-size: 38px; font-weight: 750; letter-spacing: -0.025em; line-height: 1.12; }
.hero .lead { font-size: 17px; color: var(--ink-2); margin-top: 16px; max-width: 620px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.hero-note { font-size: 12.5px; color: var(--muted); margin-top: 16px; max-width: 560px; }
.feature-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.feature h3 { font-size: 14px; margin-bottom: 4px; }
.feature p { font-size: 12.5px; color: var(--ink-2); }

/* ---- forms ----------------------------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid label, .form-stack label, .form-top label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.form-grid .span-2 { grid-column: span 2; }
.form-stack { display: grid; gap: 12px; }
.form-top { display: grid; grid-template-columns: 260px 1fr; gap: 14px; align-items: start; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.hint { font-size: 12.5px; color: var(--ink-2); background: var(--info-soft); border-radius: 8px; padding: 8px 12px; line-height: 1.45; }
.req { color: var(--neg); }
.field-err { color: var(--neg); font-size: 11.5px; min-height: 0; }
label.invalid input, label.invalid select { border-color: var(--neg); }
.preview { margin-top: 14px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; color: var(--ink-2); min-height: 40px; }
.inline-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.check-list { display: grid; gap: 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check.disabled { opacity: 0.55; cursor: not-allowed; }
.check input { margin-top: 2px; }
.check span { display: flex; flex-direction: column; }
.check small { color: var(--muted); font-size: 12px; }
.fx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; margin-top: 10px; }
.fx-grid label { display: grid; grid-template-columns: 56px 1fr 38px; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.fx-grid label.used { color: var(--ink); font-weight: 600; }
.fx-grid input { text-align: right; font-variant-numeric: tabular-nums; }
.cma-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 16px; margin-top: 10px; }
.cma-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
.with-unit { display: flex; align-items: center; gap: 6px; }
.with-unit input { width: 100%; text-align: right; }
.with-unit em { font-style: normal; color: var(--muted); width: 26px; font-size: 12px; }

/* ---- import --------------------------------------------------------------------------------------- */
.drop { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 28px 16px; text-align: center; cursor: pointer; background: var(--surface-2); transition: border-color 0.15s, background 0.15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 34px; height: 34px; color: var(--accent); margin-bottom: 6px; }
.paste { margin-top: 12px; }
.paste summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 500; }
.paste textarea { margin: 8px 0; font-family: var(--mono); font-size: 12px; }
.file-line { margin-top: 12px; font-size: 13px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; margin-top: 10px; }
.map-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.map-row.mapped { border-color: color-mix(in srgb, var(--pos) 35%, var(--line)); background: color-mix(in srgb, var(--ok-soft) 55%, var(--surface)); }
.map-head { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-sample { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-row select { font-size: 12.5px; padding: 5px 6px; }
.import-summary { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.import-summary .stat { display: flex; flex-direction: column; }
.import-summary .big { font-size: 26px; font-weight: 700; line-height: 1.1; }
.import-summary .types { flex-direction: row; flex-wrap: wrap; }

/* ---- stress & compliance ---------------------------------------------------------------------------- */
.big-number { font-size: 30px; font-weight: 700; margin-bottom: 10px; letter-spacing: -0.02em; }
.big-number small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.shock-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 24px; margin-bottom: 16px; }
.shock span { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.shock output { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.rules { display: grid; gap: 10px; }
.rule { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; background: var(--surface); }
.rule-breach { border-color: color-mix(in srgb, var(--neg) 45%, var(--line)); box-shadow: inset 3px 0 0 var(--neg); }
.rule-warn { box-shadow: inset 3px 0 0 var(--warn); }
.rule-off { opacity: 0.65; }
.rule-main { display: grid; grid-template-columns: 44px minmax(0, 1fr) 130px 120px; gap: 12px; align-items: center; }
.rule-text h3 { font-size: 13.5px; font-weight: 600; }
.rule-limit { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.rule-limit input { width: 72px; text-align: right; }
.rule-status { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.meter { position: relative; height: 6px; background: var(--surface-3); border-radius: 4px; margin-top: 10px; }
.meter-fill { height: 100%; border-radius: 4px; background: var(--pos); }
.meter-fill.warn { background: #d99a00; }
.meter-fill.breach { background: var(--neg); }
.meter-limit { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-2); }
.rule details { margin-top: 8px; font-size: 12.5px; }
.rule summary { cursor: pointer; color: var(--accent); }
.detail-list { list-style: none; padding: 6px 0 0; margin: 0; columns: 2; column-gap: 24px; }
.detail-list li { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dotted var(--line); break-inside: avoid; }
.switch { position: relative; width: 38px; height: 22px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 20px; cursor: pointer; transition: background 0.15s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- type picker & modal ---------------------------------------------------------------------------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 14, 20, 0.45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade 0.12s ease; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25); }
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.modal-foot .muted { margin-right: auto; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.picker-group { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 12px 0 8px; }
.picker-group:first-child { margin-top: 0; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.type-card { text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; padding: 10px 12px; cursor: pointer; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; }
.type-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.type-card small { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.menu-list { display: grid; gap: 4px; }
.menu-item { text-align: left; padding: 10px 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; }
.menu-item:hover { background: var(--surface-3); }
.menu-item.danger { color: var(--neg); }
.err { white-space: pre-wrap; font-size: 11px; color: var(--neg); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 9px; font-size: 13px; display: flex; align-items: center; gap: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 200; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.warn { background: #7a4b00; color: #fff; }
.toast-btn { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 6px; padding: 3px 10px; cursor: pointer; font-weight: 600; }

/* ---- responsive --------------------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .shock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, 0.35); }
  body.nav-open #sidebar { transform: none; }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 35; }
  .menu-btn { display: inline-grid; }
  #topbar { padding: 8px 16px; }
  #main { padding: 16px; }
  .disclaimer-bar { padding: 8px 16px 16px; }
  .valdate span { display: none; }
  .rule-main { grid-template-columns: 44px minmax(0, 1fr); }
  .rule-limit, .rule-status { grid-column: 2; justify-content: flex-start; align-items: flex-start; text-align: left; }
  .form-top { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .hero h1 { font-size: 28px; }
  .feature-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .shock-grid { grid-template-columns: minmax(0, 1fr); }
  .pf-switch select { max-width: 150px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 18px; white-space: normal; }
  .page-head h1 { font-size: 20px; }
  .detail-list { columns: 1; }
  .top-right { margin-left: 0; width: 100%; justify-content: space-between; }
}
@media print {
  #sidebar, #topbar, .page-actions, .toolbar { display: none !important; }
  .shell { display: block; }
  .card { break-inside: avoid; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- import: templates, transforms, mandatory datapoints ------------------------------------------------ */
.tpl-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px; border-radius: 9px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.tpl-bar select { min-width: 200px; }
.map-ctl { display: flex; flex-direction: column; gap: 4px; }
.map-row .scale-sel { font-size: 11.5px; padding: 3px 6px; }
.map-row { grid-template-columns: minmax(0, 1fr) 160px; }
.map-row.unmapped { border-color: color-mix(in srgb, var(--neg) 40%, var(--line)); }
.tpl-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.tpl-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0 10px; }
.w-160 { width: 160px; }
.card-alert { border-color: color-mix(in srgb, var(--neg) 40%, var(--line)); }
.tbl.mand td { vertical-align: middle; }
.tbl.mand input, .tbl.mand select { max-width: 190px; padding: 4px 8px; font-size: 12.5px; }

/* ---- risk class scale, cash-flow calendar, NAV --------------------------------------------------------- */
.mt { margin-top: 12px; }
.kind-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.tbl tr.row-info td { color: var(--muted); }
.nowrap { white-space: nowrap; }
.class-tbl input, .class-tbl select { width: 100%; min-width: 80px; padding: 5px 8px; font-size: 13px; }
.class-tbl .num-in { text-align: right; min-width: 110px; font-variant-numeric: tabular-nums; }
.class-tbl .num-in.sm { min-width: 70px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .form-grid.three { grid-template-columns: minmax(0, 1fr); } }
.kpi-value small { font-size: 13px; color: var(--muted); font-weight: 500; }

.check-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check-inline input { width: 16px; height: 16px; accent-color: var(--accent); }
.tgt-in { width: 64px; min-width: 0; padding: 4px 6px; text-align: right; font-variant-numeric: tabular-nums; }

/* Data status in the sidebar (linked file / backup age) and the banner above the page */
.data-status { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; line-height: 1.35; text-decoration: none; color: var(--sidebar-muted); }
.data-status svg { flex: none; width: 16px; height: 16px; margin-top: 1px; }
.data-status.ok svg { color: var(--pos); }
.data-status.warn { color: var(--warn); } .data-status.warn strong { color: var(--warn); }
.data-status.pending svg { color: var(--accent); }
.banner { padding: 12px 24px 0; } .banner .alert { margin: 0; } .banner .btn-row { flex: none; }
.file-status { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 12px; background: var(--ok-soft); }
.file-status.needs-permission { background: var(--warn-soft); } .file-status.error { background: var(--neg-soft); }

/* Methodology page */
.meth-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.meth-toc a { font-size: 12.5px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink2); background: var(--surface); }
.meth-toc a:hover { border-color: var(--accent); color: var(--accent); }
.meth-list { margin: 0; }
.meth-item { display: grid; grid-template-columns: minmax(160px, 220px) 1fr; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.meth-item:first-child { border-top: 0; padding-top: 0; }
.meth-item dt { font-weight: 600; font-size: 13.5px; }
.meth-item dd { margin: 0; font-size: 13px; color: var(--ink2); }
.meth-item dd p { margin: 8px 0 0; }
.meth-formula { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--page); border: 1px solid var(--line); font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; color: var(--ink); overflow-x: auto; }
.meth-params span { color: var(--muted); }
@media (max-width: 720px) { .meth-item { grid-template-columns: 1fr; gap: 6px; } }

/* Numbered steps (linked file), 3D chart, collapsible factor detail */
.steps { margin: 6px 0 12px; padding-left: 22px; display: grid; gap: 6px; font-size: 13px; }
.steps li strong { display: block; } .steps li span { color: var(--muted); }
.chart-3d { min-height: 520px; }
.factor-detail { margin-top: 10px; } .factor-detail summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }

/* User guide */
.guide { font-size: 14px; line-height: 1.6; color: var(--ink2); max-width: 900px; }
.guide p { margin: 0 0 10px; }
.guide .h3 { margin: 16px 0 6px; color: var(--ink); }
.guide-steps, .guide-list { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 6px; }
.guide-note { padding: 12px 14px; border-radius: 9px; border: 1px solid var(--line); margin: 0 0 12px; font-weight: 500; color: var(--ink); }
.guide-note.ok { background: var(--ok-soft); } .guide-note.warn { background: var(--warn-soft); } .guide-note.info { background: var(--page); }
.guide-privacy { border-color: color-mix(in srgb, var(--pos) 45%, var(--line)); }
.privacy-callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 9px; background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--pos) 35%, var(--line)); margin-bottom: 12px; font-size: 13px; color: var(--ink); }
.privacy-callout svg { flex: none; width: 18px; height: 18px; color: var(--pos); margin-top: 1px; }
.privacy-callout a { white-space: nowrap; }
a.privacy-note { text-decoration: none; color: inherit; }
a.privacy-note:hover span { text-decoration: underline; }

/* Breach history strips */
.bh-grid { display: grid; gap: 6px; margin: 4px 0 14px; }
.bh-row { display: grid; grid-template-columns: minmax(140px, 240px) 1fr; gap: 10px; align-items: center; }
.bh-strip { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--line); }
.bh-strip span { flex: 1 1 0; min-width: 1px; }
.bh-ok { background: color-mix(in srgb, var(--pos) 55%, transparent); }
.bh-warn { background: var(--warn); }
.bh-breach { background: var(--neg); }
.bh-axis { display: flex; justify-content: space-between; }
.w-110 { width: 110px; }
@media (max-width: 720px) { .bh-row { grid-template-columns: 1fr; gap: 3px; } }
.card-info { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.chip-suggest { cursor: pointer; border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); color: var(--ink); max-width: 100%; white-space: normal; text-align: left; line-height: 1.3; border-radius: 8px; }
.chip-suggest:hover { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.map-row.suggested { border-style: dashed; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.suggest-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reg-note { font-size: 12.5px; line-height: 1.45; }
.lmt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin: 10px 0; }
.lmt-tool { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.lmt-tool.on { border-color: color-mix(in srgb, var(--pos) 40%, var(--line)); background: color-mix(in srgb, var(--ok-soft) 50%, var(--surface)); }
.lmt-tool.fixed { opacity: 0.8; }
.alert-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--pos) 35%, var(--line)); }
.zone { font-weight: 700; text-transform: capitalize; padding: 2px 10px; border-radius: 12px; }
.zone-green { background: var(--ok-soft); color: var(--pos); } .zone-yellow { background: var(--warn-soft); color: var(--warn); } .zone-red { background: var(--neg-soft); color: var(--neg); }
.cond-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 10px; }
.cond-row { display: grid; grid-template-columns: 170px 150px minmax(0, 1fr) 30px; gap: 6px; align-items: center; }
.cond-codes { grid-column: 1 / -1; }
@media (max-width: 640px) { .cond-row { grid-template-columns: 1fr 1fr; } }
.inline-actions { display: inline-flex; gap: 4px; vertical-align: middle; margin-left: 6px; }
.lmt-tool input { flex: none; margin-top: 3px; }

/* Control log */
.form-inline { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.form-inline input { max-width: 320px; flex: 1 1 200px; }
.cl-cases { display: grid; gap: 10px; }
.cl-case { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); }
.cl-case.open { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.cl-case-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.cl-case-head .row-actions { margin-left: auto; }
.cl-notes { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 3px; }
code.hash { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
