:root {
  --bg: #0b0e11;
  --panel: #15191f;
  --panel-2: #1b2028;
  --panel-3: #11151b;
  --line: #2b3139;
  --text: #f5f5f5;
  --muted: #8b93a6;
  --accent: #f7a600;
  --accent-soft: rgba(247, 166, 0, 0.14);
  --green: #16c784;
  --red: #ef454a;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(247, 166, 0, 0.08), transparent 20%),
    linear-gradient(180deg, #111418 0%, #090b0f 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

.topbar,
.market-strip,
.panel,
.badge,
.mini-card,
.feed-item,
.metric-tile {
  border: 1px solid var(--line);
}

.topbar,
.market-strip,
.panel {
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 14px 14px 10px 10px;
}

.scanner-pulse-shell {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #12161c;
  min-width: 210px;
}

.scanner-pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #6b7280;
}

.scanner-pulse-shell.live .scanner-pulse-dot {
  background: var(--green);
  animation: scannerPulse 1.4s infinite;
}

.scanner-pulse-label {
  font-size: 0.84rem;
  font-weight: 700;
}

.scanner-pulse-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f7a600 0%, #ffcc55 100%);
  color: #111;
  font-weight: 700;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 0.82rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions a {
  text-decoration: none;
}

.btn {
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 10px 14px;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #111;
  font-weight: 700;
  border-color: #d69100;
}

.btn-ghost {
  background: #20252d;
  color: var(--text);
}

.market-strip {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-top: 10px;
  padding: 14px 18px;
  border-radius: 10px;
}

.market-main .pair {
  font-size: 1.35rem;
  font-weight: 700;
}

.market-main .pair-type {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}

.market-metrics,
.history-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  width: 100%;
}

.metric-tile {
  background: var(--panel-3);
  border-radius: 10px;
  padding: 10px 12px;
}

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

.metric-tile strong {
  font-size: 0.98rem;
}

.terminal-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 0.95fr);
  gap: 12px;
  margin-top: 12px;
}

.panel {
  border-radius: 12px;
  padding: 16px;
}

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

.panel-title {
  font-size: 1rem;
  font-weight: 700;
}

.panel-caption {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

.header-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.76rem;
}

.badge-muted {
  background: #20252d;
  color: #c4cad4;
}

.badge-running {
  background: rgba(22, 199, 132, 0.14);
  color: var(--green);
}

.chart-stage {
  position: relative;
  height: 520px;
  border-radius: 14px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
    linear-gradient(135deg, #0f1318 0%, #161b22 100%);
  border: 1px solid var(--line);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.chart-stage.live {
  border-color: rgba(22, 199, 132, 0.45);
  box-shadow: inset 0 0 0 1px rgba(22, 199, 132, 0.18), 0 0 28px rgba(22, 199, 132, 0.08);
}

.chart-canvas {
  position: absolute;
  inset: 0;
}

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

.chart-overlay {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.timeframe-strip {
  display: flex;
  gap: 6px;
}

.tf-chip {
  background: #20252d;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.tf-chip.active {
  color: var(--text);
  background: #2a3039;
  border-color: #48515e;
}

.chart-stat,
.mini-card {
  background: rgba(11, 14, 17, 0.84);
  border-radius: 10px;
  padding: 10px 12px;
}

.chart-stat span,
.mini-card span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 5px;
}

.ema-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.ema-card {
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.ema-card h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.ema-card .price {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.trade-panel {
  min-height: 100%;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  background: #20252d;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
}

.tab.active {
  color: var(--accent);
  background: rgba(247,166,0,0.08);
  border-color: rgba(247,166,0,0.28);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.stack-form label {
  display: grid;
  gap: 7px;
  font-size: 0.85rem;
  color: #d2d7df;
}

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

input:disabled {
  color: #6b7280;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.metric-panel {
  min-height: 150px;
}

.metric-title {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.metric-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.stats-filter-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.stats-chart {
  min-height: 280px;
}

.stats-chart-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}

.stats-table-row {
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr;
}

.feed-list,
.table-like {
  display: grid;
  gap: 10px;
}

.logic-panel {
  margin-top: 12px;
}

.logic-grid {
  display: grid;
  gap: 10px;
}

.logic-summary {
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.logic-summary strong {
  display: block;
  margin-bottom: 6px;
}

.logic-row {
  display: grid;
  grid-template-columns: 160px 90px 1fr;
  gap: 12px;
  align-items: start;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.logic-label {
  font-weight: 700;
}

.logic-state {
  font-size: 0.76rem;
  border-radius: 999px;
  padding: 6px 10px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.logic-state-pass {
  background: rgba(22, 199, 132, 0.14);
  color: var(--green);
}

.logic-state-warn {
  background: rgba(247, 166, 0, 0.14);
  color: var(--accent);
}

.logic-state-block {
  background: rgba(239, 69, 74, 0.14);
  color: var(--red);
}

.feed-item {
  background: var(--panel-3);
  border-radius: 10px;
  padding: 12px;
}

.feed-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.feed-title {
  font-weight: 700;
}

.signal-long,
.pnl-positive {
  color: var(--green);
}

.signal-short,
.pnl-negative {
  color: var(--red);
}

.feed-meta {
  color: var(--muted);
  font-size: 0.8rem;
  display: grid;
  gap: 4px;
}

.history-panel {
  margin-top: 12px;
}

.table-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr;
  gap: 10px;
  align-items: center;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.88rem;
}

.empty-state {
  color: var(--muted);
  padding: 12px 2px;
}

.modal-shell {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal-shell.hidden {
  display: none;
}

@keyframes scannerPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 199, 132, 0.34);
    transform: scale(1);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(22, 199, 132, 0);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 199, 132, 0);
    transform: scale(1);
  }
}

.modal-card {
  width: min(760px, calc(100% - 24px));
  background: #1d1d1d;
  border: 1px solid #363636;
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.modal-header,
.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  color: #f3f4f6;
  border: none;
  font-size: 2rem;
  cursor: pointer;
}

.modal-tabs {
  display: flex;
  gap: 24px;
  margin: 18px 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid #404040;
}

.modal-tab {
  color: #d1d5db;
  font-weight: 600;
}

.modal-tab.active {
  position: relative;
}

.modal-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -13px;
  height: 3px;
  border-radius: 999px;
  background: #f3f4f6;
}

.ma-ribbon-form {
  display: grid;
  gap: 14px;
}

.ma-row {
  display: grid;
  grid-template-columns: auto 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
}

.ma-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e5e7eb;
}

.ma-fixed-field {
  width: 100%;
  background: #242424;
  color: #d1d5db;
  border: 1px solid #4b5563;
  border-radius: 8px;
  padding: 10px 12px;
}

.ma-row input[type="number"],
.ma-row select,
.ma-row input[type="color"] {
  width: 100%;
}

.ma-row input[type="color"] {
  min-width: 52px;
  padding: 2px;
  height: 42px;
}

.ma-meta {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid #404040;
  display: grid;
  gap: 14px;
}

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

@media (max-width: 720px) {
  .app-shell {
    width: calc(100% - 12px);
  }

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

  .split,
  .table-row,
  .ma-row,
  .logic-row {
    grid-template-columns: 1fr;
  }

  .chart-stage {
    height: 280px;
  }
}
