:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #080808;
  --panel: rgba(24, 24, 24, 0.72);
  --panel-2: rgba(32, 32, 32, 0.78);
  --panel-3: #1a1a1a;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #e8e8e8;
  --muted: #9a9a9a;
  --green: #20d07a;
  --red: #ff4d64;
  --yellow: #e1b64b;
  --blue: #8aa1b6;
  --cyan: #0f6f68;
  --soft: rgba(36, 36, 36, 0.78);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: linear-gradient(135deg, #070707 0%, #111 45%, #080808 100%);
  color: var(--text);
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

.shell {
  width: min(1680px, calc(100vw - 28px));
  height: 100dvh;
  margin: 0 auto;
  padding: 10px 0 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  align-items: end;
  gap: 14px;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--line);
}

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

h1,
p {
  margin: 0;
}

h1 {
  font-family: "Space Grotesk", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.brand p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 12px;
}

.status-pill,
.phase {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
  background: var(--panel);
  color: var(--text);
  font: 12px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
}

.dot.live {
  background: var(--green);
  box-shadow: 0 0 14px rgba(32, 208, 122, 0.35);
}

.dot.error {
  background: var(--red);
  box-shadow: 0 0 14px rgba(255, 82, 106, 0.35);
}

.controls {
  display: grid;
  grid-template-columns: 94px 82px 86px 100px 76px 84px 84px 160px;
  gap: 8px;
  align-items: end;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

select,
input,
button {
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
}

input {
  min-width: 0;
}

.source-toggles {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel-2);
}

.source-toggle {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.source-toggle input {
  width: 14px;
  height: 14px;
  min-width: 14px;
  padding: 0;
  accent-color: var(--green);
}

button {
  cursor: pointer;
  background: var(--soft);
  font-weight: 700;
}

.dashboard {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 10px;
}

.chart-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.side-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto;
  gap: 10px;
}

.panel,
.chart-panel,
.market-strip {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.008)),
    linear-gradient(180deg, var(--panel-2), var(--panel));
  border-radius: 8px;
  overflow: hidden;
}

.market-strip {
  min-height: 58px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--panel-3);
}

.metric {
  min-width: 0;
  padding: 8px 10px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric-label {
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.metric-value {
  font: 700 14px/1.15 ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-panel {
  min-width: 0;
  min-height: 0;
  position: relative;
}

.main-chart {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.main-chart canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.indicator-tag {
  position: absolute;
  left: 14px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 28px);
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(18, 18, 18, 0.88);
  color: var(--text);
  font: 700 12px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  pointer-events: none;
}

.indicator-tag span {
  color: var(--muted);
  font-weight: 600;
}

.coin-tag span {
  color: #c49adf;
}

.coin-tag {
  top: calc(64% + 10px);
}

.delta-tag span {
  color: #73bf6a;
}

.delta-tag {
  top: calc(82% + 10px);
}

.panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-head {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.panel-head strong {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.summary {
  padding: 8px;
  display: grid;
  gap: 6px;
}

.summary-row {
  display: grid;
  grid-template-columns: 44px repeat(3, minmax(0, 1fr));
  gap: 7px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.018);
}

.summary-row strong,
.summary-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 12px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.alerts-panel {
  min-height: 0;
}

.alerts {
  min-height: 0;
  overflow: auto;
  padding: 9px;
  display: grid;
  align-content: start;
  gap: 7px;
  font: 12px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.alert {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.018);
}

.alert-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

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

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

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

.warn {
  color: var(--yellow);
}

.blue {
  color: var(--blue);
}

.phase.ANOMALY {
  color: var(--red);
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    min-height: 100dvh;
  }

  .topbar,
  .dashboard {
    grid-template-columns: 1fr;
  }

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

  .side-column {
    grid-template-rows: auto auto;
  }

  .chart-panel {
    height: 720px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 16px, 1680px);
  }

  .brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .controls,
  .market-strip {
    grid-template-columns: 1fr;
  }

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-row {
    grid-template-columns: 48px 1fr 1fr;
  }

  .indicator-tag {
    display: none;
  }
}
