/* Scanbot Dashboard — cozy dark theme, mobile-first */

:root {
  --bg: #0b0d12;
  --bg-2: #11141c;
  --bg-3: #171b26;
  --surface: #161a24;
  --surface-2: #1d2230;
  --border: #242a3a;
  --border-soft: #1c2230;
  --text: #e7ecf5;
  --text-2: #a8b0c0;
  --text-3: #6b7280;
  --accent: #7aa2ff;
  --accent-2: #b388ff;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --hot: #fb7185;
  --urgent: #ff6b6b;
  --warm: #fbbf24;
  --cool: #60a5fa;
  --cold: #6b7280;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter",
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(18,22,32,0.95), rgba(11,13,18,0.92));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: 0.5px; }
.brand-mark { font-size: 16px; }
.brand-text { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.health {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.health-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3);
  box-shadow: 0 0 0 0 rgba(255,255,255,0);
}
/* ---- Bot health palette (cyan → violet → magenta → crimson)
        deliberately distinct from the token-urgency heat palette so the
        two signals never visually collide. ---- */
.health-healthy .health-dot {
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 0 8px 1px rgba(52,211,153,0.55);
}
.health-healthy { color: #6ee7b7; border-color: rgba(52,211,153,0.35); }

.health-slow .health-dot { background: linear-gradient(135deg, #22d3ee, #0ea5e9); }
.health-slow { color: #7dd3fc; border-color: rgba(14,165,233,0.35); }

.health-frozen .health-dot {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  animation: pulse-violet 1.8s infinite;
}
.health-frozen { color: #c4b5fd; border-color: rgba(167,139,250,0.45); }

.health-stale .health-dot {
  background: linear-gradient(135deg, #f472b6, #db2777);
  animation: pulse-magenta 1.4s infinite;
}
.health-stale { color: #f9a8d4; border-color: rgba(236,72,153,0.45); }

.health-dead .health-dot {
  background: linear-gradient(135deg, #fb7185, #b91c1c);
  animation: pulse-crimson 1.2s infinite;
}
.health-dead { color: #fca5a5; border-color: rgba(220,38,38,0.5); }

.health-unknown .health-dot { background: linear-gradient(135deg, #94a3b8, #475569); }

@keyframes pulse-violet {
  0%, 100% { box-shadow: 0 0 0 0 rgba(167,139,250,0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(167,139,250,0); }
}
@keyframes pulse-magenta {
  0%, 100% { box-shadow: 0 0 0 0 rgba(236,72,153,0.55); }
  50%      { box-shadow: 0 0 0 7px rgba(236,72,153,0); }
}
@keyframes pulse-crimson {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.65); }
  50%      { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(248,113,113,0); }
}

.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px; font: inherit; cursor: pointer;
}
.refresh-btn:hover { background: var(--surface-2); color: var(--text); }
.refresh-icon { display: inline-block; font-size: 14px; }
.refreshing .refresh-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.last-updated { font-size: 11px; font-variant-numeric: tabular-nums; }

/* ---------- Tabs ----------
   Mobile-first, horizontally scrollable, with explicit icon + label and a
   bright underline on the active tab. Designed so a first-time visitor can
   glance at the bar and understand what's there. */
.tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  background:
    linear-gradient(180deg, rgba(18,22,32,0.95), rgba(15,18,26,0.95));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 55px;
  z-index: 30;
  scrollbar-width: none;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  /* soft edge fades so users can see there's more to scroll */
  mask-image: linear-gradient(90deg, transparent 0, black 14px, black calc(100% - 14px), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, black 14px, black calc(100% - 14px), transparent 100%);
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  scroll-snap-align: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tab .tab-ico {
  font-size: 14px;
  line-height: 1;
  filter: grayscale(0.25) opacity(0.85);
  transition: filter 0.15s;
}
.tab .tab-label { line-height: 1; }

.tab:hover {
  color: var(--text);
  border-color: rgba(122,162,255,0.3);
  background: var(--surface-2);
}
.tab:active { transform: scale(0.97); }

.tab.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(122,162,255,0.22), rgba(179,136,255,0.22));
  border-color: rgba(122,162,255,0.55);
  box-shadow:
    0 0 0 1px rgba(122,162,255,0.25),
    0 4px 14px rgba(122,162,255,0.15);
}
.tab.active .tab-ico { filter: none; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: -10px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px rgba(122,162,255,0.45);
}

/* Focus ring for keyboard nav */
.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Panels ---------- */
main#main {
  padding: 14px;
  max-width: 1440px;
  margin: 0 auto;
}
.panel { display: none; }
.panel.active { display: block; }

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-3);
  margin: 18px 6px 8px;
  font-weight: 600;
}
.section-title:first-child { margin-top: 0; }

/* ---------- Cards and grids ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.kpi-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11px; color: var(--text-2); margin-top: 2px; }

.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.token-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.token-card::before {
  /* soft glow behind the logo */
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(122,162,255,0.08), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.token-card > * { position: relative; z-index: 1; }
.token-card:hover {
  border-color: rgba(122,162,255,0.4);
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(122,162,255,0.08);
}

/* ---- Urgency stripe (heat palette: fire → amber → ice → slate)
        intentionally different from the bot-health palette. ---- */
.token-card .urgency-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
  z-index: 2;
}
.urgency-bar.hot {
  background: linear-gradient(180deg, #fbbf24 0%, #f97316 35%, #ef4444 75%, #dc2626 100%);
  box-shadow: 0 0 14px rgba(249,115,22,0.55);
}
.urgency-bar.warm {
  background: linear-gradient(180deg, #fde68a 0%, #f59e0b 70%, #ea580c 100%);
  box-shadow: 0 0 10px rgba(245,158,11,0.35);
}
.urgency-bar.cool {
  background: linear-gradient(180deg, #a5f3fc 0%, #22d3ee 50%, #0284c7 100%);
}
.urgency-bar.cold {
  background: linear-gradient(180deg, #475569 0%, #1e293b 100%);
  opacity: 0.8;
}

/* Slightly tint the card background by urgency so the signal reads at a glance */
.token-card:has(.urgency-bar.hot)  { border-color: rgba(239,68,68,0.22); }
.token-card:has(.urgency-bar.warm) { border-color: rgba(245,158,11,0.22); }
.token-card:has(.urgency-bar.cool) { border-color: rgba(34,211,238,0.18); }
.token-card:has(.urgency-bar.hot)::before {
  background: radial-gradient(circle, rgba(239,68,68,0.12), transparent 70%);
}
.token-card:has(.urgency-bar.warm)::before {
  background: radial-gradient(circle, rgba(245,158,11,0.10), transparent 70%);
}

.token-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.token-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.token-ticker { font-size: 16px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; }
.token-ticker .chain-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.chain-chip .chain-dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block;
}
.chain-chip.solana .chain-dot { background: linear-gradient(135deg,#9945FF,#14F195); }
.chain-chip.ethereum .chain-dot { background: #627eea; }
.chain-chip.base .chain-dot { background: #0052ff; }
.chain-chip.bsc .chain-dot { background: #f0b90b; }
.chain-chip.arbitrum .chain-dot { background: #2d374b; }
.chain-chip.polygon .chain-dot { background: #8247e5; }

.token-time { font-size: 11px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Token logo / avatar ---------- */
.token-logo {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  flex-shrink: 0;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  overflow: hidden;
  position: relative;
}
.token-logo.placeholder {
  background: linear-gradient(135deg, var(--logo-c1, #3b4a66), var(--logo-c2, #1f2a44));
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.token-logo img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.token-logo.sm { width: 26px; height: 26px; font-size: 11px; border-radius: 50%; }
.token-logo.xs { width: 22px; height: 22px; font-size: 10px; border-radius: 50%; }

.row-token {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.row-token .row-token-main { display: flex; flex-direction: column; min-width: 0; }
.row-token .row-token-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Market stats strip on token cards ---------- */
.token-market {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 2px;
  font-size: 11px;
}
.token-market-item {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border-soft);
  min-width: 0;
}
.token-market-item .label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
}
.token-market-item .value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.token-market-item.loading .value { color: var(--text-3); font-weight: 500; }
.token-market-item.liq .value { color: #93c5fd; }
.token-market-item.vol .value { color: #fbbf24; }
.token-market-item.mcap .value { color: #c4b5fd; }
.token-market-item .sub {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 1px;
}

.token-contract {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gain-row { display: flex; gap: 16px; flex-wrap: wrap; }
.gain-item { display: flex; flex-direction: column; }
.gain-item-label { font-size: 10px; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.05em; }
.gain-item-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.gain-pos { color: var(--good); }
.gain-neg { color: var(--bad); }
.gain-zero { color: var(--text-2); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(122,162,255,0.1);
  border: 1px solid rgba(122,162,255,0.2);
  color: var(--text-2);
  white-space: nowrap;
}
.chip.muted { background: var(--bg-3); border-color: var(--border); color: var(--text-3); }
.chip.warn { background: rgba(251,191,36,0.12); border-color: rgba(251,191,36,0.3); color: var(--warn); }
.chip.good { background: rgba(74,222,128,0.12); border-color: rgba(74,222,128,0.3); color: var(--good); }
.chip.bad { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.3); color: var(--bad); }
.chip.hot { background: rgba(251,113,133,0.15); border-color: rgba(251,113,133,0.35); color: var(--hot); }

.token-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-2);
}
.token-meta strong { color: var(--text); font-weight: 600; }

.links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.link-btn {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.link-btn:hover { background: var(--surface-2); color: var(--text); }
.link-btn.buy-btn {
  background: linear-gradient(135deg, rgba(34,197,94,0.22), rgba(134,239,172,0.18));
  border-color: rgba(34,197,94,0.55);
  color: #bbf7d0;
  font-weight: 600;
}
.link-btn.buy-btn:hover {
  background: linear-gradient(135deg, rgba(34,197,94,0.35), rgba(134,239,172,0.28));
  color: #fff;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 600px;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  font-weight: 600;
  background: var(--bg-2);
  position: sticky;
  top: 0;
  cursor: pointer;
  user-select: none;
}
th.sort-asc::after { content: ' ▲'; color: var(--accent); }
th.sort-desc::after { content: ' ▼'; color: var(--accent); }
tr:hover td { background: rgba(255,255,255,0.02); }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Controls (search, filters) ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
  align-items: center;
}
.controls input[type=text], .controls select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  min-width: 0;
  flex: 1 1 160px;
}
.controls input[type=text]:focus, .controls select:focus { outline: none; border-color: var(--accent); }
.controls .count { color: var(--text-3); font-size: 12px; margin-left: auto; }

/* ---------- Timeline ---------- */
.timeline {
  display: flex; flex-direction: column; gap: 6px;
}
.timeline-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.timeline-time { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.timeline-body { display: flex; flex-direction: column; gap: 2px; }
.timeline-main { font-weight: 600; }
.timeline-sub { font-size: 12px; color: var(--text-2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translate(-50%, -4px); }

/* ---------- History / Call tracker ---------- */
.live-dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 6px rgba(74,222,128,0.65);
  margin-right: 5px;
  vertical-align: middle;
  animation: live-pulse 1.6s infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.history-stats .kpi-card { padding: 10px 12px; }

.history-pager {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 10px 0 20px;
  flex-wrap: wrap;
  align-items: center;
}
.history-pager button {
  padding: 6px 14px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.history-pager button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.history-pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.history-pager .page-info {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* small inline price: current with live flag */
.price-live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

/* ---------- AI Double Scan ---------- */
.ai-hero {
  position: relative;
  padding: 18px 20px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 0% 0%, rgba(167,139,250,0.18), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(122,162,255,0.18), transparent 55%),
    linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid rgba(167,139,250,0.25);
  overflow: hidden;
  margin-bottom: 16px;
}
.ai-hero::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(600px circle at 50% 0, rgba(179,136,255,0.1), transparent 60%);
  pointer-events: none;
}
.ai-hero-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 16px;
  margin: 0 0 4px;
  color: var(--text);
  letter-spacing: 0.2px;
}
.ai-hero-title .spark { font-size: 18px; }
.ai-hero-sub {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
  margin: 0 0 10px;
}
.ai-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}
.ai-hero-meta .chip { font-size: 11px; }

.ai-list { display: flex; flex-direction: column; gap: 14px; }

.ai-card {
  position: relative;
  padding: 14px 16px 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  overflow: hidden;
}
.ai-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--border);
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}
.ai-card.tier-elite::before  { background: linear-gradient(180deg, #fbbf24, #ef4444); box-shadow: 0 0 14px rgba(251,191,36,0.5); }
.ai-card.tier-high::before   { background: linear-gradient(180deg, #a78bfa, #7c3aed); }
.ai-card.tier-medium::before { background: linear-gradient(180deg, #60a5fa, #2563eb); }
.ai-card.tier-low::before    { background: linear-gradient(180deg, #64748b, #334155); }

.ai-card.tier-elite  { border-color: rgba(251,191,36,0.4); }
.ai-card.tier-high   { border-color: rgba(167,139,250,0.35); }
.ai-card.tier-medium { border-color: rgba(96,165,250,0.25); }

.ai-score {
  min-width: 76px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  border: 1px solid var(--border);
}
.ai-score-value {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.5px;
}
.ai-score-max { font-size: 10px; color: var(--text-3); margin-top: 2px; }
.ai-score-tier {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-2);
}
.ai-card.tier-elite  .ai-score-tier { color: #fde68a; background: rgba(251,191,36,0.15); }
.ai-card.tier-high   .ai-score-tier { color: #c4b5fd; background: rgba(167,139,250,0.15); }
.ai-card.tier-medium .ai-score-tier { color: #93c5fd; background: rgba(96,165,250,0.15); }
.ai-card.tier-low    .ai-score-tier { color: #cbd5e1; background: rgba(148,163,184,0.12); }

.ai-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ai-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  row-gap: 4px;
}
.ai-head-ticker {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}
/* Stack holds the ticker + (optional) full name. Allow wrapping on any
   character so long tickers always show in full. */
.ai-ticker-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}
.ai-ticker-text {
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.15;
}
.ai-ticker-name {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-3);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.2;
  margin-top: 1px;
}
.ai-ticker-name:empty { display: none; }
.ai-head-meta {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}

.ai-blurb {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  padding: 8px 12px;
  background: rgba(167,139,250,0.06);
  border: 1px solid rgba(167,139,250,0.15);
  border-radius: var(--radius-sm);
  margin: 2px 0;
}
.ai-card.tier-elite .ai-blurb  { background: rgba(251,191,36,0.08); border-color: rgba(251,191,36,0.25); }
.ai-card.tier-high  .ai-blurb  { background: rgba(167,139,250,0.08); border-color: rgba(167,139,250,0.22); }

.ai-lists { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) {
  .ai-lists { grid-template-columns: 1fr 1fr; }
}
.ai-listbox {
  padding: 8px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.ai-listbox .hdr {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 4px;
}
.ai-listbox.pro .hdr { color: #6ee7b7; }
.ai-listbox.con .hdr { color: #fca5a5; }
.ai-listbox ul { list-style: none; padding: 0; margin: 0; }
.ai-listbox li {
  padding: 3px 0;
  color: var(--text-2);
  line-height: 1.45;
  position: relative;
  padding-left: 14px;
}
.ai-listbox li::before {
  content: "";
  position: absolute; left: 0; top: 10px;
  width: 5px; height: 5px; border-radius: 50%;
}
.ai-listbox.pro li::before { background: var(--good); }
.ai-listbox.con li::before { background: var(--bad); }

.ai-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 11px;
  color: var(--text-3);
  padding-top: 4px;
  border-top: 1px dashed var(--border-soft);
  margin-top: 2px;
}
.ai-stats b { color: var(--text); font-weight: 600; }

.ai-actions { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }

.ai-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
}

/* mobile tweaks */
@media (max-width: 480px) {
  .ai-card { grid-template-columns: auto 1fr; padding: 12px; gap: 10px; }
  .ai-score { min-width: 64px; padding: 8px 6px; }
  .ai-score-value { font-size: 24px; }
  .ai-head-ticker { font-size: 16px; }
}

/* ---------- Leaderboard ---------- */
.lb-windows {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}
.lb-window-btn {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.lb-window-btn:hover { background: var(--surface-2); color: var(--text); }
.lb-window-btn.active {
  background: linear-gradient(135deg, rgba(122,162,255,0.22), rgba(179,136,255,0.22));
  color: var(--text);
  border-color: rgba(122,162,255,0.55);
}

.lb-overall {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.lb-overall .kpi-card { padding: 10px 12px; }

table.lb-channels td.rank, table.lb-channels th.rank { width: 46px; text-align: center; color: var(--text-3); }
table.lb-channels td.rank { font-weight: 700; font-size: 15px; }
table.lb-channels tr:nth-child(1) td.rank { color: #fde68a; }
table.lb-channels tr:nth-child(2) td.rank { color: #e5e7eb; }
table.lb-channels tr:nth-child(3) td.rank { color: #fbbf24; }

.lb-win-bar {
  display: inline-block;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  width: 46px;
  vertical-align: middle;
  margin-left: 6px;
  position: relative;
  overflow: hidden;
}
.lb-win-bar span {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--good), var(--accent));
}

/* W/L split + Adjusted score */
.lb-wl .lb-wl-w { color: var(--good); font-weight: 600; }
.lb-wl .lb-wl-l { color: var(--bad); font-weight: 600; }
table.lb-channels td.lb-adj { font-weight: 700; }

/* Expandable channel rows */
table.lb-channels tr.lb-channel-row { cursor: pointer; }
table.lb-channels tr.lb-channel-row:hover td { background: var(--surface-2); }
table.lb-channels tr.lb-channel-row.open td { background: var(--surface-2); }
table.lb-channels tr.lb-channel-row td.lb-calls-cell { font-weight: 600; }
.lb-expand-caret {
  display: inline-block;
  width: 12px;
  margin-right: 6px;
  color: var(--text-3);
  font-size: 10px;
  transition: transform 0.15s ease;
}
table.lb-channels tr.lb-channel-row.open .lb-expand-caret { color: var(--accent); }
tr.lb-channel-detail td { padding: 0 !important; background: var(--bg-2); }
table.lb-channel-detail-tbl {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}
table.lb-channel-detail-tbl th,
table.lb-channel-detail-tbl td {
  padding: 6px 10px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
}
table.lb-channel-detail-tbl th {
  color: var(--text-3);
  font-weight: 500;
  text-align: left;
  background: var(--bg-3);
}
table.lb-channel-detail-tbl tbody tr:last-child td { border-bottom: none; }
table.lb-channel-detail-tbl tbody tr:hover td { background: var(--surface); }

/* ---------- First-time hint banner ---------- */
.hint-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(122,162,255,0.25);
  background: linear-gradient(135deg, rgba(122,162,255,0.08), rgba(179,136,255,0.06));
  font-size: 13px;
  color: var(--text-2);
}
.hint-banner strong { color: var(--text); }
.hint-banner .hint-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.hint-banner .hint-close:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Info / legend ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.info-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-2);
  font-weight: 600;
}
.info-card p { margin: 0 0 8px; color: var(--text-2); font-size: 13px; }
.info-card p:last-child { margin-bottom: 0; }

.legend-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border-soft);
}
.legend-row:last-child { border-bottom: none; }
.legend-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  justify-content: center;
}
.legend-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3);
}
/* Health badges — cyan/violet/magenta/crimson */
.legend-badge.healthy { color: #6ee7b7; border-color: rgba(52,211,153,0.35); }
.legend-badge.healthy .dot { background: linear-gradient(135deg,#34d399,#10b981); box-shadow: 0 0 6px rgba(52,211,153,0.6); }
.legend-badge.slow { color: #7dd3fc; border-color: rgba(14,165,233,0.35); }
.legend-badge.slow .dot { background: linear-gradient(135deg,#22d3ee,#0ea5e9); }
.legend-badge.frozen { color: #c4b5fd; border-color: rgba(167,139,250,0.45); }
.legend-badge.frozen .dot { background: linear-gradient(135deg,#a78bfa,#7c3aed); animation: pulse-violet 1.8s infinite; }
.legend-badge.stale { color: #f9a8d4; border-color: rgba(236,72,153,0.45); }
.legend-badge.stale .dot { background: linear-gradient(135deg,#f472b6,#db2777); animation: pulse-magenta 1.4s infinite; }
.legend-badge.dead { color: #fca5a5; border-color: rgba(220,38,38,0.5); }
.legend-badge.dead .dot { background: linear-gradient(135deg,#fb7185,#b91c1c); animation: pulse-crimson 1.2s infinite; }
.legend-badge.unknown { color: var(--text-3); }
.legend-badge.unknown .dot { background: linear-gradient(135deg,#94a3b8,#475569); }

/* Urgency badges — heat palette matching the card stripe */
.legend-badge.hot { color: #fb923c; border-color: rgba(239,68,68,0.4); }
.legend-badge.hot .dot { background: linear-gradient(135deg,#fbbf24,#ef4444); box-shadow: 0 0 6px rgba(249,115,22,0.6); }
.legend-badge.warm { color: #fbbf24; border-color: rgba(245,158,11,0.35); }
.legend-badge.warm .dot { background: linear-gradient(135deg,#fde68a,#f59e0b); }
.legend-badge.cool { color: #67e8f9; border-color: rgba(34,211,238,0.35); }
.legend-badge.cool .dot { background: linear-gradient(135deg,#a5f3fc,#0284c7); }
.legend-badge.cold { color: #94a3b8; }
.legend-badge.cold .dot { background: linear-gradient(135deg,#475569,#1e293b); }

.legend-text { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.legend-text strong { color: var(--text); }

.tab-guide-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 13px;
}
.tab-guide-row:last-child { border-bottom: none; }
.tab-guide-name {
  font-weight: 600;
  color: var(--text);
}

/* Per-tab logic accordions in the Info panel — each one gets its own
   color theme via a pair of CSS custom properties set on the root.
   --tl-c   : solid accent colour
   --tl-rgb : same color as comma-less rgb triplet for rgba() backgrounds */
.tab-logic {
  --tl-c: #94a3b8;
  --tl-rgb: 148, 163, 184;
  position: relative;
  margin: 6px 0;
  padding: 6px 12px 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--tl-rgb), 0.18);
  background: linear-gradient(90deg, rgba(var(--tl-rgb), 0.04), transparent 80%);
  transition: background 0.15s, border-color 0.15s;
}
.tab-logic::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--tl-c), rgba(var(--tl-rgb), 0.3));
}
.tab-logic:hover {
  border-color: rgba(var(--tl-rgb), 0.35);
  background: linear-gradient(90deg, rgba(var(--tl-rgb), 0.07), transparent 85%);
}
.tab-logic[open] {
  border-color: rgba(var(--tl-rgb), 0.45);
  background:
    radial-gradient(400px circle at 0 0, rgba(var(--tl-rgb), 0.10), transparent 60%),
    linear-gradient(90deg, rgba(var(--tl-rgb), 0.04), transparent 90%);
  box-shadow: 0 0 0 1px rgba(var(--tl-rgb), 0.15);
}

.tab-logic summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
.tab-logic summary::-webkit-details-marker { display: none; }
.tab-logic summary::before {
  content: "▸";
  color: var(--tl-c);
  font-size: 11px;
  transition: transform 0.2s;
  flex-shrink: 0;
  text-shadow: 0 0 8px rgba(var(--tl-rgb), 0.6);
}
.tab-logic[open] summary::before { transform: rotate(90deg); }
.tab-logic summary .tl-ico {
  font-size: 18px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-shrink: 0;
  background: rgba(var(--tl-rgb), 0.14);
  border: 1px solid rgba(var(--tl-rgb), 0.35);
  border-radius: 8px;
  filter: drop-shadow(0 0 6px rgba(var(--tl-rgb), 0.35));
}
.tab-logic summary .tl-name {
  flex: 1;
  color: var(--tl-c);
  letter-spacing: 0.2px;
}
.tab-logic summary .tl-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}
.tab-logic .tl-body {
  padding: 8px 2px 10px 38px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
  border-top: 1px dashed rgba(var(--tl-rgb), 0.2);
  margin-top: 6px;
}
.tab-logic .tl-body p { margin: 8px 0; }
.tab-logic .tl-body strong { color: var(--tl-c); font-weight: 700; }
.tab-logic .tl-body ul { margin: 4px 0 4px 16px; padding: 0; list-style: none; }
.tab-logic .tl-body li {
  padding: 3px 0;
  position: relative;
  padding-left: 14px;
}
.tab-logic .tl-body li::before {
  content: "";
  position: absolute;
  left: 0; top: 11px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--tl-c);
  box-shadow: 0 0 5px rgba(var(--tl-rgb), 0.7);
}
.tab-logic .tl-sec {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--tl-c);
  font-weight: 800;
  margin: 10px 0 4px;
  opacity: 0.95;
}
.tab-logic .tl-body code.formula {
  border-color: rgba(var(--tl-rgb), 0.25);
  background: rgba(var(--tl-rgb), 0.07);
}

/* Per-tab colour themes */
.tab-logic.t-blue    { --tl-c: #60a5fa; --tl-rgb: 96, 165, 250; }
.tab-logic.t-red     { --tl-c: #f87171; --tl-rgb: 248, 113, 113; }
.tab-logic.t-violet  { --tl-c: #a78bfa; --tl-rgb: 167, 139, 250; }
.tab-logic.t-amber   { --tl-c: #fbbf24; --tl-rgb: 251, 191, 36; }
.tab-logic.t-cyan    { --tl-c: #22d3ee; --tl-rgb: 34, 211, 238; }
.tab-logic.t-green   { --tl-c: #4ade80; --tl-rgb: 74, 222, 128; }
.tab-logic.t-yellow  { --tl-c: #facc15; --tl-rgb: 250, 204, 21; }
.tab-logic.t-sky     { --tl-c: #38bdf8; --tl-rgb: 56, 189, 248; }
.tab-logic.t-pink    { --tl-c: #f472b6; --tl-rgb: 244, 114, 182; }
.tab-logic.t-emerald { --tl-c: #34d399; --tl-rgb: 52, 211, 153; }
.tab-logic.t-crimson { --tl-c: #fb7185; --tl-rgb: 251, 113, 133; }
.tab-logic.t-orange  { --tl-c: #fb923c; --tl-rgb: 251, 146, 60; }
.tab-logic.t-slate   { --tl-c: #94a3b8; --tl-rgb: 148, 163, 184; }

kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text);
}

.formula {
  display: block;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}

/* ---------- Footer ---------- */
.footer {
  padding: 22px 14px calc(22px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 18px; }
  .topbar { padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .brand-text { font-size: 13px; }
  .tabs {
    top: 49px;
    padding: 8px 10px 12px;
    gap: 5px;
  }
  .tab {
    padding: 7px 12px;
    font-size: 12.5px;
    min-height: 36px;
  }
  .tab .tab-ico { font-size: 13px; }
  main#main { padding: 10px; }
  .token-card { padding: 10px 12px; }
  .timeline-item { grid-template-columns: 70px 1fr; padding: 8px 10px; }
  th, td { padding: 7px 8px; }
}

@media (max-width: 380px) {
  /* Extra-narrow phones: shrink a touch but keep labels — this is the
     first-time-visitor dashboard, clarity beats density. */
  .tab { padding: 7px 11px; font-size: 12px; }
  .tab .tab-ico { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
