:root {
  --bg: #0a1314; --bg-2: #0f1c1d; --surface: #132424; --surface-2: #183030; --surface-3: #1f3b3a;
  --border: rgba(165, 172, 175, 0.14); --border-strong: rgba(165, 172, 175, 0.3);
  --text: #e7eeec; --text-2: #aab6b3; --text-3: #7d8a87;
  --brand: #004c54; --brand-2: #0a6d78; --accent: #2cc1b0; --accent-ink: #052321;
  --pos: #5ed26a; --neg: #ff6b6b; --warn: #f5b942; --silver: #a5acaf;
  --radius: 10px; --radius-sm: 6px; --shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px rgba(0,0,0,0.35);
  --font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 236px; --header-h: 60px;
  --t-xs: 11px; --t-sm: 12.5px; --t-base: 14px; --t-md: 16px; --t-lg: 20px; --t-xl: 28px; --t-2xl: 36px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; max-width: 100vw; overflow-x: hidden; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: var(--t-base); line-height: 1.45; -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.num, td.num, .kpi-value, .stat-value, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums lining-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--header-h) 1fr; height: 100dvh; }
.sidebar { grid-row: 1 / -1; background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
.header { grid-column: 2; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-5); background: rgba(10,19,20,0.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.main { grid-column: 2; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: var(--s-5); scroll-behavior: smooth; min-width: 0; }
.main:focus { outline: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.brand svg { flex: none; }
.brand-name { font-weight: 600; font-size: var(--t-base); letter-spacing: -0.01em; line-height: 1.15; }
.brand-sub { font-size: var(--t-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: var(--t-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; padding: 12px 10px 6px; }
.nav-btn { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--text-2); font-size: 13.5px; transition: background .15s, color .15s; }
.nav-btn:hover { background: var(--surface); color: var(--text); }
.nav-btn[aria-current="page"] { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.nav-btn .ico { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-btn .badge { margin-left: auto; font-size: var(--t-xs); background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 1px 7px; }
.nav-btn .badge.bad { background: rgba(255,107,107,.18); color: var(--neg); }
.nav-btn .badge.ok { background: rgba(94,210,106,.15); color: var(--pos); }
.sidebar-foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--border); font-size: var(--t-xs); color: var(--text-3); line-height: 1.5; }
.sidebar-foot b { color: var(--text-2); font-weight: 500; }

.header > div { min-width: 0; }
.header h1 { font-size: var(--t-md); font-weight: 600; margin: 0; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scenario-select { display: none; }
.header .crumb { color: var(--text-3); font-size: var(--t-sm); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; }
.save-state { font-size: var(--t-xs); color: var(--text-3); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.save-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); }
.save-state.dirty .dot { background: var(--warn); }
.save-state.error .dot { background: var(--neg); }

/* Scenario switcher */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.seg button { padding: 5px 11px; font-size: var(--t-sm); border: 0; background: transparent; color: var(--text-2); border-radius: 4px; }
.seg button[aria-pressed="true"] { background: var(--brand-2); color: #fff; }
.seg button:hover:not([aria-pressed="true"]) { color: var(--text); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-size: var(--t-sm); font-weight: 500; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--neg); border-color: rgba(255,107,107,.35); }
.btn.danger:hover { background: rgba(255,107,107,.1); }
.btn.sm { padding: 4px 9px; font-size: var(--t-xs); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Cards */
.grid { display: grid; gap: var(--s-4); }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.grid > * { min-width: 0; }
.stats.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.sidebar-right { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-4) var(--s-5); box-shadow: var(--shadow); min-width: 0; }
.card.tight { padding: var(--s-3) var(--s-4); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); flex-wrap: wrap; }
.card-head h2 { font-size: var(--t-base); font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.card-head .sub { color: var(--text-3); font-size: var(--t-sm); }
.section-title { font-size: var(--t-lg); font-weight: 600; margin: 0 0 4px; letter-spacing: -0.015em; }
.section-sub { color: var(--text-2); font-size: var(--t-sm); margin: 0 0 var(--s-5); max-width: 70ch; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }

.kpi { padding: var(--s-4); }
.kpi-label { font-size: var(--t-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; }
.kpi-value { font-size: var(--t-xl); font-weight: 600; margin: 4px 0 2px; letter-spacing: -0.02em; transition: color .3s; }
.kpi-value.pos { color: var(--pos); } .kpi-value.neg { color: var(--neg); } .kpi-value.warn { color: var(--warn); }
.kpi-delta { font-size: var(--t-sm); color: var(--text-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi-delta .arrow { font-weight: 600; }
.kpi-delta.pos .arrow { color: var(--pos); } .kpi-delta.neg .arrow { color: var(--neg); }

/* Alerts */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert { display: grid; grid-template-columns: 10px 1fr; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-2); font-size: var(--t-sm); align-items: start; }
.alert .bar { width: 4px; height: 100%; min-height: 28px; border-radius: 2px; margin-top: 2px; }
.alert.critical .bar { background: var(--neg); } .alert.warn .bar { background: var(--warn); } .alert.ok .bar { background: var(--pos); }
.alert b { font-weight: 600; display: block; margin-bottom: 1px; }
.alert span { color: var(--text-2); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--text-2); font-weight: 500; text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .05em; }
thead th.num, td.num { text-align: right; }
thead th[data-sort] { cursor: pointer; user-select: none; }
thead th[data-sort]:hover { color: var(--text); }
thead th .sort-ind { opacity: .6; margin-left: 3px; }
tbody td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,0.025); }
tbody tr.selected td { background: rgba(44,193,176,0.08); }
tfoot td { padding: 9px 10px; font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
td.pos { color: var(--pos); } td.neg { color: var(--neg); } td.muted { color: var(--text-3); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: var(--t-xs); background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.tag.v { color: var(--pos); border-color: rgba(94,210,106,.3); } .tag.d { color: var(--warn); border-color: rgba(245,185,66,.3); } .tag.e { color: var(--silver); }
.tag.hi { color: var(--pos); } .tag.med { color: var(--warn); } .tag.low { color: var(--text-3); }
.tag.crit { color: var(--neg); border-color: rgba(255,107,107,.3); }
.sticky-col th:first-child, .sticky-col td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 2; }
.sticky-col thead th:first-child { z-index: 3; background: var(--surface-2); }

/* Controls */
.control { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.control:last-child { border-bottom: 0; }
.control label { font-size: var(--t-sm); color: var(--text); }
.control .hint { grid-column: 1; font-size: var(--t-xs); color: var(--text-3); }
.control .val { font-family: var(--mono); font-size: var(--t-sm); color: var(--accent); text-align: right; min-width: 72px; }
.control input[type=range] { grid-column: 1 / -1; width: 100%; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 22px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: var(--surface-3); border-radius: 2px; }
input[type=range]::-moz-range-track { height: 4px; background: var(--surface-3); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--accent); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
input[type=range]:disabled::-webkit-slider-thumb { background: var(--text-3); box-shadow: none; }
select, input[type=text], input[type=number], textarea { background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 10px; font-size: var(--t-sm); color: var(--text); min-width: 0; }
select:focus, input:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { width: 100%; min-height: 110px; resize: vertical; line-height: 1.5; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.toggle-group { display: inline-flex; gap: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.toggle-group button { padding: 4px 9px; border: 0; background: transparent; color: var(--text-2); font-size: var(--t-xs); white-space: nowrap; }
.toggle-group button[aria-pressed="true"] { background: var(--brand-2); color: #fff; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: var(--t-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.field .toggle-group { align-self: flex-start; }
.row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--s-3); }
.stat { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat-label { font-size: var(--t-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: var(--t-lg); font-weight: 600; margin-top: 2px; }
.stat-value.pos { color: var(--pos); } .stat-value.neg { color: var(--neg); } .stat-value.warn { color: var(--warn); }
.stat-sub { font-size: var(--t-xs); color: var(--text-3); margin-top: 2px; }
.big-number { font-size: var(--t-2xl); font-weight: 600; letter-spacing: -0.025em; line-height: 1.05; }
.big-number.pos { color: var(--pos); } .big-number.neg { color: var(--neg); } .big-number.warn { color: var(--warn); }
.progress { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s ease; }
.progress.neg > div { background: var(--neg); }
.progress.ok > div { background: var(--pos); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--s-4); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { padding: 8px 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-2); font-size: var(--t-sm); white-space: nowrap; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--text); }

/* Charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--mono); font-size: 11px; fill: var(--text-3); }
.chart .axis line, .chart .grid line { stroke: var(--border); }
.chart .zero { stroke: var(--text-3); stroke-dasharray: 3 3; }
.chart .label { fill: var(--text-2); font-family: var(--font); }
.chart .bar { transition: height .35s ease, y .35s ease, width .35s ease, x .35s ease; }
.chart .bar:hover { filter: brightness(1.2); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--t-xs); color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart-tip { position: fixed; pointer-events: none; z-index: 50; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 6px 9px; font-size: var(--t-xs); font-family: var(--mono); color: var(--text); box-shadow: 0 6px 20px rgba(0,0,0,.4); display: none; white-space: nowrap; }

/* Prospect cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-3); }
.pcard { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s; }
.pcard.on { border-color: var(--accent); background: rgba(44,193,176,0.06); }
.pcard .name { font-weight: 600; font-size: var(--t-base); }
.pcard .meta { font-size: var(--t-xs); color: var(--text-3); }
.pcard .need { font-size: var(--t-xs); color: var(--text-2); }
.pcard .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.grade { font-family: var(--mono); font-weight: 600; color: var(--accent); }
.empty { padding: var(--s-6) var(--s-4); text-align: center; color: var(--text-3); font-size: var(--t-sm); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.empty b { color: var(--text-2); display: block; margin-bottom: 4px; font-weight: 500; }

/* Toasts / modal */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(380px, calc(100vw - 40px)); }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 10px 14px; font-size: var(--t-sm); box-shadow: 0 10px 30px rgba(0,0,0,.45); animation: toast-in .2s ease; }
.toast.error { border-left-color: var(--neg); } .toast.warn { border-left-color: var(--warn); } .toast.ok { border-left-color: var(--pos); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 90; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: var(--s-5); width: min(520px, 100%); max-height: 90dvh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal h3 { margin: 0 0 8px; font-size: var(--t-md); }
.modal p { color: var(--text-2); font-size: var(--t-sm); margin: 0 0 var(--s-4); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: var(--s-4); }
kbd { font-family: var(--mono); font-size: var(--t-xs); background: var(--bg-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: var(--t-sm); color: var(--text-2); }

/* QA */
.qa-list { display: flex; flex-direction: column; gap: 4px; font-family: var(--mono); font-size: var(--t-xs); }
.qa-item { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; padding: 6px 10px; border-radius: 4px; background: var(--bg-2); border: 1px solid var(--border); align-items: center; }
.qa-item .st { font-weight: 600; } .qa-item.pass .st { color: var(--pos); } .qa-item.fail .st { color: var(--neg); }
.qa-item .err { grid-column: 2 / -1; color: var(--neg); white-space: pre-wrap; }
.qa-item .ms { color: var(--text-3); }
.qa-group { font-size: var(--t-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; margin: 12px 0 6px; }
.log { font-family: var(--mono); font-size: var(--t-xs); color: var(--text-2); background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; max-height: 240px; overflow: auto; white-space: pre-wrap; }

.hidden { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: var(--t-xs); }
.right { text-align: right; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }
.waterfall-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: var(--t-sm); }
.waterfall-row:last-child { border-bottom: 0; }
.waterfall-row.total { font-weight: 600; border-top: 1px solid var(--border-strong); margin-top: 4px; padding-top: 10px; }
.waterfall-row .num { color: var(--text); }
.waterfall-row .num.pos { color: var(--pos); } .waterfall-row .num.neg { color: var(--neg); }
.waterfall-row .lbl span { color: var(--text-3); font-size: var(--t-xs); margin-left: 6px; }
.scenario-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.scenario-card .nm { font-weight: 600; } .scenario-card .dt { font-size: var(--t-xs); color: var(--text-3); }
.scenario-card .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.offline-banner { display: none; background: rgba(245,185,66,.12); color: var(--warn); font-size: var(--t-xs); padding: 4px 10px; border-radius: 4px; }
body.offline .offline-banner { display: inline-block; }

/* Mobile */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 19; display: none; }
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); z-index: 20; transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .scrim { display: block; }
  .header, .main { grid-column: 1; }
  .header { padding: 0 var(--s-3); gap: 8px; overflow: hidden; }
  .menu-btn { display: inline-flex; padding: 6px; }
  #scenarioSeg { display: none; }
  .scenario-select { display: inline-block; max-width: 120px; padding: 6px 8px; font-size: var(--t-xs); }
  .header-actions { gap: 6px; }
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards { grid-template-columns: 1fr; }
  .sidebar-foot { padding-bottom: 24px; }
  .sidebar { width: min(80vw, 300px); }
  .table-wrap td, .table-wrap th { white-space: nowrap; }
  .table-wrap td .small { white-space: normal; max-width: 160px; }
  .chart text { font-size: 19px; }
  .check input, input[type=checkbox] { width: 20px; height: 20px; }
  .toggle-group button, .btn.sm { padding: 7px 10px; }
  .control input[type=range] { height: 30px; }
  input[type=range]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -10px; }
  .main { padding: var(--s-4); padding-bottom: 80px; }
  .grid.two, .grid.three, .grid.sidebar-right { grid-template-columns: 1fr; }
  .header h1 { font-size: var(--t-base); }
  .header .crumb { display: none; }
  .save-state span.txt { display: none; }
  .seg button { padding: 5px 8px; font-size: var(--t-xs); }
  .kpi-value { font-size: 24px; }
  .big-number { font-size: 30px; }
  .card { padding: var(--s-4); }
  .control { grid-template-columns: 1fr auto; }
  .toasts { bottom: 16px; left: 16px; right: 16px; max-width: none; }
  .header-actions .hide-m { display: none; }
}
@media (max-width: 480px) {
  .grid.kpis { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 20px; }
  .cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  body { overflow: visible; background: #fff; color: #000; }
  .app { display: block; height: auto; }
  .sidebar, .header-actions, .menu-btn, .toasts, .modal-bg, .tabs, .btn, input[type=range], .scrim { display: none !important; }
  .header { position: static; background: none; border: 0; }
  .main { overflow: visible; padding: 0; }
  .card { break-inside: avoid; border-color: #ccc; box-shadow: none; background: #fff; }
  :root { --text: #000; --text-2: #333; --text-3: #555; --surface: #fff; --surface-2: #f3f3f3; --bg-2: #fafafa; --border: #ddd; }
  .chart text { fill: #333; }
}

/* ===================== Franchise layer ===================== */
:root { --display: 'Barlow Condensed', 'Arial Narrow', Impact, 'IBM Plex Sans', sans-serif; }
.fm-hero { position: relative; overflow: hidden; border-radius: 14px; border: 1px solid var(--border-strong); background: linear-gradient(120deg, var(--team, #004c54) 0%, #0e2a2d 55%, var(--surface) 100%); padding: 22px 24px; display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.fm-hero::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 48px); pointer-events: none; }
.fm-hero-main { display: flex; gap: 18px; align-items: center; position: relative; z-index: 1; min-width: 0; }
.fm-crest { flex: none; width: 76px; height: 76px; border-radius: 18px; background: rgba(0,0,0,0.25); display: grid; place-items: center; border: 1px solid rgba(255,255,255,0.12); }
.fm-kicker { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.14em; color: rgba(255,255,255,0.7); }
.fm-team { font-family: var(--display); font-weight: 800; font-size: clamp(30px, 4vw, 46px); line-height: 0.95; margin: 4px 0 6px; text-transform: uppercase; letter-spacing: 0.01em; color: #fff; }
.fm-team span { color: var(--silver); }
.fm-line { color: rgba(255,255,255,0.9); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fm-line .tag { background: rgba(0,0,0,0.3); }
.fm-hero-stats { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; align-content: center; }
.hstat { background: rgba(0,0,0,0.28); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 9px 11px; min-width: 0; }
.hstat span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hstat b { display: block; font-family: var(--display); font-weight: 700; font-size: 24px; line-height: 1.1; margin-top: 2px; color: #fff; }
.hstat b small { font-size: 14px; color: rgba(255,255,255,0.6); font-weight: 600; }
.hstat b.pos { color: var(--pos); } .hstat b.neg { color: var(--neg); } .hstat b.warn { color: var(--warn); }
.fm-tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 16px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); transition: transform .15s, border-color .15s, background .15s; min-width: 0; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--surface-2); }
.tile-ico { color: var(--accent); } .tile-ico .ico { width: 22px; height: 22px; }
.tile-title { font-family: var(--display); font-weight: 700; font-size: 19px; text-transform: uppercase; letter-spacing: 0.03em; }
.tile-kpi { font-family: var(--mono); font-size: var(--t-md); font-weight: 600; color: var(--accent); }
.tile-sub { font-size: var(--t-xs); color: var(--text-3); line-height: 1.35; }
.needs { display: flex; flex-direction: column; gap: 8px; }
.need-row { display: grid; grid-template-columns: 44px 1fr 34px 70px minmax(0, 1.4fr); gap: 10px; align-items: center; }
.need-pos { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: 0.04em; }
.need-bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.need-fill { height: 100%; border-radius: 999px; background: var(--text-3); transition: width .3s; }
.need-fill.crit { background: var(--neg); } .need-fill.med { background: var(--warn); } .need-fill.hi { background: var(--accent); } .need-fill.low { background: var(--text-3); }
.need-score { text-align: right; font-weight: 600; }
.need-why { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wire { display: flex; flex-direction: column; gap: 6px; }
.wire-row { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; align-items: start; padding: 8px 0; border-top: 1px solid var(--border); font-size: var(--t-sm); }
.wire-row:first-child { border-top: 0; }
.wire-row .tag { white-space: nowrap; }
.wire-date { color: var(--text-3); font-size: var(--t-xs); padding-top: 2px; }
.mkt { display: inline-grid; place-items: center; min-width: 36px; height: 30px; padding: 0 6px; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background: var(--surface-3); color: var(--text); font-family: var(--display); font-weight: 800; font-size: 17px; flex: none; }
.ps { display:inline-flex; flex-direction:column; align-items:center; justify-content:center; min-width:46px; height:38px; padding:0 6px; border-radius:9px; background:var(--surface-3); color:var(--text); font-family:var(--display); font-weight:800; font-size:16px; line-height:1; flex:none; border:1px solid transparent }
.ps small { font:600 9px/1 system-ui,sans-serif; opacity:.8; margin-top:3px; letter-spacing:.02em }
.ps.t1 { background:var(--accent); color:var(--accent-ink) } .ps.t2 { background:var(--brand-2); color:#fff } .ps.na { opacity:.6 }
.pcard2.compact .ps { height:30px; min-width:40px; font-size:14px }
.tier-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:14px }
.tier-col h3 { margin:0 0 2px; font-family:var(--display) } .pz-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-top:1px solid var(--line, rgba(255,255,255,.08)) }
.pz-row .grow { flex:1; min-width:0 } .pz-bar { height:6px; border-radius:4px; background:var(--surface-3); overflow:hidden; margin-top:4px } .pz-bar i { display:block; height:100%; background:var(--accent) }
.sl-mark { display:inline-flex; align-items:center; gap:6px; margin-top:8px; font:700 11px/1 system-ui,sans-serif; letter-spacing:.08em; text-transform:uppercase; color:#cfd8dc; text-decoration:none; opacity:.85 } .sl-mark:hover { opacity:1 }
.mkt.solid { background: var(--brand-2); color: #fff; } .mkt.elite { background: var(--accent); color: var(--accent-ink); }
.pcard2 { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); margin-top: 6px; transition: border-color .15s, background .15s; }
.pcard2:hover { border-color: var(--accent); background: var(--surface-3); }
.pcard2.inj { border-color: rgba(255,107,107,.35); }
.pcard2.compact { padding: 6px 8px; grid-template-columns: 28px 1fr auto; }
.pcard2.compact .avatar { width: 28px; height: 28px; font-size: 11px; }
.pcard2.compact .mkt { height: 24px; min-width: 30px; font-size: 14px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: 0.04em; }
.pinfo { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmeta { font-size: var(--t-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ptags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.ptags .tag { font-size: 10px; padding: 0 6px; }
.depth-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.depth-col { padding: 12px; }
.depth-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.depth-pos { font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: 0.04em; line-height: 1; }
.depth-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); margin: 10px 0 2px; }
.empty.small { padding: 10px; border: 1px dashed var(--border-strong); border-radius: 8px; color: var(--text-3); margin-top: 6px; }
.team-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-family: var(--display); font-size: 15px; letter-spacing: 0.04em; }
.team-chip i { width: 12px; height: 12px; border-radius: 3px; background: var(--team, #666); border: 1px solid rgba(255,255,255,0.25); display: inline-block; }
.team-chip.sm { font-size: 13px; } .team-chip.sm i { width: 10px; height: 10px; }
.tm-grid { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 12px; align-items: start; }
.tm-col { padding: 14px; }
.asset-list { display: flex; flex-direction: column; gap: 6px; min-height: 44px; }
.asset { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-size: var(--t-sm); color: var(--text); text-align: left; width: 100%; }
.asset.add { background: transparent; cursor: pointer; }
.asset.add:hover { border-color: var(--accent); background: var(--surface-2); }
.asset-scroll { display: flex; flex-direction: column; gap: 5px; max-height: 330px; overflow-y: auto; padding-right: 2px; }
.asset-scroll.short { max-height: 190px; }
.vbars { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
.vbar { display: grid; grid-template-columns: 84px 1fr 48px; gap: 10px; align-items: center; font-size: var(--t-sm); }
.vtrack { height: 14px; background: var(--surface-3); border-radius: 7px; overflow: hidden; }
.vfill { height: 100%; background: var(--brand-2); transition: width .3s; } .vfill.alt { background: var(--silver); }
.meter { position: relative; height: 28px; border-radius: 14px; background: var(--surface-3); overflow: hidden; border: 1px solid var(--border); }
.meter-fill { height: 100%; transition: width .35s; background: var(--text-3); }
.meter-fill.ok { background: var(--pos); } .meter-fill.warn { background: var(--accent); } .meter-fill.low { background: var(--warn); } .meter-fill.bad { background: var(--neg); }
.meter-txt { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 16px; letter-spacing: 0.05em; text-transform: uppercase; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.partner-card { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: linear-gradient(90deg, color-mix(in srgb, var(--team, #444) 35%, var(--surface)) 0%, var(--surface-2) 100%); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; cursor: pointer; }
.link-btn:hover { color: #fff; }
table.tight th, table.tight td { padding: 5px 8px; white-space: nowrap; }
.hstat span { font-size: 10px; }
.div-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--text); }
.pcard .rank { display: inline-block; min-width: 26px; text-align: center; background: var(--surface-3); border-radius: 6px; padding: 0 4px; margin-right: 4px; font-size: var(--t-sm); }
tr.total td { border-top: 1px solid var(--border-strong); }
@media (max-width: 1180px) { .fm-tiles { grid-template-columns: repeat(3, 1fr); } .tm-grid { grid-template-columns: 1fr 1fr; } .tm-center { grid-column: 1 / -1; order: -1; } .need-row { grid-template-columns: 44px 1fr 34px 70px; } .need-why { grid-column: 1 / -1; white-space: normal; } }
@media (max-width: 900px) { .fm-hero { grid-template-columns: 1fr; padding: 18px; } .fm-hero-stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .fm-tiles { grid-template-columns: repeat(2, 1fr); } .tm-grid { grid-template-columns: 1fr; } .fm-hero-stats { grid-template-columns: repeat(2, 1fr); } .fm-crest { display: none; } .depth-grid { grid-template-columns: 1fr; } .need-row { grid-template-columns: 40px 1fr 30px 64px; gap: 6px; } .vbar { grid-template-columns: 70px 1fr 40px; } .hstat b { font-size: 21px; } }
@media print { .tile:hover { transform: none; } }

