/* Omega FIP — calm, premium financial UI. Light & dark are both designed (not auto-inverted). */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --border: #e3e1da;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #8a8880;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4;
  --series-muted: #b9b7af;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-bg: #e8f5e8; --warning-bg: #fdf3dc; --critical-bg: #fbe9e9; --info-bg: #e9f1fb;
  --sidebar: #15161a; --sidebar-text: #c9c8c2; --sidebar-active: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 15, .05), 0 4px 16px rgba(20, 20, 15, .04);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --surface-2: #222220; --border: #2f2e2b;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86; --accent: #3987e5;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
    --series-muted: #5d5c56;
    --good-bg: #13301a; --warning-bg: #352a10; --critical-bg: #3a1716; --info-bg: #14263d;
    --sidebar: #0b0b0a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #222220; --border: #2f2e2b;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86; --accent: #3987e5;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
  --series-muted: #5d5c56;
  --good-bg: #13301a; --warning-bg: #352a10; --critical-bg: #3a1716; --info-bg: #14263d;
  --sidebar: #0b0b0a; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -.005em; }
h3 { font-size: 14px; margin: 0 0 8px; }
.num, td.r, th.r { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sub { color: var(--text-2); margin: 0 0 20px; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 650; letter-spacing: .01em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #2a78d6, #1baf7a); display: grid; place-items: center; font-size: 15px; color: #fff; }
.brand small { display: block; font-weight: 400; color: #8f8e86; font-size: 11px; }
.nav a { display: block; color: var(--sidebar-text); padding: 7px 10px; border-radius: 8px; margin: 1px 0; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.10); color: var(--sidebar-active); font-weight: 600; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 6px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px 48px; max-width: 1440px; }
.menu-toggle { display: none; }

/* controls */
select, input, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
textarea { width: 100%; min-height: 80px; }
input[type=checkbox] { width: auto; }
label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 12px; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.ghost { background: transparent; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg a { padding: 6px 11px; color: var(--text-2); border-right: 1px solid var(--border); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--accent); color: #fff; font-weight: 600; }
.seg a:hover { text-decoration: none; }
form.inline { display: inline; }

/* chips & badges */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.chip.stale .dot { background: var(--warning); }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge.est { background: var(--info-bg); color: var(--text-2); border-color: transparent; }
.badge.good { background: var(--good-bg); color: var(--text); border-color: transparent; }
.badge.warn { background: var(--warning-bg); color: var(--text); border-color: transparent; }
.badge.crit { background: var(--critical-bg); color: var(--text); border-color: transparent; }
.ico { font-weight: 700; margin-right: 4px; }
.ico.good { color: var(--good); } .ico.warn { color: #b77d00; } .ico.crit { color: var(--critical); }

.demo-banner { background: repeating-linear-gradient(135deg, var(--warning-bg), var(--warning-bg) 12px, transparent 12px, transparent 24px), var(--warning-bg); color: var(--text); padding: 8px 28px; font-size: 13px; border-bottom: 1px solid var(--border); }
.demo-banner strong { letter-spacing: .04em; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card.narrow { max-width: 440px; margin: 10vh auto; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); position: relative; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi .k-label { font-size: 12px; color: var(--text-2); font-weight: 500; display: flex; justify-content: space-between; gap: 6px; }
.kpi .k-value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.hero { border-left: 4px solid var(--accent); }
.kpi.neg .k-value { color: var(--critical); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-title h2 { margin: 0; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; }
.sim-table td:first-child { white-space: normal; }
.sim-table input, .sim-table select { max-width: 100%; }
tbody tr:hover td { background: var(--surface-2); }
tr.total td { font-weight: 650; border-top: 2px solid var(--border); }
.table-wrap { overflow-x: auto; max-height: 560px; overflow-y: auto; }
.neg { color: var(--critical); }
.pos { color: var(--good); }

/* calculation explainer */
.calc { width: 100%; }
.calc .row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.calc .row:last-child { border-bottom: 0; }
.calc .row.result { border-top: 2px solid var(--text); border-bottom: 0; font-weight: 700; font-size: 15px; padding-top: 10px; }
.calc details summary { cursor: pointer; list-style: none; }
.calc details summary::-webkit-details-marker { display: none; }
.calc details summary .lbl::before { content: "▸ "; color: var(--muted); }
.calc details[open] summary .lbl::before { content: "▾ "; }
.calc .expl { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.calc .items { margin: 8px 0 4px 16px; font-size: 12px; }
.calc .items td { padding: 4px 8px; }
:target { scroll-margin-top: 80px; }
.card:target { outline: 2px solid var(--accent); outline-offset: 2px; }

/* alerts */
.alert { display: grid; grid-template-columns: 4px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.alert:last-child { border-bottom: 0; }
.alert .bar { border-radius: 4px; background: var(--muted); }
.alert.critical .bar { background: var(--critical); } .alert.warning .bar { background: var(--warning); } .alert.info .bar { background: var(--series-1); }
.alert .t { font-weight: 600; }
.alert .d { color: var(--text-2); font-size: 13px; }
.alert .a { font-size: 12px; margin-top: 2px; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; background: var(--info-bg); border: 1px solid var(--border); }
.flash.warning { background: var(--warning-bg); } .flash.critical { background: var(--critical-bg); }

/* charts */
.chart { width: 100%; height: 320px; }
.chart.tall { height: 380px; }
.chart.short { height: 240px; }
.legend-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* progress */
.meter { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.meter > span { display: block; height: 100%; background: var(--series-1); border-radius: 6px; }
.meter.warn > span { background: var(--warning); } .meter.crit > span { background: var(--critical); }

/* verdict */
.verdict { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 12px; margin-bottom: 14px; }
.verdict.ok { background: var(--good-bg); } .verdict.tight { background: var(--warning-bg); } .verdict.no { background: var(--critical-bg); }
.verdict .big { font-size: 20px; font-weight: 700; }

.ai-out { white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 13px; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-page { padding: 24px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

@media (max-width: 1100px) { .g3 { grid-template-columns: 1fr 1fr; } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  body.nav-open .sidebar { transform: none; }
  .menu-toggle { display: inline-flex; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .kpi .k-value { font-size: 20px; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .shell { display: block; } body { background: #fff; } .card { box-shadow: none; break-inside: avoid; }
}
