:root {
  --bg: #050709;
  --panel: #0a0e12;
  --panel-2: #0e141a;
  --panel-3: #131a21;
  --line: #25313c;
  --line-soft: #17212a;
  --text: #d7e1e8;
  --muted: #71808c;
  --dim: #47545f;
  --amber: #f5a623;
  --amber-2: #ffc15a;
  --cyan: #41c7e8;
  --green: #39d98a;
  --red: #ff5364;
  --yellow: #ffd166;
  --blue: #4d8dff;
  --mono: "SFMono-Regular", "Roboto Mono", "Liberation Mono", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font: 12px/1.45 var(--mono); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.terminal-body { height: 100vh; overflow: hidden; background: radial-gradient(circle at 70% -20%, #14202b 0, transparent 35%), var(--bg); }
.topbar { height: 48px; display: flex; align-items: stretch; border-bottom: 1px solid #39434b; background: #080b0e; }
.brand-lockup { min-width: 174px; padding: 0 13px; display: flex; align-items: center; gap: 9px; border-right: 1px solid var(--line); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; min-width: 53px; height: 27px; padding: 0 7px; background: var(--amber); color: #090909; font-weight: 900; font-size: 16px; letter-spacing: -.5px; }
.brand-version { color: var(--amber-2); font: 700 9px/1.2 var(--mono); letter-spacing: 1.4px; }
.topbar-segment { min-width: 91px; padding: 6px 11px; border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; justify-content: center; }
.topbar-segment .label { color: var(--muted); font-size: 9px; letter-spacing: 1px; }
.topbar-segment strong { color: var(--cyan); font-size: 11px; }
.topbar-tape { display: flex; align-items: center; gap: 18px; flex: 1; padding: 0 14px; min-width: 0; overflow: hidden; white-space: nowrap; }
.ticker { display: inline-flex; gap: 7px; }
.ticker b { color: #cbd7df; }
.ticker .up { color: var(--green); }
.ticker .down { color: var(--red); }
.clock-block { min-width: 128px; display: flex; flex-direction: column; justify-content: center; text-align: right; padding: 0 10px; color: #9cabb6; font-size: 10px; }
.top-action { border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); padding: 0 12px; cursor: pointer; }
kbd { border: 1px solid #47525b; border-radius: 2px; padding: 1px 4px; color: var(--amber-2); background: #15191d; font: 9px var(--mono); }
.operator-menu { display: flex; gap: 7px; align-items: center; padding: 0 10px; border-left: 1px solid var(--line); color: #9facb5; }
.operator-menu button { background: transparent; border: 0; color: var(--red); cursor: pointer; font-size: 9px; }
.operator-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }

.trust-ribbon { height: 28px; display: flex; align-items: center; gap: 0; padding-left: 174px; background: #0b1014; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; letter-spacing: .35px; }
.trust-item { height: 100%; display: flex; align-items: center; gap: 6px; padding: 0 12px; border-right: 1px solid var(--line-soft); }
.trust-item b { color: var(--text); }
.trust-spacer, .status-spacer { flex: 1; }
#generated-at { padding-right: 12px; }
.state-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.state-dot.good { background: var(--green); box-shadow: 0 0 7px #39d98a66; }
.state-dot.warn { background: var(--yellow); box-shadow: 0 0 7px #ffd16655; }
.state-dot.bad { background: var(--red); box-shadow: 0 0 7px #ff536455; }
.state-dot.unknown { background: var(--dim); }

.app-grid { height: calc(100vh - 100px); display: grid; grid-template-columns: 174px minmax(0, 1fr); }
.side-nav { background: #080b0e; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 7px 0; }
.nav-item { position: relative; height: 43px; display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 5px; width: 100%; padding: 0 10px; color: #8796a0; border: 0; border-left: 3px solid transparent; background: transparent; text-align: left; cursor: pointer; }
.nav-item:hover { background: #11171c; color: #dce5ea; }
.nav-item.active { background: linear-gradient(90deg, #2c210f 0, #121512 100%); border-left-color: var(--amber); color: var(--amber-2); }
.nav-item small { color: var(--dim); font-size: 8px; }
.nav-item kbd { text-align: center; }
.nav-divider { height: 1px; background: var(--line); margin: 8px 10px; }
.nav-emergency { color: #db707b; }
.nav-emergency.active { background: linear-gradient(90deg, #351017, #151012); border-left-color: var(--red); color: #ff8a95; }
.side-legend { margin-top: auto; padding: 13px; display: grid; gap: 7px; border-top: 1px solid var(--line-soft); color: var(--dim); font-size: 8px; }
.side-legend span { display: flex; align-items: center; gap: 7px; }

.workspace { overflow: auto; padding: 9px; outline: none; }
.workspace-header { display: flex; align-items: flex-end; justify-content: space-between; margin: 2px 2px 9px; }
.workspace-header h1 { margin: 0; color: #e7edf1; font: 700 18px/1.2 var(--sans); letter-spacing: -.3px; }
.workspace-header p { margin: 3px 0 0; color: var(--muted); }
.eyebrow { color: var(--amber); font-size: 9px; letter-spacing: 1.2px; text-transform: uppercase; }
.header-actions { display: flex; gap: 6px; }
.small-button { border: 1px solid var(--line); background: #11171c; color: #aebbc4; padding: 6px 9px; cursor: pointer; }
.small-button:hover { border-color: var(--amber); color: var(--amber-2); }

.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 6px; margin-bottom: 7px; }
.kpi { min-height: 77px; padding: 9px 10px; border: 1px solid var(--line); background: linear-gradient(160deg, #10161b, #090d10); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--cyan); opacity: .5; }
.kpi.warn::before { background: var(--yellow); opacity: 1; }
.kpi.bad::before { background: var(--red); opacity: 1; }
.kpi-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; letter-spacing: .6px; }
.kpi-value { display: block; margin-top: 7px; color: #edf3f6; font-size: 20px; letter-spacing: -.9px; }
.kpi-foot { display: block; color: var(--dim); font-size: 9px; margin-top: 3px; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.warning { color: var(--yellow) !important; }
.cyan { color: var(--cyan) !important; }
.amber { color: var(--amber-2) !important; }
.muted { color: var(--muted); }

.cockpit-grid { display: grid; grid-template-columns: minmax(310px, .85fr) minmax(430px, 1.35fr) minmax(300px, .9fr); gap: 7px; align-items: start; }
.stack { display: grid; gap: 7px; }
.panel { border: 1px solid var(--line); background: #090d10; min-width: 0; }
.panel-header { min-height: 31px; padding: 6px 9px; display: flex; align-items: center; justify-content: space-between; background: #10161b; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; color: #c9d3d9; font-size: 10px; letter-spacing: .8px; }
.panel-header span { color: var(--dim); font-size: 8px; }
.panel-body { padding: 8px; }
.panel-body.flush { padding: 0; }
.panel-link { border: 0; background: transparent; color: var(--cyan); font-size: 9px; cursor: pointer; }

.attention-list { display: grid; }
.attention-item { display: grid; grid-template-columns: 5px 1fr; border-bottom: 1px solid var(--line-soft); }
.attention-item:last-child { border-bottom: 0; }
.attention-severity { background: var(--yellow); }
.attention-item.critical .attention-severity { background: var(--red); }
.attention-item.medium .attention-severity { background: var(--cyan); }
.attention-copy { padding: 8px 9px; }
.attention-copy strong { display: block; color: #e3e9ed; font-size: 10px; }
.attention-copy p { margin: 2px 0; color: #82909a; font-size: 9px; }
.attention-copy small { color: var(--cyan); }
.empty-state { padding: 24px 12px; text-align: center; color: var(--muted); }
.empty-state b { display: block; color: var(--green); margin-bottom: 4px; }

.data-table { border-collapse: collapse; width: 100%; white-space: nowrap; }
.data-table th { height: 27px; position: sticky; top: 0; z-index: 1; padding: 0 8px; text-align: left; color: #65747f; background: #0d1216; border-bottom: 1px solid var(--line); font-size: 8px; letter-spacing: .7px; }
.data-table td { height: 30px; padding: 0 8px; border-bottom: 1px solid #151e25; color: #aebbc3; }
.data-table tbody tr:hover { background: #10171c; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .symbol { color: var(--amber-2); font-weight: 700; }
.data-table .main { color: #dce5ea; }
.data-table .sub { color: var(--dim); font-size: 9px; }
.table-scroll { max-height: 330px; overflow: auto; }

.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 5px; border: 1px solid #294031; color: var(--green); background: #0b1c13; font-size: 8px; text-transform: uppercase; }
.status-pill.off, .status-pill.archived, .status-pill.unknown { border-color: #343e45; color: #7a8993; background: #13181c; }
.status-pill.halted, .status-pill.rejected, .status-pill.critical { border-color: #63323a; color: #ff8490; background: #251014; }
.status-pill.shadow, .status-pill.medium { border-color: #2e5360; color: var(--cyan); background: #0a1c22; }
.strategy-list { display: grid; }
.strategy-row { padding: 9px; border-bottom: 1px solid var(--line-soft); display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.strategy-row:last-child { border-bottom: 0; }
.strategy-name { color: #dbe5ea; font-weight: 700; }
.strategy-meta { margin-top: 3px; color: var(--dim); font-size: 9px; }
.strategy-metrics { text-align: right; }
.strategy-metrics b { display: block; color: var(--cyan); }
.signal-line { height: 3px; background: #1d2830; margin-top: 7px; overflow: hidden; }
.signal-line i { display: block; height: 100%; background: var(--green); }

.view-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 7px; }
.full-panel { min-height: 180px; }
.summary-list { display: grid; gap: 0; }
.summary-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.summary-row span { color: var(--muted); }
.summary-row b { color: #d8e2e8; }
.meter { margin: 9px 0; }
.meter-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }
.meter-track { height: 5px; background: #1b242b; margin-top: 4px; }
.meter-track i { display: block; height: 100%; background: var(--cyan); max-width: 100%; }

.market-grid { display: grid; grid-template-columns: repeat(3, minmax(200px, 1fr)); gap: 7px; }
.market-card { border: 1px solid var(--line); background: linear-gradient(145deg, #10161b, #080c0f); padding: 12px; min-height: 110px; }
.market-card header { display: flex; justify-content: space-between; color: var(--muted); }
.market-card strong { display: block; color: #eef3f6; font-size: 23px; margin: 13px 0 4px; }
.market-card footer { display: flex; justify-content: space-between; color: var(--dim); font-size: 9px; }
.spark-placeholder { display: flex; align-items: end; gap: 2px; height: 22px; margin-top: 8px; }
.spark-placeholder i { width: 7px; background: #276f80; opacity: .8; }

.source-grid { display: grid; grid-template-columns: repeat(2, minmax(280px, 1fr)); gap: 7px; }
.source-card { border: 1px solid var(--line); background: #0b1014; padding: 10px; display: grid; grid-template-columns: 10px 1fr auto; gap: 9px; align-items: start; }
.source-card strong { color: #d9e3e9; }
.source-card p { margin: 3px 0 0; color: var(--muted); font-size: 9px; overflow-wrap: anywhere; }
.source-card time { color: var(--dim); font-size: 9px; }

.emergency-page { max-width: 1050px; }
.danger-banner { border: 1px solid #783540; background: linear-gradient(90deg, #2a0d12, #130b0d); padding: 14px; display: flex; gap: 13px; margin-bottom: 9px; }
.danger-banner b { color: #ff8c96; }
.danger-banner p { margin: 3px 0 0; color: #b88a8e; }
.emergency-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.emergency-card { border: 1px solid var(--line); background: #0b0f12; padding: 14px; }
.emergency-card.danger { border-color: #63313a; }
.emergency-card h3 { margin: 0 0 7px; color: #e4ebef; }
.emergency-card p { min-height: 68px; color: var(--muted); }
.emergency-card button { width: 100%; border: 1px solid #713641; background: #2b1015; color: #ff9da6; padding: 9px; cursor: pointer; }
.emergency-card button.resume { border-color: #6f5a27; background: #251d0c; color: var(--yellow); }
.emergency-card button:disabled { cursor: not-allowed; opacity: .35; }

.statusbar { height: 24px; display: flex; align-items: center; gap: 15px; padding: 0 9px; background: #0d1114; border-top: 1px solid #34404a; color: var(--dim); font-size: 8px; }

.loading-screen { height: 65vh; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--dim); letter-spacing: 1.8px; }
.loading-logo { width: 78px; height: 39px; display: grid; place-items: center; background: var(--amber); color: #080808; font-size: 23px; font-weight: 900; }
.loading-bar { width: 210px; height: 2px; background: #252c31; margin: 18px 0 8px; overflow: hidden; }
.loading-bar i { display: block; height: 100%; width: 45%; background: var(--cyan); animation: load 1.2s infinite ease-in-out; }
@keyframes load { from { transform: translateX(-110%); } to { transform: translateX(240%); } }

dialog { color: var(--text); }
dialog::backdrop { background: #000b; backdrop-filter: blur(2px); }
.command-dialog { width: min(600px, 90vw); margin-top: 85px; padding: 0; border: 1px solid #48545e; background: #090d10; box-shadow: 0 25px 80px #000; }
.command-box { margin: 0; }
.command-input-row { height: 46px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.command-input-row span { color: var(--amber); font-size: 20px; }
.command-input-row input { flex: 1; border: 0; outline: 0; background: transparent; color: #e2eaee; }
.command-results { padding: 5px; max-height: 330px; overflow: auto; }
.command-result { display: grid; grid-template-columns: 70px 1fr auto; align-items: center; width: 100%; border: 0; background: transparent; color: #9eabb4; padding: 9px; text-align: left; cursor: pointer; }
.command-result:hover, .command-result.selected { background: #192128; color: #edf3f6; }
.command-result b { color: var(--amber-2); }

.emergency-dialog { width: min(680px, 94vw); padding: 0; border: 1px solid #74333d; background: #090b0d; box-shadow: 0 25px 100px #000; }
.emergency-box > header { padding: 13px 15px; display: flex; justify-content: space-between; align-items: start; border-bottom: 1px solid #50252c; background: #1b0d10; }
.emergency-box h2 { margin: 3px 0 0; font: 700 18px var(--sans); }
.emergency-box header button { border: 0; background: transparent; color: #a06a70; font-size: 22px; cursor: pointer; }
#emergency-content { padding: 15px; }
.consequence { border: 1px solid #523038; background: #160e11; color: #c89ca0; padding: 10px; margin-bottom: 12px; }
.field { margin: 10px 0; }
.field label { display: block; color: var(--muted); font-size: 9px; letter-spacing: .7px; margin-bottom: 4px; }
.field input, .field textarea { width: 100%; border: 1px solid #34414a; background: #080c0f; color: #dfe7eb; padding: 9px; outline: none; }
.field input:focus, .field textarea:focus { border-color: var(--amber); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 13px; }
.dialog-actions button { border: 1px solid #3b4851; background: #11171b; padding: 8px 13px; cursor: pointer; }
.dialog-actions .danger-button { border-color: #74333d; background: #311117; color: #ff919b; }
.phrase-box { padding: 13px; background: #050708; border: 1px dashed #a9535f; text-align: center; color: #ff9da6; font-size: 16px; letter-spacing: 1px; user-select: all; }
.result-box { border: 1px solid var(--line); background: #0d1317; padding: 11px; overflow-wrap: anywhere; }

.toast-stack { position: fixed; right: 12px; bottom: 35px; z-index: 20; display: grid; gap: 6px; }
.toast { width: 340px; padding: 10px 12px; border: 1px solid var(--line); background: #11181d; box-shadow: 0 8px 30px #000b; color: #b8c4cb; }
.toast.error { border-color: #74333d; color: #ff9ca5; }
.toast.success { border-color: #285c43; color: var(--green); }

.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 18% 20%, #17242d 0, transparent 28%), linear-gradient(135deg, #040607, #080c0f); }
.login-shell { width: min(940px, calc(100vw - 32px)); min-height: 510px; display: grid; grid-template-columns: 1.25fr .75fr; border: 1px solid #35424c; background: #080b0e; box-shadow: 0 30px 100px #000; }
.login-brand { padding: 48px; border-right: 1px solid var(--line); background: linear-gradient(155deg, #101820, #070a0d 60%); display: flex; flex-direction: column; }
.login-brand .brand-lockup { border: 0; padding: 0; }
.login-brand h1 { margin: 80px 0 18px; color: #edf2f5; font: 300 39px/1.1 var(--sans); letter-spacing: -1.6px; }
.login-brand h1 span { color: var(--amber); }
.login-brand p { max-width: 510px; color: #81909a; font: 14px/1.65 var(--sans); }
.login-tape { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px 13px; padding-top: 20px; border-top: 1px solid var(--line-soft); color: var(--dim); font-size: 9px; }
.login-tape b { color: var(--cyan); }
.login-panel { padding: 48px 36px; align-self: center; }
.login-status { color: var(--muted); font-size: 9px; letter-spacing: 1px; }
.login-status i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-right: 7px; }
.login-panel h2 { margin: 28px 0 3px; font: 600 21px var(--sans); }
.login-panel form { margin-top: 28px; }
.login-panel label { display: block; color: #697983; font-size: 9px; letter-spacing: 1px; margin: 14px 0 5px; }
.login-panel input { width: 100%; background: #050709; color: #e1eaee; border: 1px solid #34414b; padding: 11px; outline: none; }
.login-panel input:focus { border-color: var(--amber); box-shadow: 0 0 0 1px #f5a62322; }
.primary-button { width: 100%; display: flex; justify-content: space-between; margin-top: 22px; padding: 11px; border: 1px solid #bd7b18; background: var(--amber); color: #0b0b0b; font-weight: 800; cursor: pointer; }
.primary-button kbd { color: #111; border-color: #99610e; background: #e0931e; }
.login-foot { margin-top: 28px; color: #45515a; font-size: 8px; text-align: center; }
.login-foot span { color: var(--amber); margin: 0 7px; }
.login-error { border-left: 3px solid var(--red); background: #261015; color: #ff919b; padding: 8px 10px; margin-top: 15px; }
.error-page { text-align: center; }
.error-page .brand-mark { margin: auto; }
.error-page a { color: var(--amber); }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .cockpit-grid { grid-template-columns: 1fr 1fr; }
  .cockpit-grid > .stack:last-child { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .topbar-tape { display: none; }
}
@media (max-width: 800px) {
  .terminal-body { overflow: auto; }
  .topbar { position: sticky; top: 0; z-index: 10; }
  .brand-lockup { min-width: 112px; }
  .brand-version, .topbar-segment, .clock-block, .top-action { display: none; }
  .trust-ribbon { padding-left: 0; overflow-x: auto; }
  .app-grid { height: auto; grid-template-columns: 1fr; }
  .side-nav { position: sticky; top: 48px; z-index: 9; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0; }
  .nav-item { min-width: 122px; height: 39px; }
  .nav-divider, .side-legend { display: none; }
  .workspace { overflow: visible; }
  .kpi-grid, .market-grid, .emergency-actions { grid-template-columns: 1fr 1fr; }
  .cockpit-grid, .view-grid { grid-template-columns: 1fr; }
  .cockpit-grid > .stack:last-child { grid-column: auto; grid-template-columns: 1fr; }
  .statusbar { display: none; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}
@media (max-width: 520px) {
  .kpi-grid, .market-grid, .emergency-actions, .source-grid { grid-template-columns: 1fr; }
}

