/* OpenTerminal standard theme. Zero deps. Terminal-grade dark UI. */
:root {
  --bg: #04070a;
  --bg2: #070c10;
  --panel: #0a1116;
  --panel2: #0d151c;
  --panel3: #111b24;
  --line: #1d2b36;
  --line-hi: #2c4252;
  --txt: #d7e3ea;
  --dim: #7d93a1;
  --faint: #4a5f6d;
  --up: #2bffa3;
  --up-dim: #0e5f43;
  --down: #ff5470;
  --down-dim: #5f1a28;
  --accent: #41c7ff;
  --warn: #ffb224;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
  --r: 5px;
}
* { box-sizing: border-box; }
html { scrollbar-color: var(--line-hi) var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 14px/1.5 var(--sans);
  background-image:
    radial-gradient(1200px 300px at 50% -80px, rgba(65, 199, 255, 0.07), transparent 70%),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(125, 147, 161, 0.05) 31px 32px);
  min-height: 100vh;
}
::selection { background: rgba(43, 255, 163, 0.28); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-hi); border-radius: 5px; }

/* ---- disclaimer ---- */
#disclaimer {
  background: linear-gradient(90deg, #2a2103, #3b2f04, #2a2103);
  color: #ffe9a8; padding: 5px 12px; font-size: 11.5px; text-align: center;
  letter-spacing: 0.4px; border-bottom: 1px solid #6b5716;
  font-family: var(--mono);
}

/* ---- topbar ---- */
#topbar {
  display: flex; align-items: center; gap: 14px; padding: 8px 14px;
  background: rgba(10, 17, 22, 0.92); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
  backdrop-filter: blur(6px);
}
#logo {
  font-family: var(--mono); font-weight: 700; font-size: 15px;
  color: var(--up); letter-spacing: 1.5px; white-space: nowrap;
  text-shadow: 0 0 12px rgba(43, 255, 163, 0.45);
}
#logo::before { content: "▮ "; color: var(--accent); }
#nav { display: flex; gap: 2px; flex-wrap: wrap; }
#nav a {
  color: var(--dim); text-decoration: none; padding: 6px 10px;
  font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.5px;
  border-bottom: 2px solid transparent; text-transform: uppercase;
}
#nav a:hover { color: var(--txt); background: var(--panel2); }
#nav a.active {
  color: var(--up); border-bottom-color: var(--up);
  text-shadow: 0 0 10px rgba(43, 255, 163, 0.4);
}
#userbox { margin-left: auto; display: flex; gap: 8px; align-items: center; }
#tier-badge {
  font-family: var(--mono); font-size: 11.5px; color: var(--accent);
  border: 1px solid var(--line-hi); border-radius: 3px; padding: 3px 8px;
  letter-spacing: 1px; text-transform: uppercase; background: var(--bg2);
}

/* ---- ticker tape ---- */
#tape {
  overflow: hidden; white-space: nowrap; background: #000;
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -1px 0 rgba(43, 255, 163, 0.12);
}
#tape-track {
  display: inline-block; padding: 4px 0; font-size: 12px;
  font-family: var(--mono); color: var(--up);
  animation: tape-scroll 45s linear infinite;
}
#tape-track .tape-item { margin: 0 12px; }
#tape-track .tape-item b { color: var(--accent); }
#tape-track .tape-sep { color: var(--faint); }
@keyframes tape-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---- layout / headings ---- */
#view { padding: 16px 14px 32px; max-width: 1400px; margin: 0 auto; }
#view > h2:first-child {
  font-family: var(--mono); font-size: 17px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--txt); margin: 4px 0 14px;
  border-bottom: 1px solid var(--line); padding-bottom: 8px;
}
#view > h2:first-child::before { content: "> "; color: var(--up); }
h3 {
  font-family: var(--mono); font-size: 12px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--dim); margin: 14px 0 8px;
}
h3::before { content: "// "; color: var(--faint); }
.card h3 { margin: 0 0 8px; }
.card h3::before { content: ""; }

/* ---- panels / cards / kpis ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px;
  position: relative;
}
.card::before {
  content: ""; position: absolute; top: -1px; left: 10px; right: 10px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-hi), transparent);
}
.card.stub { opacity: 0.7; border-style: dashed; }
.card h3 { margin: 0 0 8px; }
.kpi-v {
  font-family: var(--mono); font-size: 26px; font-weight: 700; color: var(--txt);
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.kpi-v.up { color: var(--up); text-shadow: 0 0 14px rgba(43, 255, 163, 0.35); }
.kpi-v.down { color: var(--down); text-shadow: 0 0 14px rgba(255, 84, 112, 0.35); }
.kpi-l { font-family: var(--mono); font-size: 11px; color: var(--dim); letter-spacing: 1px; text-transform: uppercase; }

/* ---- badges ---- */
.badge {
  display: inline-block; font-family: var(--mono); font-size: 11px;
  padding: 2px 8px; border-radius: 3px; border: 1px solid var(--line-hi);
  color: var(--dim); letter-spacing: 0.5px; background: var(--bg2);
  font-variant-numeric: tabular-nums;
}
.badge.wired { color: var(--up); border-color: var(--up-dim); background: rgba(43, 255, 163, 0.06); }
.badge.stub { color: var(--warn); border-color: #5c4413; background: rgba(255, 178, 36, 0.06); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; margin: 8px 0; font-variant-numeric: tabular-nums; }
thead, tr:first-child { border-top: 1px solid var(--line); }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
th {
  color: var(--dim); font-weight: 600; font-family: var(--mono); font-size: 11px;
  letter-spacing: 1px; text-transform: uppercase; background: var(--bg2);
}
tbody tr:hover, tr:hover td { background: rgba(65, 199, 255, 0.04); }
td { font-family: var(--mono); font-size: 12.5px; }
td a, #out a, #dash a { color: var(--accent); }

/* ---- forms / terminal keys ---- */
form label { display: block; margin: 8px 0; font-size: 12.5px; color: var(--dim); }
input, select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 3px;
  border: 1px solid var(--line-hi); background: #020507; color: var(--up);
  font-family: var(--mono); font-size: 13px; caret-color: var(--up);
}
input::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--up-dim); outline: none; box-shadow: 0 0 0 1px var(--up-dim); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row label { flex: 1 1 160px; margin: 4px 0; }
button {
  padding: 7px 14px; border-radius: 3px; border: 1px solid var(--line-hi);
  background: var(--panel3); color: var(--txt); cursor: pointer;
  font-family: var(--mono); font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
}
button:hover { border-color: var(--accent); color: #fff; box-shadow: 0 0 10px rgba(65, 199, 255, 0.25); }
button:active { transform: translateY(1px); }
button.buy { background: rgba(43, 255, 163, 0.1); border-color: var(--up-dim); color: var(--up); }
button.buy:hover { box-shadow: 0 0 12px rgba(43, 255, 163, 0.35); }
button.sell { background: rgba(255, 84, 112, 0.1); border-color: var(--down-dim); color: var(--down); }
button.sell:hover { box-shadow: 0 0 12px rgba(255, 84, 112, 0.35); }
button.danger { border-color: var(--down-dim); color: #ffb4b0; }
pre {
  background: #020507; border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; overflow-x: auto; font-family: var(--mono); font-size: 12px;
  color: #b9e8cf;
}
a { color: var(--accent); }

/* ---- login ---- */
#login-section {
  max-width: 420px; margin: 48px auto; padding: 28px 32px;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line-hi); border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 30px rgba(43, 255, 163, 0.05);
}
#login-section h2 {
  font-family: var(--mono); font-size: 16px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--up); margin: 0 0 6px;
}
#login-section h2::before { content: "> "; }
#login-section .login-subtitle {
  font-family: var(--mono); font-size: 11.5px; color: var(--dim);
  margin: 0 0 20px; letter-spacing: 0.5px;
}
#login-section label {
  display: block; margin: 12px 0 4px; font-size: 12px; color: var(--dim);
  font-family: var(--mono); letter-spacing: 0.5px; text-transform: uppercase;
}
#login-section input {
  padding: 10px 12px; border-radius: 4px; font-size: 13.5px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#login-section input:focus {
  border-color: var(--up); box-shadow: 0 0 0 2px rgba(43, 255, 163, 0.15);
}
#login-section .row { margin-top: 16px; gap: 10px; }
#login-section button {
  flex: 1; padding: 10px 16px; border-radius: 4px;
  font-size: 12.5px; letter-spacing: 1.5px; transition: all 0.2s ease;
}
#login-section button[type="submit"] {
  background: var(--up-dim); border-color: var(--up); color: var(--up);
}
#login-section button[type="submit"]:hover {
  background: rgba(43, 255, 163, 0.2); box-shadow: 0 0 16px rgba(43, 255, 163, 0.3);
}
#login-section button[type="submit"]:disabled {
  opacity: 0.5; cursor: not-allowed; transform: none;
}
#login-section button#signup-btn {
  background: var(--panel3); border-color: var(--line-hi); color: var(--dim);
}
#login-section button#signup-btn:hover {
  border-color: var(--accent); color: var(--accent);
}
#login-section .login-error {
  margin-top: 12px; padding: 8px 12px; border-radius: 4px;
  background: rgba(255, 84, 112, 0.08); border: 1px solid var(--down-dim);
  font-family: var(--mono); font-size: 12px; color: var(--down);
  display: none;
}
#login-section .login-error.visible { display: block; }
#login-section .login-hint {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--faint);
  text-align: center; letter-spacing: 0.5px;
}
#login-section .login-hint a { color: var(--accent); text-decoration: none; }
#login-section .login-hint a:hover { text-decoration: underline; }

/* ---- loading states ---- */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--line-hi); border-top-color: var(--up);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-loading { position: relative; color: transparent !important; }
.btn-loading::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid var(--line-hi); border-top-color: var(--up);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}

/* ---- toast notifications ---- */
.toast-container {
  position: fixed; top: 60px; right: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: 6px; font-family: var(--mono);
  font-size: 12.5px; letter-spacing: 0.5px; max-width: 360px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.3s ease-out;
  pointer-events: auto; cursor: pointer;
}
.toast.success { background: rgba(43, 255, 163, 0.12); border: 1px solid var(--up-dim); color: var(--up); }
.toast.error { background: rgba(255, 84, 112, 0.12); border: 1px solid var(--down-dim); color: var(--down); }
.toast.info { background: rgba(65, 199, 255, 0.12); border: 1px solid var(--accent); color: var(--accent); }
@keyframes toast-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
.toast.removing { animation: toast-out 0.3s ease-in forwards; }

/* ---- empty states ---- */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--dim);
  font-family: var(--mono); font-size: 13px;
}
.empty-state .empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }
.empty-state .empty-title { font-size: 14px; color: var(--txt); margin-bottom: 4px; }
.empty-state .empty-desc { font-size: 12px; color: var(--faint); }

/* ---- skeleton loading ---- */
.skeleton {
  background: linear-gradient(90deg, var(--panel) 25%, var(--panel2) 50%, var(--panel) 75%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- better mobile ---- */
@media (max-width: 600px) {
  #topbar { padding: 6px 10px; flex-direction: column; align-items: stretch; gap: 6px; }
  #nav { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  #nav a { padding: 4px 6px; font-size: 11px; white-space: nowrap; }
  #userbox { margin-left: 0; justify-content: space-between; flex-wrap: wrap; }
  #login-section { margin: 24px 12px; padding: 20px 18px; max-width: calc(100% - 24px); }
  .cards { grid-template-columns: 1fr; }
  table { font-size: 11px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  th, td { padding: 5px 6px; white-space: nowrap; }
  #view { padding: 10px 8px 20px; max-width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  canvas.chart { height: 220px; }
  #disclaimer { font-size: 10px; padding: 4px 8px; }
}
@media (max-width: 760px) {
  #view { padding: 12px 10px 24px; max-width: 100%; }
  #topbar { gap: 8px; }
  .kpi-v { font-size: 22px; }
  #statusbar { gap: 8px; font-size: 10.5px; padding: 5px 10px; }
  #statusbar .sb-right { margin-left: 0; width: 100%; }
}

/* ---- chart ---- */
canvas.chart {
  width: 100%; height: 340px; background: #020507; border-radius: var(--r);
  border: 1px solid var(--line-hi);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6), 0 0 24px rgba(65, 199, 255, 0.05);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
#ticker {
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
  overflow: hidden;           /* clip the marquee track */
  white-space: nowrap;
  background: #000;
  border-bottom: 1px solid var(--line);
  padding: 4px 0;
  font-family: var(--mono);
  font-size: 12px;
}
#ticker .badge { margin: 0 4px 4px 0; }
.error { color: var(--down); font-family: var(--mono); font-size: 12.5px; }
.stale { color: var(--warn); }
.pos { color: var(--up); } .neg { color: var(--down); }
.dim { color: var(--dim); font-weight: 400; }
.spb { align-items: baseline; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--dim); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px;
}
.alnk { color: var(--accent) !important; text-decoration: none; font-size: 12px; opacity: 0.8; }
.alnk:hover { opacity: 1; text-decoration: underline; }
.ch-long { color: #1fd19a; border-color: rgba(31, 209, 154, 0.35); background: rgba(31, 209, 154, 0.07); }
.ch-short { color: #ff5470; border-color: rgba(255, 84, 112, 0.35); background: rgba(255, 84, 112, 0.07); }
.ch-flat { color: var(--dim); border-color: var(--border); }
.why { color: var(--text); opacity: 0.92; }
.badge-anom {
  font-family: var(--mono); font-size: 11px; color: #ffb424; border: 1px solid #5c4413;
  border-radius: 999px; padding: 0 6px; background: rgba(255, 178, 36, 0.08); cursor: help;
}
.an-high { color: #ff5470; text-transform: uppercase; font-family: var(--mono); font-size: 10px; letter-spacing: 1px; }
.an-med { color: #ffb424; text-transform: uppercase; font-family: var(--mono); font-size: 10px; letter-spacing: 1px; }
.an-low { color: var(--dim); text-transform: uppercase; font-family: var(--mono); font-size: 10px; letter-spacing: 1px; }
/* ---- status bar ---- */
#statusbar {
  display: flex; gap: 16px; align-items: center; padding: 5px 14px;
  background: var(--bg2); border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; color: var(--dim);
  letter-spacing: 0.5px; flex-wrap: wrap;
}
#statusbar .sb-dot { color: var(--up); }
#statusbar .sb-dot.dead { color: var(--down); }
#statusbar .sb-right { margin-left: auto; }
#statusbar b { color: var(--txt); font-weight: 600; }

/* ---- OpenTerminal drawer ---- */
#terminal-toggle.active { border-color: var(--up); color: var(--up); box-shadow: 0 0 10px rgba(43, 255, 163, 0.3); }
#terminal-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(2, 6, 4, 0.98); border-top: 2px solid var(--up);
  box-shadow: 0 -8px 40px rgba(43, 255, 163, 0.12);
  transform: translateY(100%); transition: transform 0.18s ease-out;
  font-family: var(--mono);
}
#terminal-panel.open { transform: translateY(0); }
#term-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 12px; background: linear-gradient(90deg, #0d1a12, #0a1410);
  color: var(--up); font-size: 12px; letter-spacing: 3px;
  border-bottom: 1px solid var(--up-dim);
}
#term-close { padding: 2px 10px; }
#term-out {
  height: min(320px, 42vh); overflow-y: auto; padding: 8px 12px;
  font-size: 13px; white-space: pre-wrap; word-break: break-word;
  background-image: repeating-linear-gradient(0deg, transparent 0 23px, rgba(43, 255, 163, 0.025) 23px 24px);
}
.term-line { margin: 1px 0; color: #c9f2d8; }
.term-echo { color: var(--accent); }
.term-err { color: var(--down); }
.term-dim { color: var(--dim); }
/* No .term-ok: terminal.js passes "" on success (terminal.js:52), so a
   success-tinted class was never emitted. .term-err / .term-dim are. */
#term-form { display: flex; gap: 8px; align-items: center; padding: 6px 12px 10px; }
.term-prompt { color: var(--up); font-weight: 700; text-shadow: 0 0 8px rgba(43, 255, 163, 0.6); }
#term-input { font-family: inherit; }

@media (max-width: 760px) {
  #view { padding: 12px 10px 24px; }
  #topbar { gap: 8px; }
  .kpi-v { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  #tape-track { animation: none; }
  #terminal-panel { transition: none; }
}

/* ---- command palette ---- */
#palette {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(2, 5, 7, 0.7); padding: 12vh 16px 16px;
}
#palette.open { display: block; }
#pal-box {
  max-width: 560px; margin: 0 auto; background: var(--panel2);
  border: 1px solid var(--line-hi); border-radius: var(--r);
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7), 0 0 24px rgba(65, 199, 255, 0.08);
  overflow: hidden; font-family: var(--mono);
}
#pal-input { border: none; border-bottom: 1px solid var(--line); border-radius: 0; }
#pal-input:focus { box-shadow: none; border-bottom-color: var(--up-dim); }
#pal-list { max-height: 320px; overflow-y: auto; }
.pal-item { padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--txt); }
.pal-item.sel, .pal-item:hover { background: rgba(65, 199, 255, 0.1); }
.pal-kind {
  display: inline-block; min-width: 44px; font-size: 10px; color: var(--up);
  border: 1px solid var(--up-dim); border-radius: 3px; padding: 0 5px;
  margin-right: 8px; text-transform: uppercase; letter-spacing: 1px;
}
.pal-empty { padding: 12px; color: var(--dim); font-size: 12.5px; }
#pal-foot { padding: 6px 12px; font-size: 11px; color: var(--faint); border-top: 1px solid var(--line); }

/* ---- quote panel ---- */
.quote-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; margin: 8px 0;
}
.quote-cell { background: var(--panel); padding: 8px 10px; }
.quote-cell .k { font-family: var(--mono); font-size: 10px; color: var(--faint);
  letter-spacing: 1px; text-transform: uppercase; }
.quote-cell .v { font-family: var(--mono); font-size: 15px; color: var(--txt);
  font-variant-numeric: tabular-nums; }
.quote-cell .v.up { color: var(--up); } .quote-cell .v.down { color: var(--down); }

/* ---- flash on tick ---- */
@keyframes tick-up { 0% { background: rgba(43, 255, 163, 0.35); } 100% { background: transparent; } }
@keyframes tick-down { 0% { background: rgba(255, 84, 112, 0.35); } 100% { background: transparent; } }
.flash-up { animation: tick-up 0.8s ease-out; border-radius: 3px; }
.flash-down { animation: tick-down 0.8s ease-out; border-radius: 3px; }

/* ---- launch-ready polish ---- */
html { scroll-behavior: smooth; }
::selection { background: rgba(65, 199, 255, 0.25); color: var(--txt); }

/* Focus states for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Smooth transitions on interactive elements */
button, a, input, select {
  transition: background 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, box-shadow 0.15s ease;
}
button:hover { border-color: var(--accent); }
a:hover { color: var(--accent); }

/* Skip-to-content link for screen readers */
.skip-link {
  position: absolute; top: -40px; left: 8px; z-index: 100;
  background: var(--panel2); color: var(--accent); padding: 8px 14px;
  border-radius: var(--r); font-family: var(--mono); font-size: 12px;
  text-decoration: none; transition: top 0.2s ease;
}
.skip-link:focus { top: 8px; }

/* aria-live regions */
[aria-live] { min-height: 1em; }

/* Print styles */
@media print {
  #tape, #topbar, #statusbar, #terminal-panel, #palette,
  .no-print, button, input, select { display: none !important; }
  body { background: #fff; color: #000; }
  #view { max-width: 100%; padding: 0; }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  :root {
    --line: #444;
    --line-hi: #666;
    --faint: #999;
    --dim: #bbb;
  }
  .card, .quote-cell { border-width: 2px; }
}

/* ---- heatmap / news ---- */
canvas.heat { width: 100%; height: 420px; background: #020507;
  border: 1px solid var(--line-hi); border-radius: var(--r); cursor: pointer; }
canvas.spark { width: 90px; height: 26px; }
.news-item { border-bottom: 1px solid var(--line); padding: 8px 2px; }
.news-item a { color: var(--txt); text-decoration: none; font-size: 13.5px; }
.news-item a:hover { color: var(--accent); }
.news-meta { font-family: var(--mono); font-size: 11px; color: var(--faint); }
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--accent); }
canvas.rsi { width: 100%; height: 110px; background: #020507;
  border: 1px solid var(--line); border-radius: var(--r); }
kbd {
  font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-hi);
  border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; background: var(--bg2);
}

/* Anomaly radar */
.tag { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 8px; font-size: 10px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--dim);
  border: 1px solid var(--border); border-radius: 999px; }
.clean-row { opacity: 0.45; }
.clean-row a { color: var(--dim); }

/* Wallet (read-only MetaMask) */
.wallet-status { margin: .5em 0; font-size: 12px; color: var(--dim); min-height: 1.2em; }
/* Both suffixes are live: setStatus() in wallet.js builds the class as
   "wallet-status-" + kind and passes kind="ok" on connect/chain-add/
   chain-switch and kind="warn" on six error paths. .wallet-status-warn is
   also emitted directly from app.js. A grep for the literal string finds
   neither -- do not "clean up" these on a reference count. */
.wallet-status-ok { color: var(--pos); }
.wallet-status-warn { color: var(--neg); }

/* Scalp Lab ------------------------------------------------------------ */
/* The lab bar holds one symbol for every card, so the operator confirms
   the market once instead of retyping it per strategy. */
.lab-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.lab-bar label { display: flex; align-items: center; gap: 6px; margin: 0; }
.lab-bar input { width: 130px; font-family: var(--mono); text-transform: uppercase; }
.lab-quote {
  font-family: var(--mono); font-size: 12px; color: var(--dim);
  min-height: 1.2em;
}
.lab-card { display: flex; flex-direction: column; gap: 6px; }
.lab-card.locked { opacity: 0.65; }
.lab-card .row { margin-top: 2px; }
.lab-card p.muted { margin: 0; font-size: 12px; }
.lab-params {
  display: flex; flex-direction: column; gap: 3px; margin: 0;
  font-size: 11px; color: var(--dim);
}
.lab-params input {
  font-family: var(--mono); font-size: 11px; width: 100%;
}
.lab-hint { margin: 0; font-size: 11px; min-height: 1.2em; }

/* A signal is a decision, so it renders as one: a labelled verdict with
   the numbers that produced it underneath. */
.sig {
  display: flex; gap: 10px; align-items: stretch;
  margin-top: 8px; border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden;
}
.sig-label {
  display: flex; align-items: center; justify-content: center;
  min-width: 62px; padding: 6px 8px;
  font-family: var(--mono); font-weight: 700; font-size: 12px;
  letter-spacing: 1px; color: var(--bg);
}
.sig-buy  .sig-label { background: var(--up); }
.sig-sell .sig-label { background: var(--down); }
.sig-flat .sig-label { background: var(--line-hi); color: var(--txt); }
.sig-body { padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; }
.kv span { color: var(--dim); }
.kv b { font-family: var(--mono); font-weight: 500; text-align: right; }
.metrics {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px; margin-top: 8px;
}
.metrics .kv {
  flex-direction: column; align-items: flex-start; gap: 0;
  border: 1px solid var(--line); border-radius: var(--r); padding: 4px 6px;
}
.metrics .kv b { text-align: left; }

/* Significance verdict -------------------------------------------------- */
/* A backtest's verdict is the answer to "should I trade this?", so it
   renders at the same weight as a signal. Only one tone is positive:
   an unrecognised verdict falls back to "none" and never reads as
   approval. */
.sig-verdict .sig-label {
  min-width: 148px; padding: 8px 10px; font-size: 11px;
  letter-spacing: 0.5px; line-height: 1.35; text-align: center;
}
.sig-verdict.tone-edge  .sig-label { background: var(--up); color: var(--bg); }
.sig-verdict.tone-maybe .sig-label { background: var(--warn); color: var(--bg); }
.sig-verdict.tone-none  .sig-label { background: var(--line-hi); color: var(--txt); }
/* COT consensus bands reuse the verdict panel. `tone-flat` is the
   neutral band and renders like `tone-none` on purpose: neutral means no
   extreme was measured, which is not the same as a confirmed positive. */
.sig-verdict.tone-long .sig-label,
.sig-verdict.tone-long-soft .sig-label { background: var(--up); color: var(--bg); }
.sig-verdict.tone-short .sig-label,
.sig-verdict.tone-short-soft .sig-label { background: var(--down); color: var(--bg); }
.sig-verdict.tone-flat .sig-label { background: var(--line-hi); color: var(--txt); }
.verdict-why {
  margin: 6px 0 0; padding-left: 18px;
  font-size: 11px; color: var(--dim); line-height: 1.5;
}

/* Coverage ---------------------------------------------------------------- */
/* The backtest window is a permission, not a promise. A symbol with 30
   days of stored history answers a 180-day request with 30 days, and the
   operator has to be able to tell that apart from a genuine 180-day run
   without reading JSON. */
.coverage { margin-top: 8px; }
.coverage.cov-short { border-left: 2px solid var(--warn); padding-left: 8px; }
.coverage.cov-capped { border-left: 2px solid var(--accent); padding-left: 8px; }
.coverage .kv b { font-size: 11px; }

/* COT -------------------------------------------------------------------- */
/* Positioning is a slow, lagged variable. The stale banner and the muted
   "neutral" tone exist so a weekly snapshot published nine days ago is
   never mistaken for a live reading. */
.cot-stale {
  margin: 6px 0; padding: 5px 9px; font-size: 11px; line-height: 1.5;
  border: 1px solid #5c4413; border-left-width: 3px;
  background: rgba(255, 178, 36, 0.05); color: var(--dim);
}
.cot-stale b { color: var(--warn); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(65, 199, 255, 0.09); }

.badge.tone-long  { color: var(--up); border-color: var(--up-dim); }
.badge.tone-short { color: var(--down); border-color: var(--down-dim); }
/* The soft variants are for the 75-90 bands: real, but not an extreme.
   --up-dim/--down-dim are near-black on a dark ground and would be
   unreadable as text, so they stay as borders only. */
.badge.tone-long-soft  { color: var(--up); border-color: var(--up-dim); opacity: 0.72; }
.badge.tone-short-soft { color: var(--down); border-color: var(--down-dim); opacity: 0.72; }
.badge.tone-flat { color: var(--dim); }

/* The gauge is the percentile drawn as a position in range, so "where in
   the distribution" reads without interpreting the number. */
.cot-gauge { display: flex; align-items: center; gap: 6px; min-width: 108px; }
.cot-bar {
  position: relative; flex: 1; height: 5px; border-radius: 2px;
  background: var(--line); overflow: hidden;
}
.cot-fill { height: 100%; background: var(--accent); }
.cot-pct {
  font-family: var(--mono); font-size: 10px; color: var(--dim);
  min-width: 30px; text-align: right;
}
.cot-none .cot-pct, .cot-none span { font-size: 10px; color: var(--faint); }

/* The overlay says what it is. "context only" is load-bearing: this
   panel does not feed the score, and claiming otherwise would give the
   number a weight the engine has not tested. */
.cot-tag {
  margin-left: 8px; padding: 1px 6px; border-radius: 3px;
  font-family: var(--mono); font-size: 9px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--faint);
  border: 1px solid var(--line-hi); vertical-align: middle;
}
.card .cot-stale { margin: 0 0 8px; }
.card h4 .cot-tag { text-transform: uppercase; }

/* Scalp Live ticket -------------------------------------------------- */
/* A live order card must be impossible to miss and impossible to fire
   by accident, so it is bordered in the sell colour and states plainly
   that it is irreversible. */
.danger-card { border-color: var(--down-dim); }
.danger-card h3 { color: var(--down); }
.danger-card .row { margin-top: 10px; }

#t-pos { font-family: var(--mono); }
#t-positions table, #t-fills table { font-size: 12px; }
#t-positions th, #t-fills th { font-size: 10px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--dim); text-align: left; }
#t-positions td, #t-fills td { padding: 3px 6px 3px 0; }
#t-positions button { padding: 2px 8px; font-size: 11px; }
#t-hold { margin-bottom: 10px; }
#t-est { font-family: var(--mono); font-size: 11px; }
.badge.locked { border-color: var(--line-hi); color: var(--faint); }

/* Position action links ------------------------------------------------ */
/* Each position row offers three exits: the chart, and the ticket armed
   to buy or sell that exact instrument at that exact size. On a screen
   carrying thirty positions under a scrolling tape, retyping a symbol
   into a ticket is the slowest path from "act on this row" to acting. */
.pos-actions { display: inline-flex; gap: 4px; white-space: nowrap; }
.pa {
  display: inline-block; padding: 1px 7px; font-size: 11px;
  font-family: var(--mono); text-decoration: none;
  border: 1px solid var(--line-hi); border-radius: var(--r);
  color: var(--dim);
}
.pa:hover { color: var(--txt); border-color: var(--accent); }
.pa.buy  { color: var(--up); border-color: var(--up-dim); }
.pa.buy:hover  { background: rgba(43, 255, 163, 0.12); }
.pa.sell { color: var(--down); border-color: var(--down-dim); }
.pa.sell:hover { background: rgba(255, 84, 112, 0.12); }
.pa-mode {
  font-size: 10px; letter-spacing: 1px; color: var(--faint);
  text-transform: uppercase; align-self: center; padding-left: 2px;
}
.pos-table td { white-space: nowrap; }

/* A ticket button that a deep link armed. It is a highlight, not a
   pressed state -- nothing is sent until the operator clicks it. */
button.armed {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  animation: armed-pulse 1.1s ease-in-out 2;
}
@keyframes armed-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(65, 199, 255, 0); }
  50%      { box-shadow: 0 0 14px rgba(65, 199, 255, 0.55); }
}
@media (prefers-reduced-motion: reduce) {
  button.armed { animation: none; }
}

/* All-assets browser + Analysis sweep --------------------------------- */
.as-ctl { align-items: center; gap: 8px; margin: 6px 0; }
.as-ctl input { width: 190px; }
.as-ctl select { min-width: 130px; }
.as-table th, .an-all th { white-space: nowrap; }
.as-table td, .an-all td { white-space: nowrap; }
.as-th { cursor: pointer; user-select: none; }
.as-th.sorted, .as-th.sorted::after { color: var(--accent); }
.as-th.sorted.asc::after  { content: " ▲"; }
.as-th.sorted.desc::after { content: " ▼"; }
.as-th:hover { color: var(--accent); }
.an-all tbody tr:hover, .as-table tbody tr:hover { background: rgba(65, 199, 255, 0.06); }

/* Page purpose line ---------------------------------------------------- */
/* Scalp Lab and Scalp Live both lead with a symbol input and a price, so
   without a stated purpose they read as the same page. One line each
   makes the difference explicit: one researches, one executes. */
.page-purpose {
  margin: 2px 0 10px; font-size: 12px; color: var(--dim);
  max-width: 92ch;
}
.page-purpose b { color: var(--txt); }
#an-chart { margin-bottom: 14px; }

/* ---- funding console ------------------------------------------------------
   Distinct from the trading tables on purpose: this page moves real value, so
   state has to be readable at a glance (pending vs confirmed) and a failed
   withdrawal must not read like an empty cell. */
.funding-note {
  border-left: 3px solid #f0a020;
  background: rgba(240, 160, 32, 0.08);
  padding: 10px 12px;
  margin: 12px 0;
  max-width: 70ch;
}
.funding-node {
  border: 1px solid #243040;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 12px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 18px;
}
.funding-node-down { border-color: #a03030; background: rgba(200, 60, 60, 0.08); }
.funding-node code { font-size: 0.85em; word-break: break-all; }
.funding-panel {
  border: 1px solid #1c2530;
  border-radius: 6px;
  padding: 12px 14px;
  margin: 16px 0;
}
.funding-panel h3 { margin-top: 0; }
.funding-bal { display: flex; gap: 22px; flex-wrap: wrap; margin: 8px 0 4px; }
.funding-bal span { font-variant-numeric: tabular-nums; }
.funding-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.funding-table th, .funding-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #16202b;
  vertical-align: top;
}
.funding-table code { font-size: 0.85em; word-break: break-all; }
.funding-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.85em;
  border: 1px solid #2a3a4a;
}
.badge-pending   { border-color: #f0a020; color: #f0a020; }
.badge-approved  { border-color: #4aa3f0; color: #4aa3f0; }
.badge-submitted { border-color: #b070f0; color: #b070f0; }
.badge-confirmed { border-color: #35c07a; color: #35c07a; }
.badge-failed, .badge-rejected { border-color: #d05050; color: #d05050; }
.funding-fail { color: #d05050; font-size: 0.85em; margin-top: 4px; }
.funding-ok  { color: #35c07a; }
.funding-bad { color: #d05050; }
.funding-msg { margin: 12px 0; min-height: 1.2em; }
