:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #151a20;
  --panel-2: #1b222b;
  --line: #29323d;
  --text: #ecf2f8;
  --muted: #8f9daa;
  --accent: #f0b90b;
  --accent-2: #48d597;
  --danger: #ff647c;
  --neutral: #aeb9c4;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(240, 185, 11, 0.08), transparent 240px),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 26, 32, 0.85);
  color: var(--muted);
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--neutral);
}

.status.loading .dot {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(240, 185, 11, 0.12);
}

.status.ok .dot {
  background: var(--accent-2);
}

.status.error .dot {
  background: var(--danger);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr)) minmax(132px, auto) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 32px var(--shadow);
}

.settingsPanel {
  display: grid;
  grid-template-columns: repeat(8, minmax(96px, 1fr));
  gap: 10px;
  align-items: end;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 26, 32, 0.74);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1318;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.14);
}

button {
  height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

button.primary {
  background: var(--accent);
  color: #15100a;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

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

.metric {
  min-height: 74px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
}

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

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

.chartPanel {
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.chartPanel[hidden] {
  display: none;
}

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

.chartHeader span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chartHeader strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.chartActions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ghostButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #0f1318;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.chartControls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 19, 24, 0.56);
}

textarea {
  width: 100%;
  min-height: 48px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1318;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
  font: inherit;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.14);
}

.tradingViewChart {
  height: min(70vh, 720px);
  min-height: 480px;
}

.tableShell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

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

.tableHeader h2 {
  display: none;
}

.tableTabs {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.tabButton {
  height: 34px;
  border: 1px solid var(--line);
  background: #0f1318;
  color: var(--muted);
}

.tabButton.active {
  border-color: rgba(240, 185, 11, 0.45);
  background: rgba(240, 185, 11, 0.14);
  color: var(--text);
}

.tableHeader p {
  color: var(--muted);
  font-size: 13px;
}

.tableWrap {
  overflow: auto;
  max-height: calc(100vh - 292px);
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(41, 50, 61, 0.7);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #11161c;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

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

tbody tr[data-symbol] {
  cursor: pointer;
}

tbody tr.selectedRow {
  background: rgba(240, 185, 11, 0.08);
}

.symbol {
  font-weight: 900;
}

.copySymbolButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 20px;
  margin-left: 6px;
  border: 1px solid rgba(143, 157, 170, 0.35);
  border-radius: 6px;
  padding: 0;
  background: rgba(15, 19, 24, 0.72);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  vertical-align: 1px;
}

.copySymbolButton:hover,
.copySymbolButton.copied {
  border-color: rgba(240, 185, 11, 0.55);
  color: var(--accent);
}

.copySymbolButton.copied {
  width: 48px;
  background: rgba(240, 185, 11, 0.12);
}

.favoriteButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  vertical-align: middle;
}

.favoriteButton:hover,
.favoriteButton.active {
  color: var(--accent);
}

.favoriteButton.active {
  background: rgba(240, 185, 11, 0.12);
}

.sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
}

.badge.bull {
  background: rgba(72, 213, 151, 0.14);
  color: var(--accent-2);
}

.badge.green {
  background: rgba(72, 213, 151, 0.16);
  color: #48d597;
}

.badge.bear {
  background: rgba(255, 100, 124, 0.14);
  color: var(--danger);
}

.badge.red {
  background: rgba(255, 100, 124, 0.16);
  color: #ff647c;
}

.badge.yellow {
  background: rgba(240, 185, 11, 0.16);
  color: #f0b90b;
}

.badge.blue {
  background: rgba(106, 168, 255, 0.16);
  color: #6aa8ff;
}

.badge.neutral {
  background: rgba(174, 185, 196, 0.12);
  color: var(--neutral);
}

.up {
  color: var(--accent-2);
}

.down {
  color: var(--danger);
}

.hist {
  font-variant-numeric: tabular-nums;
}

.macdCell {
  width: 350px;
  min-width: 350px;
}

.spark {
  width: 320px;
  height: 108px;
  display: block;
}

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

.errorBox {
  padding: 18px;
  color: var(--danger);
}

@media (max-width: 1050px) {
  .toolbar {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .settingsPanel {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

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

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

  .metric.wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .app {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
  }

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

  .toolbar,
  .settingsPanel,
  .metrics {
    grid-template-columns: 1fr;
  }

  .tableWrap {
    max-height: none;
  }

  .chartHeader {
    align-items: flex-start;
    flex-direction: column;
  }

  .chartActions {
    width: 100%;
  }

  .chartActions .ghostButton {
    flex: 1;
  }

  .tradingViewChart {
    min-height: 420px;
  }
}
