/* SerialScan — dark trading-terminal theme.
   No build step, no external fonts. System font stack for speed. */

:root {
  --bg: #0a0d12;
  --bg-1: #0f141b;
  --bg-2: #141b24;
  --bg-3: #1b242f;
  --line: #232e3a;
  --line-2: #2c3947;
  --text: #e8edf4;
  --text-2: #9aa7b8;
  --text-3: #6b7889;
  --accent: #17c964;
  --accent-dim: #0f7a3d;
  --ok: #17c964;
  --warn: #ffb020;
  --bad: #ff3b5c;
  --info: #38bdf8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .4);
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(23, 201, 100, .06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); font-size: .9em; background: var(--bg-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--text-3); }

/* ---- Top bar ---------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 13, 18, .8);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-link { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: -.3px; }
.brand-mark { font-size: 20px; }
.brand-accent { color: var(--accent); }
.mode-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .6px;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-2);
}
.mode-badge.sample { color: var(--text-3); }
.mode-badge.live { color: var(--accent); border-color: var(--accent-dim); background: rgba(23, 201, 100, .08); }

.nav { display: flex; gap: 4px; }
.nav a {
  padding: 7px 14px; border-radius: var(--radius-sm); color: var(--text-2);
  font-weight: 500; transition: background .15s, color .15s; white-space: nowrap;
}
.nav a:hover { background: var(--bg-2); color: var(--text); }
.nav a.active { background: var(--bg-3); color: var(--text); }

/* ---- Layout ----------------------------------------------------------- */
.view { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px 22px 60px; }
.footer {
  border-top: 1px solid var(--line); padding: 16px 22px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--text-2); font-size: 12px;
}
.footer a { color: var(--accent); }

/* ---- Buttons & inputs ------------------------------------------------- */
.btn {
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text);
  cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04140a; }
.btn-primary:hover { background: #14e070; border-color: #14e070; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.input, .select, .search {
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); padding: 8px 12px; outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus, .search:focus { border-color: var(--accent-dim); }
.input { min-width: 260px; }
.input-sm { min-width: 90px; width: 90px; }
.select { cursor: pointer; }
.search { flex: 1; min-width: 200px; }

/* ---- Stats strip ------------------------------------------------------ */
.stats {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px;
}
.stat {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.stat-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.stat-warn .stat-value { color: var(--warn); }
.stat-bad .stat-value { color: var(--bad); }
.stat-ok .stat-value { color: var(--accent); }

/* ---- Toolbar & tabs --------------------------------------------------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.chain-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.chain-tab {
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s;
}
.chain-tab:hover { color: var(--text); border-color: var(--line-2); }
.chain-tab.active { background: var(--bg-3); color: var(--text); border-color: var(--accent-dim); }
.tab-count { font-size: 11px; color: var(--text-3); background: var(--bg); padding: 0 6px; border-radius: 999px; }
.chain-tab.active .tab-count { color: var(--accent); }

/* ---- Table ------------------------------------------------------------ */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-1); overflow-x: auto; }
.token-table { width: 100%; border-collapse: collapse; min-width: 1180px; }
.token-table thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3); font-weight: 600; padding: 11px 14px;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
  position: sticky; top: 0;
}
.token-row { cursor: pointer; transition: background .12s; border-bottom: 1px solid var(--line); }
.token-row:last-child { border-bottom: none; }
.token-row:hover { background: var(--bg-2); }
.token-row:focus-visible { outline: 2px solid var(--accent-dim); outline-offset: -2px; }
.token-table td { padding: 11px 14px; vertical-align: middle; }
.rank { color: var(--text-3); font-variant-numeric: tabular-nums; width: 40px; }
.num { font-variant-numeric: tabular-nums; text-align: center; font-weight: 600; }

.token-cell { min-width: 200px; }
.token-id { display: flex; align-items: center; gap: 11px; }
.token-name { font-weight: 600; }
.token-symbol { font-size: 12px; color: var(--text-3); }

.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.avatar-mono { color: #fff; font-size: 12px; font-weight: 700; letter-spacing: -.3px; }

.chain-chip {
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  padding: 3px 8px; border-radius: 6px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}

.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill-ok { color: var(--ok); background: rgba(23, 201, 100, .12); }
.pill-warn { color: var(--warn); background: rgba(255, 176, 32, .12); }
.pill-bad { color: var(--bad); background: rgba(255, 59, 92, .12); }

.risk-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.risk-bar { flex: 1; height: 6px; background: var(--bg-3); border-radius: 999px; overflow: hidden; min-width: 60px; }
.risk-bar span { display: block; height: 100%; border-radius: 999px; }
.risk-num { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; color: var(--text-2); width: 30px; text-align: right; }

.src { font-size: 11px; font-weight: 600; }
.src-open { color: var(--accent); }
.src-closed { color: var(--text-3); }

/* Market columns */
.mkt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mkt.num { text-align: right; color: var(--text-2); font-weight: 500; }
.mkt.price { font-weight: 600; }
.price-compact sub { font-size: .72em; color: var(--text-3); vertical-align: baseline; position: relative; bottom: -.15em; padding: 0 1px; }
.muted-cell { color: var(--text-3); }

/* Market panel (detail) */
.market-panel { margin: 18px 0; }
.market-panel h3 { font-size: 15px; margin: 0 0 12px; }
.market-body { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--text-3); }
.market-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.market-cell-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; }
.market-cell-value { font-size: 16px; font-weight: 600; color: var(--text); margin-top: 3px; font-variant-numeric: tabular-nums; }
.market-empty { color: var(--warn); font-weight: 500; }
.market-src { margin-top: 12px; font-size: 11px; }
.cadence-hint { margin-top: 14px; padding: 10px 14px; background: rgba(56, 189, 248, .07); border: 1px solid rgba(56, 189, 248, .25); border-radius: var(--radius-sm); color: var(--text-2); font-size: 13px; }
.cadence-hint strong { color: var(--info); }

.audited { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.addr { font-family: var(--mono); font-size: 11px; color: var(--text-2); background: var(--bg-2); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; cursor: pointer; }
.addr:hover { color: var(--text); border-color: var(--line-2); }
.freshness { font-size: 10px; color: var(--text-3); }
.freshness.stale { color: var(--warn); }
.chevron { color: var(--text-3); font-size: 18px; }

.empty { padding: 60px 20px; text-align: center; color: var(--text-3); }
.empty h2 { color: var(--text-2); }

/* ---- Detail view ------------------------------------------------------ */
.back { background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 13px; padding: 4px 0; margin-bottom: 12px; font-family: inherit; }
.back:hover { color: var(--text); }
.loading { padding: 60px; text-align: center; color: var(--text-3); }

.detail-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.detail-title { flex: 1; min-width: 200px; }
.detail-title h1 { margin: 0; font-size: 26px; display: flex; align-items: baseline; gap: 10px; }
.detail-symbol { font-size: 14px; color: var(--text-3); font-weight: 500; }
.detail-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

.verdict-badge { text-align: center; padding: 12px 20px; border-radius: var(--radius); border: 1px solid var(--line-2); min-width: 130px; }
.verdict-ok { background: rgba(23, 201, 100, .1); border-color: var(--accent-dim); }
.verdict-warn { background: rgba(255, 176, 32, .1); border-color: rgba(255, 176, 32, .35); }
.verdict-bad { background: rgba(255, 59, 92, .1); border-color: rgba(255, 59, 92, .35); }
.verdict-text { font-size: 18px; font-weight: 700; }
.verdict-ok .verdict-text { color: var(--ok); }
.verdict-warn .verdict-text { color: var(--warn); }
.verdict-bad .verdict-text { color: var(--bad); }
.verdict-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.fresh-line { display: flex; align-items: center; gap: 10px; margin: 18px 0; padding: 10px 14px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-sm); flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-ok { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot-neutral { background: var(--text-3); }
.dot-sample { background: var(--info); }
.fresh-line .btn { margin-left: auto; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.metric { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.metric-value { font-size: 22px; font-weight: 700; }
.metric-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }
.metric-hint { font-size: 11px; color: var(--text-3); margin-top: 6px; line-height: 1.4; }
.metric-gauge { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.gauge { width: 76px; height: 76px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.gauge-hole { width: 58px; height: 58px; border-radius: 50%; background: var(--bg-1); display: flex; align-items: center; justify-content: center; }
.gauge-num { font-size: 22px; font-weight: 700; }

.verdict-desc { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 18px 0; }
.verdict-desc h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); }
.verdict-desc p { margin: 0; }

.findings h3 { font-size: 15px; margin: 24px 0 12px; }
.finding { display: flex; gap: 14px; padding: 14px 16px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.finding-impact { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); background: color-mix(in srgb, var(--c) 12%, transparent); padding: 4px 10px; border-radius: 6px; height: fit-content; white-space: nowrap; }
.finding-type { font-weight: 600; margin-bottom: 3px; }
.finding-desc { color: var(--text-2); font-size: 13px; }
.no-findings { padding: 20px; text-align: center; color: var(--accent); background: rgba(23, 201, 100, .06); border: 1px solid var(--accent-dim); border-radius: var(--radius); }
.finding-flag { margin-left: 8px; font-size: 10px; vertical-align: middle; }
.finding-code { margin-top: 8px; }
.finding-code summary { cursor: pointer; font-size: 12px; color: var(--info); }
.finding-code pre { margin: 8px 0 0; padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow-x: auto; font-family: var(--mono); font-size: 12px; color: #cbd5e1; line-height: 1.5; }
.proxy-warn { margin: 0 0 18px; padding: 12px 16px; background: rgba(255, 176, 32, .08); border: 1px solid rgba(255, 176, 32, .35); border-radius: var(--radius-sm); color: var(--text-2); font-size: 13px; }
.proxy-warn strong { color: var(--warn); }

.detail-actions { display: flex; gap: 10px; margin: 20px 0 12px; flex-wrap: wrap; }
.raw { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-1); }
.raw summary { cursor: pointer; padding: 12px 16px; font-weight: 600; color: var(--text-2); }
.raw pre { margin: 0; padding: 0 16px 16px; overflow-x: auto; font-family: var(--mono); font-size: 12px; color: var(--text-2); }

.error-card { background: var(--bg-1); border: 1px solid rgba(255, 59, 92, .35); border-radius: var(--radius); padding: 24px; }
.error-card h3 { margin-top: 0; color: var(--bad); }
.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- Settings --------------------------------------------------------- */
.settings h1, .learn h1 { font-size: 24px; margin: 0 0 6px; }
.card { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 16px 0; }
.card h2 { margin: 0 0 8px; font-size: 16px; }
.card p { margin: 0 0 14px; color: var(--text-2); }
.radio-row { display: flex; gap: 12px; flex-wrap: wrap; }
.radio-card { flex: 1; min-width: 200px; display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); cursor: pointer; background: var(--bg-2); transition: border-color .15s; }
.radio-card.checked { border-color: var(--accent); background: rgba(23, 201, 100, .06); }
.radio-card input { margin-top: 3px; accent-color: var(--accent); }
.radio-title { font-weight: 600; }
.radio-hint { font-size: 12px; color: var(--text-3); }
.inline-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.quick-result { margin-top: 12px; }
.quick-hit { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); flex-wrap: wrap; }
.quick-err { padding: 12px 14px; background: rgba(255, 59, 92, .08); border: 1px solid rgba(255, 59, 92, .3); border-radius: var(--radius-sm); color: var(--bad); }

/* ---- Learn ------------------------------------------------------------ */
.learn { max-width: 820px; }
.lede { font-size: 16px; color: var(--text-2); margin: 0 0 24px; }
.learn-section { margin: 28px 0; }
.learn-section h2 { font-size: 18px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.learn-section p { color: var(--text-2); }
.learn-section li { color: var(--text-2); margin: 5px 0; }
.code { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; color: #cbd5e1; line-height: 1.6; }
.mini-table { border-collapse: collapse; width: 100%; max-width: 420px; margin: 12px 0; }
.mini-table th, .mini-table td { text-align: left; padding: 8px 12px; border: 1px solid var(--line); }
.mini-table th { background: var(--bg-2); font-size: 12px; color: var(--text-3); }
.chain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.chain-badge { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg-1); border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: var(--radius-sm); }
.chain-badge-sym { font-weight: 700; font-size: 12px; color: var(--c); }
.chain-badge-name { font-size: 12px; color: var(--text-3); }

/* ---- Toast ------------------------------------------------------------ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--text);
  padding: 11px 18px; border-radius: 999px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .25s, transform .25s; z-index: 100;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-ok { border-color: var(--accent-dim); }
.toast-warn { border-color: rgba(255, 176, 32, .4); }
.toast-bad { border-color: rgba(255, 59, 92, .4); }

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .market-grid { grid-template-columns: repeat(3, 1fr); }
  .nav a { padding: 7px 10px; }
}
@media (max-width: 560px) {
  .view { padding: 16px 14px 40px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats .stat:last-child:nth-child(odd) { grid-column: span 2; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search, .select { width: 100%; }
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; }
  .nav { width: 100%; justify-content: space-between; }
  .nav a { padding: 6px 8px; font-size: 13px; white-space: nowrap; }
  .detail-head { gap: 12px; }
  .verdict-badge { min-width: 0; flex: 1; }
}
