:root {
  --bg: #080a0f;
  --bg-elevated: #0e1219;
  --card: #11151c;
  --card-hover: #151b24;
  --border: #1e2736;
  --border-subtle: #161d28;
  --text: #e8edf4;
  --muted: #6b7d96;
  --accent: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --bear-bg: #2a1218;
  --bear-border: #7f1d1d;
  --bull-bg: #0f2a1a;
  --bull-border: #166534;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --chart-h: clamp(380px, 52vh, 560px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 10px 14px 28px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Topbar ── */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px 20px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.topbar-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

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

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.pill {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.pill.stopped { background: var(--bear-bg); color: #fca5a5; border: 1px solid var(--bear-border); }
.pill.running { background: var(--bull-bg); color: #86efac; border: 1px solid var(--bull-border); }
.pill.live-badge {
  background: #172554;
  color: #93c5fd;
  border: 1px solid #1d4ed8;
  animation: live-pulse 2s ease-in-out infinite;
}
.pill.live-badge.offline {
  animation: none;
  background: #1a1f2e;
  color: var(--muted);
  border-color: var(--border);
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.tick-time {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-center {
  text-align: center;
}

.symbol-select {
  margin-bottom: 0.25rem;
  padding: 0.2rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.symbol-select.hidden {
  display: none;
}

.price-label {
  display: block;
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.head-price {
  font-size: 1.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}

.head-price.price-up { color: var(--green); }
.head-price.price-down { color: var(--red); }
.head-price.price-flash { color: var(--accent); }

.topbar-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-weight: 600;
  font-size: 0.75rem;
  cursor: pointer;
  color: #fff;
  transition: opacity 0.15s;
}

.btn:hover:not(:disabled) { opacity: 0.88; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-green { background: #15803d; }
.btn-red { background: #b91c1c; }
.btn-blue { background: #1d4ed8; }
.btn-gray { background: #334155; color: #e2e8f0; }

/* ── KPI strip ── */
.kpi-strip {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) repeat(4, minmax(0, 1fr));
  gap: 10px 14px;
  align-items: center;
  padding: 10px 14px;
  margin-bottom: 10px;
}

.kpi-label {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi-value.muted { color: var(--muted); font-weight: 500; }

.kpi-bias {
  display: inline-block;
  margin-right: 10px;
}

.kpi-bias::before {
  content: 'L ';
  color: var(--green);
  font-size: 0.65rem;
  font-weight: 600;
}

.kpi-bias.muted::before {
  content: 'S ';
  color: var(--red);
}

.kpi-pill { margin-top: 2px; }

.kpi-tp-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.72rem;
  color: var(--muted);
}

.kpi-tp-row strong { color: var(--text); font-weight: 600; }

.verdict-compact {
  padding: 6px 10px;
  margin: 0;
  text-align: left;
  border-radius: var(--radius-sm);
}

.verdict-compact span:first-child {
  font-size: 1rem;
  font-weight: 800;
}

.verdict-compact .verdict-sub {
  font-size: 0.68rem;
  margin-top: 2px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Workspace ── */
.workspace-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* ── Chart ── */
.chart-wrap {
  padding: 0;
  overflow: hidden;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.chart-tabs {
  display: flex;
  gap: 4px;
}

.chart-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.chart-tab:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.chart-tab.active {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.4);
  color: #93c5fd;
}

.chart-legend-drawer {
  font-size: 0.72rem;
}

.chart-legend-drawer summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  list-style: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.chart-legend-drawer summary::-webkit-details-marker { display: none; }

.chart-legend-drawer[open] summary {
  color: var(--text);
  margin-bottom: 6px;
}

.chart-indicator-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 0 4px 6px;
  max-width: min(100%, 920px);
}

.chart-ind-toggle {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s, background 0.15s;
}

.chart-ind-toggle:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
}

.chart-ind-toggle.is-on {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.08);
}

.chart-ind-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.chart-ind-toggle__box {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  margin-top: 2px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  position: relative;
}

.chart-ind-toggle.is-on .chart-ind-toggle__box {
  border-color: #3b82f6;
  background: rgba(37, 99, 235, 0.35);
}

.chart-ind-toggle.is-on .chart-ind-toggle__box::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #dbeafe;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.chart-ind-toggle__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.chart-ind-toggle__label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-ind-toggle__label.leg::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.chart-ind-toggle__label.leg.ema34::before { background: #06b6d4; }
.chart-ind-toggle__label.leg.lrc-mid::before { background: #94a3b8; }
.chart-ind-toggle__label.leg.tl-up::before { background: #22c55e; }
.chart-ind-toggle__label.leg.tl-down::before { background: #fb923c; }
.chart-ind-toggle__label.leg.supply::before { background: #ef4444; }

.chart-ind-toggle__hint {
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.25;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 0 4px 4px;
}

.chart-legend .leg::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 3px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

.chart-legend .leg.ema34::before { background: #06b6d4; }
.chart-legend .leg.ema89::before { background: #f59e0b; }
.chart-legend .leg.ema200::before { background: #a855f7; }
.chart-legend .leg.lrc-upper::before { background: #ef4444; }
.chart-legend .leg.lrc-mid::before { background: #94a3b8; }
.chart-legend .leg.lrc-lower::before { background: #2dd4bf; }
.chart-legend .leg.tl-up::before { background: #22c55e; }
.chart-legend .leg.tl-down::before { background: #fb923c; }
.chart-legend .leg.supply::before { background: #ef4444; }
.chart-legend .leg.demand::before { background: #22c55e; }

.chart-pane {
  display: none;
  position: relative;
  height: var(--chart-h);
  width: 100%;
}

.chart-pane.active {
  display: block;
  width: 100%;
}

#strategy-chart,
#tv-chart {
  min-height: var(--chart-h);
  min-width: 0;
}

.lrc-fill-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#strategy-chart > table,
#strategy-chart > div {
  position: relative;
  z-index: 1;
}

.tv-chart { height: var(--chart-h); width: 100%; }

.tv-zone-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 6px 12px 8px;
  font-size: 0.68rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.tv-zone-hint .tv-hint-note { color: #64748b; font-style: italic; }

/* ── Live calc panel ── */
.live-panel {
  padding: 10px 12px 12px;
}

.live-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.live-pulse.active {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulse-ring 1.8s ease-out infinite;
}

.live-pulse.ws {
  background: var(--accent);
  animation: pulse-ring 1.2s ease-out infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.live-panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
}

.live-last-calc {
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.btn-link {
  background: none;
  border: none;
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.btn-link:hover { text-decoration: underline; }

.signal-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.metric-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  min-width: 0;
}

.metric-chip span {
  display: block;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 2px;
}

.metric-chip strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-chip.ok strong { color: var(--green); }
.metric-chip.warn strong { color: var(--orange); }
.metric-chip.block strong { color: var(--red); }
.metric-chip.bull strong { color: #86efac; }
.metric-chip.bear strong { color: #fca5a5; }

.calc-feed {
  max-height: 148px;
  overflow-y: auto;
  overflow-anchor: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
}

.calc-feed-empty {
  margin: 0;
  padding: 20px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
}

.calc-feed-line {
  display: grid;
  grid-template-columns: 52px 54px 1fr;
  gap: 8px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border-subtle);
  align-items: start;
}

.calc-feed-line:last-child { border-bottom: none; }

.calc-feed-line:hover { background: rgba(255, 255, 255, 0.02); }

.calc-feed-line .cf-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.calc-feed-line .cf-tag {
  font-weight: 700;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
}

.calc-feed-line.kind-calc .cf-tag { color: #38bdf8; }
.calc-feed-line.kind-tick .cf-tag { color: #60a5fa; }
.calc-feed-line.kind-zones .cf-tag { color: #f472b6; }
.calc-feed-line.kind-tp .cf-tag { color: #fbbf24; }
.calc-feed-line.kind-dca .cf-tag { color: #86efac; }
.calc-feed-line.kind-order .cf-tag { color: #4ade80; }
.calc-feed-line.kind-order .cf-msg,
.log-line.kind-order .log-msg {
  color: #bbf7d0;
  line-height: 1.45;
}
.calc-feed-line.kind-skip .cf-tag { color: #fb923c; }
.calc-feed-line.kind-error .cf-tag { color: #f87171; }
.calc-feed-line.kind-warn .cf-tag { color: #fbbf24; }
.calc-feed-line.source-dashboard { border-left: 2px solid #334155; }
.calc-feed-line.source-bot { border-left: 2px solid #2563eb; }

.calc-feed-line .cf-msg {
  color: #cbd5e1;
  word-break: break-word;
  line-height: 1.35;
}

/* ── Panel tabs ── */
.panel-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel-tab {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.panel-tab:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.panel-tab.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.panel-view {
  display: none;
  animation: panel-in 0.2s ease;
}

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

@keyframes panel-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Overview dashboard ── */
.ov-hero {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.ov-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 72px;
}

.ov-stat-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.ov-stat-value {
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.ov-stat-sub {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
}

.ov-stat.bull .ov-stat-value { color: #86efac; }
.ov-stat.bear .ov-stat-value { color: #fca5a5; }

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

.ov-panel {
  padding: 12px 14px;
}

.ov-kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-bottom: 12px;
}

.ov-kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.72rem;
}

.ov-kv span { color: var(--muted); font-size: 0.65rem; }
.ov-kv strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.ov-kv strong.bull { color: #86efac; }
.ov-kv strong.bear { color: #fca5a5; }

.ov-bias-block {
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.ov-bias-title {
  margin: 0 0 8px;
  font-size: 0.68rem;
  color: var(--muted);
}

.ov-bias-sub {
  margin: 6px 0 0;
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.4;
}

.bar-pct {
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 42px;
  text-align: right;
}

.bar-row {
  grid-template-columns: 36px 1fr 42px;
}

.ov-ready-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ov-ready-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-elevated);
}

.ov-ready-card.long { border-color: rgba(22, 101, 52, 0.35); }
.ov-ready-card.short { border-color: rgba(127, 29, 29, 0.35); }
.ov-ready-card.ready { box-shadow: inset 3px 0 0 #22c55e; }
.ov-ready-card.blocked { box-shadow: inset 3px 0 0 #ef4444; }
.ov-ready-card.idle { box-shadow: inset 3px 0 0 #64748b; }

.ov-ready-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.ov-ready-head h3 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
}

.ov-ready-pill {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: #1e293b;
  color: #94a3b8;
}

.ov-ready-card.ready .ov-ready-pill { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.ov-ready-card.blocked .ov-ready-pill { background: rgba(239, 68, 68, 0.12); color: #fca5a5; }

.ov-ready-meta {
  margin: 0 0 8px;
  font-size: 0.68rem;
  color: var(--muted);
}

.ov-blockers {
  margin: 0;
  padding-left: 16px;
  font-size: 0.66rem;
  color: #fca5a5;
  line-height: 1.45;
}

.ov-blockers-empty {
  margin: 0;
  font-size: 0.66rem;
  color: var(--muted);
}

.ov-pos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ov-pos-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-elevated);
}

.ov-pos-card.long { border-color: rgba(22, 101, 52, 0.3); }
.ov-pos-card.short { border-color: rgba(127, 29, 29, 0.3); }
.ov-pos-card.empty { opacity: 0.85; }

.ov-pos-card h4 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.ov-pos-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  font-size: 0.68rem;
}

.ov-pos-metrics p {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ov-pos-metrics span { color: var(--muted); font-size: 0.6rem; }
.ov-pos-metrics strong { font-variant-numeric: tabular-nums; }
.ov-pos-metrics strong.bull { color: #86efac; }
.ov-pos-metrics strong.bear { color: #fca5a5; }

.ov-pos-hint {
  margin: 6px 0 0;
  font-size: 0.62rem;
  color: var(--muted);
}

.ov-zone-rows {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.ov-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.ov-zone span { color: var(--muted); min-width: 56px; }
.ov-zone strong { font-variant-numeric: tabular-nums; }
.ov-zone em {
  font-size: 0.58rem;
  font-style: normal;
  font-weight: 700;
  color: #fbbf24;
  margin-left: auto;
}

.ov-zone.supply.in-zone { border-color: rgba(239, 68, 68, 0.4); }
.ov-zone.demand.in-zone { border-color: rgba(34, 197, 94, 0.4); }
.ov-zone.micro-supply.in-zone { border-color: rgba(251, 146, 60, 0.55); background: rgba(251, 146, 60, 0.06); }
.ov-zone.micro-demand.in-zone { border-color: rgba(52, 211, 153, 0.55); background: rgba(52, 211, 153, 0.06); }
.ov-zone-meta {
  display: block;
  font-size: 0.58rem;
  color: var(--muted);
  margin-top: 2px;
}

.ov-tp-rows p {
  margin: 0 0 6px;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  font-size: 0.68rem;
  align-items: baseline;
}

.ov-tp-rows span { color: var(--muted); }
.ov-tp-rows strong { font-variant-numeric: tabular-nums; }

.ov-ema21-row strong.bear { color: #f87171; }
.ov-ema21-row strong.bull { color: #4ade80; }

.ov-micro-stable {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.35);
  font-size: 0.68rem;
}

.ov-micro-stable.blocked {
  border-color: rgba(251, 146, 60, 0.55);
  background: rgba(251, 146, 60, 0.08);
}

.ov-micro-stable.ready {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.06);
}

.ov-micro-stable-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  margin-bottom: 4px;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ov-micro-stable-head em {
  font-style: normal;
  font-weight: 700;
}

.ov-micro-stable.blocked .ov-micro-stable-head em { color: #fb923c; }
.ov-micro-stable.ready .ov-micro-stable-head em { color: #4ade80; }

.ov-micro-stable strong {
  display: block;
  font-size: 0.72rem;
  line-height: 1.35;
}

.ov-micro-stable-reason {
  margin: 6px 0 0;
  color: #fdba74;
  line-height: 1.4;
}

.ov-micro-stable-detail {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.ov-pipeline .tiers { margin-bottom: 0; }

.guard-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.guard-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.66rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  max-width: 100%;
}

.guard-chip b {
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.guard-chip.ok { border-color: rgba(34, 197, 94, 0.35); color: #86efac; }
.guard-chip.warn { border-color: rgba(251, 146, 60, 0.4); color: #fdba74; }
.guard-chip.muted { opacity: 0.75; }

/* ── Strategy tab ── */
.strat-top {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
  margin-bottom: 10px;
}

.strat-panel {
  padding: 12px 14px;
}

.strat-formula {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.strat-formula code {
  font-size: 0.68rem;
  color: #7dd3fc;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.strat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.strat-table th,
.strat-table td {
  padding: 5px 0;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
}

.strat-table th {
  color: var(--muted);
  font-weight: 600;
  width: 42%;
  padding-right: 8px;
}

.strat-elig-hint {
  margin: 0 0 8px;
  font-size: 0.65rem;
  color: var(--muted);
}

.elig-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.68rem;
}

.elig-table th,
.elig-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
}

.elig-table thead th {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--bg-elevated);
}

.elig-table tbody th {
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
}

.elig-cell .elig-status {
  display: inline-block;
  font-weight: 800;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
}

.elig-cell.ok .elig-status { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.elig-cell.block .elig-status { background: rgba(239, 68, 68, 0.12); color: #fca5a5; }
.elig-cell.na .elig-status { background: #1e293b; color: #64748b; }

.elig-cell .elig-detail {
  display: block;
  margin-top: 3px;
  font-size: 0.6rem;
  color: var(--muted);
  line-height: 1.35;
}

.elig-note {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.35;
}

.grid-block-reason {
  display: block;
  margin-top: 2px;
  font-size: 0.58rem;
  color: var(--muted);
  line-height: 1.3;
  font-weight: 400;
}

.tiers {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 10px;
  scrollbar-width: thin;
}

.tier {
  flex: 0 0 auto;
  min-width: 148px;
  max-width: 180px;
  background: var(--card);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.tier-id {
  font-size: 0.62rem;
  color: #60a5fa;
  font-weight: 700;
  text-transform: uppercase;
}

.tier-title {
  font-weight: 700;
  font-size: 0.82rem;
  margin: 4px 0 2px;
}

.tier-sub {
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.3;
}

.tier-status {
  margin-top: 6px;
  font-weight: 700;
  font-size: 0.78rem;
}

.tier-detail {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tier.bear .tier-status { color: #f87171; }
.tier.bull .tier-status { color: #4ade80; }
.tier.warn .tier-status { color: var(--orange); }


.section-label {
  margin: 0 0 8px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.bar-row {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.75rem;
}

.bar {
  height: 6px;
  background: #1a2230;
  border-radius: 3px;
  overflow: hidden;
}

.bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.bar .fill.bull { background: var(--green); }
.bar .fill.bear { background: var(--red); }

.macro-detail {
  margin: 8px 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.4;
}

.macro-detail-sub {
  display: block;
  margin-top: 2px;
  opacity: 0.85;
}

.macro-big.bearish { color: #f87171; }
.macro-big.bullish { color: #4ade80; }
.macro-big.neutral { color: var(--orange); }

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

.guard-compact li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.72rem;
}

.guard-compact li span:first-child { color: var(--muted); }
.guard-compact li span:last-child {
  text-align: right;
  line-height: 1.35;
  word-break: break-word;
}

/* ── Orders ── */
.live-account { padding: 12px 14px; }

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

.live-head h2 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
}

.api-badge {
  font-size: 0.6rem;
  background: rgba(37, 99, 235, 0.2);
  color: #93c5fd;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
}

.order-filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.order-filter {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}

.order-filter:hover { color: var(--text); border-color: #334155; }

.order-filter.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.45);
  color: #93c5fd;
}

.pos-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.pos-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.75rem;
}

.pos-box h4 {
  margin: 0 0 4px;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pos-box p { margin: 2px 0; }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
}

.data-table th.num,
.data-table td.num { text-align: right; }

.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
}

.data-table.compact td,
.data-table.compact th { padding: 5px 8px; }

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

.orders-tp-block {
  margin: 12px 0 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

.orders-tp-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.orders-tp-col-title {
  margin: 0 0 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.orders-tp-col-title.long { color: #86efac; }
.orders-tp-col-title.short { color: #fca5a5; }

.orders-tp-cols .tp-table tbody tr.tp-nearest td {
  background: rgba(56, 189, 248, 0.06);
}

.orders-tp-block .section-label .muted {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.72rem;
}

.orders-other-label { margin-top: 8px; }


.side-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.side-badge.long { background: var(--bull-bg); color: #86efac; }
.side-badge.short { background: var(--bear-bg); color: #fca5a5; }

.role-tag {
  font-size: 0.68rem;
  color: var(--muted);
}

/* ── Verdict (shared) ── */
.verdict-box {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.verdict-box.bear {
  background: var(--bear-bg);
  border-color: var(--bear-border);
  color: #fecaca;
}

.verdict-box.bull {
  background: var(--bull-bg);
  border-color: var(--bull-border);
  color: #bbf7d0;
}

.verdict-box.neutral {
  background: #1a1f28;
  color: var(--orange);
}

/* ── DCA ── */
.dca-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.dca-card { padding: 12px 14px; }

.dca-body { font-size: 0.78rem; }

.dca-body .status {
  font-weight: 700;
  font-size: 0.72rem;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

.dca-body .status.inactive { color: var(--muted); }
.dca-body .status.active { color: var(--green); }

.dca-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.dca-kpi {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.dca-kpi span:first-child {
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
}

.dca-kpi span:last-child {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.dca-kpi.positive span:last-child { color: var(--green); }
.dca-kpi.negative span:last-child { color: var(--red); }

.dca-line {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  gap: 8px;
}

.dca-line span:first-child { color: var(--muted); flex-shrink: 0; }
.dca-line span:last-child { text-align: right; }

.dca-line.dca-condition span:last-child {
  font-size: 0.65rem;
  line-height: 1.35;
  max-width: 65%;
}

.dca-line.positive span:last-child { color: var(--green); }
.dca-line.negative span:last-child { color: var(--red); }
.dca-line.neutral span:last-child { color: var(--orange); }

.dca-accordion {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.dca-accordion + .dca-accordion { margin-top: 4px; }

.dca-accordion summary {
  cursor: pointer;
  padding: 6px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(0,0,0,0.2);
  list-style: none;
}

.dca-accordion summary::-webkit-details-marker { display: none; }

.dca-accordion[open] summary {
  color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
}

.dca-accordion-body {
  padding: 6px 10px 8px;
}

.dca-accordion-body .dca-line { font-size: 0.72rem; }

.dca-footer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

/* ── Logs ── */
.logs-card { padding: 12px 14px; }

.logs-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.applied-config-drawer summary {
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.applied-config-drawer ul {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.72rem;
  max-height: 160px;
  overflow: auto;
}

.applied-config-drawer li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.applied-config-drawer li span:first-child { color: var(--muted); }

.verdict-log {
  min-height: 280px;
  max-height: min(480px, 55vh);
  margin: 0;
  overflow: auto;
  overflow-anchor: none;
  font-size: 0.68rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 0;
}

.verdict-log-empty {
  margin: 0;
  padding: 32px 16px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}

.log-section-divider {
  padding: 4px 8px 2px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  border-top: 1px solid #1e293b;
  background: #0a0e14;
}

.log-line {
  display: grid;
  grid-template-columns: 48px 40px 48px 1fr;
  gap: 6px;
  padding: 3px 8px;
  border-bottom: 1px solid #151b26;
  align-items: start;
}

.log-line .log-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log-line .log-section {
  color: #94a3b8;
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-line .log-tag {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.58rem;
}
.log-line .log-msg { color: #cbd5e1; word-break: break-word; }

.log-line.kind-tick .log-tag { color: #60a5fa; }
.log-line.kind-calc .log-tag { color: #38bdf8; }
.log-line.kind-dca .log-tag { color: #86efac; }
.log-line.kind-error .log-tag { color: #f87171; }
.log-line.level-error { background: rgba(127, 29, 29, 0.2); }

/* ── Ruồi Bu ── */
.ruoi-bu-panel {
  padding: 12px 14px;
}

.ruoi-bu-head { margin-bottom: 10px; }

.ruoi-bu-title {
  margin: 2px 0 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.ruoi-mode-pill {
  background: #172554;
  color: #93c5fd;
  border: 1px solid #1d4ed8;
}

.ruoi-mode-pill.suspended {
  background: var(--bear-bg);
  color: #fca5a5;
  border-color: var(--bear-border);
}

.ruoi-bu-pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.ruoi-pipe-step {
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.ruoi-pipe-step.active {
  background: rgba(37, 99, 235, 0.15);
  color: #bfdbfe;
  border-color: rgba(37, 99, 235, 0.5);
  font-weight: 700;
}

.ruoi-bu-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.ruoi-metric {
  flex: 0 0 auto;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 100px;
}

.ruoi-metric span:first-child {
  display: block;
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ruoi-metric span:last-child {
  font-weight: 600;
  font-size: 0.8rem;
}

.ruoi-bu-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ruoi-bu-side-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-elevated);
}

.ruoi-bu-side-card.long { border-color: rgba(22, 101, 52, 0.5); }
.ruoi-bu-side-card.short { border-color: rgba(127, 29, 29, 0.5); }

.ruoi-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.ruoi-side-head h3 { margin: 0; font-size: 0.85rem; }

.ruoi-side-lines {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.ruoi-side-lines p {
  margin: 2px 0;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.ruoi-side-lines strong { color: var(--text); }

.ruoi-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ruoi-action-row .btn {
  font-size: 0.68rem;
  padding: 5px 8px;
}

.ruoi-blocked {
  margin-top: 6px;
  font-size: 0.68rem;
  color: #f87171;
  line-height: 1.35;
}

.ruoi-preview {
  margin-top: 6px;
  font-size: 0.68rem;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}

/* ── Modals & toasts ── */
.config-modal {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(720px, 92vw);
  max-height: 85vh;
}

.config-modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.config-modal pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  max-height: 60vh;
  font-size: 0.72rem;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1e293b;
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  z-index: 100;
  box-shadow: var(--shadow);
}

.order-toast {
  position: fixed;
  top: 64px;
  right: 16px;
  max-width: 340px;
  background: #1a2332;
  border: 1px solid var(--accent);
  border-left: 4px solid var(--orange);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  z-index: 101;
  box-shadow: var(--shadow);
}

.order-toast strong {
  display: block;
  margin-bottom: 4px;
  color: var(--orange);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.order-toast-main {
  display: block;
  line-height: 1.35;
}

.order-toast-why {
  margin: 6px 0 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.76rem;
  line-height: 1.3;
}

.order-toast-detail {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .kpi-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .kpi-verdict { grid-column: 1 / -1; }

  .orders-tp-cols { grid-template-columns: 1fr; }
  .ov-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-split,
  .strat-top,
  .dca-grid,
  .ruoi-bu-sides,
  .ov-ready-grid,
  .ov-pos-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .topbar-center { text-align: left; }

  .topbar-actions { justify-content: flex-start; }

  .kpi-strip {
    grid-template-columns: 1fr 1fr;
  }

  .ov-hero { grid-template-columns: 1fr; }
  .ov-kv-grid { grid-template-columns: 1fr; }

  .panel-tab {
    padding: 8px 6px;
    font-size: 0.72rem;
  }

  :root { --chart-h: 320px; }
}
