/* Phase E13.2 -- shared styling for the MANUAL_DZ scalping dashboard.
   Color tokens/zone-band/marker conventions ported from UI-B's own
   index.html (research_artifacts/manual_dz_replay/index.html) to keep
   visual parity -- UI-B itself is never modified. */
:root {
  --bg: #0A0F0D;
  --panel: #12181A;
  --panel-2: #161D20;
  --panel-3: #1B2225;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.16);
  --text: #E7ECEF;
  --muted: #8A96A3;
  --muted-2: #5C6773;
  --bull: #26D9A8;
  --bear: #FF4D6D;
  --amber: #E3B04B;
  --blue: #4DA3FF;
  --forming: #A78BFA;
  --live-color: #26D9A8;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px; -webkit-font-smoothing: antialiased;
}
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
a { color: var(--blue); text-decoration: none; }
button, select { font-family: inherit; }

#app { display: flex; flex-direction: column; min-height: 100vh; width: 100%; }

#topbar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-size: 14px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.brand .sub { font-size: 11px; color: var(--muted); font-weight: 600; margin-left: 8px; }
.spacer { flex: 1; }
.nav-link { font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 7px; color: var(--muted); }
.nav-link.active { color: var(--text); background: var(--panel-2); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; padding: 5px 10px; border-radius: 999px; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.live { color: var(--bull); border-color: rgba(38,217,168,0.4); background: rgba(38,217,168,0.08); }
.badge.live .dot { animation: pulse 1.1s ease-in-out infinite; }
.badge.reconnecting { color: var(--amber); border-color: rgba(227,176,75,0.4); background: rgba(227,176,75,0.08); }
.badge.offline, .badge.stale { color: var(--bear); border-color: rgba(255,77,109,0.4); background: rgba(255,77,109,0.08); }
.badge.market-open { color: var(--bull); }
.badge.market-closed { color: var(--muted); }
.badge.market-pre { color: var(--amber); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

select.dateSel { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700; }

#body { display: flex; flex: 1; min-height: 0; gap: 8px; padding: 8px; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#side { width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 11px; }
.panel-head { padding: 7px 10px; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.panel-body { padding: 10px; }

.chart-pane { flex: 1; min-height: 320px; position: relative; overflow: hidden; }
.lwc-host { position: absolute; inset: 0; }

.zone-band { position: absolute; z-index: 3; pointer-events: none; border-radius: 2px; }
.zone-band.support { background: linear-gradient(180deg, rgba(38,217,168,0.16), rgba(38,217,168,0.06)); border-top: 1px solid rgba(38,217,168,0.55); border-bottom: 1px solid rgba(38,217,168,0.55); }
.zone-band.resistance { background: linear-gradient(180deg, rgba(255,77,109,0.16), rgba(255,77,109,0.06)); border-top: 1px solid rgba(255,77,109,0.55); border-bottom: 1px solid rgba(255,77,109,0.55); }
.zone-label { position: absolute; z-index: 4; font-family: ui-monospace, monospace; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; pointer-events: none; white-space: nowrap; background: rgba(18,24,26,0.92); line-height: 1.4; opacity: 0.9; }
.zone-label .zl-role { color: var(--muted); font-weight: 800; letter-spacing: .03em; margin-right: 5px; font-size: 9px; }
.zone-label.support .zl-role { color: var(--bull); }
.zone-label.resistance .zl-role { color: var(--bear); }
.zone-label .zl-range { color: var(--text); font-weight: 800; }

.kv { display: flex; justify-content: space-between; padding: 3px 0; font-size: 12px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; }

.zone-card { display: flex; flex-direction: column; gap: 2px; padding: 8px; border-radius: 8px; background: var(--panel-2); margin-bottom: 6px; }
.zone-card.support { border-left: 3px solid var(--bull); }
.zone-card.resistance { border-left: 3px solid var(--bear); }
.zone-card .zk { font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.zone-card .zv { font-size: 13px; font-weight: 800; }
.zone-card .zmeta { font-size: 10px; color: var(--muted-2); }

.pos-panel { padding: 10px; border-radius: 9px; background: var(--panel-2); }
.pos-panel.empty { color: var(--muted); text-align: center; padding: 16px 10px; }
.pos-panel .pos-side { font-weight: 800; font-size: 13px; }
.pos-panel .pos-side.CE { color: var(--amber); }
.pos-panel .pos-side.PE { color: var(--forming); }
.pos-panel .pnl.up { color: var(--bull); }
.pos-panel .pnl.down { color: var(--bear); }

#timelineWrap { flex-shrink: 0; padding: 8px 10px; max-height: 130px; overflow-y: auto; }
.trace-item { padding: 4px 0; font-size: 11.5px; border-bottom: 1px solid var(--border); cursor: pointer; }
.trace-item:hover { background: var(--panel-2); }
.trace-item .tt { font-weight: 700; }
.trace-item.is-trade .tt { color: var(--amber); }
.trace-item .body { color: var(--muted); font-size: 10.5px; }

.legend-mini { display: flex; gap: 10px; font-size: 10px; color: var(--muted); flex-wrap: wrap; padding: 4px 10px; }
.legend-mini span { display: inline-flex; align-items: center; gap: 4px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

table.ledger { width: 100%; border-collapse: collapse; font-size: 12px; }
table.ledger th { text-align: left; padding: 8px 10px; color: var(--muted); font-size: 10.5px; text-transform: uppercase; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); }
table.ledger td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.ledger tr:hover { background: var(--panel-2); cursor: pointer; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 5px; font-size: 10px; font-weight: 800; }
.tag.CE { background: rgba(227,176,75,0.15); color: var(--amber); }
.tag.PE { background: rgba(167,139,250,0.15); color: var(--forming); }
.tag.OPEN { background: rgba(77,163,255,0.15); color: var(--blue); }
.tag.TARGET_HIT { background: rgba(38,217,168,0.15); color: var(--bull); }
.tag.STRUCTURAL_EXIT, .tag.TIMEOUT_EXIT, .tag.EOD_EXIT { background: rgba(255,77,109,0.15); color: var(--bear); }
.pnl-pos { color: var(--bull); font-weight: 700; }
.pnl-neg { color: var(--bear); font-weight: 700; }

.filters { display: flex; gap: 8px; padding: 10px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 5px 8px; font-size: 12px; }

.summary-row { display: flex; gap: 14px; padding: 10px 14px; flex-wrap: wrap; }
.summary-stat { display: flex; flex-direction: column; gap: 2px; }
.summary-stat .k { font-size: 10px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.summary-stat .v { font-size: 15px; font-weight: 800; }
.summary-stat.paper .k::after { content: " (PAPER)"; opacity: 0.5; }

.trade-detail { padding: 12px; border-top: 1px solid var(--border); background: var(--panel-2); font-size: 12px; }
.trade-detail .section-title { font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; margin: 10px 0 4px; }
.trade-detail .section-title:first-child { margin-top: 0; }
.trade-detail .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 12px; }
.link-btn { background: none; border: 1px solid var(--border); color: var(--blue); border-radius: 6px; padding: 4px 9px; font-size: 11px; cursor: pointer; }

.pagination { display: flex; gap: 6px; align-items: center; padding: 10px; }
.pagination button { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

.linkage-error { color: var(--bear); font-weight: 700; }

@media (max-width: 900px) {
  #body { flex-direction: column; }
  #side { width: 100%; order: 2; }
  .chart-pane { min-height: 260px; }
  table.ledger { display: block; overflow-x: auto; }
}
