:root {
  color-scheme: dark;
  --bg: #111615;
  --panel: #18201f;
  --panel-2: #202a28;
  --text: #edf5f1;
  --muted: #9fb0aa;
  --line: #33413e;
  --accent: #4fc3a1;
  --accent-2: #87a9ff;
  --bull: #40d38a;
  --bear: #ff6f7d;
  --warn: #ffcc66;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(79, 195, 161, 0.14), transparent 28rem),
    linear-gradient(135deg, #0f1413 0%, #141a1a 46%, #151c1a 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.6rem);
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
}

.status-pill,
.count-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.status-pill.loading {
  color: var(--accent);
  border-color: rgba(79, 195, 161, 0.6);
}

.control-grid,
.workspace-grid,
.metrics-grid,
.visual-grid,
.ops-grid {
  display: grid;
  gap: 16px;
}

.control-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.workspace-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  align-items: stretch;
}

.ops-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.visual-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-bottom: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 32, 31, 0.92);
  box-shadow: var(--shadow);
}

.settings-panel,
.input-panel,
.alert-panel,
.table-panel,
.visual-panel,
.heatmap-panel,
.telegram-panel,
.ops-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.heading-stack {
  display: grid;
  gap: 5px;
}

.last-updated {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.field-grid {
  display: grid;
  gap: 12px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #101615;
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 308px;
  resize: vertical;
  padding: 14px;
  line-height: 1.45;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.88rem;
}

.input-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.telegram-panel {
  margin-bottom: 16px;
}

.telegram-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  align-items: end;
  gap: 12px;
}

.telegram-enable {
  min-height: 42px;
  align-content: center;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 195, 161, 0.13);
}

.toggle-row,
.button-row,
.panel-actions,
.legend,
.results-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-row {
  margin-top: 14px;
}

.check {
  display: inline-flex;
  grid-template-columns: auto;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.check input {
  width: 17px;
  height: 17px;
}

.compact-check {
  min-height: 34px;
  align-content: center;
  color: var(--muted);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #08110e;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.06);
}

button:disabled {
  cursor: wait;
  filter: grayscale(0.35);
  opacity: 0.68;
}

button.secondary {
  color: var(--text);
  background: #2a3835;
}

button.ghost {
  min-height: 34px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
}

.panel-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.alert-list {
  display: grid;
  gap: 10px;
  max-height: 390px;
  overflow: auto;
  padding-right: 2px;
}

.alert-card {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-2);
}

.alert-card.bullish {
  border-left-color: var(--bull);
}

.alert-card.bearish {
  border-left-color: var(--bear);
}

.alert-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-weight: 900;
}

.alert-meta,
.empty-state {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 16px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(32, 42, 40, 0.82);
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric strong {
  display: block;
  font-size: 1.75rem;
}

.metric.bullish strong {
  color: var(--bull);
}

.metric.bearish strong {
  color: var(--bear);
}

.stat-grid,
.coverage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-grid div,
.coverage-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #101615;
}

.stat-grid span,
.coverage-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

.stat-grid strong,
.coverage-grid strong {
  display: block;
  font-size: 1.1rem;
}

.coverage-details {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #101615;
}

.coverage-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

.coverage-details p {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
}

.leaderboard-chart {
  display: grid;
  gap: 10px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 78px;
  align-items: center;
  gap: 10px;
}

.leaderboard-symbol {
  font-weight: 900;
}

.leaderboard-track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: #101615;
  border: 1px solid var(--line);
}

.leaderboard-bar {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 999px;
}

.leaderboard-bar.positive {
  background: linear-gradient(90deg, rgba(64, 211, 138, 0.55), var(--bull));
}

.leaderboard-bar.negative {
  background: linear-gradient(90deg, rgba(255, 111, 125, 0.48), var(--bear));
}

.leaderboard-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rotation-map {
  min-height: 340px;
}

.rotation-map svg {
  width: 100%;
  height: auto;
  display: block;
}

.rotation-axis {
  stroke: rgba(159, 176, 170, 0.35);
  stroke-width: 1;
}

.rotation-grid {
  stroke: rgba(159, 176, 170, 0.16);
  stroke-width: 1;
}

.rotation-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rotation-point {
  stroke: rgba(237, 245, 241, 0.88);
  stroke-width: 1.2;
}

.rotation-point.positive {
  fill: var(--bull);
}

.rotation-point.negative {
  fill: var(--bear);
}

.rotation-token {
  fill: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.heatmap-panel {
  margin-bottom: 16px;
}

.tier-heatmap {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.tier-group {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #101615;
}

.tier-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.tier-count {
  color: var(--text);
}

.tier-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  gap: 8px;
}

.heat-tile {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.heat-tile.positive {
  border-color: rgba(64, 211, 138, 0.46);
  background: rgba(64, 211, 138, var(--heat-alpha, 0.11));
}

.heat-tile.negative {
  border-color: rgba(255, 111, 125, 0.46);
  background: rgba(255, 111, 125, var(--heat-alpha, 0.1));
}

.heat-symbol {
  display: block;
  margin-bottom: 4px;
  font-weight: 900;
}

.heat-value {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow-x: auto;
}

.results-tools {
  display: grid;
  grid-template-columns: minmax(150px, 1.15fr) repeat(4, minmax(138px, 1fr)) auto;
  align-items: end;
  margin-bottom: 14px;
}

.result-count {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--muted);
  background: #101615;
  white-space: nowrap;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.035);
}

tbody tr.top-row {
  background: rgba(79, 195, 161, 0.08);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 900;
}

.top-row .rank-badge {
  color: #07130f;
  background: var(--accent);
  border-color: var(--accent);
}

.token {
  font-weight: 900;
}

.empty-table {
  color: var(--muted);
  text-align: center;
}

.sparkline {
  display: block;
  width: 96px;
  height: 32px;
}

.sparkline-axis {
  stroke: rgba(159, 176, 170, 0.28);
  stroke-width: 1;
}

.sparkline-path {
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-path.positive {
  stroke: var(--bull);
}

.sparkline-path.negative {
  stroke: var(--bear);
}

.sparkline-dot {
  stroke: #101615;
  stroke-width: 1.5;
}

.sparkline-dot.positive {
  fill: var(--bull);
}

.sparkline-dot.negative {
  fill: var(--bear);
}

.value-positive {
  color: var(--bull);
}

.value-negative {
  color: var(--bear);
}

.signal-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.signal-pill.bullish {
  color: #052015;
  background: var(--bull);
}

.signal-pill.bearish {
  color: #25080c;
  background: var(--bear);
}

.signal-pill.neutral {
  color: var(--muted);
  border: 1px solid var(--line);
  background: transparent;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-badge.outperforming {
  color: #052015;
  background: rgba(64, 211, 138, 0.92);
}

.status-badge.underperforming {
  color: #25080c;
  background: rgba(255, 111, 125, 0.92);
}

.status-badge.matched {
  color: var(--muted);
  border: 1px solid var(--line);
  background: transparent;
}

.severity-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.severity-badge.watch {
  color: var(--muted);
  border: 1px solid var(--line);
  background: transparent;
}

.severity-badge.active {
  color: #07130f;
  background: var(--warn);
}

.severity-badge.strong {
  color: #06150f;
  background: var(--bull);
}

.severity-badge.extreme {
  color: #24080c;
  background: var(--bear);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot.bull {
  background: var(--bull);
}

.dot.bear {
  background: var(--bear);
}

.dot.flat {
  background: var(--muted);
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100vw - 20px, 760px);
    padding-top: 18px;
  }

  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-grid,
  .workspace-grid,
  .metrics-grid,
  .visual-grid,
  .ops-grid,
  .results-tools,
  .telegram-grid,
  .field-grid.two {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.2rem;
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ops-grid {
    grid-template-columns: 1fr;
  }

  .telegram-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tier-heatmap {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .tier-heatmap {
    grid-template-columns: 1fr;
  }
}
