:root {
  --bg: #02060b;
  --bg-bottom: #07131d;
  --panel: rgba(7, 12, 18, 0.94);
  --panel-soft: rgba(9, 16, 24, 0.88);
  --screen: #071723;
  --line: rgba(112, 138, 168, 0.22);
  --line-strong: rgba(146, 180, 214, 0.34);
  --text: #edf4fb;
  --muted: #8fa5bd;
  --accent: #6ea8ff;
  --accent-soft: rgba(110, 168, 255, 0.14);
  --success: #4bb58f;
  --warning: #d5a949;
  --danger: #d46a62;
  --sell: #9397a3;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.38);
  --monitor-shadow: 0 30px 90px rgba(0, 0, 0, 0.54);
  color-scheme: dark;
  font-family: "Inter", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 120%, rgba(31, 77, 126, 0.4), transparent 34%),
    linear-gradient(180deg, var(--bg) 0%, #03080f 45%, var(--bg-bottom) 100%);
}

body {
  min-height: 100vh;
}

body.overlay-open {
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 10px 12px 8px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 2px;
}

.deck-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(640px, 1fr) minmax(280px, 320px);
  gap: 2px;
}

.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10, 15, 23, 0.97), rgba(7, 11, 17, 0.95));
  box-shadow: var(--shadow);
}

.sidebar,
.sources-panel,
.hero-panel,
.matrix-panel,
.rationale-panel {
  min-height: 0;
}

.sidebar,
.sources-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-tabbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.panel-tabbar__button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.panel-tabbar__button:last-child {
  border-right: 0;
}

.panel-tabbar__button.is-active {
  background: rgba(110, 168, 255, 0.12);
  color: var(--text);
}

.side-panel-view {
  min-height: 0;
  display: none;
  gap: 14px;
}

.side-panel-view.is-active {
  display: grid;
}

.sidebar-header,
.section-header,
.watchlist-item,
.signal-detail__header,
.metric-grid,
.source-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-header {
  align-items: flex-start;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(110, 168, 255, 0.16);
}

.brand-mark,
.eyebrow,
.section-header h2,
.watchlist-item__symbol,
.signal-badge,
.stat-card__label,
.detail-chip,
.source-pill {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.brand-mark,
.eyebrow {
  margin: 0 0 6px;
  color: #8eb7ff;
  font-size: 0.72rem;
  font-weight: 700;
}

h1,
.hero-panel h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
}

h1 {
  font-size: clamp(1.15rem, 1.5vw, 1.65rem);
  line-height: 1;
}

.sidebar-intro,
.hero-summary__lead,
.source-card p,
.strategy-item p,
.setting-card p,
.signal-detail p {
  margin: 0;
  color: #c0cfde;
  line-height: 1.55;
}

.status-badge,
.text-button,
.source-pill,
.detail-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.status-badge,
.source-pill,
.detail-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.72rem;
}

.status-badge.is-ok {
  border-color: rgba(75, 181, 143, 0.36);
  background: rgba(75, 181, 143, 0.13);
}

.status-badge.is-error {
  border-color: rgba(212, 106, 98, 0.36);
  background: rgba(212, 106, 98, 0.13);
}

.text-button {
  min-height: 34px;
  padding: 7px 11px;
}

.text-button--small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 0.78rem;
}

.text-button:hover,
.watchlist-item:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-weight: 700;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-section,
.sources-panel__section,
.strategy-list,
.settings-list,
.source-list,
.overview-strip,
.watchlist {
  display: grid;
  gap: 10px;
}

.sidebar-section {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-section--compact {
  padding-top: 10px;
}

.sidebar-section--grow {
  flex: 1;
  min-height: 0;
}

.watchlist,
.settings-list,
.signal-detail {
  overflow: auto;
}

.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stats-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
}

.stats-pill__label {
  color: var(--muted);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stats-pill__value {
  font-size: 0.86rem;
  font-weight: 600;
}

.watchlist-item,
.setting-card,
.strategy-item,
.stat-card,
.source-card,
.signal-detail__panel {
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.watchlist-item {
  width: 100%;
  text-align: left;
  color: inherit;
}

.watchlist-item.is-active {
  border-color: rgba(110, 168, 255, 0.36);
  background: rgba(110, 168, 255, 0.1);
}

.watchlist-item__copy {
  min-width: 0;
}

.watchlist-item__symbol {
  margin: 0 0 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.watchlist-item__name,
.stat-card__value,
.detail-metric strong {
  font-size: 1rem;
  font-weight: 600;
}

.watchlist-item__price,
.section-meta,
.setting-card small,
.detail-metric span,
.signal-table td small {
  color: var(--muted);
}

.center-stage {
  min-height: 0;
}

.hero-panel {
  padding: 12px 14px;
  display: grid;
  gap: 12px;
  box-shadow: var(--monitor-shadow);
}

.hero-panel__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.hero-panel__titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-panel__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-items: end;
  align-items: center;
}

.hero-panel__timestamp {
  color: var(--muted);
  font-size: 0.85rem;
}

.hero-compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.overview-strip,
.strategy-list--compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.overview-strip--compact .stat-card {
  padding: 8px 10px;
}

.overview-strip--compact .stat-card__value {
  margin-top: 6px;
  font-size: 0.92rem;
}

.strategy-list--compact {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.strategy-item--compact {
  min-width: 110px;
  padding: 8px 10px;
}

.strategy-item--compact strong {
  font-size: 0.84rem;
}

.strategy-item--compact p {
  font-size: 0.76rem;
}

.stat-card__label,
.detail-chip,
.source-pill {
  font-size: 0.68rem;
  color: var(--muted);
}

.stat-card__value {
  margin-top: 10px;
}

.strategy-item,
.setting-card {
  display: grid;
  gap: 8px;
}

.setting-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-card__values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.timeframe-switch {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.timeframe-switch__button {
  min-width: 56px;
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.timeframe-switch__button:last-child {
  border-right: 0;
}

.timeframe-switch__button.is-active {
  background: rgba(110, 168, 255, 0.12);
  color: var(--text);
}

.setting-chip {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.lower-deck {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 2px;
}

.matrix-panel,
.rationale-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.signal-table {
  width: 100%;
  border-collapse: collapse;
}

.signal-table th,
.signal-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  font-size: 0.9rem;
  vertical-align: top;
}

.signal-table th {
  position: sticky;
  top: 0;
  background: #0a121b;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.signal-table tbody tr {
  cursor: pointer;
}

.signal-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.signal-table tbody tr.is-active {
  background: rgba(110, 168, 255, 0.08);
}

.signal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 118px;
  min-height: 30px;
  padding: 5px 9px;
  font-size: 0.68rem;
  border: 1px solid transparent;
}

.signal-buy {
  color: #b8f3de;
  background: rgba(75, 181, 143, 0.16);
  border-color: rgba(75, 181, 143, 0.32);
}

.signal-watch {
  color: #fdebb6;
  background: rgba(213, 169, 73, 0.16);
  border-color: rgba(213, 169, 73, 0.32);
}

.signal-avoid {
  color: #ffd6d2;
  background: rgba(212, 106, 98, 0.16);
  border-color: rgba(212, 106, 98, 0.32);
}

.signal-sell,
.signal-waiting {
  color: #dde0e6;
  background: rgba(147, 151, 163, 0.16);
  border-color: rgba(147, 151, 163, 0.3);
}

.signal-detail {
  min-height: 280px;
}

.signal-detail__panel {
  display: grid;
  gap: 14px;
}

.chart-panel {
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 10px;
}

.chart-panel__header,
.chart-panel__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chart-panel__title {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
}

.chart-panel__subtle {
  color: var(--muted);
  font-size: 0.82rem;
}

.chart-stack {
  display: grid;
  gap: 8px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 0.78rem;
}

.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chart-legend__line {
  width: 18px;
  height: 0;
  border-top: 2px solid transparent;
}

.chart-legend__line--ema-fast {
  border-color: #7dc4ff;
}

.chart-legend__line--ema-slow {
  border-color: #d5a949;
}

.price-chart {
  width: 100%;
  height: 200px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(110, 168, 255, 0.04), rgba(110, 168, 255, 0.01)),
    rgba(255, 255, 255, 0.01);
}

.price-chart__grid {
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 1;
}

.price-chart__last-guide {
  stroke: rgba(207, 224, 255, 0.32);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.price-chart__ema {
  fill: none;
  stroke-width: 1.75;
  vector-effect: non-scaling-stroke;
}

.price-chart__ema--fast {
  stroke: #7dc4ff;
}

.price-chart__ema--slow {
  stroke: #d5a949;
}

.price-chart__wick {
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
}

.price-chart__body {
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.price-chart__candle.is-up .price-chart__wick,
.price-chart__candle.is-up .price-chart__body {
  stroke: #4bb58f;
}

.price-chart__candle.is-up .price-chart__body {
  fill: rgba(75, 181, 143, 0.36);
}

.price-chart__candle.is-down .price-chart__wick,
.price-chart__candle.is-down .price-chart__body {
  stroke: #d46a62;
}

.price-chart__candle.is-down .price-chart__body {
  fill: rgba(212, 106, 98, 0.3);
}

.volume-chart {
  width: 100%;
  height: 72px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.01);
}

.volume-chart__baseline {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.volume-chart__bar.is-up {
  fill: rgba(75, 181, 143, 0.44);
}

.volume-chart__bar.is-down {
  fill: rgba(212, 106, 98, 0.38);
}

.chart-empty {
  min-height: 200px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
}

.timeframe-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.timeframe-card {
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 6px;
  text-align: left;
  color: inherit;
}

.timeframe-card.is-active {
  border-color: rgba(110, 168, 255, 0.4);
  background: rgba(110, 168, 255, 0.1);
}

.timeframe-card__head,
.timeframe-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.timeframe-card__label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.timeframe-card__price,
.timeframe-card__time {
  color: var(--muted);
  font-size: 0.84rem;
}

.signal-detail__header {
  align-items: flex-start;
}

.signal-detail__title {
  margin: 0;
  font-size: 1.15rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.detail-metric {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 4px;
}

.detail-reasons {
  margin: 0;
  padding-left: 18px;
  color: #d7e4f2;
  display: grid;
  gap: 8px;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state--block {
  min-height: 240px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
}

@media (max-width: 1280px) {
  .deck-grid,
  .lower-deck,
  .hero-compact {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-rows: auto auto;
  }
}

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

  .overview-strip,
  .strategy-list--compact,
  .setting-card__values,
  .metric-grid,
  .timeframe-grid {
    grid-template-columns: 1fr;
  }

  .signal-table th:nth-child(5),
  .signal-table th:nth-child(6),
  .signal-table td:nth-child(5),
  .signal-table td:nth-child(6) {
    display: none;
  }
}

.admin-form,
.admin-grid,
.admin-coins-list {
  display: grid;
  gap: 10px;
}

.admin-form--compact {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.field input,
.field select {
  min-height: 36px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--line-strong);
}

.admin-inline-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-inline-status.is-ok {
  color: #b8f3de;
}

.admin-inline-status.is-error {
  color: #ffd6d2;
}

.admin-coin-card {
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 10px;
}

.admin-coin-card__header,
.admin-coin-card__meta,
.admin-coin-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-coin-card__meta {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-state-field {
  display: grid;
  gap: 6px;
  min-width: 128px;
}

.admin-state-field span {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.admin-state-field select {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 11, 0.72);
}

.overlay__dialog {
  position: relative;
  width: min(720px, calc(100vw - 32px));
  max-height: min(78vh, 860px);
  margin: 56px auto;
  padding: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10, 15, 23, 0.99), rgba(7, 11, 17, 0.97));
  box-shadow: var(--monitor-shadow);
  overflow: auto;
}

.overlay__header,
.overlay__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.overlay__header {
  margin-bottom: 14px;
}

.admin-state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.admin-state-pill.is-active {
  color: #b8f3de;
  background: rgba(75, 181, 143, 0.12);
  border-color: rgba(75, 181, 143, 0.3);
}

.admin-state-pill.is-inactive {
  color: #ffd6d2;
  background: rgba(212, 106, 98, 0.12);
  border-color: rgba(212, 106, 98, 0.3);
}

@media (max-width: 720px) {
  .admin-form--compact,
  .admin-grid {
    grid-template-columns: 1fr;
  }
}
