:root {
  color-scheme: dark;
  --bg: #0b0c0f;
  --surface: #16181d;
  --surface-2: #202329;
  --surface-3: #2b2f36;
  --text: #f5f7fb;
  --muted: #9aa3b2;
  --line: #2b3038;
  --green: #32d74b;
  --red: #ff453a;
  --amber: #ffd60a;
  --cyan: #5ac8fa;
  --violet: #bf9cff;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.26);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root.light {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --surface-3: #e4e8ee;
  --text: #101318;
  --muted: #5f6875;
  --line: #d7dce4;
  --shadow: 0 10px 28px rgba(26, 38, 54, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(90, 200, 250, 0.08), transparent 260px),
    var(--bg);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  transform: translateY(-140%);
  padding: 10px 12px;
  border-radius: 7px;
  color: #061318;
  background: var(--cyan);
  font-size: 0.86rem;
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: auto;
  max-width: 1540px;
  margin: 0 auto;
  padding: 18px;
}

main,
section,
aside,
.panel,
.quick-search,
.metric-card,
.terminal-hero,
.hero-copy,
.search-row {
  min-width: 0;
  max-width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  min-height: 64px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border: 1px solid color-mix(in srgb, var(--cyan) 58%, var(--line));
  border-radius: 8px;
  color: var(--cyan);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--cyan) 11%, var(--surface-2));
  font-size: 0.86rem;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.2;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.topnav {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 58%, transparent);
}

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.topnav a:hover {
  color: var(--text);
  background: var(--surface-3);
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.live-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px 7px 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.live-pill::before {
  position: absolute;
  left: 11px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
}

.live-pill.is-live {
  border-color: color-mix(in srgb, var(--green) 44%, var(--line));
  color: var(--green);
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
}

.live-pill.is-live::before {
  background: var(--green);
}

.live-pill.is-stale,
.live-pill.is-connecting {
  border-color: color-mix(in srgb, var(--amber) 44%, var(--line));
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
}

.live-pill.is-stale::before,
.live-pill.is-connecting::before {
  background: var(--amber);
}

.button,
.icon-button,
.text-button,
.segment,
.sort {
  border: 0;
  color: var(--text);
  background: transparent;
}

.button {
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 7px;
  font-weight: 800;
}

.button.primary {
  color: #061318;
  background: var(--cyan);
}

.button.secondary {
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.button.full {
  width: 100%;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.sun {
  width: 16px;
  height: 16px;
  border: 2px solid var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(248, 189, 76, 0.16);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 16%, transparent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.terminal-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 8px;
  font-size: 2.55rem;
  line-height: 1.04;
  letter-spacing: 0;
  overflow-wrap: break-word;
}

h2 {
  margin-bottom: 4px;
  font-size: 1rem;
}

h3 {
  margin-bottom: 0;
  font-size: 0.88rem;
}

.quick-search {
  align-self: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}

.hero-subcopy {
  max-width: 720px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.status-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}

.status-chip {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
}

.status-chip dt,
.status-chip dd {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1;
}

.status-chip dt {
  color: var(--muted);
}

.status-chip dd {
  color: var(--text);
  font-weight: 850;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-2);
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(53, 194, 214, 0.24);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 24%, transparent);
  outline: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric-card {
  min-height: 92px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 1.45rem;
  line-height: 1.1;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}

.panel-heading {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.panel-heading.small {
  padding: 0 0 10px;
  border-bottom: 0;
}

.text-button {
  min-height: 34px;
  padding: 6px 0;
  color: var(--cyan);
  font-size: 0.84rem;
  font-weight: 800;
}

.filters-panel {
  padding-bottom: 14px;
}

.filters-heading {
  gap: 10px;
}

.filters-heading h2 {
  margin-right: auto;
}

.filter-close {
  color: var(--muted);
}

.filter-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.42);
}

.filter-drawer {
  position: fixed;
  top: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  width: min(380px, calc(100vw - 36px));
  overflow: auto;
  transform: translateX(calc(100% + 28px));
  transition: transform 180ms ease, opacity 180ms ease;
  opacity: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.filter-drawer.is-open {
  transform: translateX(0);
  opacity: 1;
}

.filter-toggle {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
  font-size: 0.88rem;
  font-weight: 850;
}

.filter-toggle small {
  display: inline-flex;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 850;
}

.filter-body {
  display: block;
}

.filters-panel.is-collapsed {
  padding-bottom: 0;
}

.filters-panel.is-collapsed .filter-body {
  display: none;
}

.control-block {
  display: grid;
  gap: 8px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.range-readout {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
}

input[type="range"] {
  min-height: 24px;
  padding: 0;
  accent-color: var(--cyan);
}

.watchlist {
  padding: 13px 14px;
}

.watchlist-items {
  display: grid;
  gap: 8px;
}

.watch-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 0.84rem;
}

.watch-item small {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.72rem;
}

.watch-item span {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.market-heading {
  align-items: start;
}

.market-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  gap: 4px;
  min-width: 150px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.segment {
  min-height: 32px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.segment.active {
  color: #061318;
  background: var(--cyan);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th,
td {
  height: 52px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.75rem;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(53, 194, 214, 0.06);
  background: color-mix(in srgb, var(--cyan) 6%, transparent);
}

.sort {
  min-height: 32px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.sort.active-sort {
  color: var(--cyan);
}

.empty-row td {
  height: 120px;
  color: var(--muted);
  text-align: center;
}

.market-cell {
  display: flex;
  gap: 10px;
  align-items: center;
}

.coin {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  color: #071116;
  background: var(--amber);
  font-size: 0.78rem;
  font-weight: 900;
}

.market-meta strong,
.market-meta small {
  display: block;
}

.market-meta small {
  color: var(--muted);
  font-size: 0.75rem;
}

.pos {
  color: var(--green);
}

.neg {
  color: var(--red);
}

.neutral {
  color: var(--muted);
}

.signal-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--text);
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 850;
}

.signal-badge.hot {
  color: #1f1200;
  background: var(--amber);
}

.signal-badge.risk {
  color: #210306;
  background: var(--red);
}

.signal-badge.growth {
  color: #00180b;
  background: var(--green);
}

.signal-badge.divergence {
  color: #061318;
  background: var(--cyan);
}

.sparkline {
  width: 58px;
  height: 24px;
  vertical-align: middle;
}

.side-stack {
  display: grid;
  gap: 14px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.scanner-feed {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.scanner-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.scanner-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.scanner-row strong {
  font-size: 0.9rem;
}

.scanner-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.alert-form,
.risk-form {
  display: grid;
  gap: 12px;
  padding: 12px 14px 14px;
}

.form-note {
  min-height: 18px;
  margin-bottom: 0;
  color: var(--green);
  font-size: 0.8rem;
}

.form-note.warning {
  color: var(--amber);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.risk-output {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.risk-output span {
  color: var(--muted);
  font-size: 0.82rem;
}

.risk-output strong {
  font-size: 1.35rem;
}

.footer {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding: 16px 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.footer-links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.footer-links a {
  color: var(--cyan);
  font-weight: 800;
}

.legal-page {
  max-width: 860px;
  margin: 0 auto;
}

.legal-page .panel {
  padding: 24px;
}

.legal-page h1 {
  margin-bottom: 18px;
  font-size: 2.2rem;
}

.legal-page h2 {
  margin-top: 22px;
}

.legal-page p,
.legal-page li {
  color: var(--muted);
  line-height: 1.65;
}

.crawler-fallback {
  display: block;
}

.crawler-fallback .panel {
  padding: 18px;
}

.crawler-fallback table {
  min-width: 0;
}

.crawler-fallback th,
.crawler-fallback td {
  height: auto;
  text-align: left;
  white-space: normal;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media (max-width: 1180px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-stack {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .terminal-hero,
  .workspace-grid,
  .side-stack,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
  }

  .topnav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .top-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .terminal-hero {
    align-items: stretch;
  }

  h1 {
    font-size: 2rem;
  }

  .filter-toggle {
    flex: 0 0 auto;
  }

  .filter-drawer {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: 84vh;
    transform: translateY(calc(100% + 20px));
  }

  .filter-drawer.is-open {
    transform: translateY(0);
  }

  .market-tools {
    justify-content: space-between;
  }

  .market-heading {
    display: grid;
  }

  .footer {
    display: grid;
  }

  .footer-links {
    flex-wrap: wrap;
  }
}

@media (max-width: 520px) {
  .search-row,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .quick-search,
  .metric-card,
  .panel {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }

  .search-row,
  .search-row input,
  .search-row .button {
    width: 100%;
    max-width: 100%;
  }

  .brand {
    min-width: 0;
  }

  .segmented-control {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }

  .metric-card {
    min-height: 96px;
  }

  h1 {
    font-size: 1.8rem;
    line-height: 1.08;
  }
}

@media (max-width: 380px) {
  .brand small {
    display: none;
  }

  .topnav {
    gap: 4px;
    overflow-x: visible;
  }

  .topnav a {
    min-height: 38px;
    padding: 7px 8px;
    font-size: 0.88rem;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
  }

  .live-pill {
    width: max-content;
  }

  .button.secondary {
    grid-column: 1 / -1;
  }

  h1 {
    font-size: 1.65rem;
  }
}
