:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #131315;
  --panel-2: #1c1c1f;
  --panel-3: #232326;
  --line: #2a2a2e;
  --text: #f5f5f6;
  --muted: #8b8b90;
  --muted-soft: #55555a;
  --white: #ffffff;
  --green: #34d399;
  --green-strong: #16a76f;
  --green-bg: #102019;
  --red: #fb7185;
  --red-strong: #e0234f;
  --red-bg: #251218;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.shell { width: min(100%, 560px); margin: auto; padding: calc(16px + var(--safe-top)) 16px calc(36px + var(--safe-bottom)); }

.hidden { display: none !important; }
.label { display: block; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .02em; }

/* Multi-strategy tab switch (BTC5M_MULTI_STRATEGY_TERMINAL_V1, 2026-08-30) */
.strategy-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px;
}
.strategy-tab {
  border: none; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700;
  letter-spacing: .01em; padding: 10px 4px; border-radius: 9px; cursor: pointer;
}
.strategy-tab.active { background: var(--panel-3); color: var(--text); }
.twap-research-label { margin-top: 0; margin-bottom: 12px; text-transform: uppercase; letter-spacing: .04em; }
.twap-value-cell { display: flex; flex-direction: column; gap: 4px; }
.twap-value-cell small { color: var(--muted-soft); font-weight: 600; }
.twap-settlement-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.twap-settlement-grid dt { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.twap-settlement-grid dd { margin: 0; font-size: 15px; font-weight: 700; }

/* Header */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 20px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 17px; font-weight: 800;
}
.brand b { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; }
.live-pill {
  display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 11px; color: var(--muted); font-size: 11px; font-weight: 600;
}
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-soft); }
.live-pill.live i { background: var(--green); }

/* Price panel */
.price-panel { display: flex; justify-content: space-between; align-items: flex-end; padding: 4px 2px 0; }
.price-item { display: flex; flex-direction: column; gap: 4px; }
.price-item.align-right { align-items: flex-end; text-align: right; }
.price-item span { color: var(--muted); font-size: 12px; }
.price-item strong { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.price-item strong.current-price { color: var(--white); }
.window-meta {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 2px 18px;
  border-bottom: 1px solid var(--line); margin-bottom: 16px; color: var(--muted); font-size: 12px;
}
.clock { display: flex; align-items: baseline; gap: 6px; }
.clock strong { color: var(--text); font-weight: 700; font-size: 14px; }
.clock small { color: var(--muted); font-size: 11px; }

/* Shared card */
.trade-card, .position-card, .chart-card, .signal-card, .details-card, .history-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; margin-bottom: 12px;
}

/* Signal card — hero, kept quiet */
.signal-card { padding: 20px; }
.signal-top { display: flex; justify-content: space-between; align-items: flex-start; }
.signal-top h2 { margin: 4px 0 0; font-size: 30px; font-weight: 700; letter-spacing: -.015em; line-height: 1.05; }
.score { text-align: right; }
.score strong { display: block; font-size: 24px; font-weight: 700; }
.score span { color: var(--muted); font-size: 11px; }
.signal-card.up h2, .signal-card.up .score strong { color: var(--green); }
.signal-card.down h2, .signal-card.down .score strong { color: var(--red); }
.open-indicator {
  display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 14px;
  padding: 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line);
  transition: background .2s, border-color .2s;
}
.oi-arrow { font-size: 18px; line-height: 1; color: var(--muted-soft); min-width: 16px; text-align: center; }
.oi-label { font-size: 13px; font-weight: 700; letter-spacing: .03em; color: var(--muted); }
.open-indicator.lit-up { background: var(--green-bg); border-color: rgba(52, 211, 153, .45); }
.open-indicator.lit-up .oi-arrow, .open-indicator.lit-up .oi-label { color: var(--green); }
.open-indicator.lit-down { background: var(--red-bg); border-color: rgba(251, 113, 133, .45); }
.open-indicator.lit-down .oi-arrow, .open-indicator.lit-down .oi-label { color: var(--red); }
.open-indicator.in-position { background: var(--panel-3); border-color: var(--line); }
.open-indicator.in-position .oi-arrow, .open-indicator.in-position .oi-label { color: var(--text); }
/* RECON_V1_MANUAL_HIGH_CONVICTION_STATE_MACHINE_FIX -- a candidate is a live,
   still-changeable recommendation, not an executed position: dashed border
   and slightly lower opacity keep it visually distinct from in-position. */
.open-indicator.candidate { border-style: dashed; opacity: .82; }
.meter { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 16px 0 14px; }
.meter i { display: block; width: 0; height: 100%; background: var(--muted); border-radius: inherit; transition: width .35s; }
.signal-card.up .meter i { background: var(--green); }
.signal-card.down .meter i { background: var(--red); }
.comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.comparison > div { background: var(--panel-2); border-radius: 12px; padding: 12px; }
.comparison span { display: block; color: var(--muted); font-size: 11px; }
.comparison strong { display: block; margin-top: 4px; font-size: 16px; font-weight: 700; }
.edge-note { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); color: var(--muted); font-size: 12px; text-align: center; }

/* RECON_EVENT_GATED_V2 -- event/quality strip */
.gate-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.gate-row > div { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; }
.gate-row span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .03em; }
.gate-row strong { display: block; margin-top: 3px; font-size: 13px; font-weight: 700; }
.gate-domains { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.domain-chip { flex: 1; min-width: 40px; text-align: center; padding: 5px 4px; border-radius: 8px; background: var(--panel-2); color: var(--muted); font-size: 11px; font-weight: 700; }
.domain-chip.on { background: var(--green-bg); color: var(--green); }

/* Trade card */
.trade-title { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.trade-title h2 { margin: 0; font-size: 17px; font-weight: 700; }
.balance { text-align: right; }
.balance span { display: block; color: var(--muted); font-size: 11px; }
.balance strong { display: block; margin-top: 2px; color: var(--white); font-size: 16px; font-weight: 700; }
.pnl-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.pnl-row > div { background: var(--panel-2); border-radius: 10px; padding: 9px 10px; }
.pnl-row span { display: block; color: var(--muted); font-size: 10px; }
.pnl-row strong { display: block; margin-top: 3px; font-size: 13px; font-weight: 700; }
.pnl-row strong.pos { color: var(--green); }
.pnl-row strong.neg { color: var(--red); }

.secondary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.secondary-btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  border-radius: 10px; padding: 9px 0; font-size: 12px; font-weight: 600;
}
.secondary-btn:active { transform: scale(.97); }

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.side {
  display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line);
  background: var(--panel-2); border-radius: 12px; padding: 14px 15px; color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
}
.side:active { transform: scale(.98); }
.side:disabled { opacity: .4; }
.side span { font-size: 15px; font-weight: 600; }
.side strong { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.side.yes strong { color: var(--green); }
.side.no strong { color: var(--red); }
.side.selected.yes { border-color: var(--green-strong); background: var(--green-bg); }
.side.selected.no { border-color: var(--red-strong); background: var(--red-bg); }
.amount-block { background: var(--panel-2); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.amount-row { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.amount-display { font-size: 30px; font-weight: 700; margin: 6px 0 12px; color: var(--white); }
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.step {
  border: 1px solid var(--line); background: var(--panel-3); color: var(--text); border-radius: 9px;
  padding: 9px 0; font-size: 13px; font-weight: 600;
}
.step:active { transform: scale(.96); }
.step.reset { color: var(--muted); }
.cta {
  width: 100%; border: 0; border-radius: 12px; padding: 15px; font-size: 15px; font-weight: 700;
  background: var(--line); color: var(--muted);
}
.cta.ready-up { background: var(--green); color: #06281c; }
.cta.ready-down { background: var(--red); color: #2c0812; }
.cta:disabled { opacity: .55; }
/* Split layout only for the BUY button ("BUY UP    +$2.41 if win") -- other
   .cta buttons (auto-trade enable/confirm) keep the plain centered text. */
.cta.cta-split { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cta.cta-split small { font-size: 12px; font-weight: 600; opacity: .85; font-variant-numeric: tabular-nums; }
.risk-note { text-align: center; color: var(--muted-soft); font-size: 11px; margin: 12px 0 0; }

.auto-pill {
  width: 100%; margin-top: 12px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--muted); border-radius: 10px; padding: 10px; font-size: 12px; font-weight: 600;
}
.auto-pill.on { background: var(--green-bg); border-color: rgba(52, 211, 153, .35); color: var(--green); }
.auto-input {
  width: 100%; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 15px; font-variant-numeric: tabular-nums;
}
.auto-duration.selected { border-color: var(--white); background: var(--panel); color: var(--white); }
#autoConfirmRow .cta { margin-top: 8px; }
#autoDurationPresets { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
#autoSheet #autoStatusDetail { margin: 4px 0 18px; }
#autoSheet #autoEnableBtn { margin-top: 8px; }
#autoSheet #autoDisableBtn { margin-top: 18px; }
#autoSheet .cancel { margin-top: 12px; }

/* Position */
.position-card { border-color: var(--line); }
.position-head h2 { margin: 3px 0 0; font-size: 17px; font-weight: 700; }
.position-card dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.position-card dl div { background: var(--panel-2); border-radius: 10px; padding: 10px; }
.position-card dt { color: var(--muted); font-size: 10px; }
.position-card dd { margin: 3px 0 0; font-weight: 700; font-size: 13px; }
.exit {
  width: 100%; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--red); border-radius: 12px; padding: 12px; font-weight: 700; font-size: 14px;
}

/* Chart */
.chart-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
#chart, #dualChart { width: 100%; height: 170px; display: block; }

/* Details (collapsible signal tape) */
.details-card { padding: 0; overflow: hidden; }
.details-card summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px;
}
.details-card summary::-webkit-details-marker { display: none; }
.summary-meta { color: var(--muted); font-size: 12px; }
.summary-meta b { color: var(--text); font-weight: 700; }
.details-body { padding: 0 18px 18px; }
.targets-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.targets { display: flex; gap: 7px; overflow: auto; flex: 1; }
.target {
  min-width: 46px; padding: 7px; border: 1px solid var(--line); border-radius: 9px; text-align: center;
  color: var(--muted); font-size: 11px; font-weight: 600;
}
.target.hit { background: var(--green-bg); color: var(--green); border-color: rgba(52, 211, 153, .35); }
.targets-hit { color: var(--muted); font-size: 11px; white-space: nowrap; }
.signals { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.signal { display: grid; grid-template-columns: 7px 1fr auto; align-items: center; gap: 8px; padding: 9px 10px; background: var(--panel-2); border-radius: 10px; font-size: 12px; }
.signal i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-soft); }
.signal.bull i { background: var(--green); }
.signal.bear i { background: var(--red); }
.signal span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.signal b { font-size: 11px; font-weight: 600; }

/* History */
#historyWinrate { color: var(--white); font-size: 12px; font-weight: 600; }
.history-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.history-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 10px 0; }
.history-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 9px; padding: 10px 11px; background: var(--panel-2); border-radius: 10px; font-size: 12px; }
.history-row .dot { width: 6px; height: 6px; border-radius: 50%; }
.history-row.correct .dot { background: var(--green); }
.history-row.wrong .dot { background: var(--red); }
.history-row time { color: var(--muted); font-size: 11px; }
.history-row .call { font-weight: 600; }
.history-row .result { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 99px; }
.history-row.correct .result { background: var(--green-bg); color: var(--green); }
.history-row.wrong .result { background: var(--red-bg); color: var(--red); }

.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }

footer { text-align: center; color: var(--muted-soft); font-size: 11px; padding: 10px 0; }

/* Confirm sheet */
.sheet { position: fixed; inset: 0; z-index: 20; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .65); backdrop-filter: blur(3px); }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; margin: auto; width: min(100%, 560px);
  padding: 22px 18px calc(20px + var(--safe-bottom)); background: var(--panel);
  border: 1px solid var(--line); border-radius: 20px 20px 0 0;
}
.sheet-body h2 { margin: 6px 0 14px; font-size: 19px; font-weight: 700; }
.sheet-body p { font-size: 12px; color: var(--muted); line-height: 1.5; }
.review-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

.list-body { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; margin: 4px 0 14px; }
.list-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 0; }
.list-item { background: var(--panel-2); border-radius: 12px; padding: 12px 14px; }
.list-item .li-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.list-item .li-head b { font-size: 14px; }
.list-item .li-head time { color: var(--muted); font-size: 11px; }
.list-item dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; }
.list-item dt { color: var(--muted); font-size: 10px; }
.list-item dd { margin: 2px 0 0; font-size: 12px; font-weight: 700; }
.pnl-pos { color: var(--green); }
.pnl-neg { color: var(--red); }
.result-pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; }
.result-pill.win { background: var(--green-bg); color: var(--green); }
.result-pill.loss { background: var(--red-bg); color: var(--red); }
.side-pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--panel-3); }
#loadMoreHistory { width: 100%; margin-bottom: 10px; }
.cancel {
  width: 100%; margin-top: 4px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); border-radius: 12px; padding: 13px; font-weight: 600;
}

.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%);
  width: min(calc(100% - 32px), 480px); padding: 12px 15px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 12px; text-align: center; font-size: 12px;
}

@media (min-width: 640px) {
  .shell { padding-left: 24px; padding-right: 24px; }
  .signals { grid-template-columns: repeat(3, 1fr); }
  #chart, #dualChart { height: 220px; }
}
