:root {
  color-scheme: dark;
  --bg: #08111d;
  --surface: #101d2d;
  --surface-2: #142438;
  --surface-3: #192c42;
  --line: #263b52;
  --text: #eaf2fa;
  --muted: #91a7bd;
  --cyan: #51d7e8;
  --blue: #6d9fff;
  --green: #61d6a6;
  --amber: #ffbf69;
  --red: #ff7e86;
  --shadow: 0 16px 40px rgba(0,0,0,.22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 78% -20%, #173451 0, transparent 42%), var(--bg); color: var(--text); }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px clamp(16px,3vw,34px); border-bottom: 1px solid rgba(119,160,199,.18); background: rgba(8,17,29,.92); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; letter-spacing: .08em; font-size: 13px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #06121d; font-size: 18px; background: linear-gradient(135deg,var(--cyan),#8cbbff); box-shadow: 0 6px 22px rgba(81,215,232,.2); }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .18em; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 9px; }
.global-controls { display: flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid rgba(119,160,199,.14); border-radius: 10px; background: rgba(13,27,43,.75); }
.top-meta { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.sync-pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: #b8c9d9; font-size: 11px; white-space: nowrap; }
.sync-pill:before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(97,214,166,.7); }
.workspace { flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; display: grid; grid-template-columns: 246px minmax(0,1fr); }
.sidebar { padding: 24px 14px 30px 22px; border-right: 1px solid rgba(119,160,199,.13); }
.sidebar-label { margin: 0 0 11px 10px; color: #718ba5; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.module-nav { display: grid; gap: 5px; }
.nav-link { display: flex; gap: 11px; align-items: center; padding: 10px 11px; border: 1px solid transparent; border-radius: 10px; color: #a7bacd; transition: .18s ease; }
.nav-link:hover { background: rgba(87,130,172,.1); color: var(--text); }
.nav-link.active { color: #effaff; border-color: rgba(81,215,232,.25); background: linear-gradient(90deg,rgba(81,215,232,.13),rgba(109,159,255,.06)); }
.nav-number { flex: 0 0 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; color: #9ab0c5; background: #1a2b40; font-size: 10px; font-weight: 800; }
.nav-link.active .nav-number { color: #06202b; background: var(--cyan); }
.nav-text { min-width: 0; font-size: 12px; line-height: 1.25; font-weight: 650; }
.nav-home { margin-bottom: 20px; }
.sidebar-note { margin: 24px 7px 0; padding: 13px; border: 1px solid rgba(81,215,232,.14); border-radius: 12px; background: rgba(81,215,232,.045); color: var(--muted); font-size: 11px; line-height: 1.55; }
.sidebar-note strong { display: block; margin-bottom: 4px; color: #c6e8ef; font-size: 11px; }
main { min-width: 0; padding: clamp(18px,3vw,34px); }
.page-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 23px; }
.eyebrow { margin-bottom: 8px; color: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
h1 { margin: 0; max-width: 850px; font-size: clamp(24px,3vw,37px); line-height: 1.1; letter-spacing: -.035em; }
.subtitle { max-width: 820px; margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; color: #dceaf6; background: #17283c; font-size: 11px; font-weight: 750; transition: .18s ease; }
.btn:hover { border-color: #52728f; background: #1d344c; }
.btn.primary { border-color: rgba(81,215,232,.45); color: #061a25; background: linear-gradient(135deg,#63dce9,#86b9ff); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 30px; padding: 6px 9px; font-size: 10px; }
.btn.danger { color: #ffb5b9; border-color: rgba(255,126,134,.28); }
.card { min-width: 0; border: 1px solid rgba(119,160,199,.18); border-radius: 15px; background: linear-gradient(145deg,rgba(20,36,56,.98),rgba(14,27,43,.98)); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-title { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .01em; }
.card-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.kpi-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 11px; margin-bottom: 16px; }
.kpi { padding: 14px 15px; border: 1px solid rgba(119,160,199,.15); border-radius: 12px; background: rgba(9,20,33,.56); }
.kpi-label { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.kpi-value { margin-top: 7px; font-size: clamp(19px,2.4vw,27px); font-weight: 800; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.kpi-unit { margin-left: 4px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0; }
.kpi-note { margin-top: 4px; color: #7f99b1; font-size: 10px; }
.two-col { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(280px,.85fr); gap: 15px; align-items: start; }
.three-col { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 13px; }
.panel-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.viz-wrap { position: relative; min-height: 280px; overflow: hidden; border: 1px solid rgba(119,160,199,.12); border-radius: 12px; background: radial-gradient(ellipse at 50% 40%,rgba(40,82,112,.18),transparent 68%),#0a1725; }
.viz-wrap canvas { display: block; width: 100%; height: 310px; }
.viz-wrap.tall canvas { height: 390px; }
.viz-wrap.compact canvas { height: 240px; }
.chart-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 9px; color: #829ab1; font-size: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 15px; height: 3px; border-radius: 2px; display: inline-block; }
.control-panel { padding: 17px; }
.control-group { display: grid; gap: 13px; }
.control-row { display: grid; gap: 7px; }
.control-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.control-label { color: #d4e2ef; font-size: 11px; font-weight: 700; }
.control-value { color: var(--cyan); font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; height: 5px; border-radius: 10px; outline: none; appearance: none; background: #29415a; accent-color: var(--cyan); }
input[type=range]::-webkit-slider-thumb { width: 15px; height: 15px; border: 2px solid #d8faff; border-radius: 50%; appearance: none; background: #48cfe1; box-shadow: 0 0 0 4px rgba(81,215,232,.12); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid #d8faff; border-radius: 50%; background: #48cfe1; box-shadow: 0 0 0 4px rgba(81,215,232,.12); }
.control-hint { color: #7089a2; font-size: 9px; }
.control-divider { height: 1px; margin: 2px 0; background: rgba(119,160,199,.13); }
.metric-list { display: grid; gap: 0; }
.metric-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(119,160,199,.1); font-size: 11px; }
.metric-row:last-child { border-bottom: 0; }
.metric-row span { color: var(--muted); }
.metric-row strong { color: #e3f0fa; font-variant-numeric: tabular-nums; text-align: right; }
.note { padding: 12px 14px; border-left: 2px solid var(--cyan); border-radius: 0 9px 9px 0; color: #a9bfd2; background: rgba(81,215,232,.055); font-size: 11px; line-height: 1.6; }
.note strong { color: #d6f7fa; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid rgba(97,214,166,.22); border-radius: 999px; color: #9ce9c7; background: rgba(97,214,166,.07); font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.status.warn { border-color: rgba(255,191,105,.25); color: #ffd49c; background: rgba(255,191,105,.07); }
.status.bad { border-color: rgba(255,126,134,.25); color: #ffb6bb; background: rgba(255,126,134,.07); }
.equation { overflow-x: auto; padding: 15px; border: 1px solid rgba(81,215,232,.18); border-radius: 10px; color: #d8f8fb; background: rgba(7,18,29,.72); font-family: "Cambria Math", Georgia, serif; font-size: clamp(15px,2vw,21px); text-align: center; white-space: nowrap; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-table th, .data-table td { padding: 10px 9px; border-bottom: 1px solid rgba(119,160,199,.12); text-align: right; font-variant-numeric: tabular-nums; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table th { color: #91a9c0; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.module-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; }
.module-card { position: relative; display: flex; min-height: 178px; flex-direction: column; padding: 17px; border: 1px solid rgba(119,160,199,.17); border-radius: 14px; background: linear-gradient(145deg,rgba(20,36,56,.95),rgba(12,25,40,.96)); transition: transform .18s,border-color .18s,background .18s; }
.module-card:hover { transform: translateY(-3px); border-color: rgba(81,215,232,.45); background: linear-gradient(145deg,#1a334b,#11253a); }
.module-icon { width: 34px; height: 34px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 10px; color: var(--cyan); background: rgba(81,215,232,.1); font-size: 16px; }
.module-card h3 { margin: 0; font-size: 13px; line-height: 1.35; }
.module-card p { margin: 7px 0 16px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.module-card .card-link { margin-top: auto; color: #8be4ed; font-size: 10px; font-weight: 800; }
.home-hero { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(240px,.8fr); gap: 18px; margin-bottom: 22px; }
.hero-visual { min-height: 220px; display: flex; flex-direction: column; justify-content: center; padding: 22px; border: 1px solid rgba(81,215,232,.2); border-radius: 15px; background: radial-gradient(ellipse at 60% 40%,rgba(81,215,232,.15),transparent 60%),linear-gradient(135deg,#122b42,#0c1b2d); }
.hero-visual .equation { margin-top: 17px; background: rgba(4,13,23,.42); }
.assumption-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-top: 14px; }
.assumption { padding: 12px; border: 1px solid rgba(119,160,199,.12); border-radius: 10px; color: var(--muted); background: rgba(9,20,33,.45); font-size: 10px; line-height: 1.5; }
.assumption strong { display: block; margin-bottom: 4px; color: #d6e6f3; font-size: 11px; }
.footer { max-width: 1600px; width: 100%; margin: 0 auto; padding: 13px 30px 18px; color: #5f7891; font-size: 10px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: min(360px,calc(100vw - 40px)); padding: 12px 15px; border: 1px solid rgba(81,215,232,.32); border-radius: 10px; color: #dffaff; background: #142b40; box-shadow: var(--shadow); font-size: 11px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.inline-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.field { display: grid; gap: 5px; }
.field label { color: var(--muted); font-size: 10px; }
.field input, .field select { min-width: 90px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; outline: none; color: var(--text); background: #0c1a29; font-size: 11px; }
.field input:focus, .field select:focus { border-color: var(--cyan); }
.progress { height: 7px; overflow: hidden; border-radius: 99px; background: #25394e; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--cyan),var(--blue)); transition: width .2s; }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 205px minmax(0,1fr); }
  .module-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .topbar { min-height: 58px; }
  .top-meta { display: none; }
  .topbar-right { gap: 5px; }
  .topbar-right > .btn { padding: 6px 8px; }
  .global-controls { gap: 2px; }
  .workspace { display: block; }
  .sidebar { padding: 9px 12px; border-right: 0; border-bottom: 1px solid rgba(119,160,199,.13); }
  .sidebar-label, .sidebar-note, .nav-home { display: none; }
  .module-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: thin; }
  .nav-link { flex: 0 0 auto; padding: 7px 9px; }
  .nav-number { flex-basis: 22px; height: 22px; }
  .nav-text { max-width: 115px; font-size: 10px; }
  main { padding: 18px 13px 28px; }
  .page-hero { display: block; }
  .hero-actions { justify-content: flex-start; margin-top: 14px; }
  .two-col, .home-hero { grid-template-columns: 1fr; }
  .panel-grid, .three-col { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .module-card { min-height: 170px; padding: 13px; }
  .assumption-grid { grid-template-columns: 1fr; }
  .footer { padding: 12px 14px 18px; }
}
@media (max-width: 430px) {
  .sync-pill { display: none; }
  .kpi-grid { gap: 8px; }
  .kpi { padding: 11px; }
  .module-grid { grid-template-columns: 1fr; }
  .module-card { min-height: auto; }
  .viz-wrap canvas { height: 260px; }
}
