:root {
  --bg: #050607;
  --panel: #0c1016;
  --panel-strong: #111723;
  --ink: #f5f7fb;
  --muted: #96a0b7;
  --line: rgba(255, 255, 255, 0.1);
  --green: #00d395;
  --red: #ff4f61;
  --amber: #ffbf4d;
  --cyan: #66d9ef;
  --violet: #8b7cff;
  --mono: "IBM Plex Mono", "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    #050607;
  background-size: 64px 64px;
  font-family: var(--serif);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.terminal-shell {
  width: min(100% - 24px, 1500px);
  margin: 0 auto;
  padding: 14px 0 28px;
}

.terminal-topbar,
.terminal-search-bar,
.terminal-tape,
.terminal-grid,
.terminal-sponsor-row,
.terminal-footer {
  border: 1px solid var(--line);
  background: rgba(8, 11, 16, 0.92);
}

.terminal-topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 8px 8px 0 0;
}

.terminal-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.terminal-brand img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
}

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

.terminal-nav a,
.terminal-actions a,
.terminal-sponsored-side a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: #151b26;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 800;
}

.terminal-nav a:hover,
.terminal-actions a:hover,
.terminal-sponsored-side a:hover {
  border-color: rgba(102, 217, 239, 0.5);
  color: var(--cyan);
}

.terminal-tape {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-height: 42px;
  overflow: hidden;
  border-top: 0;
  border-radius: 0;
}

.tape-pools {
  min-width: 0;
  flex: 1;
  display: flex;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tape-item {
  min-width: 180px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: #dfe5f4;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.76rem;
  text-align: left;
  white-space: nowrap;
}

.tape-item span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 3px 5px;
  border-radius: 5px;
  background: #1b2440;
  color: var(--cyan);
  font-size: 0.67rem;
  font-weight: 900;
}

.tape-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tape-item em {
  margin-left: auto;
  color: var(--green);
  font-style: normal;
  font-weight: 800;
}

.tape-ad {
  flex: 0 0 auto;
  background: #121728;
}

.tape-ad span {
  color: #050607;
  background: var(--amber);
}

.terminal-search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-top: 0;
}

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

.terminal-search-form input {
  width: 100%;
  min-height: 42px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  color: var(--ink);
  background: #05070b;
  outline: none;
}

.terminal-search-form input:focus {
  border-color: rgba(102, 217, 239, 0.75);
  box-shadow: 0 0 0 2px rgba(102, 217, 239, 0.12);
}

.terminal-search-form button,
.terminal-timeframes button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: #1b2030;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 900;
}

.terminal-search-form button {
  padding: 0 18px;
}

.terminal-search-form button:hover,
.terminal-timeframes button:hover,
.terminal-timeframes button.is-active {
  border-color: rgba(139, 124, 255, 0.7);
  background: #24224a;
}

.terminal-source-pill {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--muted);
  background: #090d14;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.terminal-source-pill.is-live {
  color: var(--green);
}

.terminal-source-pill.is-fallback {
  color: var(--amber);
}

.terminal-grid {
  min-height: 650px;
  display: grid;
  grid-template-columns: minmax(230px, 270px) minmax(0, 1fr) minmax(270px, 330px);
  border-top: 0;
}

.terminal-sidebar,
.terminal-chart-panel,
.terminal-detail-panel {
  min-width: 0;
  padding: 14px;
}

.terminal-sidebar,
.terminal-chart-panel {
  border-right: 1px solid var(--line);
}

.panel-heading {
  display: grid;
  gap: 2px;
  margin-bottom: 12px;
}

.panel-heading p,
.terminal-chart-header p {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-heading h1,
.panel-heading h2,
.terminal-chart-header h2 {
  margin: 0;
  color: var(--ink);
  line-height: 1.05;
  font-size: 1.25rem;
}

.terminal-pool-list {
  display: grid;
  gap: 8px;
}

.pool-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  background: #0a0e15;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.pool-row:hover,
.pool-row.is-active {
  border-color: rgba(102, 217, 239, 0.52);
  background: #111827;
}

.pool-row strong,
.pool-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pool-row > span {
  display: grid;
  gap: 4px;
}

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

.pool-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pool-row small,
.pool-row > span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.pool-change {
  align-self: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
}

.is-up {
  color: var(--green);
}

.is-down {
  color: var(--red);
}

.terminal-chart-panel {
  display: grid;
  grid-template-rows: auto auto minmax(380px, 1fr) auto;
  gap: 12px;
}

.terminal-chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.terminal-price-stack {
  display: grid;
  justify-items: end;
  gap: 3px;
  font-family: var(--mono);
}

.terminal-price-stack strong {
  font-size: clamp(1.4rem, 3vw, 2.2rem);
}

.terminal-price-stack span {
  color: var(--muted);
  font-weight: 900;
}

.terminal-timeframes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.terminal-timeframes button {
  min-width: 54px;
  padding: 0 11px;
}

.terminal-chart {
  min-height: 380px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    #030405;
  background-size: 56px 56px;
  overflow: hidden;
}

.terminal-chart-fallback {
  min-height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-family: var(--mono);
  padding: 24px;
  text-align: center;
}

.terminal-note {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.terminal-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.terminal-stat-grid div {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  background: #090d14;
}

.terminal-stat-grid span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.terminal-stat-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.terminal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.terminal-sponsored-side {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 13px;
  border: 1px solid rgba(255, 191, 77, 0.28);
  border-radius: 7px;
  background: #171208;
}

.terminal-sponsored-side span,
.terminal-sponsor-row span {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.terminal-sponsored-side strong,
.terminal-sponsor-row strong {
  font-size: 1rem;
}

.terminal-sponsored-side p,
.terminal-sponsor-row p,
.terminal-footer {
  color: var(--muted);
  line-height: 1.45;
}

.terminal-sponsored-side p {
  margin: 0;
}

.terminal-sponsored-side a {
  width: fit-content;
  background: #2a1c08;
}

.terminal-sponsor-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-top: 0;
}

.terminal-sponsor-row article {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.terminal-sponsor-row article:last-child {
  border-right: 0;
}

.terminal-sponsor-row p {
  margin: 0;
}

.terminal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  border-top: 0;
  border-radius: 0 0 8px 8px;
  font-family: var(--mono);
  font-size: 0.72rem;
}

.terminal-footer a {
  color: var(--cyan);
  text-decoration: none;
}

@media (max-width: 1080px) {
  .terminal-grid {
    grid-template-columns: minmax(220px, 270px) minmax(0, 1fr);
  }

  .terminal-detail-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .terminal-shell {
    width: min(100% - 12px, 1500px);
    padding-top: 8px;
  }

  .terminal-topbar,
  .terminal-search-bar,
  .terminal-chart-header,
  .terminal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .terminal-topbar,
  .terminal-chart-header,
  .terminal-footer {
    display: flex;
  }

  .terminal-nav {
    justify-content: flex-start;
  }

  .terminal-search-bar,
  .terminal-search-form,
  .terminal-grid,
  .terminal-sponsor-row {
    grid-template-columns: 1fr;
  }

  .terminal-source-pill {
    justify-content: flex-start;
  }

  .terminal-sidebar,
  .terminal-chart-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .terminal-chart-panel {
    grid-template-rows: auto auto 360px auto;
  }

  .terminal-chart {
    min-height: 360px;
  }

  .terminal-price-stack {
    justify-items: start;
  }

  .terminal-sponsor-row article {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .terminal-sponsor-row article:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 480px) {
  .terminal-brand span {
    font-size: 0.78rem;
  }

  .terminal-stat-grid,
  .terminal-actions {
    grid-template-columns: 1fr;
  }

  .tape-item {
    min-width: 158px;
  }
}
