:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: #10131a;
  --panel-raised: #141821;
  --panel-soft: #0d1016;
  --line: #242934;
  --line-soft: #1b202a;
  --text: #f1f3f7;
  --muted: #858c9c;
  --muted-2: #5c6372;
  --accent: #ffb46b;
  --accent-bright: #ffd29e;
  --accent-soft: rgba(255, 180, 107, 0.12);
  --green: #78d9a4;
  --green-soft: rgba(120, 217, 164, 0.12);
  --red: #ff7d83;
  --red-soft: rgba(255, 125, 131, 0.12);
  --sidebar-width: 244px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  letter-spacing: -0.01em;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background: radial-gradient(circle at 78% -8%, rgba(255, 180, 107, 0.08), transparent 31%), radial-gradient(circle at 15% 66%, rgba(102, 130, 191, 0.035), transparent 28%);
  content: "";
  pointer-events: none;
}

button, a { font: inherit; }

a { color: inherit; text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  min-height: 100vh;
  padding: 27px 18px 22px;
  border-right: 1px solid var(--line-soft);
  background: rgba(10, 12, 17, 0.88);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 11px 39px; }

.brand-mark { position: relative; display: flex; align-items: end; gap: 3px; width: 25px; height: 25px; padding: 4px; border: 1px solid rgba(255, 180, 107, 0.45); border-radius: 8px; background: var(--accent-soft); }
.brand-mark span { display: block; width: 4px; border-radius: 2px; background: var(--accent); }
.brand-mark span:nth-child(1) { height: 8px; opacity: 0.55; }
.brand-mark span:nth-child(2) { height: 13px; opacity: 0.8; }
.brand-mark span:nth-child(3) { height: 17px; }
.brand-name { margin: 0; color: var(--text); font-size: 11px; font-weight: 760; letter-spacing: 0.16em; }
.brand-subtitle { margin: 4px 0 0; color: var(--muted-2); font-size: 9px; font-weight: 700; letter-spacing: 0.17em; }

.sidebar-section-label { margin: 0 12px 11px; color: var(--muted-2); font-size: 10px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; }
.nav-list { display: grid; gap: 5px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 600; transition: border-color 160ms ease, color 160ms ease, background 160ms ease; }
.nav-link:hover { border-color: var(--line); color: var(--text); background: var(--panel-soft); }
.nav-link.active { border-color: rgba(255, 180, 107, 0.2); color: var(--accent-bright); background: var(--accent-soft); }
.nav-icon { width: 17px; color: var(--muted-2); font-size: 17px; line-height: 1; text-align: center; }
.nav-link.active .nav-icon { color: var(--accent); }
.nav-indicator { width: 4px; height: 4px; margin-left: auto; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(255, 180, 107, 0.1); }

.sidebar-spacer { flex: 1; }
.sidebar-footnote { margin: 18px 8px 18px; padding: 13px 12px; border: 1px solid var(--line-soft); border-radius: 8px; background: rgba(18, 21, 29, 0.7); }
.footnote-status { display: flex; align-items: center; gap: 7px; color: var(--accent-bright); font-size: 11px; font-weight: 700; }
.sidebar-footnote p { margin: 9px 0 0; color: var(--muted-2); font-size: 10px; line-height: 1.55; }
.sidebar-version { padding: 0 11px; color: var(--muted-2); font-size: 9px; font-weight: 700; letter-spacing: 0.12em; }
.sidebar-version span { float: right; color: #454b57; }

.main-content { width: calc(100% - var(--sidebar-width)); max-width: 1540px; min-height: 100vh; margin-left: var(--sidebar-width); padding: 0 48px 36px; }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 75px; border-bottom: 1px solid var(--line-soft); }
.breadcrumb { display: flex; gap: 9px; align-items: center; color: var(--muted-2); font-size: 12px; }
.breadcrumb strong { color: var(--muted); font-weight: 600; }
.breadcrumb-slash { color: #3c424d; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.network-chip { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 11px; font-weight: 600; }
.session-chip strong { color: var(--accent-bright); font-weight: 700; }
.pulse-dot, .status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.status-dot-warm { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.status-dot-danger { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.icon-button { display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; font-size: 19px; line-height: 1; transition: border-color 160ms ease, color 160ms ease, transform 160ms ease; }
.icon-button:hover { border-color: var(--accent); color: var(--accent); }
.icon-button.is-loading span { animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.avatar { display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid rgba(255, 180, 107, 0.35); border-radius: 50%; color: var(--accent-bright); background: var(--accent-soft); font-size: 9px; font-weight: 800; letter-spacing: 0.05em; }

.hero { display: flex; align-items: end; justify-content: space-between; gap: 32px; padding: 53px 0 38px; }
.eyebrow, .panel-kicker { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: 0.14em; text-transform: uppercase; }
.eyebrow-line { display: inline-block; width: 19px; height: 1px; background: var(--accent); }
h1 { max-width: 730px; margin: 14px 0 15px; font-size: clamp(38px, 4.4vw, 67px); font-weight: 350; letter-spacing: -0.07em; line-height: 0.98; }
h1 span { color: #9da4b2; }
.hero-copy { max-width: 530px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.hero-status-card { min-width: 218px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 9px; background: linear-gradient(135deg, rgba(25, 28, 37, 0.9), rgba(14, 17, 23, 0.9)); }
.hero-status-label { color: var(--muted-2); font-size: 10px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; }
.hero-status-value { margin-top: 10px; color: var(--accent-bright); font-size: 21px; font-weight: 550; letter-spacing: -0.04em; }
.hero-status-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 11px; }

.notice { display: flex; align-items: center; gap: 9px; margin: 0 0 18px; padding: 11px 13px; border: 1px solid rgba(255, 125, 131, 0.25); border-radius: 7px; color: #ffb0b4; background: var(--red-soft); font-size: 12px; }
.notice::before { content: "!"; display: grid; width: 17px; height: 17px; place-items: center; border: 1px solid rgba(255, 125, 131, 0.4); border-radius: 50%; font-size: 10px; font-weight: 800; }
.hidden { display: none; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.kpi-card { min-height: 139px; padding: 18px 19px 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.kpi-card-accent { border-color: rgba(255, 180, 107, 0.29); background: linear-gradient(135deg, rgba(255, 180, 107, 0.1), rgba(16, 19, 26, 0.98) 68%); }
.kpi-topline { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { color: var(--muted); font-size: 11px; font-weight: 650; }
.kpi-icon { color: var(--muted-2); font-size: 17px; }
.kpi-card-accent .kpi-icon { color: var(--accent); }
.kpi-value { margin: 20px 0 14px; color: var(--text); font-size: 30px; font-weight: 420; letter-spacing: -0.055em; }
.kpi-card-accent .kpi-value { color: var(--accent-bright); }
.kpi-foot { display: flex; align-items: center; gap: 6px; color: var(--muted-2); font-size: 10px; }
.trend-positive { color: var(--green); font-weight: 700; }

.funnel-panel { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr minmax(150px, .7fr); align-items: stretch; gap: 10px; margin-top: 13px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.funnel-step, .funnel-aside { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 4px 12px; padding: 10px 12px; border-radius: 7px; background: var(--panel-soft); }
.funnel-step span, .funnel-aside span { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.funnel-step strong, .funnel-aside strong { color: var(--text); font-size: 18px; font-weight: 550; }
.funnel-step small, .funnel-aside small { grid-column: 1 / -1; color: var(--muted-2); font-size: 9px; }
.funnel-step small b { color: var(--red); font-weight: 700; }
.funnel-step-accent { background: var(--green-soft); }
.funnel-step-accent strong { color: var(--green); }
.funnel-aside { border-left: 2px solid var(--accent); }
.funnel-arrow { align-self: center; color: var(--muted-2); font-size: 15px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr); gap: 13px; margin-top: 13px; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.panel-header { display: flex; align-items: start; justify-content: space-between; gap: 18px; padding: 20px 21px 0; }
h2 { margin: 6px 0 0; color: var(--text); font-size: 17px; font-weight: 550; letter-spacing: -0.035em; }
.panel-range, .routes-meta { display: flex; align-items: center; gap: 7px; color: var(--muted-2); font-size: 10px; }
.legend-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chart-panel { min-height: 306px; }
.chart-wrap { height: 224px; padding: 17px 20px 0; }
.chart-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-grid-line { stroke: #202530; stroke-width: 1; stroke-dasharray: 2 4; }
.chart-area { fill: url(#areaFill); }
.chart-line { fill: none; stroke: var(--accent); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.3; }
.chart-point { fill: var(--panel); stroke: var(--accent); stroke-width: 2; }
.chart-empty { fill: var(--muted-2); font-size: 11px; letter-spacing: 0.02em; }
.chart-axis { display: flex; justify-content: space-between; padding: 1px 21px 18px; color: var(--muted-2); font-size: 9px; text-transform: uppercase; }

.posture-panel, .stream-panel, .mix-panel { min-height: 306px; }
.mode-badge { padding: 5px 8px; border: 1px solid rgba(255, 180, 107, 0.3); border-radius: 5px; color: var(--accent-bright); background: var(--accent-soft); font-size: 9px; font-weight: 800; letter-spacing: 0.1em; }
.gate-list { margin: 20px 21px 0; border-top: 1px solid var(--line-soft); }
.gate-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.gate-name { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.gate-icon { color: var(--muted-2); font-size: 15px; }
.gate-value { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.gate-value.ok { color: var(--green); }
.gate-value.warn { color: var(--accent); }
.gate-value.danger { color: var(--red); }
.posture-callout { display: flex; align-items: start; gap: 8px; margin: 17px 21px 0; padding: 10px; border-radius: 6px; color: var(--muted); background: var(--panel-soft); font-size: 10px; line-height: 1.45; }
.callout-mark { display: grid; flex: 0 0 auto; width: 14px; height: 14px; place-items: center; border: 1px solid var(--muted-2); border-radius: 50%; color: var(--muted); font-size: 9px; }

.live-label { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 10px; font-weight: 700; }
.stream-list { margin: 20px 21px 0; border-top: 1px solid var(--line-soft); }
.stream-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.stream-name, .stream-source { display: block; }
.stream-name { color: var(--muted); font-size: 11px; font-weight: 600; }
.stream-source { margin-top: 3px; color: var(--muted-2); font-size: 9px; }
.stream-row strong { color: var(--accent-bright); font-size: 12px; font-weight: 650; white-space: nowrap; }

.panel-count { display: grid; min-width: 24px; height: 24px; padding: 0 7px; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 10px; font-weight: 700; }
.asset-list { display: grid; gap: 10px; margin: 20px 21px 0; }
.asset-row { display: flex; align-items: center; gap: 10px; }
.asset-symbol { display: grid; width: 27px; height: 27px; place-items: center; border: 1px solid rgba(255, 180, 107, 0.2); border-radius: 7px; color: var(--accent-bright); background: var(--accent-soft); font-size: 10px; font-weight: 800; }
.asset-info { min-width: 0; flex: 1; }
.asset-name { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; font-weight: 650; }
.asset-name strong { color: var(--muted-2); font-size: 10px; }
.asset-bar { height: 3px; margin-top: 6px; overflow: hidden; border-radius: 99px; background: var(--line); }
.asset-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.empty-mini { color: var(--muted-2); font-size: 11px; }

.discovery-panel { grid-column: 1 / -1; padding-bottom: 20px; }
.discovery-header { align-items: center; }
.discovery-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 18px 21px 0; overflow: hidden; border: 1px solid var(--line-soft); border-radius: 7px; background: var(--line-soft); }
.discovery-summary div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 11px 12px; background: var(--panel-soft); }
.discovery-summary span { color: var(--muted-2); font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.discovery-summary strong { color: var(--text); font-size: 14px; font-weight: 650; }
.discovery-list { display: grid; gap: 7px; max-height: 360px; margin: 14px 21px 0; overflow-y: auto; }
.discovery-row { display: grid; grid-template-columns: minmax(90px, .7fr) minmax(140px, 1fr) minmax(0, 3fr); align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 7px; background: var(--panel-soft); }
.discovery-identity { display: flex; align-items: center; gap: 8px; min-width: 0; }
.discovery-identity strong { overflow: hidden; color: var(--text); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.discovery-venue { color: var(--accent-bright); font-size: 9px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.discovery-reason { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 9px; }
.discovery-detail { overflow: hidden; color: var(--muted-2); font-size: 10px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }

.routes-panel { grid-column: 1 / -1; overflow: hidden; }
.routes-header { align-items: end; padding-bottom: 19px; }
.routes-meta { margin-bottom: 2px; }
.panel-divider { width: 1px; height: 12px; background: var(--line); }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line-soft); }
table { width: 100%; border-collapse: collapse; min-width: 740px; }
th { padding: 12px 21px; color: var(--muted-2); font-size: 9px; font-weight: 750; letter-spacing: 0.1em; text-align: left; text-transform: uppercase; }
td { padding: 14px 21px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; vertical-align: middle; }
tbody tr { transition: background 160ms ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
.asset-cell { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 650; }
.asset-cell .asset-symbol { width: 25px; height: 25px; font-size: 9px; }
.route-cell { display: flex; align-items: center; gap: 7px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; }
.route-arrow { color: var(--accent); font-family: sans-serif; font-size: 14px; }
.edge-cell { color: var(--green); font-size: 12px; font-weight: 750; }
.edge-cell-negative { color: var(--red); }
.edge-bps { display: block; margin-top: 3px; color: var(--muted-2); font-size: 9px; font-weight: 500; }
.economics-badge { display: inline-flex; padding: 4px 7px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: var(--panel-soft); font-size: 9px; font-weight: 750; white-space: nowrap; text-transform: uppercase; }
.filter-toggle { display: inline-flex; padding: 3px 8px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted-2); background: var(--panel-soft); font: inherit; font-size: 9px; font-weight: 750; text-transform: uppercase; cursor: pointer; transition: color .15s ease, border-color .15s ease, background .15s ease; }
.filter-toggle:hover { color: var(--muted); }
.filter-toggle.is-active { border-color: rgba(99, 218, 153, .35); color: var(--green); background: var(--green-soft); }
.economics-complete_gate { border-color: rgba(99, 218, 153, .25); color: var(--green); background: var(--green-soft); }
.economics-below_chain_cost { border-color: rgba(255, 125, 131, .2); color: var(--red); background: var(--red-soft); }
.economics-below_profit_floor { border-color: rgba(255, 180, 107, .25); color: var(--accent); background: var(--accent-soft); }
.size-cell { color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; }
.slot-cell { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; }
.time-cell { color: var(--muted-2); font-size: 10px; white-space: nowrap; }
.empty-state { display: flex; align-items: center; flex-direction: column; gap: 5px; padding: 41px 20px 45px; color: var(--muted-2); text-align: center; }
.empty-state strong { margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 650; }
.empty-state span { font-size: 10px; }
.empty-orbit { display: grid; width: 35px; height: 35px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); font-size: 17px; box-shadow: 0 0 0 7px rgba(255, 180, 107, 0.035); }

.page-footer { display: flex; justify-content: space-between; padding: 23px 2px 0; color: var(--muted-2); font-size: 10px; }

@media (max-width: 1120px) {
  .funnel-panel { grid-template-columns: repeat(3, 1fr); }
  .funnel-arrow { display: none; }
  .funnel-aside { grid-column: 1 / -1; }
  :root { --sidebar-width: 78px; }
  .sidebar { align-items: center; padding: 27px 11px 22px; }
  .brand { padding: 0 0 39px; }
  .brand > div:last-child, .sidebar-section-label, .nav-link > span:not(.nav-icon):not(.nav-indicator), .sidebar-footnote, .sidebar-version { display: none; }
  .nav-list { width: 100%; }
  .nav-link { justify-content: center; padding: 12px 0; }
  .nav-indicator { position: absolute; right: 8px; width: 4px; margin: 0; }
  .main-content { padding-right: 30px; padding-left: 30px; }
}

@media (max-width: 840px) {
  .hero { align-items: start; flex-direction: column; }
  .hero-status-card { width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .routes-panel, .discovery-panel { grid-column: auto; }
  .discovery-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .discovery-row { grid-template-columns: 1fr; gap: 5px; }
}

@media (max-width: 560px) {
  .funnel-panel { grid-template-columns: 1fr; }
  .funnel-aside { grid-column: auto; }
  :root { --sidebar-width: 0px; }
  .sidebar { display: none; }
  .main-content { width: 100%; margin: 0; padding: 0 17px 27px; }
  .topbar { height: 63px; }
  .network-chip { display: none; }
  .hero { padding-top: 38px; }
  h1 { font-size: 42px; }
  .kpi-grid { gap: 8px; }
  .kpi-card { min-height: 127px; padding: 14px; }
  .kpi-value { margin-top: 17px; font-size: 25px; }
  .kpi-foot { display: block; line-height: 1.45; }
  .kpi-foot span { display: block; }
  .panel-header { padding-right: 15px; padding-left: 15px; }
  .gate-list, .stream-list, .asset-list { margin-right: 15px; margin-left: 15px; }
  .discovery-summary, .discovery-list { margin-right: 15px; margin-left: 15px; }
  .posture-callout { margin-right: 15px; margin-left: 15px; }
  .chart-wrap { padding-right: 14px; padding-left: 14px; }
  .chart-axis { padding-right: 15px; padding-left: 15px; }
  .routes-header { align-items: start; flex-direction: column; gap: 10px; }
  .page-footer { display: block; line-height: 1.7; }
}
