/* V3 Trading Terminal — minimal dark theme */

:root {
  --bg:        #0b0e14;
  --bg2:       #11151c;
  --bg3:       #1a1f29;
  --border:    #2a3140;
  --text:      #e6edf3;
  --dim:       #7a8290;
  --green:     #26a269;
  --red:       #e01b24;
  --yellow:    #f7c948;
  --blue:      #3b82f6;
  --orange:    #f59e0b;
  --purple:    #a855f7;
  --accent:    #00d9ff;
  /* Font choice locked in 2026-04-25 after side-by-side comparison of
     IBM Plex Mono / Iosevka / JetBrains Mono NL / Inter / Roboto Mono.
     Inter (sans-serif, modern fintech UI) wins for legibility at 12-13px;
     numeric column alignment is preserved via OpenType `tnum` (tabular-nums)
     applied globally on body so every digit is the same width. */
  --font:      Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  height: 100%;
  /* Inter has tabular-figure variants; this enables them everywhere so P&L,
     prices, qty, time-stamps stay column-aligned without monospace look. */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum", "cv11";   /* cv11 = stylistic alternate for ones */
}

.green  { color: var(--green); }
.red    { color: var(--red); }
.yellow { color: var(--yellow); }
.blue   { color: var(--blue); }
.dim    { color: var(--dim); }
.orange { color: var(--orange); }
.zerodha { color: var(--blue); }
.shoonya { color: var(--orange); }

/* ── Modal (full-screen overlay + centered box) ─────────────────────────
   Used by mode-switch confirm dialog (Widget #3) and any future modals.
   Hidden by default; toggle .open on .modal-bg to show. V2 parity. */
.modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  justify-content: center; align-items: center;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 22px; min-width: 420px; max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  font-family: var(--font);
}
.modal h3       { font-size: 16px; margin-bottom: 12px; color: var(--red); }
.modal h3.warn  { color: var(--yellow); }
.modal-body     { font-size: 12px; color: var(--text); line-height: 1.7; margin-bottom: 12px; }
.modal-body b   { color: var(--text); }
.modal-warn     { font-size: 11px; color: var(--yellow); margin-bottom: 12px; }
.modal-btns     { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ── Padlock banner ─────────────────────────────────────────────────────
   Full-width red bar pinned to top of page; hidden by default.
   Shown by app.js renderHeader() when state.padlock_triggered === true.
   Color matches V2 (#b71c1c). */
/* Old V2-style full-width banner — superseded by #padlock-pill in the header.
   Kept as hidden mirror so renderHeader() writes don't crash on missing element. */
#padlock-banner { display: none !important; }

/* Compact padlock pill (header-only). Visible only when state.padlock_triggered. */
#padlock-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 14px;
  background: #b71c1c; color: #fff;
  font-weight: 700; font-size: 11px; letter-spacing: 0.5px;
  font-family: var(--font);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.4);
  animation: padlock-pulse 2s ease-in-out infinite;
  white-space: nowrap;
}
#padlock-pill[hidden] { display: none; }
@keyframes padlock-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 2px 6px rgba(0,0,0,0.4); }
  50%      { box-shadow: 0 0 0 2px rgba(255,80,80,0.5),  0 2px 8px rgba(0,0,0,0.5); }
}

/* ── Top bar — STICKY to viewport top so brand / broker dropdown / KPI
       tiles / KILL SWITCH stay visible while scrolling long pane content. */
#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 20;          /* above tabs (10) and table sticky thead (5) */
}
.brand { display: flex; align-items: center; gap: 6px; }
.logo { font-size: 18px; color: var(--accent); }
.title { font-weight: 700; letter-spacing: 1.5px; color: var(--text); }

#broker-filter {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 4px; font-family: var(--font); font-size: 12px;
}

/* Rich broker dropdown — replaces native <select>. Closed state shows broker
   icon + (for single-broker selection) user name + mode pill. Open state
   shows the same layout per row for all options. */
.broker-pick { position: relative; }
.broker-pick-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; min-height: 32px;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  font-family: var(--font); font-size: 12px; font-weight: 600;
  cursor: pointer;
  max-width: 320px; min-width: 150px;
}
.broker-pick-btn:hover { background: #1f2531; }
.broker-pick-btn[aria-expanded="true"] { border-color: var(--accent); }
.broker-pick-btn .bp-caret { margin-left: auto; opacity: 0.6; font-size: 10px; }
.broker-pick-btn .bp-name {
  font-weight: 700; letter-spacing: 1px; min-width: 0;
}
.broker-pick-btn .bp-user {
  color: var(--dim); font-weight: 400; letter-spacing: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 130px; min-width: 0;
}
.broker-pick-btn .bp-sep { color: var(--dim); }

.broker-pick-menu {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  z-index: 1000;
  min-width: 380px;
}
.broker-pick-menu[hidden] { display: none; }

/* Row layout: flex (NOT grid) so icon + name + user cluster tight on the
   left like the closed-state header button, while the mode-pill anchors
   to the far right via margin-left:auto. Single-line for every row,
   including ALL BROKERS (whose mode-pill cell is empty and collapses). */
.broker-pick-opt {
  display: flex;
  align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  /* Reserve a 3 px gutter for the active-row coloured border so the row
     content doesn't shift when selection toggles. */
  border-left: 3px solid transparent;
  cursor: pointer; user-select: none;
  font-family: var(--font); font-size: 12px;
  white-space: nowrap;
}
.broker-pick-opt .bp-mode-pill { margin-left: auto; }
.broker-pick-opt:hover { background: #1a1f29; }
/* Active row: drop the cyan tint, use a broker-coloured left border + bold
   so the selected option is visually anchored to its broker palette. */
.broker-pick-opt.active { background: transparent; font-weight: 700; }
.broker-pick-opt.active[data-broker="zerodha"] { border-left-color: #3b82f6; }
.broker-pick-opt.active[data-broker="shoonya"] { border-left-color: #f59e0b; }
.broker-pick-opt.active[data-broker="all"]     { border-left-color: var(--accent); }
.broker-pick-opt .bp-name { font-weight: 700; letter-spacing: 1px; }
.broker-pick-opt[data-broker="zerodha"] .bp-name { color: #3b82f6; }
.broker-pick-opt[data-broker="shoonya"] .bp-name { color: #f59e0b; }
.broker-pick-opt[data-broker="all"] .bp-name { color: var(--accent); }
.broker-pick-opt .bp-user {
  color: var(--text); font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px; min-width: 0;
}
.bp-mode-pill {
  font-size: 9px; font-weight: 700; letter-spacing: 1px;
  padding: 2px 7px; border-radius: 8px;
  border: 1px solid transparent;
}
.bp-mode-pill[data-mode="PAPER"] {
  background: rgba(124, 58, 237, 0.18); color: #c4b5fd;
  border-color: rgba(124, 58, 237, 0.5);
}
.bp-mode-pill[data-mode="REAL"] {
  background: rgba(239, 68, 68, 0.18); color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.5);
}
.bp-conn { font-size: 11px; }
.bp-conn[data-on="1"] { color: var(--green); }
.bp-conn[data-on="0"] { color: var(--red); }

.hpnl { display: flex; gap: 24px; margin-left: 12px; }
.hpnl-cell { display: flex; flex-direction: column; }
.hlabel { font-size: 9px; color: var(--dim); letter-spacing: 1px; }
.hval { font-size: 14px; font-weight: 700; }

.hctrl { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.badge {
  padding: 3px 8px; border-radius: 3px; font-size: 10px; font-weight: 700;
  letter-spacing: 1px; background: var(--bg3); border: 1px solid var(--border);
}
/* Mode badge — V2 parity: PAPER = purple bg / white text, REAL = red bg / white text */
.badge.mode { background: var(--bg3); color: var(--text); border-color: var(--border); }
.badge.mode.paper { background: #4a148c; color: #fff; border-color: #6a1b9a; }
.badge.mode.real  { background: #c62828; color: #fff; border-color: #e53935; }

/* Mode-switch header button — "current → next" smart label.
   Bold current half, dim next half, mode-coloured background.
   MIXED state (ALL scope + brokers diverge) gets amber tint and a warn glyph. */
#h-mode-switch.h-mode-switch {
  padding: 6px 12px;
  font-weight: 600; letter-spacing: 0.5px;
  border-width: 1px; border-style: solid;
  font-family: var(--font);
}
#h-mode-switch .ms-current { font-weight: 700; }
#h-mode-switch .ms-arrow   { opacity: 0.55; padding: 0 1px; }
#h-mode-switch .ms-next    { font-weight: 400; opacity: 0.65; }
#h-mode-switch .ms-mixed   { font-weight: 700; }
#h-mode-switch.mode-paper {
  background: rgba(124, 58, 237, 0.18); color: #c4b5fd;
  border-color: rgba(124, 58, 237, 0.5);
}
#h-mode-switch.mode-real {
  background: rgba(239, 68, 68, 0.20); color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.55);
}
#h-mode-switch.mode-mixed {
  background: rgba(245, 158, 11, 0.20); color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.6);
}
.badge.ws { color: var(--green); }
.clock { color: var(--yellow); font-weight: 700; font-size: 14px; min-width: 70px; }

.btn {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 3px; font-family: var(--font); font-size: 11px;
  cursor: pointer; font-weight: 700;
}
.btn:hover { background: var(--border); }
.btn.red    { color: var(--red);    border-color: var(--red); }
.btn.yellow { color: var(--yellow); border-color: var(--yellow); }
.btn.green  { color: var(--green);  border-color: var(--green); }
.btn.blue   { color: var(--blue);   border-color: var(--blue); }
.btn.dim    { color: var(--dim);    border-color: var(--border); }

/* ── Tabs — STICKY directly below #topbar (which is 48px tall + 1px border).
       Stays visible while scrolling so user can switch panes from any
       scroll depth. z-index below #topbar so the bar wins on overlap. */
#tabs {
  display: flex; gap: 4px; padding: 0 16px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky;
  top: 49px;            /* topbar height (48px) + its 1px bottom border */
  z-index: 10;
}
.tab {
  background: transparent; color: var(--dim);
  padding: 10px 16px; border: none; cursor: pointer;
  font-family: var(--font); font-size: 11px; font-weight: 700;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Panes ───────────────────────────────────────────────────────────── */
#content { padding: 12px 16px; }
.pane { display: none; }
.pane.active { display: block; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; padding: 12px; margin-bottom: 12px;
}
.card-title {
  font-size: 10px; color: var(--dim);
  letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 8px;
}

.cards {
  /* T2.3 follow-up: V2-parity responsive flex — was repeat(6,1fr) which
     hardcoded 6 columns and forced T2.3's 7th card (AVAILABLE CASH) to wrap.
     auto-fit + minmax mirrors V2's `flex-wrap` behavior — cards re-flow as
     we add/remove cards in future Tier-2 widgets without further CSS edits. */
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 12px;
}
.cards .card { margin: 0; }
.clbl { font-size: 9px; color: var(--dim); letter-spacing: 1px; margin-bottom: 4px; }
/* T2.3 — sub-text under AVAILABLE CASH (Margin used) — matches V2's .csub */
.csub { font-size: 10px; color: var(--dim); margin-top: 2px; }
.cval { font-size: 18px; font-weight: 700; }

/* legacy .mega kept for back-compat with any other panes that still use it */
.mega {
  display: flex; align-items: center; gap: 24px;
  padding: 16px 24px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 12px;
}
.mega-label { font-size: 10px; color: var(--dim); letter-spacing: 2px; min-width: 70px; }
.mega-val   { font-size: 36px; font-weight: 700; flex: 1; color: var(--green); }
.mega-side  { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--dim); }
.mega-side span { color: var(--text); font-weight: 700; }

/* ═══════════════════════════════════════════════════════════════════════
   ROW 1 — KPI strip: single horizontal band of 8 cells.
   TRUE P&L cell is ~2.5× wide; the other 7 are equal-width. Auto-fit lets
   it wrap to a 2-row grid on narrow viewports without overflowing.
   ═══════════════════════════════════════════════════════════════════════ */
.kpi-strip {
  display: grid;
  grid-template-columns: 2.5fr repeat(7, 1fr);
  gap: 10px; margin-bottom: 10px;
}
@media (max-width: 1280px) {
  .kpi-strip { grid-template-columns: 2.5fr repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .kpi-strip { grid-template-columns: 1fr 1fr; }
}
.kpi-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 12px; min-width: 0;
}
.kpi-card .clbl { font-size: 9px; color: var(--dim); letter-spacing: 1px; margin-bottom: 4px; }
.kpi-card .cval { font-size: 17px; font-weight: 700; line-height: 1.1; }
.kpi-card .csub { font-size: 10px; color: var(--dim); margin-top: 3px; white-space: nowrap;
                  overflow: hidden; text-overflow: ellipsis; }
.kpi-mega { padding: 10px 16px; }
.kpi-mega .clbl { letter-spacing: 2px; }
.kpi-mega-val {
  font-size: 30px; font-weight: 800;
  color: var(--green);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-clickable { cursor: pointer; transition: background 0.15s; }
.kpi-clickable:hover { background: var(--bg3, #1a2030); }

/* ═══════════════════════════════════════════════════════════════════════
   ROW 3 — Daily Risk Capacity bar
   ═══════════════════════════════════════════════════════════════════════ */
.risk-cap-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 14px; margin-bottom: 10px;
  font-size: 11px;
}
.rcb-label { color: var(--dim); letter-spacing: 1px; font-weight: 700; min-width: 90px; }
.rcb-amount { color: var(--text); font-variant-numeric: tabular-nums; min-width: 130px; }
.rcb-track {
  flex: 1; height: 10px; background: rgba(255,255,255,0.06);
  border-radius: 5px; overflow: hidden; position: relative;
}
.rcb-fill {
  height: 100%; background: var(--green, #22c55e);
  width: 0%; transition: width 0.3s ease, background 0.3s ease;
  border-radius: 5px;
}
.rcb-fill.warn { background: var(--yellow, #f7c948); }
.rcb-fill.danger { background: var(--red, #ef4444); }
.rcb-pct {
  font-variant-numeric: tabular-nums; font-weight: 700; min-width: 44px;
  text-align: right;
}

/* ═══════════════════════════════════════════════════════════════════════
   ROW 4 — Tabbed chart panel
   ═══════════════════════════════════════════════════════════════════════ */
.dash-chart-panel { padding: 4px 8px 30px; }
.dash-chart-tabs {
  display: flex; align-items: center; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px; padding-right: 240px; /* leave room for chart-mode-toggle */
  position: relative;
}
.dash-chart-tab {
  background: transparent; border: 0; cursor: pointer;
  padding: 6px 10px; font-size: 11px; font-weight: 700;
  color: var(--dim); letter-spacing: 0.5px;
  border-bottom: 2px solid transparent;
  font-family: var(--font);
  transition: color 0.15s, border-color 0.15s;
}
.dash-chart-tab:hover { color: var(--text); }
.dash-chart-tab.active { color: var(--accent, #4fc3f7); border-bottom-color: var(--accent, #4fc3f7); }
.dash-chart-tab[data-chart-tab="zerodha"].active { color: #3b82f6; border-bottom-color: #3b82f6; }
.dash-chart-tab[data-chart-tab="shoonya"].active { color: #f59e0b; border-bottom-color: #f59e0b; }
.dash-chart-tab-spacer { flex: 1; }
.dash-chart-tab-date {
  font-size: 10px; color: var(--dim); letter-spacing: 0.5px;
  padding: 6px 8px;
}
/* Hidden but kept-in-DOM split charts (used by V3Charts API for back-compat) */
.hidden-keepalive { position: absolute; left: -99999px; width: 1px; height: 1px;
                    visibility: hidden; overflow: hidden; }

/* ═══════════════════════════════════════════════════════════════════════
   Per-broker rows — two-row CSS Grid with subgrid so columns anchor at the
   same x across Zerodha & Shoonya rows. Variable-width labels ("Pallu" vs
   "Pallu-S") no longer push later columns out of alignment.
   Columns: Broker · Label · Mode · WS state · TotalPnL · Realized(L) · Realized(V)
            · Floating(L) · Floating(V) · OpenTrades(L) · OpenTrades(V)
            · AvailCash(L) · AvailCash(V)  [13 columns]
   ═══════════════════════════════════════════════════════════════════════ */
.per-broker-tiles {
  display: grid;
  /* 14 columns auto-sized to content. Structure:
     Broker · Label · Mode · WS-state · TruePnL-lbl · TruePnL-val
       · Realized-lbl · Realized-val · Floating-lbl · Floating-val
       · OpenTrades-lbl · OpenTrades-val · AvailCash-lbl · AvailCash-val
     10 px column-gap is the sweet spot between "clubbed" (6 px) and
     "floppy" (14 px). Container uses fit-content so the grid doesn't
     stretch to the full pane width. */
  grid-template-columns: repeat(14, auto);
  row-gap: 4px;
  column-gap: 10px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 10px 0;
}
.pb-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid transparent;
  border-left-width: 4px;
  font-size: 12px;
}
/* Numeric values: tabular numerals + right-align so column digits line up */
.pb-row .pb-val,
.pb-row .pb-pnl {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.pb-row .pb-lbl {
  color: var(--dim, #aaa);
  font-size: 11px;
  margin-left: 8px;     /* group: small gap LEFT of each label, separating from previous value */
}
/* Right margin on each metric value to add visual grouping between pairs
   (so "Realized ₹+0" feels like a unit, with extra air before "Floating"). */
.pb-row .pb-val { margin-right: 0; }

/* ── Chart cards ─────────────────────────────────────────────────────── */
/* Bottom padding bumped to 30px to make room for the absolute-positioned
   legend chip (which sits at bottom: -22px relative to the .uchart inside). */
.chart-card { padding: 8px 12px 30px; min-width: 0; }

/* Centered date caption above each uPlot chart — used on Dashboard,
   Analytics Equity Curve, and History per-broker charts. Format:
   "PnL on 25 Apr 2026" or "Equity Curve on 25 Apr 2026". */
.dash-chart-caption,
.uchart-caption {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  letter-spacing: 0.5px;
  margin: 4px 0 6px;
}
/* uchart container is position:relative so the legend can be absolutely
   placed INSIDE the canvas drawing area (overlay), not below it. The chart
   itself fills the full container — uPlot's ResizeObserver re-measures on
   any resize so it stays width:100% / height:280px. */
.uchart {
  width: 100%; height: 280px; min-width: 0; max-width: 100%;
  position: relative;
}
/* Don't fight uPlot's inline-style width on .u-wrap — letting uPlot manage
   it lets ResizeObserver in charts.js re-size cleanly when the container
   reflows.  Earlier we forced width:100% !important which collapsed the
   wrap to 0px in some flex contexts. */
.uchart .u-wrap { min-width: 0; }

/* uPlot's live-legend table — pulled INSIDE the canvas as a small overlay
   chip pinned to the bottom-centre, ~6px above the time-axis. Semi-transparent
   so the chart line behind stays visible. Descendant selector catches the
   legend regardless of how deeply uPlot nests it. */
.uchart .u-legend {
  position: absolute !important;
  /* uPlot sets inline top/right on the legend table; we explicitly
     null them out (NOT via `inset` shorthand — that would re-blow our
     left/bottom in the cascade). */
  top: auto !important;
  right: auto !important;
  left: 50% !important;
  /* Bottom-anchored just BELOW the time axis labels (in the chart card's
     bottom padding band). Negative bottom pulls the chip outside the canvas
     so it never overlaps the 13:40 / 13:45 / … tick text. */
  bottom: -22px !important;
  transform: translateX(-50%);
  width: auto !important;
  max-width: max-content;
  margin: 0 !important;
  padding: 1px 10px;
  font-size: 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 3px;
  border-collapse: separate !important;
  text-align: center;
  z-index: 6;
  pointer-events: none;
  white-space: nowrap;
}
.uchart .u-legend th,
.uchart .u-legend td { padding: 0 4px; }

/* Belt-and-braces: if uPlot ever appends a second legend node, suppress
   the duplicates so only the first chip is visible. */
.uchart .u-legend ~ .u-legend { display: none !important; }

/* Fix: at 100% zoom the uPlot canvas in each split pane was wider than its
   1fr column because grid items default to min-width:auto (=min-content).
   Once the canvas was drawn at e.g. 750px, the column never shrank back —
   forcing horizontal page scroll. min-width:0 + overflow:hidden lets the
   ResizeObserver shrink the canvas to fit. */
.split-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  min-width: 0;
}
.split-pane {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; padding: 8px;
  min-width: 0; overflow: hidden;
}
.split-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; margin-bottom: 6px; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 11px;
}
.data-table thead {
  background: var(--bg3); color: var(--dim);
}
/* Sticky table header REMOVED (was breaking layout — `.table-wrap` with
   `overflow-x: auto` becomes the sticky context, so `top: 81px` measures
   from the wrap's top edge, not viewport. Result: thead floated 81px down
   inside the wrap with data rows shifted above it.
   Topbar (#topbar) and tab nav (#tabs) remain sticky to viewport, which is
   the intended behaviour. To get true viewport-sticky table headers we'd
   need to drop overflow on the wrap (breaks horizontal scroll on wide
   tables) or use a JS-based floating header. Deferred for now.) */
.data-table th {
  padding: 8px 6px; text-align: left; font-weight: 700;
  letter-spacing: 0.5px; border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 6px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr:hover { background: var(--bg3); }

/* ── Analytics Performance Lab (SHIP B) ─────────────────────────────── */
.an-filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px 14px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 12px;
}
.an-range-presets {
  display: inline-flex; gap: 0;
  border: 1px solid var(--border); border-radius: 4px; overflow: hidden;
}
.an-range-btn {
  background: transparent; border: 0;
  padding: 6px 10px;
  font-family: var(--font); font-size: 11px; font-weight: 700;
  color: var(--dim); cursor: pointer; min-width: 38px;
}
.an-range-btn + .an-range-btn { border-left: 1px solid var(--border); }
.an-range-btn:hover { color: var(--text); background: var(--bg3); }
.an-range-btn.active { background: rgba(0, 217, 255, 0.12); color: var(--accent); }
.an-custom-range {
  display: inline-flex; gap: 6px; align-items: center;
  background: var(--bg3); padding: 4px 8px; border-radius: 4px;
}
.an-custom-range input[type=date] {
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 3px 6px; font-family: var(--font); font-size: 11px;
}
/* SHIP D #4: Make the native date-picker icon visible against dark
   backgrounds. Webkit's calendar-picker-indicator defaults to black —
   invisible on V3's dark theme. Apply globally to all date inputs. */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(0.85);
  cursor: pointer;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
  filter: invert(1) brightness(1);
}
.an-chips-wrap { display: inline-flex; gap: 8px; align-items: center; flex: 1; }
.an-chips-label { color: var(--dim); font-size: 11px; }
.an-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.an-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.an-chip-x {
  background: transparent; border: 0; color: var(--dim);
  cursor: pointer; padding: 0 2px; font-size: 12px;
}
.an-chip-x:hover { color: var(--red); }
.an-add-signal {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); padding: 4px 8px;
  font-family: var(--font); font-size: 11px; border-radius: 3px;
  max-width: 200px;
}

/* SHIP D #16: Export split-button — primary button + chevron + dropdown.
   Used by both History and Analytics. Primary triggers default export;
   chevron opens dropdown for explicit range override. */
.export-split { display: inline-flex; position: relative; }
.export-split button { border-radius: 0; }
.export-split button:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.export-split .export-split-arrow {
  border-left: 1px solid rgba(0,0,0,0.25);
  padding: 0 8px;
  border-top-right-radius: 4px; border-bottom-right-radius: 4px;
}
.export-split .export-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 4px;
  z-index: 100; min-width: 200px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  padding: 4px;
}
.export-split .export-dropdown[hidden] { display: none; }
.export-split .export-opt {
  display: block; width: 100%;
  background: transparent; border: 0; color: var(--text);
  padding: 8px 10px; text-align: left; cursor: pointer;
  font-family: var(--font); font-size: 11px;
  border-radius: 3px;
}
.export-split .export-opt:hover { background: var(--bg3); }
.export-split .export-custom-row {
  display: flex; gap: 4px; align-items: center;
  padding: 6px 10px; border-top: 1px solid var(--border);
  margin-top: 4px;
}
.export-split .export-custom-row input[type=date] {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 3px 6px; font-family: var(--font); font-size: 11px;
}

.an-mode-badge {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; margin-bottom: 14px;
  background: var(--bg2); border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.an-mode-label { font-weight: 600; font-size: 13px; }
.an-mode-pill {
  font-size: 9px; font-weight: 700; letter-spacing: 1px;
  padding: 3px 8px; border-radius: 8px;
  background: rgba(0, 217, 255, 0.15); color: var(--accent);
}
.an-mode-pill[data-mode="single"]     { background: rgba(124,58,237,.18); color: #c4b5fd; }
.an-mode-pill[data-mode="comparison"] { background: rgba(245,158,11,.20); color: #fcd34d; }

.an-tier-block { margin-bottom: 18px; }
.an-tier-title {
  display: flex; align-items: baseline; gap: 12px;
  font-weight: 700; font-size: 12px; letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}
.an-tier1-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  margin-bottom: 10px;
}
.an-tier2-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 10px;
}
.an-card.primary {
  background: linear-gradient(135deg, var(--bg2), var(--bg3));
  border: 1px solid var(--accent);
  padding: 10px 12px;
  text-align: center;
}
.an-card.primary .an-val {
  font-size: 24px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.an-cards-secondary { margin-top: 6px; }
.an-hint { font-size: 9px; margin-top: 4px; }
/* SHIP D #13: holding-time row — three cards showing win/loss avg holds
   plus disposition ratio (losers÷winners). > 1.5× triggers a warning. */
.an-holdtime-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 8px;
}
.an-card.holdtime {
  background: var(--bg2); border: 1px solid var(--border);
  padding: 10px 12px;
}
.an-card.holdtime .an-val { font-size: 18px; font-weight: 700; }
.an-card.holdtime.warn { border-color: var(--yellow); }
.an-card.holdtime.warn .an-val { color: var(--yellow); }

.an-tier5-table { font-size: 11px; }
.an-tier5-table th { cursor: pointer; user-select: none; }
.an-tier5-table th:hover { color: var(--accent); }
.an-tier5-table th.num, .an-tier5-table td.num { text-align: right; }
.an-tier5-table td { font-variant-numeric: tabular-nums; padding: 6px 8px; }
.an-tier5-table tbody tr:hover { background: var(--bg3); cursor: pointer; }
.an-tier5-table tbody tr.row-active { background: rgba(0,217,255,0.08); }
.an-tier5-spark { display: inline-block; width: 120px; height: 24px; vertical-align: middle; }
.an-tier5-spark path { fill: none; stroke-width: 1.4; }
.an-tier5-spark.profit path { stroke: var(--green); }
.an-tier5-spark.loss   path { stroke: var(--red); }

/* ── History ─────────────────────────────────────────────────────────── */
.hist-controls {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  padding: 12px; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  flex-wrap: wrap;
}
.hist-controls label { color: var(--dim); font-size: 11px; }
.hist-controls select {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); padding: 6px 10px;
  font-family: var(--font); font-size: 12px; border-radius: 3px;
  margin-left: 6px;
}

/* Mode toggle (By Date / By Signal) — segmented buttons */
.hist-mode-toggle {
  display: inline-flex; gap: 0;
  border: 1px solid var(--border); border-radius: 4px; overflow: hidden;
}
.hist-mode-btn {
  background: transparent; border: 0;
  padding: 6px 12px;
  font-family: var(--font); font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--dim); cursor: pointer;
}
.hist-mode-btn:hover { color: var(--text); background: var(--bg3); }
.hist-mode-btn.active {
  background: rgba(0, 217, 255, 0.12);
  color: var(--accent);
}
.hist-mode-btn + .hist-mode-btn { border-left: 1px solid var(--border); }

/* 40/60 split — calendar on left, detail on right */
.hist-split {
  display: grid;
  grid-template-columns: minmax(360px, 40%) 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) { .hist-split { grid-template-columns: 1fr; } }

/* ── Calendar widget ─────────────────────────────────────────────────── */
.hist-calendar-wrap {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px;
}
.hist-cal-nav {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.hist-cal-arrow {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 4px 10px; border-radius: 3px; cursor: pointer; font-size: 12px;
}
.hist-cal-arrow:hover { background: var(--border); }
.hist-cal-month-label {
  flex: 1; text-align: center;
  font-weight: 700; font-size: 13px; letter-spacing: 0.5px;
  color: var(--text);
}
.hist-cal-summary {
  font-size: 11px; color: var(--dim); margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.hist-cal-summary b { color: var(--text); font-weight: 700; }
/* Day-of-week header row */
.hist-cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; margin-bottom: 4px;
}
.hist-cal-dow > div {
  text-align: center; font-size: 10px; font-weight: 700;
  color: var(--dim); letter-spacing: 0.5px;
  padding: 4px 0;
}
/* The grid itself — 6 weeks × 7 days */
.hist-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
/* Each cell — date number top-left, P&L center, mode pill top-right */
.hist-cal-cell {
  position: relative;
  min-height: 60px;
  padding: 6px 6px 4px 8px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between;
  font-family: var(--font); font-variant-numeric: tabular-nums;
  transition: border-color 0.12s, transform 0.06s;
}
.hist-cal-cell:hover { border-color: var(--accent); }
.hist-cal-cell:active { transform: scale(0.98); }
.hist-cal-cell.empty {
  background: transparent; border: 1px dashed var(--border);
  cursor: default; opacity: 0.4;
}
.hist-cal-cell.empty:hover { border-color: var(--border); }
.hist-cal-cell.no-data {
  /* Dimmed but still clickable — clicking shows "no data" state in detail panel.
     Cursor stays as pointer (inherited from base .hist-cal-cell rule). */
  opacity: 0.55;
}
.hist-cal-cell.no-data:hover { opacity: 0.9; border-color: var(--accent); }
.hist-cal-cell.today {
  border: 2px dashed var(--accent);
  padding: 5px 5px 3px 7px;   /* compensate for thicker border */
}
.hist-cal-cell.selected {
  border-color: var(--accent); border-width: 2px;
  padding: 5px 5px 3px 7px;
}
.hist-cal-cell .hcc-day {
  font-size: 11px; color: var(--dim); font-weight: 700;
}
.hist-cal-cell.weekend .hcc-day { color: #6b7280; }
.hist-cal-cell .hcc-pnl {
  font-size: 13px; font-weight: 700;
  text-align: center;
  margin: 2px 0;
}
.hist-cal-cell .hcc-pnl.profit { color: var(--green); }
.hist-cal-cell .hcc-pnl.loss   { color: var(--red); }
.hist-cal-cell .hcc-pnl.flat   { color: var(--dim); }
.hist-cal-cell .hcc-trades {
  font-size: 9px; color: var(--dim);
  text-align: center;
}
/* Mode pill — top-right corner of cell */
.hist-cal-cell .hcc-mode {
  position: absolute; top: 4px; right: 4px;
  font-size: 8px; font-weight: 700; letter-spacing: 0.5px;
  padding: 1px 5px; border-radius: 6px;
}
.hist-cal-cell .hcc-mode[data-mode="PAPER"] {
  background: rgba(124,58,237,.20); color: #c4b5fd;
}
.hist-cal-cell .hcc-mode[data-mode="REAL"] {
  background: rgba(239,68,68,.22); color: #fca5a5;
}
.hist-cal-cell .hcc-mode[data-mode="MIXED"] {
  background: rgba(245,158,11,.22); color: #fcd34d;
}
/* P&L magnitude tint — overlay on the cell background */
.hist-cal-cell.tint-profit { background: linear-gradient(to bottom, rgba(38,162,105,0.06), rgba(38,162,105,0.16)); }
.hist-cal-cell.tint-loss   { background: linear-gradient(to bottom, rgba(224,27,36,0.06),  rgba(224,27,36,0.18)); }

/* Legend — beneath the grid */
.hist-cal-legend {
  display: flex; gap: 14px; align-items: center;
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 10px; color: var(--dim);
}
.hist-cal-legend-item { display: inline-flex; align-items: center; gap: 4px; }
.hist-cal-swatch {
  width: 10px; height: 10px; border-radius: 2px;
  display: inline-block;
}
.hist-cal-swatch.profit { background: rgba(38,162,105,0.4); }
.hist-cal-swatch.loss   { background: rgba(224,27,36,0.4); }

/* ── Detail panel (right of split) ────────────────────────────────────── */
.hist-detail-wrap { min-width: 0; }
.hist-detail-empty {
  background: var(--bg2); border: 1px dashed var(--border); border-radius: 6px;
  padding: 32px 20px;
  text-align: center; color: var(--dim); font-size: 13px;
}

/* SHIP A: Per-broker breakdown card at top of detail panel.
   Mirrors Dashboard's per-broker tile strip styling for visual consistency. */
.hist-perbroker-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-family: var(--font);
  font-size: 12px;
}
.hist-perbroker-card .hpb-row {
  display: grid;
  grid-template-columns: 90px 110px auto auto auto;
  gap: 10px; align-items: baseline;
  padding: 4px 0;
}
.hist-perbroker-card .hpb-name {
  font-weight: 700; letter-spacing: 1px; font-size: 12px;
}
.hist-perbroker-card .hpb-row[data-broker="zerodha"] .hpb-name { color: #3b82f6; }
.hist-perbroker-card .hpb-row[data-broker="shoonya"] .hpb-name { color: #f59e0b; }
.hist-perbroker-card .hpb-row[data-broker="all"]     .hpb-name { color: var(--accent); }
.hist-perbroker-card .hpb-pnl {
  font-weight: 700; font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.hist-perbroker-card .hpb-pnl.profit { color: var(--green); }
.hist-perbroker-card .hpb-pnl.loss   { color: var(--red); }
.hist-perbroker-card .hpb-pnl.flat   { color: var(--dim); }
.hist-perbroker-card .hpb-lbl  { color: var(--dim); }
.hist-perbroker-card .hpb-val  { color: var(--text); font-variant-numeric: tabular-nums; }
.hist-perbroker-card .hpb-mode {
  font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
  padding: 2px 7px; border-radius: 8px;
  justify-self: start; min-width: 50px; text-align: center;
}
.hist-perbroker-card .hpb-mode[data-mode=""]      { background: transparent; color: transparent; }
.hist-perbroker-card .hpb-mode[data-mode="PAPER"] { background: rgba(124,58,237,.18); color: #c4b5fd; }
.hist-perbroker-card .hpb-mode[data-mode="REAL"]  { background: rgba(239,68,68,.20); color: #fca5a5; }
.hist-perbroker-card .hpb-mode[data-mode="MIXED"] { background: rgba(245,158,11,.20); color: #fcd34d; }
.hist-perbroker-card .hpb-divider {
  border-top: 1px solid var(--border);
  margin: 4px 0;
}
.hist-perbroker-card .hpb-combined .hpb-name { font-weight: 800; }
.hist-perbroker-card .hpb-combined .hpb-pnl  { font-size: 16px; }

/* SHIP A: History chart tab strip — same look as Dashboard chart tabs. */
.chart-card .dash-chart-tabs {
  display: inline-flex; gap: 4px;
  margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: 4px;
  padding: 2px;
}
.chart-card .dash-chart-tab {
  background: transparent; border: 0;
  padding: 4px 12px;
  font-family: var(--font); font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--dim); cursor: pointer;
  border-radius: 3px;
}
.chart-card .dash-chart-tab:hover { color: var(--text); background: var(--bg3); }
.chart-card .dash-chart-tab.active {
  background: rgba(0, 217, 255, 0.12);
  color: var(--accent);
}

/* By Signal mode placeholder */
.hist-signal-empty {
  background: var(--bg2); border: 1px dashed var(--border); border-radius: 6px;
  padding: 40px 24px; text-align: center; font-size: 13px;
  line-height: 1.6;
}

/* ── Logs ────────────────────────────────────────────────────────────── */
.log-pre {
  background: #000; color: var(--text); padding: 12px;
  font-family: var(--font); font-size: 11px;
  max-height: 70vh; overflow-y: auto; white-space: pre-wrap;
  border: 1px solid var(--border); border-radius: 4px;
}

/* ── Toasts ──────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-left-width: 4px;
  padding: 10px 14px; border-radius: 4px;
  font-size: 12px; min-width: 220px; max-width: 360px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.toast.ok    { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.info  { border-left-color: var(--blue); }

/* ── Config tab (Widget #4) ───────────────────────────────────────────
   5-column responsive grid; sections wrap naturally so Row 2 starts after
   the first 5. iOS-style toggle switches; strategy radio cards with
   colored borders; whitelist editor rows. */
/* Widget #4 v3 layout — 4 flex columns, each independently stacked:
   Col 1: Credentials → Filters → Options
   Col 2: Trading → Equity
   Col 3: Risk → Features
   Col 4: Whitelisted Alerts (1.5x wider — long alert names need room)

   Why flex over grid: CSS Grid forces all cells in a row to share the
   tallest cell's height. Risk Management (5 strategy cards) is tall and
   pushed Credentials/Trading down with empty space below them. Flexbox
   lets each column stack its own sections tightly with no forced
   row alignment. */
.cfg-grid {
  display: flex;
  gap: 12px;
  align-items: stretch;
  padding-bottom: 70px;  /* clearance for floating Save FAB */
}
.cfg-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cfg-col-wide { flex: 1.5 1 0; }   /* Whitelisted Alerts column */
@media (max-width: 1100px) {
  .cfg-grid     { flex-direction: column; }
  .cfg-col,
  .cfg-col-wide { flex: 1 1 auto; }
}

/* ALL-mode credentials lock — visual signal that credentials can't be saved
   when global header is on 'all'. Server drops them silently; the local
   broker tabs (.cfg-cred-tabs) and pick-cue keep pointer-events so the
   user can still click a tab to unlock by flipping global. */
.cfg-section.area-cred.locked { opacity: 0.6; pointer-events: none; }
.cfg-section.area-cred.locked input,
.cfg-section.area-cred.locked button { background: #1a1a1a; }
.cfg-section.area-cred.locked .cfg-cred-tabs,
.cfg-section.area-cred.locked .cfg-cred-pick-cue {
  opacity: 1; pointer-events: auto;
}
.cfg-cred-lock-note { display: none; }   /* legacy, hidden via [hidden] attr */

/* Local broker tab strip inside Credentials — tabs flip the global header
   on click (Option A). Active tab gets the broker color so it visually
   matches the header dropdown's broker palette. */
.cfg-cred-tabs {
  display: flex; gap: 4px; margin: -4px 0 8px 0;
  border-bottom: 1px solid var(--border);
}
.cfg-cred-tab {
  background: transparent; border: 0;
  padding: 6px 12px;
  font-family: var(--font); font-size: 11px; font-weight: 700; letter-spacing: 1px;
  color: var(--dim); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}
.cfg-cred-tab:hover { color: var(--text); }
.cfg-cred-tab[aria-selected="true"][data-cred-broker="zerodha"] {
  color: #3b82f6; border-bottom-color: #3b82f6;
}
.cfg-cred-tab[aria-selected="true"][data-cred-broker="shoonya"] {
  color: #f59e0b; border-bottom-color: #f59e0b;
}
.cfg-cred-pick-cue {
  display: none;
  margin: 4px 0 8px 0; padding: 8px 10px;
  background: rgba(247,201,72,0.15); color: var(--yellow);
  border-left: 2px solid var(--yellow);
  font-size: 11px; border-radius: 2px;
}
/* Show the cue only when the section is in locked (ALL) state. */
.cfg-section.area-cred.locked .cfg-cred-pick-cue { display: block; }

/* Floating Save FAB — fixed bottom-right of viewport. Inside #pane-config so
   it's auto-hidden when another tab is active (parent display:none). */
#cfg-save-fab {
  position: fixed; right: 24px; bottom: 24px;
  z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg2); border: 1px solid var(--green); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6), 0 0 12px rgba(38,162,105,0.3);
}
.cfg-save-fab-btn {
  background: var(--green); color: #000; border: none; padding: 8px 16px;
  border-radius: 4px; font-family: var(--font); font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.cfg-save-fab-btn:hover { background: #2db974; }
.cfg-save-fab-btn.saving { background: var(--yellow); color: #000; }
.cfg-save-fab-btn.saved  { background: var(--green); color: #000; }
.cfg-save-fab-msg { font-size: 11px; color: var(--green); font-weight: 700; }
.cfg-section {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 14px; min-width: 0;
}
.cfg-section h3 {
  font-size: 12px; color: var(--accent); margin-bottom: 10px;
  letter-spacing: 1px; text-transform: uppercase;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.cfg-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 8px; margin-bottom: 6px; align-items: center; font-size: 11px;
}
.cfg-row > label  { color: var(--dim); font-size: 11px; }
.cfg-row.dim      { color: var(--dim); display: block; padding: 4px 0; }
.cfg-row input,
.cfg-row select {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  border-radius: 3px; padding: 5px 8px;
  font-family: var(--font); font-size: 11px; min-width: 0;
}
.cfg-row input:focus, .cfg-row select:focus {
  outline: none; border-color: var(--accent);
}

/* Strategy radio cards */
.cfg-strat-title {
  font-size: 10px; color: var(--accent); margin: 14px 0 6px;
  letter-spacing: 1px; text-transform: uppercase;
}
.cfg-strat-card {
  display: block; cursor: pointer; padding: 10px 12px;
  border: 2px solid var(--border); border-radius: 6px;
  margin-bottom: 8px; transition: border-color 0.15s, background 0.15s;
}
/* Strategy pair rows (Lock | Lock Modified, TSL | TSL Modified) — Option A side-by-side */
.cfg-strat-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.cfg-strat-pair > .cfg-strat-card { margin-bottom: 0; }
@media (max-width: 900px) {
  .cfg-strat-pair { grid-template-columns: 1fr; }
}
.cfg-strat-card:hover { background: var(--bg3); }
.cfg-strat-head { display: flex; align-items: center; gap: 8px; }
.cfg-strat-head input[type="radio"] { margin: 0; }
.cfg-strat-name { font-weight: 700; font-size: 12px; }
.cfg-strat-name.lock   { color: var(--yellow); }
.cfg-strat-name.tsl    { color: var(--green); }
.cfg-strat-name.amount { color: var(--blue); }
.cfg-strat-name.points { color: var(--purple); }
.cfg-strat-name.none   { color: var(--dim); }
.cfg-strat-desc {
  font-size: 11px; color: var(--dim); margin: 6px 0 0 22px; line-height: 1.5;
}
.cfg-strat-fields { display: none; margin-top: 10px; }
.cfg-strat-card.active.lock   { border-color: var(--yellow); }
.cfg-strat-card.active.tsl    { border-color: var(--green); }
.cfg-strat-card.active.amount { border-color: var(--blue); }
.cfg-strat-card.active.points { border-color: var(--purple); }
.cfg-strat-card.active.none   { border-color: #555; }
.cfg-strat-card.active .cfg-strat-fields { display: block; }

/* iOS-style toggle switch (used in Feature Toggles + VWAP toggle) */
.toggle {
  position: relative; display: inline-block;
  width: 38px; height: 20px; cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; inset: 0; background: #444; border-radius: 20px;
  transition: background 0.15s;
}
.toggle .slider::before {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: transform 0.15s;
}
.toggle input:checked + .slider { background: var(--green); }
.toggle input:checked + .slider::before { transform: translateX(18px); }

/* VWAP filter sub-block (inside Entry Filters) */
.cfg-vwap-block {
  margin-top: 12px; padding: 10px;
  background: var(--bg3); border: 1px dashed var(--border); border-radius: 4px;
}
.cfg-vwap-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.cfg-vwap-label { font-size: 11px; font-weight: 700; color: var(--text); }
.cfg-vwap-scope { display: none; margin-top: 8px; padding-left: 4px; }
.cfg-vwap-block.on .cfg-vwap-scope { display: block; }
.cfg-check {
  display: block; font-size: 11px; color: var(--text); margin: 4px 0;
  cursor: pointer;
}
.cfg-check input { margin-right: 6px; }
.cfg-warn-note {
  display: none; margin-top: 6px; padding: 4px 8px;
  background: rgba(247,201,72,0.15); color: var(--yellow);
  border-left: 2px solid var(--yellow);
  font-size: 10px; border-radius: 2px;
}
.cfg-warn-badge {
  font-size: 9px; font-weight: 600; color: var(--yellow);
  background: rgba(247,201,72,0.15); border: 1px solid var(--yellow);
  padding: 1px 6px; border-radius: 3px; letter-spacing: 0.5px;
}
.cfg-ok-badge {
  font-size: 9px; font-weight: 600; color: #6ee7b7;
  background: rgba(34,197,94,0.15); border: 1px solid #22c55e;
  padding: 1px 6px; border-radius: 3px; letter-spacing: 0.5px;
}

/* Whitelisted Alerts editor */
.cfg-wl-help {
  font-size: 11px; color: var(--dim); margin-bottom: 8px; line-height: 1.5;
}
.cfg-wl-bulk {
  background: var(--bg2); border: 1px dashed var(--border); border-radius: 4px;
  padding: 8px; margin-bottom: 10px;
}
.cfg-wl-bulk textarea {
  width: 100%; min-height: 60px; resize: vertical;
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  border-radius: 3px; padding: 6px 8px;
  font-family: var(--font); font-size: 11px; line-height: 1.4;
}
.cfg-wl-bulk-row { margin-top: 6px; display: flex; align-items: center; }
.cfg-wl-list { display: flex; flex-direction: column; gap: 6px; }
.cfg-wl-row {
  display: grid;
  /* Q3 (Ship E): 4 columns now — [alert | broker | vwap | × delete] */
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 6px; align-items: center;
}
.cfg-wl-row .cfg-wl-vwap {
  font-weight: 600; min-width: 110px;
}
.cfg-wl-row input[type="text"] {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  border-radius: 3px; padding: 5px 8px;
  font-family: var(--font); font-size: 11px; min-width: 0;
}
.cfg-wl-row select {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  border-radius: 3px; padding: 4px 6px; font-size: 11px; font-family: var(--font);
}
.cfg-wl-row .cfg-wl-del {
  background: transparent; color: var(--red); border: 1px solid var(--red);
  width: 26px; height: 26px; padding: 0; border-radius: 3px;
  cursor: pointer; font-size: 14px; line-height: 1;
}
.cfg-wl-row .cfg-wl-del:hover { background: var(--red); color: #fff; }

/* Save row spans the full grid width */
.cfg-save-row {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; margin-top: 4px;
}
.cfg-save-msg { font-size: 11px; color: var(--green); font-weight: 700; }

/* ── Widget #5: per-trade row controls (Trail/Lock/Strategy/Exit) ──────
   Compact variants of the existing toggle for table cells (the regular
   toggle is too tall for table rows). Strategy dropdown + inline Tgt/SL
   inputs + saving-status flash. */
.toggle.toggle-sm {
  width: 28px; height: 16px;
}
.toggle.toggle-sm .slider::before {
  width: 12px; height: 12px;
  left: 2px; top: 2px;
}
.toggle.toggle-sm input:checked + .slider::before {
  transform: translateX(12px);
}

/* Strategy cell wrapper — keeps dropdown + inline inputs + status on one line */
.tr-strat-cell {
  display: flex; gap: 4px; align-items: center; flex-wrap: nowrap;
}
.tr-strat-cell select {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 2px 4px; font-size: 10px; font-family: var(--font);
  max-width: 110px;
}
.tr-strat-cell input[type="number"] {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 1px 3px; font-size: 10px; font-family: var(--font);
  width: 50px;
}
.tr-strat-cell .ov-status {
  font-size: 10px; color: var(--dim); min-width: 40px;
}
.tr-strat-cell .ov-status.ok    { color: var(--green); }
.tr-strat-cell .ov-status.err   { color: var(--red); }
.tr-strat-cell .ov-status.busy  { color: var(--dim); }

/* Compact action buttons in table rows */
.tr-act-btn {
  background: var(--red); color: #fff; border: none; border-radius: 3px;
  padding: 2px 8px; font-size: 10px; font-weight: 700;
  font-family: var(--font); cursor: pointer;
}
.tr-act-btn:hover { background: #c01620; }
.tr-act-btn.kill { background: #c62828; padding: 2px 6px; }

/* ── T2.2: Exit Status chip (V2 parity) ──────────────────────────────
   COMPLETE = green, PENDING/OPEN/RETRY = yellow, REJECTED/FAILED = red,
   NAKED = bold red with warning emoji. Surfaces broker-side exit
   lifecycle so user can spot REAL-mode naked-short conditions. */
.exit-chip {
  display: inline-block;
  padding: 1px 6px; border-radius: 3px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px;
  font-family: var(--font);
}
.exit-chip.complete { background: #2e7d32; color: #fff; }
.exit-chip.pending  { background: #f9a825; color: #000; }
.exit-chip.failed   { background: #c62828; color: #fff; }
.exit-chip.naked    { background: #c62828; color: #fff; font-weight: 800; }

/* ── T2.2 follow-up: Trades toolbar + column-toggle panel (V2 line 527 parity) ──
   Pure-CSS positioning (V2 used inline style). The panel is absolutely positioned
   under the button so it floats above the table without consuming layout space. */
.trades-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  position: relative;
}
.btn-mini {
  background: var(--bg2, #1a1f2e);
  color: var(--fg, #e3e8f0);
  border: 1px solid var(--border, #2a3142);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 120ms;
}
.btn-mini:hover { background: var(--bg3, #232a3a); }
.col-panel {
  display: none;
  position: absolute;
  top: 32px;
  left: 220px;
  z-index: 999;
  background: var(--bg2, #1a1f2e);
  border: 1px solid var(--border, #2a3142);
  border-radius: 6px;
  padding: 10px 12px;
  min-width: 230px;
  max-height: 420px;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  font-size: 12px;
}
.col-panel .col-panel-title {
  font-weight: bold;
  color: var(--accent, #4fc3f7);
  margin-bottom: 8px;
}
.col-panel label {
  display: block;
  padding: 3px 0;
  cursor: pointer;
  user-select: none;
}
.col-panel .col-panel-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}
.col-panel .col-panel-actions button {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--bg3, #232a3a);
  color: var(--fg, #e3e8f0);
  border: 1px solid var(--border, #2a3142);
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font);
}
.col-panel .col-panel-actions button:hover { background: var(--bg, #0f131a); }

/* ─────────────────────────────────────────────────────────────────────────
   Batch B — Dashboard Tier 2 widgets
   ───────────────────────────────────────────────────────────────────────── */

/* B-T2.4 — Wipe Today's Session toolbar (V2 line 393 parity) */
.session-controls {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px; padding: 6px 8px;
  background: var(--bg2, #1a1a2e);
  border: 1px solid var(--border, #333); border-radius: 6px;
}
.session-label { color: var(--dim, #888); font-size: 11px; flex: 1; }
.btn-wipe-today {
  background: #4a2600; color: #ffb347;
  border: 1px solid #ff8c00; border-radius: 4px;
  font-size: 11px; padding: 4px 10px;
  font-family: var(--font); cursor: pointer;
  transition: background 120ms;
}
.btn-wipe-today:hover { background: #663400; }
/* Fix 3 — header-variant: matches sibling .btn padding/font in topbar */
.btn-wipe-today-hdr {
  font-size: 11px; padding: 4px 10px;
  font-weight: 600;
}

/* B-T2.7 — Per-broker rows colour theming. Subtle row backgrounds + the
   broker-coloured left border anchor each row visually. Broker name on the
   left is bold + broker-coloured for at-a-glance identification. */
.pb-row.zerodha { background: #0f1626; border-color: #1e3a6f; border-left-color: #3b82f6; }
.pb-row.shoonya { background: #1e1408; border-color: #78532a; border-left-color: #f59e0b; }
.pb-row.zerodha .pb-name { color: #3b82f6; }
.pb-row.shoonya .pb-name { color: #f59e0b; }
.pb-name { font-size: 13px; font-weight: 700; letter-spacing: 1px; }

/* User/label sub-text — sits in its own grid column so labels of any length
   can't push later columns. Dimmed since broker name keeps prominence. */
.pb-row .pb-user {
  font-size: 11px; color: var(--dim);
  font-weight: 400; letter-spacing: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 120px;
}

/* Mode pill — its own grid column so it always anchors at the same x. */
.pb-mode {
  font-size: 10px; padding: 2px 8px; border-radius: 10px;
  background: var(--bg, #1a1a2e); color: var(--dim, #888); font-weight: 700;
  text-align: center;
  justify-self: start;
}
.pb-mode.paper { background: rgba(124,58,237,.18); color: #c4b5fd; }
.pb-mode.real  { background: rgba(239,68,68,.20);  color: #fca5a5; }

/* WS state — verbose text "✓ WebSocket Connected" / "✕ WebSocket Disconnected"
   so the field is honest about the underlying signal. Colour-coded for safety. */
.pb-conn {
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.pb-conn.up   { color: var(--green, #10b981); }
.pb-conn.down { color: var(--red, #ef4444); }

/* Total PnL — bigger, tabular numerals so column anchors regardless of digit count */
.pb-pnl {
  font-size: 16px; font-weight: 700;
}

/* B-T2.15 — Compressed/Real-time chart toggle (V2 line 460 parity) */
.chart-card-with-toggle { position: relative; }
.chart-mode-toggle {
  position: absolute; top: 6px; right: 8px; z-index: 5;
  display: flex; gap: 4px; font-size: 10px;
  background: rgba(0,0,0,.55); border-radius: 4px; padding: 2px 4px;
}
.chart-mode-btn {
  cursor: pointer; padding: 2px 6px;
  border: 1px solid #444; background: #222; color: #ccc;
  border-radius: 3px; font-family: var(--font); font-size: 10px;
}
.chart-mode-btn:hover { background: #333; }
.chart-mode-btn.active {
  background: var(--accent, #4fc3f7); color: #000; border-color: var(--accent, #4fc3f7);
  font-weight: 700;
}

/* B-T2.5 + B-T2.6 — Dashboard mini-panels (Active Trades + Recent Signals + Closed Trades) */
.dash-mini-panel { margin-bottom: 10px; }
.dash-mini-panel .stitle {
  font-size: 12px; color: var(--accent, #4fc3f7);
  font-weight: 700; margin-bottom: 4px; letter-spacing: 0.5px;
}
.mini-badge {
  background: #ffd600; color: #000;
  font-size: 10px; padding: 1px 6px; border-radius: 10px;
  margin-left: 6px; font-weight: bold;
}
.dash-mini-tbl {
  max-height: 140px; overflow-y: auto;
  border: 1px solid var(--border, #2a3142); border-radius: 4px;
}
.dash-mini-tbl.tall { max-height: 180px; }
.dash-mini-tbl table {
  width: 100%; border-collapse: collapse; font-size: 11px;
}
.dash-mini-tbl thead th {
  position: sticky; top: 0; background: var(--bg2, #1a1a2e);
  color: var(--dim, #888); font-weight: 600;
  text-align: left; padding: 4px 8px; font-size: 10px; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border, #2a3142);
}
.dash-mini-tbl tbody td {
  padding: 3px 8px; color: var(--fg, #ddd);
  border-bottom: 1px solid rgba(42, 49, 66, 0.3);
}
.dash-mini-tbl tbody tr:hover { background: rgba(79, 195, 247, 0.05); }
.dash-mini-tbl .kill-mini {
  background: #c62828; color: #fff;
  border: none; border-radius: 3px;
  padding: 2px 6px; cursor: pointer; font-size: 11px;
}
.dash-mini-tbl .kill-mini:hover { background: #d32f2f; }

.dash-quickstats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 12px;
}

/* ─────────────────────────────────────────────────────────────────────────
   Batch C — Trades / Positions / Orders / Signals Tier 2 widgets
   ───────────────────────────────────────────────────────────────────────── */

/* C-T2.9 — Per-symbol Exit on Positions (V2 line 3735 parity) */
.btn-exit-pos {
  background: #c62828; color: #fff;
  border: 1px solid #d32f2f; border-radius: 3px;
  padding: 2px 10px; font-size: 11px; cursor: pointer;
  font-family: var(--font); font-weight: 600;
  transition: background 120ms;
}
.btn-exit-pos:hover { background: #d32f2f; }

/* C-T2.10 — Order Cancel button (V2 line 3768 parity) */
.btn-cancel-ord {
  background: var(--bg3, #2a3142); color: var(--fg, #ddd);
  border: 1px solid var(--border, #3a4256); border-radius: 3px;
  padding: 2px 8px; font-size: 10px; cursor: pointer;
  font-family: var(--font);
  transition: background 120ms;
}
.btn-cancel-ord:hover { background: #3a4256; }
.btn-cancel-ord:disabled {
  opacity: 0.4; cursor: not-allowed;
}
/* Order status colour helpers */
.order-status.complete { color: var(--green, #10b981); font-weight: 600; }
.order-status.rejected,
.order-status.cancelled { color: var(--red, #ef4444); font-weight: 600; }
.order-status.pending,
.order-status.open,
.order-status.trigger-pending { color: var(--yellow, #f59e0b); font-weight: 600; }

/* C-T2.11 — Signals toolbar + Fire Test + Refresh (V2 line 623 parity) */
.signals-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
}
.btn-fire-test {
  background: #4a1a4d; color: #e1aafd;
  border: 1px solid #8e44ad; border-radius: 4px;
  padding: 4px 12px; font-size: 11px; cursor: pointer;
  font-family: var(--font); font-weight: 600;
  transition: background 120ms;
}
.btn-fire-test:hover { background: #6a2a6d; }
.btn-refresh-sm {
  background: var(--bg2, #1a1a2e); color: var(--fg, #ddd);
  border: 1px solid var(--border, #2a3142); border-radius: 4px;
  padding: 4px 10px; font-size: 11px; cursor: pointer;
  font-family: var(--font);
}
.btn-refresh-sm:hover { background: var(--bg3, #232a3a); }

/* C-T2.11 — Inline route buttons (V2 line 1559-1571 parity) */
.route-btn-group { display: inline-flex; gap: 3px; align-items: center; }
.route-btn-quarantine {
  color: #fbbf24; font-size: 10px; margin-right: 6px;
}
.route-btn {
  padding: 1px 8px; font-size: 10px;
  border-radius: 3px; font-weight: 700; cursor: pointer;
  font-family: var(--font);
}
.route-btn.zerodha {
  background: rgba(59,130,246,.18); color: #3b82f6; border: 1px solid #3b82f6;
}
.route-btn.shoonya {
  background: rgba(245,158,11,.18); color: #f59e0b; border: 1px solid #f59e0b;
}
.route-btn.both {
  color: #fff;
  background: linear-gradient(90deg, #3b82f6, #f59e0b);
  border: 1px solid #555;
}
.route-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.signal-row.routed { opacity: 0.5; }

/* ─────────────────────────────────────────────────────────────────────────
   Batch D — Analytics / History / Logs Tier 2 widgets
   ───────────────────────────────────────────────────────────────────────── */

/* D-T2.1 — Analytics tab */
.an-filter-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.an-filter-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--dim, #888); }
.an-filter-row select {
  background: var(--bg2, #1a1a2e); color: var(--fg, #ddd);
  border: 1px solid var(--border, #2a3142); border-radius: 4px;
  padding: 4px 8px; font-size: 11px; font-family: var(--font);
}
.btn-export-an {
  background: #1b3a2a; color: #69f0ae;
  border: 1px solid #2e7d32; border-radius: 4px;
  padding: 4px 10px; font-size: 11px; cursor: pointer;
  font-family: var(--font); font-weight: 600;
}
.btn-export-an:hover { background: #244a37; }

.an-multidate-panel {
  background: var(--bg2, #1a1a2e); border: 1px solid var(--border, #2a3142);
  border-radius: 6px; padding: 10px; margin-bottom: 10px;
}
.an-multidate-title {
  font-size: 11px; color: var(--accent, #4fc3f7);
  font-weight: 700; margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.an-date-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; }
.an-date-checkboxes label {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 3px 8px;
  background: var(--bg3, #232a3a); border-radius: 3px; cursor: pointer;
}

.an-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.an-card {
  background: var(--bg2, #1a1a2e); border: 1px solid var(--border, #2a3142);
  border-radius: 6px; padding: 12px;
}
.an-label { font-size: 9px; color: var(--dim, #888); letter-spacing: 1px; margin-bottom: 4px; }
.an-val { font-size: 18px; font-weight: 700; }
.an-val.green { color: var(--green, #10b981); }
.an-val.red   { color: var(--red, #ef4444); }

.an-bars {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 0; min-height: 80px;
}
.an-bar-row {
  display: grid; grid-template-columns: 140px 1fr 80px;
  gap: 8px; align-items: center; font-size: 11px;
}
.an-bar-label { color: var(--fg, #ddd); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-bar-track {
  height: 14px; background: rgba(255,255,255,0.04);
  border-radius: 3px; overflow: hidden; position: relative;
}
.an-bar-fill {
  height: 100%; min-width: 2px;
  border-radius: 3px;
  transition: width 200ms;
}
.an-bar-fill.pos { background: linear-gradient(90deg, #1b3a2a, #00c853); }
.an-bar-fill.neg { background: linear-gradient(90deg, #3a1a1a, #ff3d3d); }
.an-bar-val {
  text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.an-bar-val.pos { color: var(--green, #10b981); }
.an-bar-val.neg { color: var(--red, #ef4444); }

/* D-T2.14 — History session card + extended filters + Upload/Export/Delete + trade table */
.hist-session-card {
  display: flex; flex-wrap: wrap; gap: 18px;
  background: var(--bg2, #1a1a2e); border: 1px solid var(--border, #2a3142);
  border-radius: 6px; padding: 10px 16px; margin-bottom: 12px;
}
.hist-session-card .sc-item { display: flex; flex-direction: column; min-width: 110px; }
.hist-session-card .sc-label { color: var(--dim, #888); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.hist-session-card .sc-val   { color: var(--fg, #ddd); font-weight: 700; margin-top: 2px; font-size: 13px; }

.btn-upload-hist {
  background: #1b3a2a; color: #69f0ae;
  border: 1px solid #2e7d32; border-radius: 4px;
  padding: 4px 10px; font-size: 11px; cursor: pointer;
  font-family: var(--font); font-weight: 600;
}
.btn-upload-hist:hover { background: #244a37; }
.btn-export-hist {
  background: #4a2600; color: #ffb347;
  border: 1px solid #ff8c00; border-radius: 4px;
  padding: 4px 10px; font-size: 11px; cursor: pointer;
  font-family: var(--font); font-weight: 600;
}
.btn-export-hist:hover { background: #663400; }
.btn-delete-hist {
  background: #3a1a1a; color: #ff8a80;
  border: 1px solid #c62828; border-radius: 4px;
  padding: 4px 10px; font-size: 11px; cursor: pointer;
  font-family: var(--font); font-weight: 600;
}
.btn-delete-hist:hover { background: #4a2424; }
.upload-progress { font-size: 11px; color: var(--yellow, #f59e0b); }

.hist-tbl-wrap { max-height: 480px; overflow: auto; }
.hist-tbl-wrap table { font-size: 10px; }
.hist-tbl-wrap th, .hist-tbl-wrap td { padding: 3px 6px; }
/* FINAL: cross-pane click — alert_name cell → Analytics with signal pre-filtered */
.hist-alert-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.hist-alert-link:hover { color: var(--text); text-decoration: underline; }

/* D-T2.16 — Wipe All modal */
.btn-wipe-all {
  background: #6b0000; color: #fff;
  border: 2px solid #ff4444; border-radius: 4px;
  padding: 4px 12px; font-size: 11px; cursor: pointer;
  font-family: var(--font); font-weight: 700;
}
.btn-wipe-all:hover { background: #8b0000; }
.wipe-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
}
.wipe-modal-box {
  background: #1e1e2e; border: 2px solid #ff4444;
  border-radius: 12px; padding: 2rem;
  max-width: 480px; width: 90%; color: #fff; text-align: center;
}
.wipe-modal-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.wipe-modal-title { color: #ff4444; margin: 0 0 1rem; font-size: 18px; }
.wipe-modal-warn  { color: #ffb347; margin-bottom: 0.5rem; font-weight: 600; font-size: 13px; }
.wipe-modal-list  { text-align: left; color: #ccc; margin: 0.5rem auto 1rem; max-width: 320px; line-height: 1.8; font-size: 12px; padding-left: 20px; }
.wipe-modal-final { color: #ff4444; font-weight: 700; margin-bottom: 1.2rem; font-size: 13px; }
.wipe-modal-prompt{ margin-bottom: 0.5rem; color: #aaa; font-size: 12px; }
.wipe-modal-input {
  width: 100%; padding: 0.6rem; border: 1px solid #555;
  border-radius: 6px; background: #2a2a3e; color: #fff;
  font-size: 1rem; text-align: center; margin-bottom: 1rem;
}
.wipe-modal-actions { display: flex; gap: 1rem; justify-content: center; }
.btn-wipe-confirm {
  background: #c62828; color: #fff;
  border: 1px solid #d32f2f; border-radius: 4px;
  padding: 6px 16px; font-size: 12px; cursor: pointer;
  font-family: var(--font); font-weight: 700;
}
.btn-wipe-confirm:disabled { opacity: 0.4; cursor: not-allowed; background: #5a0000; }
.btn-wipe-cancel {
  background: #1976d2; color: #fff;
  border: 1px solid #1565c0; border-radius: 4px;
  padding: 6px 16px; font-size: 12px; cursor: pointer;
  font-family: var(--font); font-weight: 600;
}

/* D-T2.13 — Logs toolbar + sub-tabs */
.logs-toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.logs-date-label { font-size: 12px; color: var(--dim, #888); display: flex; align-items: center; gap: 6px; }
.logs-date-label select {
  background: var(--bg2, #1a1a2e); color: var(--fg, #ddd);
  border: 1px solid var(--border, #2a3142); padding: 4px 8px; font-size: 12px;
}
.logs-autoscroll { font-size: 12px; color: var(--dim, #888); display: flex; align-items: center; gap: 6px; }
.log-live-badge { font-size: 11px; color: #00e676; margin-left: auto; }

.log-subtabs {
  display: flex; gap: 4px; margin-bottom: 8px;
  padding: 4px; background: #0f1626;
  border: 1px solid #2a2a3a; border-radius: 6px;
}
.log-sub-btn {
  background: transparent; border-radius: 4px;
  padding: 5px 14px; font-weight: 700; font-size: 11px;
  letter-spacing: 1px; cursor: pointer;
  font-family: var(--font);
  color: #93c5fd; border: 1px solid #3b82f6;
}
.log-sub-btn[data-sub="SHOONYA"] { color: #f59e0b; border-color: #78532a; }
.log-sub-btn[data-sub="SYS"]     { color: #a78bfa; border-color: #3d2f6a; }
.log-sub-btn.active[data-sub="KITE"]    { background: rgba(59,130,246,.18); }
.log-sub-btn.active[data-sub="SHOONYA"] { background: rgba(245,158,11,.18); }
.log-sub-btn.active[data-sub="SYS"]     { background: rgba(167,139,250,.18); }
.log-subtabs-note { color: #666; font-size: 11px; align-self: center; margin-left: auto; }

.log-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: none; margin-left: 6px; vertical-align: middle;
  background: #666; box-shadow: 0 0 4px currentColor;
}
.log-dot.show { display: inline-block; }
.log-dot.warn { background: #f59e0b; color: #f59e0b; }
.log-dot.err  { background: #ef4444; color: #ef4444; animation: logPulse 1.2s infinite; }
@keyframes logPulse { 50% { opacity: 0.4; } }

/* Hide non-matching log lines per active sub-tab */
body[data-log-sub="KITE"]    #log-view .log-line:not([data-pfx="KITE"])    { display: none; }
body[data-log-sub="SHOONYA"] #log-view .log-line:not([data-pfx="SHOONYA"]) { display: none; }
body[data-log-sub="SYS"]     #log-view .log-line:not([data-pfx="SYS"])     { display: none; }
/* SHIP C: DATA sub-tab swaps the entire content area (not just filters log lines).
   Hide #log-view and show #data-view when DATA is active. */
body[data-log-sub="DATA"] #log-view  { display: none; }
body[data-log-sub="DATA"] #data-view { display: block; }
#data-view {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 14px;
  font-family: var(--font); font-size: 12px;
}
#data-view .data-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
#data-view .data-section {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
#data-view .data-row {
  display: grid;
  grid-template-columns: 1fr 110px 110px;
  gap: 12px;
  padding: 4px 0;
  font-variant-numeric: tabular-nums;
}
#data-view .data-row-head {
  color: var(--dim); font-size: 10px; letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px; margin-bottom: 4px;
}
#data-view .data-row.data-sub { color: var(--dim); font-size: 11px; }
#data-view .data-rt { text-align: right; }
#data-view .data-total {
  border-top: 1px solid var(--border);
  padding-top: 6px; margin-top: 6px;
  font-weight: 700;
}
#data-view .data-policy {
  display: grid; grid-template-columns: auto auto;
  gap: 6px 14px; font-size: 11px; padding: 6px 0;
}
#data-view .data-pv { color: var(--text); font-weight: 600; }
#data-view .data-advanced {
  border: 1px dashed var(--border); border-radius: 4px;
  padding: 6px 12px; font-size: 11px;
}
#data-view .data-advanced summary {
  cursor: pointer; padding: 4px 0; color: var(--dim);
  font-weight: 600; letter-spacing: 0.5px;
}
#data-view .data-advanced[open] summary { color: var(--text); }
#data-view .data-advanced-body { padding: 6px 0; }
#data-view .data-trigger-row {
  display: flex; gap: 12px; align-items: center;
}

/* SHIP C: One-time auto-enable banner — fires when trading.db crosses the
   archival threshold. Dismissible; stored in localStorage so it never
   nags after the user acknowledges it. */
.archive-auto-banner {
  position: fixed; right: 24px; bottom: 24px;
  z-index: 1000;
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg2); border: 1px solid var(--accent); border-radius: 6px;
  padding: 12px 16px;
  max-width: 420px;
  font-size: 12px; color: var(--text);
  box-shadow: 0 4px 16px rgba(0,217,255,0.25), 0 0 8px rgba(0,217,255,0.15);
}
.archive-auto-banner-close {
  background: transparent; border: 0; color: var(--dim); cursor: pointer;
  font-size: 14px; padding: 0;
}
.archive-auto-banner-close:hover { color: var(--text); }

#log-view { display: block; }
.log-line { display: block; padding: 1px 4px; font-family: ui-monospace, monospace; font-size: 11px; white-space: pre-wrap; word-break: break-word; }
.log-line.warn { color: var(--yellow, #f59e0b); }
.log-line.err  { color: var(--red, #ef4444); }

/* ─────────────────────────────────────────────────────────────────────────
   Batch D follow-up — inline button-confirmation messages + Trades export
   ───────────────────────────────────────────────────────────────────────── */

/* FIX2 — inline button feedback (auto-fades 5s after click) */
.btn-msg {
  margin-left: 6px; font-size: 11px;
  opacity: 0; transition: opacity 250ms ease;
  font-family: var(--font); font-weight: 600;
  pointer-events: none;
  display: inline-block; min-width: 0;
}
.btn-msg.show { opacity: 1; }
.btn-msg.ok   { color: #69f0ae; }
.btn-msg.err  { color: #ff8a80; }
.btn-msg.info { color: #90caf9; }

/* The redundant `.trades-export-broker` dropdown was removed — exports now
   inherit scope from the global header `broker-filter`. Rule kept hidden so
   any third-party scrape that still references the class doesn't break.   */
.trades-export-broker { display: none !important; }

/* Reserve breathing room next to Export Excel: the export-status message
   ("✓ Downloaded") fades in/out here, so we give the slot a stable width
   so the trade counters next to it don't twitch when the message appears. */
.trd-export-msg-slot {
  display: inline-flex; align-items: center;
  min-width: 140px; max-width: 180px;
  padding: 0 6px;
  /* override the generic .btn-msg fallback width if any */
}

/* Broker pill — coloured tag for the Broker column in tables (V2 parity).
   Same blue/orange palette as the per-broker dashboard tiles so the dashboard
   tile and the table cell read as the same brand visual.
   Future broker #3 → add `.broker-pill[data-broker="newbrokername"]` rule. */
.broker-pill {
  display: inline-block;
  padding: 1px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  border: 1px solid transparent;
  font-family: var(--font);
  /* font-variant-numeric inherits tabular-nums from body — keeps any digits
     in broker names (rare) lined up. */
}
.broker-pill[data-broker="zerodha"] {
  background: rgba(59, 130, 246, .18);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, .45);
}
.broker-pill[data-broker="shoonya"] {
  background: rgba(245, 158, 11, .18);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, .45);
}
.broker-pill[data-broker=""],
.broker-pill[data-broker="—"] {
  background: rgba(120, 130, 144, .18);
  color: var(--dim, #aaa);
  border-color: rgba(120, 130, 144, .35);
}

/* ─────────────────────────────────────────────────────────────────────────
   Batch E — Tier 3 polish + missing V2 cols
   ───────────────────────────────────────────────────────────────────────── */

/* T3.1 — USER name in top bar.  Fix 1 (round 2) — flex-shrink:0 prevents the
   topbar from squeezing this element when other items grow.  min-width:auto
   lets the cell size to its content. */
.huser {
  display: flex; flex-direction: column; align-items: flex-start;
  margin: 0 12px; min-width: auto;
  flex-shrink: 0;
}
.huser .hulabel {
  font-size: 9px; color: var(--dim, #888);
  letter-spacing: 1px; text-transform: uppercase;
}
.huser .hval-user {
  font-size: 11px; color: var(--fg, #ddd);
  font-weight: 700;
  /* Fix 1 (round 2) — show BOTH client names in ALL mode without ellipsis.
     The 420px cap was being defeated by flex-shrink on the parent .huser; even
     with enough horizontal space, the topbar squeezed this cell.  Solution:
     drop max-width entirely + flex-shrink:0 on parent (set in .huser below). */
  white-space: nowrap;
}

/* T3.3 — Engine Detail panel + clickable card */
.card-clickable { cursor: pointer; transition: border-color 120ms; }
.card-clickable:hover { border-color: var(--accent, #4fc3f7); }
.engine-detail-panel {
  background: #1a2332; border: 1px solid #263245;
  border-radius: 8px; padding: 10px; margin-bottom: 12px;
  font-size: 12px;
}
.engine-detail-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.engine-detail-grid > div {
  padding: 4px 8px; background: rgba(255,255,255,0.03);
  border-radius: 4px;
}
.engine-detail-grid span { color: var(--fg, #ddd); font-weight: 700; }

/* T3.5 — Trade counters strip */
/* Counters now sit just after the export-msg slot (not pushed to far right).
   The .trd-export-msg-slot above provides the breathing-room gap. */
.trade-counters { display: flex; gap: 8px; font-size: 11px; }
.tc-pill { padding: 4px 10px; border-radius: 4px; font-family: var(--font); }
.tc-pill-total  { background: #263238; color: var(--fg, #ddd); }
.tc-pill-active { background: #1b3a2a; color: var(--fg, #ddd); }
.tc-pill-closed { background: #3a2323; color: var(--fg, #ddd); }
.tc-pill-total  b { color: #90caf9; }
.tc-pill-active b { color: #69f0ae; }
.tc-pill-closed b { color: #ff8a80; }
