:root {
  --bg: #04070d;
  --bg-2: #080f1a;
  --card: #0b1423;
  --border: #1a2942;
  --border-hi: #29436b;
  --text: #edf3fa;
  --text-2: #9ab0c9;
  --muted: #627793;
  --cobalt: #3b82f6;
  --ice: #7dd3fc;
  --crimson: #f43f5e;
  --amber: #f59e0b;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Space Grotesk", -apple-system, sans-serif;
  --display: "Syne", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); min-height: 100vh; overflow-x: clip; max-width: 100%; }
.mono { font-family: var(--mono); }
.ice { color: var(--ice); }
.crimson { color: var(--crimson); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }

/* TOP HEADER + DECK TABS */
.term-hdr {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(4, 7, 13, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.term-hdr-row1 {
  max-width: 1440px;
  margin: 0 auto;
  height: 58px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.term-left { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.term-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.term-logo { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(125,211,252,0.4); }
.term-word { font-family: var(--display); font-weight: 800; font-size: 16px; letter-spacing: 0.06em; }

.term-search {
  flex: 1;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: 7px;
  padding: 4px 4px 4px 12px;
}
.term-search:focus-within { border-color: var(--ice); }
.term-search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 12.5px;
}
.scan-btn {
  height: 30px;
  padding: 0 14px;
  border: none;
  border-radius: 5px;
  background: linear-gradient(135deg, #3b82f6, #0ea5e9);
  color: #030812;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.term-right { display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.hud-stat { color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 5px; background: rgba(255,255,255,0.03); border: 1px solid var(--border); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ice); box-shadow: 0 0 8px var(--cobalt); }
.ca-chip, .hdr-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border-hi);
  background: var(--card);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.hdr-btn.primary { background: linear-gradient(135deg, #3b82f6, #38bdf8); color: #030812; border: none; font-weight: 700; }

.deck-tabs {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid rgba(255,255,255,0.04);
  overflow-x: auto;
}
.deck-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 10px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.deck-tab:hover { color: var(--text); }
.deck-tab.active { color: var(--ice); border-bottom-color: var(--cobalt); }
.push-right { margin-left: auto; color: var(--muted); }

/* MAIN WORKSPACE */
.stage {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 18px 60px;
}
.view { display: none; }
.view.active { display: block; }
.err-bar {
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.45);
  color: #fda4af;
  padding: 10px 14px;
  border-radius: 7px;
  margin-bottom: 14px;
  font-size: 12px;
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.preset-group { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: 11.5px; }
.chip {
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid var(--border-hi);
  background: var(--card);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover:not(:disabled) { border-color: var(--ice); color: var(--ice); }
.chip:disabled { opacity: 0.4; cursor: not-allowed; }
.ice-chip {
  border-color: rgba(125, 211, 252, 0.45);
  background: rgba(59, 130, 246, 0.14);
  color: var(--ice);
}

.box {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(12, 22, 38, 0.94), rgba(6, 11, 20, 0.96));
  overflow: hidden;
}
.box-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
}
.box-title { font-weight: 700; letter-spacing: 0.05em; color: var(--text); }
.mode-tag {
  margin-left: 8px;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.16);
  color: var(--ice);
  border: 1px solid rgba(125, 211, 252, 0.3);
}
.legend { display: flex; gap: 10px; font-size: 10.5px; color: var(--text-2); }
.lg { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.lg.clean { background: #38bdf8; }
.lg.high { background: #f59e0b; }
.lg.crit { background: #f43f5e; }

.radar-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.85fr);
  gap: 14px;
  margin-bottom: 14px;
}
.graph-stage { position: relative; height: 430px; }
#fundingCanvas { width: 100%; height: 100%; display: block; }
.loader {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 13, 0.78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ice);
  font-size: 12px;
}
.spin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-hi);
  border-top-color: var(--ice);
  animation: sp 0.7s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }
.node-bar {
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-2);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.node-bar a { color: var(--ice); }

.side-col { display: flex; flex-direction: column; gap: 14px; }
.score-box { padding: 16px; }
.score-top { display: flex; align-items: center; gap: 16px; }
.dial-wrap { position: relative; width: 104px; height: 104px; flex-shrink: 0; }
.dial { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial-bg { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 9; }
.dial-fg { fill: none; stroke: var(--ice); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.dial-txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dial-txt #scoreNum { font-size: 26px; font-weight: 700; line-height: 1; }
.dial-txt #scoreGrade { font-size: 10px; margin-top: 3px; font-weight: 700; }

.kpi-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: 1; }
.km { background: rgba(4,7,13,0.7); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; display: flex; flex-direction: column; gap: 2px; font-size: 10px; }
.km strong { font-size: 12.5px; color: var(--text); }
.addr-strip { margin-top: 12px; padding: 7px 10px; border-radius: 6px; background: rgba(4,7,13,0.7); border: 1px solid var(--border); font-size: 10.5px; color: var(--text-2); word-break: break-all; }

.spider-wrap { height: 220px; padding: 8px; }
#spiderCanvas { width: 100%; height: 100%; display: block; }

.radar-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mini-act { background: transparent; border: 1px solid rgba(125,211,252,0.4); color: var(--ice); font-size: 10.5px; padding: 4px 9px; border-radius: 5px; cursor: pointer; }
.sig-grid { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.sig-item { padding: 10px 12px; border-radius: 7px; border: 1px solid var(--border); border-left: 3px solid var(--ice); background: rgba(4,7,13,0.65); }
.sig-item.critical { border-left-color: var(--crimson); }
.sig-item.high { border-left-color: #fb7185; }
.sig-item.medium { border-left-color: var(--amber); }
.sig-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.sig-sev { font-family: var(--mono); font-size: 10px; text-transform: uppercase; color: var(--muted); }
.sig-desc { font-size: 12.5px; color: var(--text-2); }

.tx-list { padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; max-height: 300px; overflow-y: auto; }
.tx-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 6px; border: 1px solid var(--border); background: rgba(4,7,13,0.65); font-family: var(--mono); font-size: 11.5px; }
.tag-clean { color: var(--ice); }
.tag-leak { color: var(--crimson); }
.empty-msg { padding: 20px; text-align: center; color: var(--muted); font-size: 12px; }

/* STEALTH VAULT */
.stealth-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 12px; }
.stealth-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.pad-in { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.copy-row { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 7px; border: 1px solid var(--border-hi); background: rgba(4,7,13,0.8); }
.copy-row.glow { border-color: var(--ice); box-shadow: 0 0 20px rgba(59,130,246,0.2); }
.copy-row code { flex: 1; font-size: 11.5px; word-break: break-all; color: var(--ice); }
.cbtn { border: 1px solid var(--border-hi); background: var(--card); color: var(--text); padding: 5px 10px; border-radius: 5px; font-size: 11px; cursor: pointer; }
.pair-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv-box { padding: 9px 10px; border-radius: 6px; border: 1px solid var(--border); background: rgba(4,7,13,0.65); display: flex; flex-direction: column; gap: 4px; font-size: 10px; }
.kv-box code { font-size: 10.5px; word-break: break-all; color: var(--text-2); }
.stealth-inp { width: 100%; padding: 10px 12px; border-radius: 7px; border: 1px solid var(--border-hi); background: rgba(4,7,13,0.85); color: var(--text); font-size: 12px; outline: none; }
.stealth-inp:focus { border-color: var(--ice); }
.derive-cta { width: 100%; height: 40px; border: none; border-radius: 7px; background: linear-gradient(135deg, #3b82f6, #0ea5e9); color: #030812; font-weight: 700; font-size: 12px; cursor: pointer; }
.derived-panel { display: flex; flex-direction: column; gap: 10px; }
.d-meta { font-size: 11px; color: var(--text-2); word-break: break-all; display: flex; flex-direction: column; gap: 4px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.proof-box { padding: 10px 12px; border-radius: 6px; border: 1px solid rgba(125,211,252,0.4); background: rgba(59,130,246,0.12); color: var(--ice); font-size: 11px; line-height: 1.6; word-break: break-all; }

/* PULSE */
.pulse-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.spark-wrap { height: 150px; padding: 12px; }
#sparkCanvas { width: 100%; height: 100%; display: block; }
.pulse-kpis { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); }
.pulse-kpis > div { padding: 14px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; font-size: 10.5px; }
.pulse-kpis > div:last-child { border-right: none; }
.pulse-kpis strong { font-size: 18px; }
.spec-cards { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.sc-item { padding: 12px; border-radius: 7px; border: 1px solid var(--border); background: rgba(4,7,13,0.65); }
.sc-item p { margin: 6px 0 0; font-size: 13px; color: var(--text-2); }
.sc-item code { color: var(--ice); font-family: var(--mono); font-size: 12px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--card); border: 1px solid var(--ice); color: var(--ice); padding: 9px 14px; border-radius: 6px; font-size: 12px; z-index: 90; }

@media (max-width: 980px) {
  .radar-grid, .radar-bottom, .stealth-cols, .pulse-grid { grid-template-columns: 1fr; }
  .hide-md { display: none; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .pair-row { grid-template-columns: 1fr; }
}
