:root {
  --bg: #07070d;
  --bg-elevated: rgba(12, 12, 22, 0.78);
  --bg-panel: rgba(16, 16, 30, 0.72);
  --bg-fill: rgba(117, 102, 255, 0.12);
  --label: #e8e8f0;
  --secondary: #8b8b9e;
  --separator: rgba(117, 102, 255, 0.18);
  --accent: #7566FF;
  --accent-bright: #9b8fff;
  --accent-soft: rgba(117, 102, 255, 0.2);
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.14);
  --cyan-glow: rgba(34, 211, 238, 0.45);
  --violet-glow: rgba(117, 102, 255, 0.4);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --orange: #fbbf24;
  --orange-soft: rgba(251, 191, 36, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --glow: 0 0 20px rgba(117, 102, 255, 0.25), 0 0 40px rgba(34, 211, 238, 0.08);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-sans: "JetBrains Sans", "JetBrains Mono", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --max: 1100px;
  --header-h: auto;
}

:root[data-theme="light"] {
  --bg: #f0eef8;
  --bg-elevated: rgba(255, 255, 255, 0.86);
  --bg-panel: rgba(255, 255, 255, 0.82);
  --bg-fill: rgba(117, 102, 255, 0.1);
  --label: #16161f;
  --secondary: #5c5c6e;
  --separator: rgba(117, 102, 255, 0.2);
  --accent: #7566FF;
  --accent-bright: #5a4de0;
  --accent-soft: rgba(117, 102, 255, 0.12);
  --cyan: #0891b2;
  --cyan-soft: rgba(8, 145, 178, 0.12);
  --cyan-glow: rgba(8, 145, 178, 0.25);
  --violet-glow: rgba(117, 102, 255, 0.2);
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.12);
  --orange: #d97706;
  --orange-soft: rgba(217, 119, 6, 0.12);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.1);
  --glow: 0 4px 24px rgba(117, 102, 255, 0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--label);
  min-height: 100%;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  position: relative;
  overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }

/* —— HUD backdrop —— */
.hud-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.hud-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(117, 102, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(117, 102, 255, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
}

.hud-noise {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.hud-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
}
.hud-glow-a {
  width: 420px; height: 420px;
  top: -120px; left: -80px;
  background: var(--violet-glow);
}
.hud-glow-b {
  width: 360px; height: 360px;
  top: -60px; right: -100px;
  background: var(--cyan-glow);
}

#app {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(16px + var(--safe-bottom));
}

/* —— Sticky header —— */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(var(--safe-top) + 8px) 14px 0;
  background: var(--bg-elevated);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--separator);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.top-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan), 0 0 22px var(--accent);
  flex-shrink: 0;
  animation: pulse-dot 2.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 1px;
  line-height: 1.2;
}

.title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  background: linear-gradient(90deg, var(--label), var(--accent-bright));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--separator);
  background: var(--bg-fill);
  color: var(--label);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.theme-toggle:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.25);
}

.asof-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--secondary);
  background: var(--bg-fill);
  border: 1px solid var(--separator);
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* —— KPI strip —— */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

@media (max-width: 640px) {
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.kpi {
  background: var(--bg-panel);
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--accent), transparent);
  opacity: 0.7;
}

.kpi .k-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi .k-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--label);
}

.kpi .k-delta {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  margin-top: 3px;
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
}

.k-delta.up { color: var(--green); background: var(--green-soft); }
.k-delta.down { color: var(--red); background: var(--red-soft); }
.k-delta.flat { color: var(--secondary); background: var(--bg-fill); }
.k-delta.na { color: var(--orange); background: var(--orange-soft); }

/* —— Segment nav —— */
.seg-nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 8px;
}
.seg-nav::-webkit-scrollbar { display: none; }

.seg {
  flex: 1 0 auto;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--secondary);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.seg:hover { color: var(--label); background: var(--bg-fill); }
.seg.active {
  color: var(--cyan);
  background: var(--cyan-soft);
  border-color: rgba(34, 211, 238, 0.35);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.15);
}

/* —— Main / views —— */
.main {
  padding: 12px 14px 0;
}

.view { display: none; }
.view.active { display: block; animation: fade-in 0.2s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  box-shadow: var(--glow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 12px 10px;
  margin-bottom: 10px;
  position: relative;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.panel-head h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  color: var(--label);
}

.panel-meta, .muted {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--secondary);
}

.row-between {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

/* —— Overview layout —— */
.overview-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
}
.overview-grid .span-full { grid-column: 1 / -1; }

@media (max-width: 800px) {
  .overview-grid { grid-template-columns: 1fr; }
}

.chart-wrap {
  height: 140px;
  position: relative;
}
@media (min-width: 800px) {
  .chart-wrap { height: 160px; }
}

.chart-footnote {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--secondary);
  margin-top: 6px;
  line-height: 1.35;
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 800px) {
  .split-grid { grid-template-columns: 1fr; }
}

/* —— Topic chips (dense) —— */
.topic-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}

.topic-chip {
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: rgba(117, 102, 255, 0.06);
  min-width: 0;
}
.topic-chip .tc-title {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.topic-chip .tc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.topic-chip .tc-vis { color: var(--cyan); font-weight: 700; }
.topic-chip .tc-bar {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: rgba(117, 102, 255, 0.15);
  overflow: hidden;
  max-width: 60px;
}
.topic-chip .tc-bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  border-radius: 999px;
}

/* —— HOLD grid —— */
.hold-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}

.hold-card {
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: rgba(117, 102, 255, 0.05);
  display: grid;
  gap: 6px;
}
.hold-card:hover {
  border-color: rgba(34, 211, 238, 0.35);
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.1);
}

.hold-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.hold-card h3 {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }

.badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 999px;
  text-transform: uppercase;
}
.badge.hold { background: var(--orange-soft); color: var(--orange); border: 1px solid rgba(251, 191, 36, 0.3); }
.badge.new { background: var(--accent-soft); color: var(--accent-bright); border: 1px solid rgba(117, 102, 255, 0.35); }
.badge.strengthen { background: var(--green-soft); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.3); }

.meta-line {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.meta-line a { color: var(--cyan); text-decoration: none; font-weight: 600; }
.meta-line a:hover { text-decoration: underline; }
.meta-line code {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-fill);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--label);
  border: 1px solid var(--separator);
}

/* —— Tables —— */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-height: min(52vh, 420px);
  overflow-y: auto;
}
.table-wrap.compact { max-height: min(36vh, 280px); }
.table-wrap.is-expanded {
  max-height: none;
  overflow: visible;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--separator);
  vertical-align: top;
}

.data-table th {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--secondary);
  font-weight: 700;
  background: rgba(7, 7, 13, 0.6);
  position: sticky;
  top: 0;
  z-index: 1;
  backdrop-filter: blur(8px);
}
:root[data-theme="light"] .data-table th {
  background: rgba(240, 238, 248, 0.9);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(117, 102, 255, 0.06); }
.data-table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 11px;
}
.data-table a { color: var(--label); text-decoration: none; font-weight: 600; }
.data-table a:hover { color: var(--cyan); }
.data-table .slug {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--secondary);
  font-weight: 500;
  margin-top: 1px;
  word-break: break-all;
}

.bar-cell { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.bar {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  min-width: 2px;
}

.owned-row td { background: var(--accent-soft); }

.status-pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(52, 211, 153, 0.3);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search {
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--separator);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  padding: 6px 12px;
  min-width: 160px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
:root[data-theme="light"] .search {
  background: rgba(255, 255, 255, 0.7);
}
.search:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.foot-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--secondary);
}

.btn-more {
  pointer-events: auto;
  position: relative;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.4);
  background: var(--cyan-soft);
  color: var(--cyan);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.btn-more:hover { box-shadow: 0 0 14px rgba(34, 211, 238, 0.25); }
.btn-more:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.empty {
  padding: 16px;
  color: var(--secondary);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
}

.footer-note {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--secondary);
  padding: 4px 2px 8px;
  line-height: 1.4;
}
