/* Review Intelligence Terminal - dark executive terminal theme */
:root {
  color-scheme: dark;
  --bg: #070b12;
  --panel: #0e1420;
  --panel-2: #121a29;
  --panel-3: #172236;
  --line: #1e2a3d;
  --line-2: #2a3850;
  --text: #e6edf7;
  --text-2: #b7c3d6;
  --muted: #8b9bb4;
  --dim: #5d6b82;
  --amber: #f5a623;
  --amber-2: #c98500;
  --amber-soft: rgba(245, 166, 35, 0.14);
  --up: #2fbf71;
  --up-soft: rgba(47, 191, 113, 0.14);
  --down: #e66767;
  --down-soft: rgba(230, 103, 103, 0.14);
  --blue: #3987e5;
  --s1: #c98500; --s2: #3987e5; --s3: #d95926; --s4: #199e70; --s5: #9085e9; --s6: #d55181; --s7: #008300; --s8: #e66767;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 4px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.amber { color: var(--amber); }
.small { font-size: 12px; }
.tiny { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
[hidden] { display: none !important; }

#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: #05080e; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 3px; background: linear-gradient(135deg, var(--amber) 0%, #ff7a18 100%); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 7px; height: 12px; background: linear-gradient(to top right, transparent 46%, #05080e 47%, #05080e 55%, transparent 56%); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; }
.brand-tag { font-size: 11px; color: var(--muted); margin-top: 2px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { padding: 7px 12px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--amber); border-bottom-color: var(--amber); }
.status { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.status-item { display: flex; flex-direction: column; line-height: 1.15; }
.status-label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.status-value { font-size: 12px; color: var(--text-2); }

/* ---------- ticker ---------- */
.ticker { background: #0a0f18; border-bottom: 1px solid var(--line); overflow: hidden; white-space: nowrap; height: 30px; display: flex; align-items: center; }
.ticker-track { display: inline-flex; gap: 34px; padding-left: 100%; animation: tick 180s linear infinite; font-family: var(--mono); font-size: 12px; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item { display: inline-flex; gap: 8px; align-items: center; color: var(--text-2); }
.ticker-item b { color: var(--text); font-weight: 500; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; padding-left: 12px; } }

.banner { background: var(--amber-soft); border-bottom: 1px solid rgba(245,166,35,.35); color: #ffd58a; padding: 8px 20px; font-size: 13px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.banner a, .banner button { color: var(--amber); font-weight: 600; }
.banner .btn-primary { color: #1a1200; }

/* ---------- layout ---------- */
.view { flex: 1; padding: 18px 20px 40px; max-width: 1600px; width: 100%; margin: 0 auto; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.page-head .crumbs { font-size: 12px; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 4px; }
.page-head .crumbs a:hover { color: var(--amber); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
@media (max-width: 1100px) { .grid-4, .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: 1fr; } .span-2, .span-3 { grid-column: auto; } .status { display: none; } .view { padding: 12px; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--amber); }
.panel-head .meta { font-size: 11px; color: var(--muted); }
.panel-body { padding: 12px; }
.panel-body.flush { padding: 0; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 200px; }

/* ---------- KPI tiles ---------- */
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 600; line-height: 1.1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.accent .kpi-value { color: var(--amber); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.grid-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid-table th { position: sticky; top: 0; background: var(--panel-2); color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; cursor: pointer; user-select: none; }
.grid-table th.num { text-align: right; }
.grid-table th.sorted { color: var(--amber); }
.grid-table th.sorted::after { content: " ▾"; }
.grid-table th.sorted.asc::after { content: " ▴"; }
.grid-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.grid-table tr:hover td { background: rgba(255,255,255,.025); }
.grid-table tr.clickable { cursor: pointer; }
.grid-table td.name { white-space: normal; min-width: 180px; font-weight: 500; }
.grid-table td.name .sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.grid-table td.name a:hover { color: var(--amber); }
.grid-table tr.is-client td.name::before { content: "●"; color: var(--blue); margin-right: 6px; font-size: 9px; vertical-align: middle; }
.rank { color: var(--dim); font-family: var(--mono); width: 34px; }
.delta { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
.delta::before { display: inline-block; width: 1em; }
.delta.up::before { content: "▲"; font-size: 9px; }
.delta.down::before { content: "▼"; font-size: 9px; }
.delta.flat::before { content: ""; width: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 3px; border: 1px solid transparent; white-space: nowrap; }
.badge i { font-style: normal; font-size: 10px; }
.sig-accelerating { color: #7be3a9; background: rgba(47,191,113,.16); border-color: rgba(47,191,113,.35); }
.sig-growing { color: #6fd39a; background: rgba(47,191,113,.10); border-color: rgba(47,191,113,.25); }
.sig-steady { color: #9fb6d8; background: rgba(57,135,229,.12); border-color: rgba(57,135,229,.3); }
.sig-stalled { color: #c5ccd8; background: rgba(139,155,180,.12); border-color: rgba(139,155,180,.3); }
.sig-declining { color: #ff9c9c; background: var(--down-soft); border-color: rgba(230,103,103,.35); }
.sig-baseline { color: var(--muted); background: rgba(139,155,180,.08); border-color: var(--line-2); }
.tier-prime { color: #ffd27a; background: var(--amber-soft); border-color: rgba(245,166,35,.45); }
.tier-strong { color: #ffc65c; background: rgba(245,166,35,.08); border-color: rgba(245,166,35,.28); }
.tier-emerging { color: #b7c3d6; background: rgba(183,195,214,.08); border-color: rgba(183,195,214,.25); }
.tier-watch { color: var(--dim); background: transparent; border-color: var(--line-2); }
.status-pill { font-size: 10.5px; padding: 2px 7px; border-radius: 3px; background: var(--panel-3); color: var(--text-2); border: 1px solid var(--line-2); text-transform: capitalize; }
.status-pill.customer { color: #7be3a9; border-color: rgba(47,191,113,.4); }
.status-pill.qualified, .status-pill.proposal { color: #ffd27a; border-color: rgba(245,166,35,.4); }
.status-pill.not_fit { color: var(--dim); }

.score { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); }
.score-bar { width: 64px; height: 6px; background: var(--panel-3); border-radius: 3px; overflow: hidden; }
.score-bar i { display: block; height: 100%; background: var(--amber); border-radius: 3px; }
.spark { width: 90px; height: 24px; vertical-align: middle; }
.spark path { fill: none; stroke: var(--blue); stroke-width: 1.5; }
.spark.up path { stroke: var(--up); }
.spark.down path { stroke: var(--down); }
.spark circle { fill: var(--amber); }
.stars { color: var(--amber); font-size: 11px; letter-spacing: -1px; }

/* ---------- lists / rows ---------- */
.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row:hover { background: rgba(255,255,255,.025); }
.row .name { font-weight: 500; }
.row .sub { grid-column: 1; font-size: 11px; color: var(--muted); }
.row .big { font-family: var(--mono); font-size: 18px; font-weight: 600; text-align: right; }
.row .bar { grid-column: 1 / -1; height: 4px; background: var(--panel-3); border-radius: 2px; overflow: hidden; }
.row .bar i { display: block; height: 100%; background: var(--up); }
.empty { color: var(--muted); padding: 24px; text-align: center; font-size: 13px; }

/* ---------- forms / controls ---------- */
.btn { background: var(--panel-3); border: 1px solid var(--line-2); color: var(--text); padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: .03em; white-space: nowrap; }
.btn:hover { border-color: var(--amber); color: var(--amber); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #1a1200; }
.btn-primary:hover { background: #ffbb3d; color: #1a1200; }
.btn-ghost { background: transparent; }
.btn-danger:hover { border-color: var(--down); color: var(--down); }
.btn-sm { padding: 3px 8px; font-size: 11px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea, .input { background: #0a0f18; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 7px 9px; color: var(--text); font-size: 13px; min-width: 0; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--amber); }
.field textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11px; padding: 3px 9px; border: 1px solid var(--line-2); border-radius: 12px; color: var(--muted); cursor: pointer; background: transparent; }
.chip.active { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
.check-list { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; }
.check-list label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; color: var(--text-2); }
.check-list label i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); display: inline-block; }
.note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding-top: 2px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd a:hover { color: var(--amber); }
pre.code { background: #05080e; border: 1px solid var(--line); padding: 10px; border-radius: var(--radius); font-family: var(--mono); font-size: 12px; overflow-x: auto; color: var(--text-2); margin: 6px 0; }
.quadrant-note { font-size: 11px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- modal / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(2,4,8,.7); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow: auto; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px; width: min(720px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--amber); }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel-3); border: 1px solid var(--amber); color: var(--text); padding: 10px 14px; border-radius: var(--radius); z-index: 60; font-size: 13px; max-width: 420px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.toast.error { border-color: var(--down); }

.footer { display: flex; justify-content: space-between; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--line); color: var(--dim); font-size: 11px; flex-wrap: wrap; }

/* ---------- market picker ---------- */
.picker { display: grid; grid-template-columns: 220px 220px 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 900px) { .picker { grid-template-columns: 1fr 1fr; } }
.market-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.market-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.market-card:hover { border-color: var(--amber); }
.market-card .title { font-weight: 600; }
.market-card .stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.market-card .stats b { color: var(--text); font-weight: 500; }

.progress { height: 4px; background: var(--panel-3); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--amber); transition: width .3s; }
.results { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); max-height: 320px; overflow: auto; }
.result { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); align-items: center; }
.result:last-child { border-bottom: 0; }
.result .r-name { font-weight: 500; }
.result .r-sub { font-size: 11px; color: var(--muted); }
.pipeline { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 6px; }
.pipe { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; text-align: center; cursor: pointer; }
.pipe.active { border-color: var(--amber); }
.pipe b { display: block; font-family: var(--mono); font-size: 18px; }
.pipe span { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 900px) { .pipeline { grid-template-columns: repeat(4, minmax(0,1fr)); } }
@media print { .topbar, .ticker, .footer, .toolbar, .btn { display: none !important; } body { background: #fff; color: #000; } .panel, .kpi { border-color: #ccc; background: #fff; } }
.grid-table tr.hl td { background: rgba(245, 166, 35, .10); font-weight: 600; }
.grid-table tr.hl td.num { font-weight: 600; }
