:root {
  --bg: #0a0e14;
  --panel: #121820;
  --border: #1e2a38;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --green: #3dd68c;
  --red: #f07178;
  --accent: #6eb6ff;
  --amber: #e6c07b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.banner {
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.banner-loading {
  background: #1a2430;
  color: var(--muted);
}

.banner-ok {
  background: #14241c;
  color: var(--green);
}

.banner-warn {
  background: #2a2418;
  color: var(--amber);
}

.banner-error {
  background: #2a1818;
  color: var(--red);
}

.header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.controls {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tf-toggle {
  margin-bottom: 0.35rem;
}

.tf-toggle .mode-btn {
  min-width: 2.5rem;
  font-size: 0.78rem;
}

.mode-toggle {
  display: flex;
  gap: 0.35rem;
}

.mode-btn {
  flex: 1;
  padding: 0.55rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  font-weight: 600;
}

.mode-btn.active {
  border-color: var(--accent);
  background: #1a2a40;
  color: var(--accent);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.primary {
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #061018;
  font-weight: 700;
  font-size: 0.95rem;
}

.primary:disabled {
  opacity: 0.5;
}

.panel {
  margin: 0.75rem 1rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.master-summary {
  font-size: 0.95rem;
  line-height: 1.45;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.chip {
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  background: var(--bg);
}

.chip-long {
  color: var(--green);
  border-color: #2a5a40;
}

.chip-short {
  color: var(--red);
  border-color: #5a2a30;
}

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

.chip-watch {
  color: var(--muted);
  border-color: var(--border);
  border-style: dashed;
}

.chip-enter {
  font-weight: 600;
}

.chip-long.chip-enter {
  background: rgba(46, 160, 67, 0.12);
}

.chip-short.chip-enter {
  background: rgba(248, 81, 73, 0.12);
}

.bias-enter {
  box-shadow: 0 0 0 1px var(--green);
}

.pairs {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0 1rem;
}

.pair-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.pair-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.pair-head h3 {
  margin: 0;
  font-size: 1.1rem;
}

.bias {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.bias-LONG {
  background: #14241c;
  color: var(--green);
}

.bias-SHORT {
  background: #2a1818;
  color: var(--red);
}

.bias-NO_TRADE,
.bias-NEUTRAL {
  background: #1a2430;
  color: var(--muted);
}

.news-line {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.65rem 0 0;
}

.metrics {
  margin-top: 0.65rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.metrics-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.65rem;
}

.regime-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.regime-RISK_ON {
  background: #14241c;
  color: var(--green);
}

.regime-RISK_OFF {
  background: #2a1818;
  color: var(--red);
}

.regime-TRANSITION {
  background: #2a2418;
  color: var(--amber);
}

.price-tag {
  font-weight: 700;
  font-size: 0.95rem;
}

.tf-tag {
  font-size: 0.72rem;
  color: var(--muted);
}

.score-row {
  margin: 0.45rem 0 0.15rem;
}

.score-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.score-track {
  height: 6px;
  background: #1a2430;
  border-radius: 999px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 999px;
}

.score-good {
  background: var(--green);
}

.score-mid {
  background: var(--amber);
}

.score-bad {
  background: var(--red);
}

.metric-note {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.indicator-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem 0.75rem;
  margin: 0.65rem 0;
  font-size: 0.78rem;
}

.indicator-grid dt {
  color: var(--muted);
  margin: 0;
}

.indicator-grid dd {
  margin: 0;
  font-weight: 600;
}

.reason-box,
.levels-box,
.mtf-box,
.gate-box {
  margin-top: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.45;
  background: #1a2430;
}

.gate-ok {
  border-left: 3px solid var(--green);
}

.gate-skip {
  border-left: 3px solid var(--muted);
}

.structure-chart-block {
  margin-top: 0.65rem;
  padding: 0.55rem;
  background: #0d1218;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.structure-chart-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
}

.chart-hint {
  color: var(--muted);
  font-size: 0.72rem;
}

.structure-chart {
  display: block;
  width: 100%;
  border-radius: 6px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  margin-top: 0.45rem;
  font-size: 0.68rem;
  color: var(--muted);
}

.leg {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.leg::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.leg-zone::before {
  background: rgba(230, 192, 123, 0.55);
}

.leg-box::before {
  background: rgba(110, 182, 255, 0.75);
}

.leg-tp::before {
  background: rgba(61, 214, 140, 0.85);
}

.leg-stop::before {
  background: var(--red);
}

.steps-details {
  margin-top: 0.65rem;
}

.steps-details summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.steps li {
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}

.step-agent {
  color: var(--accent);
  font-weight: 600;
  text-transform: capitalize;
}

.step-ms {
  color: var(--muted);
  font-size: 0.75rem;
}

.exec-ok {
  color: var(--green);
}

.exec-fail {
  color: var(--red);
}

.journal-panel {
  margin-bottom: 2rem;
}

.journal {
  list-style: none;
  margin: 0;
  padding: 0;
}

.journal li {
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}

.journal time {
  color: var(--muted);
  display: block;
  font-size: 0.75rem;
}

.validation-panel {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.validation-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.validation-head h2 {
  margin: 0;
}

.validation-badge {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid var(--border);
}

.validation-badge-pending {
  color: var(--amber);
  border-color: #5a4a28;
  background: #2a2418;
}

.validation-badge-ready {
  color: var(--green);
  border-color: #2a5a40;
  background: #14241c;
}

.validation-badge-blocked {
  color: var(--red);
  border-color: #5a3030;
  background: #2a1818;
}

.validation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.validation-card {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.validation-label {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.validation-value {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.95rem;
}

.validation-detail {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.validation-gates {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.validation-gates li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
}

.validation-gates li:first-child {
  border-top: none;
  padding-top: 0;
}

.gate-pass {
  color: var(--green);
}

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

.gate-detail {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.validation-footnote {
  margin: 0.65rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.paper-panel {
  margin-bottom: 2rem;
}

.paper-hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.paper-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.paper-stat strong {
  color: var(--green);
}

.paper-plays {
  list-style: none;
  margin: 0;
  padding: 0;
}

.paper-plays li {
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}

.paper-plays time {
  color: var(--muted);
  display: block;
  font-size: 0.75rem;
}

.paper-win .paper-pair {
  color: var(--green);
}

.paper-loss .paper-pair {
  color: var(--red);
}

.paper-open .paper-pair {
  color: var(--amber);
}

@media (min-width: 720px) {
  .validation-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }

  .controls {
    min-width: 280px;
    margin-top: 0;
  }

  .pairs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}
