/* ========================================================================
   MNQ DCA Bot Dashboard — dark theme refresh (gold brand, slate titles)
   Inspired by Linear / Vercel / TradingView / Stripe dashboards.
   Fonts: Inter (UI) + JetBrains Mono (data) — loaded via Google Fonts
   preconnect in dashboard.html <head>.
   ======================================================================== */

:root {
  /* Canvas — deeper near-black so cards pop. */
  --bg: #0a0d16;
  --bg2: #05070f;
  --bg3: #1e2438;
  --card: #141826;
  --card2: #1b2132;

  /* Typography */
  --text: #e8ecff;
  --text2: #a8b2d1;
  --text3: #6d7aa3;
  --title: #94a3b8;  /* slate-400, uppercase section titles */

  /* Brand — gold is the single accent. */
  --gold: #f5b942;
  --gold2: #fbbf24;

  /* Semantic palette */
  --green: #22c55e;
  --green2: #4ade80;
  --red: #ef4444;
  --red2: #f87171;
  --amber: #f59e0b;
  --cyan: #06b6d4;
  --purple: #a855f7;

  /* Legacy alias retained only for stray inline styles that still reference
     --accent (cycle-distance rows, a handful of borders). Aliases to --gold
     so a typoed or unmigrated usage still lands on the brand color. */
  --accent: var(--gold);

  /* Chrome */
  --border: #242b42;
  --border-soft: #1d2333;

  /* Fonts */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  /* Legacy alias (style.css used `var(--mono)` in some inline styles). */
  --mono: var(--font-mono);

  /* Spacing scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Radius scale */
  --radius-sm: 8px;    /* chips, small pills */
  --radius-md: 12px;   /* kpi cards, inputs */
  --radius-lg: 16px;   /* panels */
  --radius-xl: 20px;   /* hero banners */
  --radius-round: 999px;

  /* Elevation (box-shadows) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-xl: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 48px rgba(0, 0, 0, 0.35);

  /* Motion (durations + easings) */
  --motion-fast: 150ms;
  --motion-base: 200ms;
  --motion-slow: 400ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --transition-base: var(--motion-fast) var(--ease-out);

  /* Keyframe durations (pulse/shimmer/blink) */
  --anim-pulse: 1.5s;
  --anim-shimmer: 2s;
}

* { box-sizing: border-box; }

html, body { background: var(--bg); }

body {
  margin: 0;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(245, 185, 66, 0.04), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(124, 58, 237, 0.04), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  font-feature-settings: "cv11" 1;
}

/* Numeric tabular lining figures, applied to any element carrying monospace
   data so columns align even when the mono fallback kicks in. */
.kpi-val,
.kpi-sub,
.value,
.pill,
.log .ts,
.log .kind,
.log .txt,
.cycle-detail,
table.grid td,
#cyc-id,
.heartbeat-age,
#clock,
.builder-preview,
.range-chip,
input[type="text"],
input[type="number"],
input[type="time"],
select {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv11" 1;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* -------- Header ---------------------------------------------------------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 18px var(--space-6);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-lg);
}
.header h1 {
  font-size: 20px;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
  font-weight: 600;
}
.header h1 .accent {
  background: linear-gradient(90deg, var(--gold), var(--gold2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  font-weight: 700;
}
.header .meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text3);
}

/* Status badge --------------------------------------------------------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  border-radius: var(--radius-round);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-ui);
  background: rgba(108, 122, 163, 0.18);
  color: var(--text2);
  border: 1px solid var(--border);
}
.status-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text3);
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
}
.status-badge.idle    { background: rgba(108, 122, 163, 0.18); color: var(--text2); }
.status-badge.idle .dot { background: var(--text3); }
.status-badge.offline { background: rgba(108, 122, 163, 0.18); color: var(--text3); }
.status-badge.offline .dot { background: var(--text3); }
.status-badge.trading { background: rgba(34, 197, 94, 0.16); color: var(--green2); border-color: rgba(34, 197, 94, 0.35); }
.status-badge.trading .dot {
  background: var(--green2);
  color: var(--green2);
  animation: pulse var(--anim-pulse) infinite;
}
.status-badge.stopping { background: rgba(245, 158, 11, 0.18); color: var(--amber); border-color: rgba(245, 158, 11, 0.35); }
.status-badge.stopping .dot { background: var(--amber); }
.status-badge.killed  { background: rgba(239, 68, 68, 0.18); color: var(--red2); border-color: rgba(239, 68, 68, 0.4); }
.status-badge.killed .dot { background: var(--red2); }
.status-badge.error   { background: rgba(239, 68, 68, 0.28); color: #fff; border-color: var(--red); }
.status-badge.error .dot {
  background: var(--red);
  color: var(--red);
  animation: pulse var(--anim-pulse) infinite;
}

/* Pulse — used only on "live" states (trading, error). currentColor trick lets
   us reuse the dot's CSS color as the shockwave tint. */
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; }
  70%      { box-shadow: 0 0 0 8px transparent; }
}

/* -------- Panels ---------------------------------------------------------- */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-lg);
}
.panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--title);
  margin: 0 0 var(--space-4);
  font-weight: 600;
  font-family: var(--font-ui);
}

/* -------- Icons ----------------------------------------------------------- */
.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  vertical-align: -3px;
  stroke-width: 2;
}
.btn .icon { margin-right: 6px; }

/* -------- Controls -------------------------------------------------------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px var(--space-4);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .06s ease, background var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-start { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.45); color: var(--green2); }
.btn-start:hover:not(:disabled) { background: rgba(34, 197, 94, 0.22); }
.btn-stop  { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.45); color: var(--amber); }
.btn-stop:hover:not(:disabled)  { background: rgba(245, 158, 11, 0.22); }
.btn-kill  { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.5); color: var(--red2); }
.btn-kill:hover:not(:disabled)  { background: rgba(239, 68, 68, 0.22); }
/* btn-apply = gold, the brand's primary action. */
.btn-apply { background: rgba(245, 185, 66, 0.12); border-color: rgba(245, 185, 66, 0.45); color: var(--gold); }
.btn-apply:hover:not(:disabled) { background: rgba(245, 185, 66, 0.22); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text2); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.04); color: var(--text); }

.tpl-row { display: flex; align-items: center; gap: 10px; margin-left: auto; }
select, input[type="text"], input[type="number"], input[type="time"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.15);
}

/* -------- Custom template builder ---------------------------------------- */
.builder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px var(--space-5);
}
.builder-field { display: flex; flex-direction: column; gap: var(--space-1); }
.builder-field.full { grid-column: 1 / -1; }
.builder-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  font-family: var(--font-ui);
  font-weight: 500;
}
.builder-field input[type="text"],
.builder-field input[type="number"] {
  width: 100%;
}
.builder-hint { font-size: 11px; color: var(--text3); font-family: var(--font-mono); }
.builder-preview {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gold);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-height: 38px;
  white-space: pre-wrap;
}
.builder-preview.err { color: var(--red2); border-color: rgba(239, 68, 68, 0.5); }
.builder-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: var(--space-1);
}
.builder-overwrite {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: auto;
}


@media (max-width: 700px) {
  .builder-grid { grid-template-columns: 1fr; }
}

/* -------- KPI grid -------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-flow: dense;          /* fill holes created by the hero span-2
                                     so we never leave a gap in the middle
                                     of a row */
  gap: var(--space-4);
}
/* Desktop stays at a fixed 4-col grid so the layout is predictable:
   - 7 KPIs visible (SL hidden) = 8 slots (hero spans 2) = 2 rows × 4 ✓
   - 8 KPIs (SL target set)     = 9 slots → 2 rows × 4 + 1 orphan card
   auto-fit created "trou à droite" on row 2 when the viewport fit 5 cols
   per row but only 3 cards remained — dense 4-col kills that. */
.kpi {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-base), transform var(--transition-base);
}
.kpi:hover { border-color: rgba(245, 185, 66, 0.2); }
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
}
.kpi.gold::before  { background: linear-gradient(90deg, var(--gold), var(--gold2)); }
.kpi.green::before { background: linear-gradient(90deg, var(--green), var(--green2)); }
.kpi.red::before   { background: linear-gradient(90deg, var(--red), var(--red2)); }
/* "cyan" modifier maps to a flat slate stripe — the original gradient went
   from text3 to title, two nearly identical shades, so the gradient read as
   a muddy line. A single --title fill is cleaner and matches the brand. */
.kpi.cyan::before  { background: var(--title); }
.kpi-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  font-weight: 500;
}

.kpi-val {
  font-size: 28px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.kpi-val.green { color: var(--green2); }
.kpi-val.red   { color: var(--red2); }
.kpi-val.gold  { color: var(--gold); }
.kpi-val.cyan  { color: var(--title); }
.kpi-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: var(--space-2);
  font-family: var(--font-mono);
}

/* Hero card: PnL du jour — visually distinct via a larger value font,
   NOT via a grid-column span. Spanning 2 columns caused an odd slot
   count (7 or 8 KPIs → 8 or 9 slots) that forced a 3rd row with a
   single orphan card on desktop. Same width as every other card = two
   clean rows of four. */
.kpi.hero .kpi-val { font-size: 32px; }

/* -------- Risk tiles (DLL / MLL / Cycles) --------------------------------
   Flat text replacements for the former radial gauges. Tier class on the
   host .kpi drives the value color — no SVG, no pulse, no decoration.
-------------------------------------------------------------------------- */
#kpi-dll-card.safe    .kpi-val,
#kpi-mll-card.safe    .kpi-val,
#kpi-cycles-card.safe .kpi-val { color: var(--green2); }
#kpi-dll-card.caution    .kpi-val,
#kpi-mll-card.caution    .kpi-val,
#kpi-cycles-card.caution .kpi-val { color: var(--amber); }
#kpi-dll-card.danger    .kpi-val,
#kpi-mll-card.danger    .kpi-val,
#kpi-cycles-card.danger .kpi-val { color: var(--red2); }

/* Progress bar for daily TP */
.progress {
  margin-top: var(--space-3);
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-round);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--green2));
  transition: width .3s ease;
}
.progress-bar.reached {
  background: linear-gradient(90deg, var(--gold) 0%, rgba(245, 185, 66, 0.4) 50%, var(--gold) 100%);
  background-size: 200% 100%;
  animation: shimmer var(--anim-shimmer) linear infinite;
}
.progress-bar.near-goal {
  /* Triggered when % > 80 — same shimmer, keeps momentum visible. */
  background: linear-gradient(90deg, var(--gold) 0%, rgba(245, 185, 66, 0.4) 50%, var(--gold) 100%);
  background-size: 200% 100%;
  animation: shimmer var(--anim-shimmer) linear infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Daily SL progress bar — symmetric to TP, red gradient. */
.progress-bar.sl-bar { background: linear-gradient(90deg, var(--amber), var(--red2)); }
.progress-bar.sl-bar.warn { background: linear-gradient(90deg, var(--red), var(--red2)); }
.progress-bar.sl-bar.critical {
  background: linear-gradient(90deg, var(--red) 0%, rgba(239, 68, 68, 0.4) 50%, var(--red) 100%);
  background-size: 200% 100%;
  animation: shimmer var(--anim-shimmer) linear infinite, sl-blink 1.2s ease-in-out infinite;
  box-shadow: 0 0 8px var(--red);
}
@keyframes sl-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* -------- Two-column mid-row --------------------------------------------- */
.mid-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}


/* -------- Collapsible panel (<details>) ---------------------------------- */
/* Used by the Custom Template Builder: default closed, click summary / press
   Enter to open. Native <details> gives us keyboard + screen-reader support
   for free — we only style the summary + chevron. */
details.panel-collapsible { padding: 0; }
details.panel-collapsible > summary {
  list-style: none;             /* hide default triangle */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  user-select: none;
  border-radius: var(--radius-lg);
  transition: background-color var(--transition-base);
}
details.panel-collapsible > summary::-webkit-details-marker { display: none; }
details.panel-collapsible > summary::marker { content: ''; }
details.panel-collapsible > summary:hover { background: rgba(255,255,255,.02); }
details.panel-collapsible > summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}
details.panel-collapsible > summary h2 {
  margin: 0;                    /* override default h2 margin */
  padding: 0;
}
details.panel-collapsible > summary .chevron {
  width: 18px;
  height: 18px;
  color: var(--title);
  flex-shrink: 0;
  transition: transform .2s ease;
}
details.panel-collapsible[open] > summary .chevron { transform: rotate(180deg); }
details.panel-collapsible[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
details.panel-collapsible > .builder-grid { padding: var(--space-5) var(--space-6) var(--space-6); }
/* Respect prefers-reduced-motion (zero animation on the chevron) */
@media (prefers-reduced-motion: reduce) {
  details.panel-collapsible > summary .chevron { transition: none; }
}

/* Cycle panel */
.cycle-detail { font-family: var(--font-mono); font-size: 13px; color: var(--text2); }
.cycle-detail .row { display: flex; justify-content: space-between; padding: var(--space-2) 0; border-bottom: 1px dashed var(--border-soft); }
.cycle-detail .row:last-child { border-bottom: none; }
.cycle-detail .label {
  color: var(--text3);
  font-family: var(--font-ui);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cycle-detail .value { color: var(--text); }
.cycle-detail .value.red { color: var(--red2); }
.cycle-detail .value.green { color: var(--green2); }
.cycle-detail .value.gold { color: var(--gold); }

/* Grid table */
table.grid { width: 100%; border-collapse: collapse; font-size: 12px; }
table.grid th {
  background: var(--bg);
  color: var(--title);
  text-align: left;
  padding: 10px var(--space-3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  font-family: var(--font-ui);
  border-bottom: 1px solid var(--border);
}
table.grid td {
  padding: 10px var(--space-3);
  border-bottom: 1px solid var(--border-soft);
  color: var(--text2);
  font-family: var(--font-mono);
}
table.grid tr:last-child td { border-bottom: none; }
table.grid tr.filled {
  background: rgba(34, 197, 94, 0.06);
}
table.grid tr.filled td {
  color: var(--green2);
  font-weight: 600;
}
table.grid tr.filled td:first-child {
  border-left: 2px solid var(--green2);
}
table.grid tr.filled td:first-child::before { content: '✓ '; color: var(--green2); }
table.grid tr.pending { opacity: 0.55; }

/* Grid preset buttons */
.grid-presets { gap: 10px; margin-top: 12px; }
.btn-preset {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 14px; border: 1px solid var(--border-soft);
  border-radius: var(--radius-md); background: var(--card2);
  cursor: pointer; text-align: center; gap: 2px;
  flex: 1; transition: border-color 0.2s, background 0.2s;
  font-family: var(--font-ui); font-size: 11px;
}
.btn-preset:hover { border-color: var(--accent); background: rgba(99,102,241,0.08); }
.btn-preset.active { border-color: var(--green2); background: rgba(34,197,94,0.08); }
.btn-preset .preset-name { font-weight: 700; font-size: 14px; color: var(--title); font-family: var(--mono); }
.btn-preset .preset-detail { color: var(--text2); font-family: var(--mono); }
.btn-preset .preset-sizes { color: var(--accent); font-weight: 600; }
.btn-preset .preset-sl { color: var(--red2); font-family: var(--mono); }
.btn-preset.active .preset-name { color: var(--green2); }

/* -------- Filters --------------------------------------------------------- */
.filter-block { border-bottom: 1px dashed var(--border-soft); padding: 14px 0; }
.filter-block:last-child { border-bottom: none; }

/* Filter bricks (vue d'ensemble) — tri-color tier pattern from /opt/MES */
.filter-bricks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.brick {
  background: var(--card2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 68px;
}
.brick-label {
  color: var(--text3);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
.brick-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.brick-note {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text3);
}
.brick[data-tier="go"] {
  background: rgba(34, 197, 94, 0.10);
  border-color: rgba(34, 197, 94, 0.45);
}
.brick[data-tier="go"] .brick-value { color: var(--green2); }
.brick[data-tier="approach"] {
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.45);
  animation: brick-pulse-amber 2.4s ease-in-out infinite;
}
.brick[data-tier="approach"] .brick-value { color: var(--amber); }
.brick[data-tier="blocked"] {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.45);
}
.brick[data-tier="blocked"] .brick-value { color: var(--red2); }
.brick[data-tier="off"] { opacity: 0.55; }
.brick[data-tier="none"] .brick-value { color: var(--text3); }
.brick[data-group="overall"] {
  grid-column: 1 / -1;
  min-height: 56px;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}
.brick[data-group="overall"] .brick-value {
  font-size: 18px;
  letter-spacing: 0.06em;
}
@keyframes brick-pulse-amber {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.28); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}
.filter-head { display: flex; align-items: center; gap: 10px; }
.filter-head label { color: var(--text); font-weight: 500; font-size: 14px; cursor: pointer; }
.filter-body {
  margin-top: 10px;
  padding-left: 28px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
/* Read-only TP/SL target display — values are edited through the KPI
   popover; this row is just a mirror so the kill-switch block still
   carries the "threshold" context next to the enable toggle. */
.filter-target-display {
  display: inline-flex;
  align-items: baseline;
  padding: 2px 10px;
  background: var(--card2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.filter-edit-hint {
  color: var(--text3);
  font-size: 11px;
  font-style: italic;
}
.range-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-1) 10px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-round);
  font-size: 11px;
  color: var(--text);
}
.range-chip .x {
  cursor: pointer;
  color: var(--red2);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}
.range-chip .x:hover { color: var(--red); }
.range-chip .icon { width: 12px; height: 12px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-round);
  transition: var(--motion-base);
}
.slider::before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: var(--text3);
  border-radius: 50%;
  transition: var(--motion-base);
}
.switch input:checked + .slider {
  background: rgba(245, 185, 66, 0.25);
  border-color: var(--gold);
}
.switch input:checked + .slider::before {
  transform: translateX(18px);
  background: var(--gold);
}

/* -------- Trades log ------------------------------------------------------ */
.log {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;             /* no horizontal bleed */
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--space-3) 14px;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;                   /* allow the parent grid cell to shrink */
}
.log .line {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(36, 43, 66, 0.5);
  align-items: center;
  min-width: 0;                   /* let flex children ellipsize */
}
.log .line:last-child { border-bottom: none; }
.log .ts {
  color: var(--title);
  flex: 0 0 auto;                 /* fixed prefix */
  min-width: 64px;
  font-variant-numeric: tabular-nums;
}
.log .txt {
  color: var(--text2);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;            /* trades log is 1 event per line */
}
.log .txt.buy  { color: var(--green2); }
.log .txt.sell { color: var(--red2); }
.log .txt.info { color: var(--text2); }
.log-empty { color: var(--text3); font-style: italic; padding: var(--space-2) 0; }

/* -------- Event log (icons for kind instead of plain dots) --------------- */
.log .line .kind-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;                 /* never shrink the icon */
  color: var(--text3);
}
.log .line .kind-dot .icon { width: 14px; height: 14px; }
.log .line .kind-dot.red    { color: var(--red2); }
.log .line .kind-dot.amber  { color: var(--amber); }
.log .line .kind-dot.green  { color: var(--green2); }
.log .line .kind-dot.grey   { color: var(--text3); }
.log .line .kind {
  color: var(--text);
  font-weight: 600;
  font-family: var(--font-mono);
  flex: 0 0 auto;                 /* tag label — don't stretch */
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log .line .reason {
  color: var(--text3);
  flex: 1 1 auto;                 /* eat the rest, ellipsize cleanly */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -------- Logs row (Trades + Events side by side) ------------------------ */
.logs-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);   /* critical: allow
     each column to shrink to 0 so its .log child can ellipsize instead of
     forcing the grid to expand past the container width */
  gap: 18px;
  align-items: stretch;                                    /* equal heights */
}
.logs-row .panel {
  margin-bottom: 18px;
  min-width: 0;                   /* same rationale as above for panel itself */
  display: flex;
  flex-direction: column;
}
.logs-row .panel .log {
  flex: 1 1 auto;                 /* log body fills the panel height so
                                     sibling columns visually align */
}

/* -------- Muted / pill helpers ------------------------------------------- */
.muted { color: var(--text3); }
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-round);
  font-size: 11px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text2);
  margin-left: 6px;
}
.pill .icon { width: 12px; height: 12px; }
.pill.pill-muted { color: var(--text3); }
.pill.pill-warn  { color: var(--amber); border-color: rgba(245, 158, 11, 0.45); }
.pill.pill-err   { color: var(--red2);  border-color: rgba(239, 68, 68, 0.5); }
.pill.pill-ok    { color: var(--green2); border-color: rgba(34, 197, 94, 0.45); }

/* Heartbeat age pill next to status-badge.
   .err variant absorbs the former full-width stalled-banner role: a red
   pill sitting right next to the bot status that pulses quietly when the
   heartbeat is stale. No separate alert ribbon. */
.heartbeat-age {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
}
.heartbeat-age.warn { color: var(--amber); }
.heartbeat-age.err  {
  color: white;
  font-weight: 700;
  background: rgba(239, 68, 68, 0.95);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  animation: hb-stalled-pulse 2s infinite;
}
@keyframes hb-stalled-pulse {
  0%, 100% { background: rgba(239, 68, 68, 0.95); }
  50%      { background: rgba(239, 68, 68, 0.70); }
}

/* Cycle-detail TP/SL distance rows use the same layout as .row. */
.cycle-detail .row.cyc-distance-row { font-size: 12px; }
.cycle-detail .row .value.muted { color: var(--text3); }

/* -------- Toast ----------------------------------------------------------- */
#toast-host {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}
.toast {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--space-3) 18px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-ui);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 240px;
  animation: slideIn var(--motion-base) ease;
}
.toast.ok    { border-left: 4px solid var(--green2); }
.toast.err   { border-left: 4px solid var(--red2); }
.toast.info  { border-left: 4px solid var(--gold); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* -------- Modal (native <dialog>) ---------------------------------------- */
dialog.modal {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--red);
  border-radius: var(--radius-lg);
  padding: 28px var(--space-8);
  max-width: 480px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
dialog.modal::backdrop {
  background: rgba(5, 7, 15, 0.75);
  backdrop-filter: blur(2px);
}
dialog.modal[open] {
  overflow: hidden;
}
.modal h3 {
  margin: 0 0 var(--space-3);
  color: var(--red2);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal p { color: var(--text2); margin-bottom: var(--space-5); }
.modal .actions { display: flex; justify-content: center; gap: 14px; }
/* Stacked actions for the 3-option apply-mode modal — layout top-to-bottom
   on phones, still inline on desktop with a clear primary (Now = filled
   green) vs. secondary (Next cycle = gold) vs. ghost (Cancel). */
.modal .actions-stack { flex-wrap: wrap; }
.btn-apply-next {
  background: rgba(245, 185, 66, 0.15);
  color: var(--gold);
  border: 1px solid rgba(245, 185, 66, 0.4);
}
.btn-apply-next:hover {
  background: rgba(245, 185, 66, 0.28);
  border-color: var(--gold);
}

/* -------- Responsive tweaks ---------------------------------------------- */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .mid-row { grid-template-columns: 1fr; }
  .logs-row { grid-template-columns: 1fr; }
  .header { flex-direction: column; align-items: flex-start; }
  .tpl-row { margin-left: 0; }
}

/* ===== Tablette (<= 768px) ===== */
@media (max-width: 768px) {
  .container { padding: var(--space-4) 14px 64px; }
  .panel { padding: 18px var(--space-4); border-radius: 14px; }
  .panel h2 { font-size: 11px; margin-bottom: var(--space-3); }
  .header { padding: 14px var(--space-4); gap: 10px; border-radius: 14px; }
  .header h1 { font-size: 18px; }
  .header .meta { flex-wrap: wrap; gap: 10px; width: 100%; }
  .header .meta select#account-select { width: 100%; min-width: 0 !important; }
  .controls { gap: 10px; }
  .tpl-row { width: 100%; flex-wrap: wrap; gap: var(--space-2); }
  .tpl-row select { flex: 1 1 140px; min-width: 0; }
  .btn, select, input[type="text"], input[type="number"], input[type="time"] {
    min-height: 44px; font-size: 14px; padding: 10px 14px;
  }
  .btn { padding: var(--space-3) var(--space-4); }
  .panel table.grid { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .filter-body { padding-left: 0; gap: 10px; }
  .filter-body input[type="time"], .filter-body input[type="number"] {
    width: auto !important; flex: 0 1 auto; min-width: 80px;
  }
  .kpi.hero .kpi-val { font-size: 28px; }
}

/* ===== Mobile (<= 480px) — iPhone SE @ 375px and up ===== */
@media (max-width: 480px) {
  .container { padding: 12px 10px 56px; }
  .panel { padding: 14px 12px; margin-bottom: 14px; border-radius: 12px; }
  .header h1 { font-size: 17px; line-height: 1.25; }
  .header .meta { font-size: 11px; gap: 8px; }
  #clock { font-size: 12px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 14px; text-align: left; min-height: 160px; }
  .kpi-val { font-size: 22px; }
  .kpi.hero .kpi-val { font-size: 26px; }
  .kpi-label { font-size: 10px; }
  .controls { flex-direction: column; align-items: stretch; }
  .controls > .btn { width: 100%; text-align: center; justify-content: center; }
  .tpl-row { margin-top: 4px; }
  .tpl-row > * { flex: 1 1 100%; }
  .cycle-detail .row { flex-wrap: wrap; gap: 4px; font-size: 12px; }
  .builder-actions { flex-direction: column; align-items: stretch; }
  .builder-actions .btn { width: 100%; justify-content: center; }
  .builder-overwrite { margin-right: 0; justify-content: center; }
  .log { max-height: 240px; font-size: 11px; padding: 8px 10px; }
  .log .line { gap: 8px; }
  .log .ts { min-width: 56px; }
  #toast-host { top: 10px; right: 10px; left: 10px; }
  .toast { min-width: 0; width: 100%; padding: 10px 14px; font-size: 12px; }
  dialog.modal { padding: 20px 18px; max-width: calc(100vw - 24px); border-radius: 14px; }
  .modal h3 { font-size: 17px; }
  .modal .actions { flex-direction: column-reverse; gap: 10px; }
  .modal .actions .btn { width: 100%; justify-content: center; }
  .status-badge { padding: 6px 10px; font-size: 10px; }
  .filter-head label { font-size: 13px; }
  .switch { width: 44px; height: 24px; }
  .switch .slider::before { height: 16px; width: 16px; }
  .switch input:checked + .slider::before { transform: translateX(20px); }
}

/* =========================================================================
   Mission Control Strip — sticky hero band at top of <body>.
   Glassy dark surface with frosted blur so the gradient backdrop still
   shows through; metrics centered, status left, kill button pinned right.
   ========================================================================= */
.mission-control {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-6);
  background: rgba(10, 13, 22, 0.92);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.mc-group { display: flex; align-items: center; gap: var(--space-4); }
.mc-metrics { flex: 1 1 auto; justify-content: center; gap: var(--space-8); }
.mc-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.mc-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--title);
  font-family: var(--font-ui);
  font-weight: 600;
}
.mc-value {
  font-size: 15px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv11" 1;
  color: var(--text);
  white-space: nowrap;
}
.mc-huge { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }

.mc-account {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text3);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mc-account .mc-account-name { color: var(--text2); }

.mc-status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  border-radius: var(--radius-round);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text2);
}
.mc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
}
.mc-status-badge.mc-trading {
  color: var(--green2);
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.08);
}
.mc-status-badge.mc-trading .mc-dot {
  background: var(--green2);
  color: var(--green2);
  animation: pulse var(--anim-pulse) infinite;
}
.mc-status-badge.mc-stopped {
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
}
.mc-status-badge.mc-stopped .mc-dot { background: var(--amber); }
.mc-status-badge.mc-error {
  color: var(--red2);
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
}
.mc-status-badge.mc-error .mc-dot {
  background: var(--red);
  color: var(--red);
  animation: pulse var(--anim-pulse) infinite;
}
.mc-status-badge.mc-idle { color: var(--text2); }
.mc-status-badge.mc-idle .mc-dot { background: var(--text3); }

/* Semantic value colors — shared with KPI cards. */
.mc-pnl.up   { color: var(--green2); }
.mc-pnl.down { color: var(--red2); }
.mc-value.green  { color: var(--green2); }
.mc-value.amber  { color: var(--amber); }
.mc-value.danger { color: var(--red2); }

/* Urgent flat-by state: blinks until the user flattens. */
.mc-flatby.urgent {
  color: var(--red2);
  animation: pulse-text 1s infinite alternate;
}
@keyframes pulse-text {
  from { opacity: 1; }
  to   { opacity: 0.55; }
}

/* Mission Control action buttons
   ------------------------------
   Hierarchy:
   - .mc-start  = primary (filled green, most used when bot is idle)
   - .mc-stop   = secondary (ghost amber, paired with Start)
   - .mc-kill   = destructive emergency (filled red, separated by a
                  divider + extra margin so it's not fired by accident)
   All three share .mc-btn (sizing + label + kbd chip layout). Min
   height 38px keeps the click target comfortable on touch devices.
*/
.mc-actions { gap: var(--space-3); align-items: center; }
.mc-actions-pair { display: inline-flex; gap: 6px; }
.mc-actions-divider {
  width: 1px; height: 28px; background: var(--border);
  margin: 0 2px;
}

.mc-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  transition: background var(--transition-base), border-color var(--transition-base),
              color var(--transition-base), transform 0.06s ease,
              box-shadow var(--transition-base);
  color: var(--text);
}
.mc-btn-icon { width: 16px; height: 16px; flex-shrink: 0; }
.mc-btn-label { line-height: 1; }
.mc-btn-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: inherit;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid currentColor;
  border-radius: 5px;
  opacity: 0.75;
  line-height: 1;
}
.mc-btn:hover:not(:disabled) .mc-btn-kbd { opacity: 1; }
.mc-btn:active:not(:disabled) { transform: translateY(1px); }
.mc-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.mc-btn:disabled .mc-btn-kbd { opacity: 0.5; }

/* Start — PRIMARY filled green. This is the most-used action when the
   bot is idle; it should read as "the thing to press". */
.mc-start {
  background: var(--green);
  border-color: var(--green);
  color: #0a1b0e;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset,
              0 2px 8px rgba(34, 197, 94, 0.25);
}
.mc-start:hover:not(:disabled) {
  background: var(--green2);
  border-color: var(--green2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset,
              0 4px 14px rgba(34, 197, 94, 0.35);
}
.mc-start:focus-visible { outline: 2px solid var(--green2); outline-offset: 2px; }
.mc-start .mc-btn-kbd {
  background: rgba(10, 27, 14, 0.25);
  border-color: rgba(10, 27, 14, 0.45);
}

/* Stop — SECONDARY ghost amber, paired with Start. Filled only on hover
   so it doesn't compete with the green primary. */
.mc-stop {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--amber);
}
.mc-stop:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.22);
  border-color: var(--amber);
}
.mc-stop:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* Kill — DESTRUCTIVE emergency. Filled red so it's unmistakable, but
   uses double-confirm modal so the emphasis isn't dangerous. */
.mc-kill {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.5);
  color: var(--red2);
  font-weight: 700;
}
.mc-kill:hover:not(:disabled) {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}
.mc-kill:focus-visible { outline: 2px solid var(--red2); outline-offset: 2px; }

/* Running-state polish: when the bot is live, Start is disabled, so Stop
   becomes the effective primary. Give it a hint of solid amber to match. */
.mc-stop:not(:disabled) {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--amber);
}

/* Mission Control responsive — wrap to 2 rows on tablets, hide clock on phone. */
@media (max-width: 900px) {
  .mission-control {
    flex-wrap: wrap;
    padding: 10px 16px;
    gap: 12px;
  }
  .mc-metrics {
    order: 2;
    width: 100%;
    justify-content: space-between;
    gap: 12px;
    overflow-x: auto;
  }
  .mc-identity, .mc-actions { order: 1; }
  .mc-huge { font-size: 20px; }
  .mc-value { font-size: 13px; }
  .mc-account { max-width: 140px; }
}
@media (max-width: 480px) {
  .mission-control { padding: 8px 12px; gap: 8px; }
  .mc-metrics { gap: 10px; }
  .mc-metric-clock { display: none; }
  /* Compact buttons for phones: keep label + icon but drop the kbd chip
     (no physical keyboard) and slim the padding a touch. */
  .mc-btn { min-height: 40px; padding: 0 12px; font-size: 12px; gap: 6px; }
  .mc-btn-icon { width: 14px; height: 14px; }
  .mc-btn-kbd { display: none; }
  .mc-account { max-width: 100px; font-size: 11px; }
}

/* -------- Global :focus-visible — coherent keyboard-nav outline --------
   Only shows on keyboard focus (tab), not on mouse click, so the gold ring
   never pollutes pointer users. Component-specific :focus-visible blocks
   above (mc-start/mc-stop/mc-kill) take precedence via specificity. */
:where(.btn, button, .switch input, .pill, summary, [role="button"]):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: inherit;
}
.switch input:focus-visible + .slider {
  box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.3);
}

/* -------- Reduced motion — respect OS preference ------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================================================================
   Fix 1 — Empty states
   Shared utility for every "no data yet" surface: KPIs with no account,
   idle cycle panel, trades log, events log. Centered column with a muted
   Lucide icon + two-line copy. Replaces the old wall of "--" placeholders.
   ========================================================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-6);
  color: var(--text3);
  text-align: center;
}
/* `display: flex` on .empty-state silently overrode the native `hidden`
   attribute — once data arrived we set `hidden=true` but the empty
   block kept rendering under the chart. Respect the attribute. */
.empty-state[hidden] { display: none !important; }
.empty-state .icon {
  width: 32px;
  height: 32px;
  opacity: 0.4;
  stroke-width: 1.5;
}
.empty-state-title {
  font-size: 13px;
  color: var(--text2);
  font-family: var(--font-ui);
  font-weight: 500;
}
.empty-state-hint {
  font-size: 11px;
  color: var(--text3);
  font-style: italic;
  font-family: var(--font-ui);
  max-width: 320px;
}

/* KPI card in empty state — label + value fade to text3; icon slots
   next to the label via a flex row. Kept layout-compatible with the
   existing centered KPI so heights stay stable. */
.kpi.is-empty .kpi-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text3);
}
.kpi.is-empty .kpi-label .icon {
  width: 12px;
  height: 12px;
  color: var(--text3);
  opacity: 0.7;
}
.kpi.is-empty .kpi-val,
.kpi.is-empty .kpi-sub {
  color: var(--text3);
  opacity: 0.55;
}

/* Trades/events log empty — upgrade the plain .log-empty to a centered
   illustrated block. Kept .log-empty as a namespaced alias so existing
   JS that still writes textContent keeps working. */
.log .empty-state {
  padding: var(--space-6) var(--space-3);
}

/* =========================================================================
   Fix 2 — STALLED banner + sticky-top wrapper
   The <header class="sticky-top"> wraps the banner + Mission Control Strip
   so they stick together at the viewport top. Banner z-index 101 > strip
   100 so the banner is never occluded by the strip's backdrop blur.
   ========================================================================= */
.sticky-top {
  position: sticky;
  top: 0;
  z-index: 100;
}
/* Override the strip's own sticky — when nested in .sticky-top the parent
   handles stickiness and the strip just flows inside. Dropping position
   from the child prevents a double-sticky jitter when the banner shows. */
.sticky-top .mission-control {
  position: static;
}
/* .heartbeat-age.err now carries the STALLED semantics — see below for the
   alert pill styling. Former full-width .stalled-banner removed; one sticky
   element beats two competing top strips. */

/* =========================================================================
   Fix 3 — Mission Control: add heartbeat-age under status badge.
   Stacks the badge + hb pill vertically to reclaim the slot vacated by
   the header cleanup. The badge keeps its horizontal layout; the age
   pill sits directly beneath in a tight 2-line column.
   ========================================================================= */
.mc-identity-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  min-width: 0;
}
.mc-identity-col .heartbeat-age {
  font-size: 10px;
  padding-left: 4px;
  line-height: 1;
}

/* =========================================================================
   Fix 4 — Flash "Applied" feedback
   Subtle gold wash that fades out over 600ms. Reused by template-apply and
   daily-target save paths. var(--ease-out) keeps motion consistent with
   the rest of the design system.
   ========================================================================= */
@keyframes flash-applied {
  0%   { background-color: rgba(245, 185, 66, 0.20); }
  100% { background-color: transparent; }
}
.flash-applied {
  animation: flash-applied var(--motion-slow) var(--ease-out);
}

/* =========================================================================
   Fix 5 — KPI popover (inline edit for Daily TP / SL targets)
   Attached below the KPI card via position:absolute; the parent .kpi-clickable
   gets position:relative so the popover aligns to its left edge. z-index 50
   keeps it below the sticky header (100) but above sibling cards.
   ========================================================================= */
.kpi-clickable {
  cursor: pointer;
  position: relative;
}
.kpi-clickable:hover { border-color: rgba(245, 185, 66, 0.35); }
.kpi-clickable:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.kpi-popover {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  z-index: 50;
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-align: left;
  cursor: default;
  animation: popover-enter var(--motion-fast) var(--ease-out);
}
.kpi-popover[hidden] { display: none; }
.kpi-popover label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  font-family: var(--font-ui);
  font-weight: 500;
}
.kpi-popover input[type="number"] {
  width: 100%;
  font-size: 14px;
}
.kpi-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-1);
}
.kpi-popover-actions .btn {
  padding: 6px var(--space-3);
  font-size: 11px;
}
@keyframes popover-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Mobile: popover sits below the card full-width so it doesn't overflow. */
@media (max-width: 480px) {
  .kpi-popover {
    left: 0;
    right: 0;
    min-width: 0;
  }
}

/* ====================================================================
   Équity curve panel — signature visuelle, rendu uPlot.
   uPlot ships a light-theme default CSS; we override axis/grid/legend
   colors so it blends into our dark trader theme.
   ==================================================================== */
.panel-chart { padding-top: var(--space-5); }
.panel-chart .chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-4);
}
.panel-chart .chart-header h2 { margin: 0; }
.chart-legend {
  display: flex;
  gap: var(--space-4);
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-mono);
  flex-wrap: wrap;
}
.chart-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.chart-legend .legend-item .dot {
  width: 14px;
  height: 2px;
  border-radius: 1px;
  display: inline-block;
}
.chart-legend .legend-item .dot.gold  { background: var(--gold); }
.chart-legend .legend-item .dot.green { color: #4ade80; }
.chart-legend .legend-item .dot.amber { color: var(--amber); }
.chart-legend .legend-item .dot.red   { color: var(--red2); }
/* Dashed dots use a repeating-linear-gradient so the legend matches the
   actual dashed stroke of the on-chart line (no <svg> needed). */
.chart-legend .legend-item .dot.dashed {
  background-image: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 6px);
  background-color: transparent;
}
/* "Reset" link after the legend — restores auto-scale after drag zoom. */
.chart-legend .btn-link {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 2px 10px;
  border-radius: var(--radius-round);
  cursor: pointer;
  text-transform: uppercase;
  transition: color var(--transition-base), border-color var(--transition-base);
}
.chart-legend .btn-link:hover {
  color: var(--text);
  border-color: var(--gold);
}
.chart-host {
  width: 100%;
  height: 220px;
  min-height: 180px;
  position: relative;
}
/* Hide the chart host when empty-state is shown (JS toggles [hidden] on
   #equity-empty — if it's visible, shrink the host to 0 to avoid a blank
   uPlot placeholder eating vertical space). */
#equity-panel .empty-state {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text3);
}
#equity-panel .empty-state .icon {
  width: 32px;
  height: 32px;
  opacity: 0.5;
  margin-bottom: var(--space-2);
}
#equity-panel .empty-state-title {
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: var(--space-1);
}
#equity-panel .empty-state-hint {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-mono);
}

/* uPlot dark-theme overrides — uPlot.min.css targets a light theme. */
.uplot {
  font-family: var(--font-mono);
  color: var(--text2);
  width: 100% !important;
}
.uplot .u-title,
.uplot .u-legend,
.uplot .u-label {
  color: var(--text3) !important;
}
.uplot .u-legend {
  font-size: 11px;
  text-align: left;
}
.uplot .u-select {
  background: rgba(245, 185, 66, 0.08);
}
.uplot .u-cursor-x,
.uplot .u-cursor-y {
  border-color: rgba(245, 185, 66, 0.35) !important;
}

@media (max-width: 640px) {
  .chart-host { height: 180px; }
  .panel-chart .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  .chart-legend { font-size: 10px; gap: var(--space-3); }
}

/* =========================================================================
   Hero Status Banner — tri-tier verdict (ON TRACK / CAUTION / STOP)
   Sits between the local .header title block and the équity-panel.
   The [data-state="…"] attribute is flipped by renderHeroStatus(data) in
   app.js and drives every visual layer (bg gradient, border, badge color
   and the STOP pulse animation). Colors lift the existing tier-ramp
   tokens (green/amber/red at 12-20% alpha) so the banner reads as an
   extension of the gauge language, not a new palette.
   ========================================================================= */
.hero-status {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-5);
  font-family: var(--font-ui);
  box-shadow: var(--shadow-lg);
  border: 1px solid transparent;
  transition: background var(--transition-base), border-color var(--transition-base);
}
.hero-status .hs-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.hero-status .hs-icon { width: 20px; height: 20px; }
.hero-status .hs-reason {
  flex: 1 1 auto;
  font-size: 13px;
  color: var(--text2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero-status .hs-metrics {
  display: flex;
  gap: var(--space-4);
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.hero-status .hs-metric-label {
  color: var(--text3);
  margin-right: var(--space-1);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.hero-status .hs-metric-val { color: var(--text); }

/* Tier colors — gradient + border keyed off data-state. */
.hero-status[data-state="on-track"] {
  background: linear-gradient(90deg, rgba(34,197,94,0.12), rgba(34,197,94,0.04));
  border-color: rgba(34,197,94,0.3);
}
.hero-status[data-state="on-track"] .hs-badge { color: var(--green2); }

.hero-status[data-state="caution"] {
  background: linear-gradient(90deg, rgba(245,158,11,0.14), rgba(245,158,11,0.04));
  border-color: rgba(245,158,11,0.35);
}
.hero-status[data-state="caution"] .hs-badge { color: var(--amber); }

.hero-status[data-state="stop"] {
  background: linear-gradient(90deg, rgba(239,68,68,0.20), rgba(239,68,68,0.06));
  border-color: rgba(239,68,68,0.5);
  box-shadow: 0 0 0 1px rgba(239,68,68,0.35);
}
.hero-status[data-state="stop"] .hs-badge { color: var(--red2); }
/* Former hero-stop-pulse removed — the STALLED pill in Mission Control and
   the critical sl-blink already compete for attention when things go south;
   a third pulsing element trained users to tune out the siren. */

/* Mobile: stack reason below badge/metrics and let the metrics row fill
   the width so DLL / MLL / Flat stay scannable without horizontal scroll. */
@media (max-width: 640px) {
  .hero-status {
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }
  .hero-status .hs-reason {
    flex: 1 1 100%;
    order: 3;
    white-space: normal;
  }
  .hero-status .hs-metrics {
    order: 2;
    width: 100%;
    justify-content: space-between;
  }
}

/* ============================================================
   Resume-info banner — shown when the bot is running but idle
   (daily TP/SL hit, DLL gate, time blacklist, session mode…).
   data-reason drives the color family; data-auto=true/false
   swaps between "reprise auto dans X" and "intervention requise".
   ============================================================ */
.resume-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  margin: 0 0 var(--space-5) 0;
  font-family: var(--font-ui);
  font-size: 13px;
  border: 1px solid transparent;
  transition: background var(--transition-base), border-color var(--transition-base);
}
/* !important defeats any future lower-specificity rule that might set
   display:flex on .resume-info — the [hidden] attribute is the single
   contract from renderResumeInfo(), so nothing else should override it. */
.resume-info[hidden] { display: none !important; }
.resume-info .ri-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex: 1 1 auto;
}
.resume-info .ri-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.resume-info .ri-label {
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.resume-info .ri-countdown {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text2);
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.resume-info .ri-countdown-prefix { color: var(--text3); font-size: 11px; }
.resume-info .ri-countdown-value { color: var(--text); font-weight: 600; }
.resume-info .ri-countdown-clock { color: var(--text3); font-size: 11px; }

/* Color families by reason */
.resume-info[data-reason="daily_tp"],
.resume-info[data-reason="max_cycles"] {
  background: linear-gradient(90deg, rgba(34,197,94,0.10), rgba(34,197,94,0.03));
  border-color: rgba(34,197,94,0.25);
}
.resume-info[data-reason="daily_tp"] .ri-badge,
.resume-info[data-reason="max_cycles"] .ri-badge { color: var(--green2); }

.resume-info[data-reason="daily_sl"],
.resume-info[data-reason="dll_gate"],
.resume-info[data-reason="trailing_gate"] {
  background: linear-gradient(90deg, rgba(239,68,68,0.12), rgba(239,68,68,0.04));
  border-color: rgba(239,68,68,0.3);
}
.resume-info[data-reason="daily_sl"] .ri-badge,
.resume-info[data-reason="dll_gate"] .ri-badge,
.resume-info[data-reason="trailing_gate"] .ri-badge { color: var(--red2); }

.resume-info[data-reason="time_blacklist"],
.resume-info[data-reason="session_mode"],
.resume-info[data-reason="volatility"],
.resume-info[data-reason="flat_deadline"],
.resume-info[data-reason="cooling"],
.resume-info[data-reason="filter"] {
  background: linear-gradient(90deg, rgba(245,158,11,0.10), rgba(245,158,11,0.03));
  border-color: rgba(245,158,11,0.25);
}
.resume-info[data-reason="time_blacklist"] .ri-badge,
.resume-info[data-reason="session_mode"] .ri-badge,
.resume-info[data-reason="volatility"] .ri-badge,
.resume-info[data-reason="flat_deadline"] .ri-badge,
.resume-info[data-reason="cooling"] .ri-badge,
.resume-info[data-reason="filter"] .ri-badge { color: var(--amber); }

.resume-info[data-reason="auto_off"],
.resume-info[data-reason="max_contracts"],
.resume-info[data-reason="stopped"],
.resume-info[data-reason="offline"],
.resume-info[data-reason="error"] {
  background: linear-gradient(90deg, rgba(109,122,163,0.10), rgba(109,122,163,0.03));
  border-color: rgba(109,122,163,0.25);
}

/* No auto-resume => clearly label it */
.resume-info[data-auto="false"] .ri-countdown { color: var(--amber); }

@media (max-width: 640px) {
  .resume-info {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .resume-info .ri-countdown { width: 100%; flex-wrap: wrap; }
}

/* ── Indicateurs Live panel ── */
.indicator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
}

.indicator-card {
  background: var(--bg2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.indicator-card.tier-danger { border-color: var(--red); box-shadow: 0 0 8px rgba(255,70,70,0.15); }
.indicator-card.tier-caution { border-color: var(--amber); box-shadow: 0 0 8px rgba(255,180,50,0.15); }
.indicator-card.tier-safe { border-color: var(--green); }

.ind-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.ind-name {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
}
.ind-threshold {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text3);
  background: var(--bg3);
  padding: 1px 8px;
  border-radius: var(--radius-round);
}

.ind-body {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.ind-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.ind-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 10px;
  border-radius: var(--radius-round);
  background: var(--bg3);
  color: var(--text3);
}
.ind-pill.pill-safe  { background: rgba(50,205,50,0.18); color: var(--green); }
.ind-pill.pill-danger { background: rgba(255,70,70,0.18); color: var(--red); }
.ind-pill.pill-caution { background: rgba(255,180,50,0.18); color: var(--amber); }
.ind-pill-ia { background: var(--bg3) !important; color: var(--text3) !important; }
.ind-pill-ia.pill-safe { background: rgba(50,205,50,0.18) !important; color: var(--green) !important; }

/* IA card — centered pill + robot */
#ind-ai-card .ind-body { justify-content: center; gap: 8px; }
#ind-ai-card .ind-sub { text-align: center; }
.ind-robot { font-size: 22px; line-height: 1; }

.ind-sub {
  font-size: 11px;
  color: var(--text3);
  min-height: 16px;
}
.ind-range {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text2);
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.ind-range span:first-child { color: var(--cyan); }
.ind-range span:last-child  { color: var(--gold); }

/* ── RSI gauge bar ── */
.ind-gauge {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  margin-bottom: var(--space-2);
  overflow: hidden;
}
.ind-gauge-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease, background 0.4s ease;
  background: var(--text3);
}
.ind-gauge-fill.fill-safe   { background: var(--green); }
.ind-gauge-fill.fill-caution { background: var(--amber); }
.ind-gauge-fill.fill-danger  { background: var(--red); }

/* ========================================================================
   Filter Bricks — entry readiness overview
   ======================================================================== */
.filter-bricks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.fb-brick {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--bg3);
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid transparent;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.fb-brick.fb-overall {
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
}
.fb-brick .fb-label {
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
}
.fb-brick .fb-value {
  color: var(--text);
  font-weight: 500;
}
.fb-brick .fb-note {
  color: var(--text3);
  font-size: 10px;
}
/* Tier colors */
.fb-brick.fb-go      { border-color: var(--green); }
.fb-brick.fb-go .fb-value { color: var(--green2); }
.fb-brick.fb-approach { border-color: var(--amber); }
.fb-brick.fb-approach .fb-value { color: var(--amber); }
.fb-brick.fb-blocked  { border-color: var(--red); background: rgba(239,68,68,0.08); }
.fb-brick.fb-blocked .fb-value { color: var(--red2); }
.fb-brick.fb-off,
.fb-brick.fb-none     { border-color: var(--text3); opacity: 0.55; }
.fb-brick.fb-off .fb-value,
.fb-brick.fb-none .fb-value { color: var(--text3); }

/* ========================================================================
   Copy Trading Strip — multi-broker copy target checkboxes
   ======================================================================== */
.copy-strip {
  margin: 0 0 16px 0;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.copy-strip-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.copy-strip-label {
  font-weight: 600; font-size: 12px; color: var(--gold);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.copy-strip-hint {
  font-size: 10px; color: var(--text3);
  margin-left: auto;
}
.btn-tokens {
  margin-left: 8px; padding: 3px 10px;
  font-size: 10px; font-weight: 600;
  font-family: inherit;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold);
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}
.btn-tokens:hover {
  background: var(--gold); color: var(--bg);
}
.btn-tokens:active {
  transform: scale(0.96);
}
.btn-tokens.spinning {
  pointer-events: none; opacity: 0.6;
}
.copy-strip-targets {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.copy-target-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 5px;
  background: var(--bg3); border: 1px solid transparent;
  cursor: pointer; user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.copy-target-item:hover {
  border-color: var(--gold);
}
.copy-target-item.checked {
  border-color: var(--green); background: rgba(34,197,94,0.08);
}
.copy-target-item input[type=checkbox] {
  accent-color: var(--gold); width: 14px; height: 14px; cursor: pointer;
}
.copy-target-name {
  font-size: 11px; font-family: var(--mono); color: var(--text2);
}
.copy-target-badge {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.copy-target-badge.sim {
  background: rgba(59,130,246,0.15); color: var(--blue2);
}
.copy-target-badge.live {
  background: rgba(239,68,68,0.12); color: var(--red2);
}
.copy-target-badge.token-ok {
  background: rgba(0,230,118,0.12); color: #00e676; margin-left: 6px;
}
.copy-target-badge.token-expired {
  background: rgba(255,82,82,0.12); color: #ff5252; margin-left: 6px;
}

/* ========================================================================
   Trade Copy Live (PR4 2026-05-24) — santé physique des stops follower
   Surfaced via GET /MNQ2/api/copy_health.
   ======================================================================== */
.copy-live {
  margin: 0 0 16px 0;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-ui);
}
.copy-live-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.copy-live-label {
  font-weight: 600; font-size: 12px; color: var(--gold);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.btn-cl-tokens {
  padding: 2px 9px; font-size: 10px; font-weight: 600;
  font-family: inherit;
  color: var(--gold); background: transparent;
  border: 1px solid var(--gold); border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.04em;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.btn-cl-tokens:hover { background: var(--gold); color: var(--bg); }
.btn-cl-tokens:active { transform: scale(0.96); }
.btn-cl-tokens.spinning { pointer-events: none; opacity: 0.6; }
.btn-cl-tokens:disabled { cursor: progress; opacity: 0.6; }
.copy-live-meta {
  font-size: 10px; color: var(--text3);
  margin-left: auto;
  font-family: var(--font-mono);
}
.copy-live-summary {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.cl-pill {
  font-size: 10px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg3); color: var(--text2);
  font-family: var(--font-mono); border: 1px solid var(--border-soft);
}
.cl-pill.cl-pill-warn {
  background: rgba(245,158,11,0.12); color: var(--amber);
  border-color: var(--amber);
}
.cl-pill.cl-pill-armed {
  background: rgba(245,185,66,0.12); color: var(--gold);
  border-color: var(--gold);
}
.copy-live-stale {
  font-size: 10px; padding: 4px 8px; margin-bottom: 6px;
  background: rgba(239,68,68,0.10); color: var(--red2);
  border: 1px solid rgba(239,68,68,0.30);
  border-radius: 4px;
}
.copy-live-table {
  width: 100%; border-collapse: collapse; font-size: 11px;
  font-family: var(--font-mono);
}
.copy-live-table th {
  text-align: left; padding: 4px 8px; color: var(--text3);
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em;
  font-size: 9px; border-bottom: 1px solid var(--border-soft);
}
.copy-live-table td {
  padding: 5px 8px; color: var(--text2);
  border-bottom: 1px solid var(--border-soft);
}
.copy-live-table tr:last-child td { border-bottom: 0; }
.copy-live-table tr.row-danger { background: rgba(239,68,68,0.08); }
.copy-live-table tr.row-danger td { color: var(--red2); }
.copy-live-table tr.row-warn { background: rgba(245,158,11,0.06); }
.copy-live-table tr.row-warn td { color: var(--amber); }
.cl-label { font-weight: 600; color: var(--text); }
.cl-broker { text-transform: uppercase; font-size: 9px; color: var(--text3); }
.cl-lastupd { font-size: 10px; color: var(--text3); }
.tok-ok   { color: var(--green); }
.tok-bad  { color: var(--red2); font-weight: 600; }
.stops-warn { color: var(--amber); font-weight: 600; }
.dist-ok     { color: var(--green); }
.dist-warn   { color: var(--amber); }
.dist-alert  { color: #fb923c; }
.dist-danger { color: var(--red2); font-weight: 600; }

/* Fleet section : tous les comptes Tradovate connus (actifs + dormants) */
.copy-live-fleet {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
}
.cl-fleet-title {
  font-size: 10px; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.cl-fleet-profiles {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px;
}
.fleet-profile {
  font-size: 10px; padding: 2px 7px; border-radius: 4px;
  font-family: var(--font-mono);
  background: var(--bg3); border: 1px solid var(--border-soft);
}
.fleet-profile.fp-ok  { color: var(--green); border-color: rgba(34,197,94,0.30); }
.fleet-profile.fp-bad { color: var(--red2); border-color: rgba(239,68,68,0.30); }
.cl-fleet-accounts {
  display: flex; flex-direction: column; gap: 3px;
}
.fleet-account {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; padding: 4px 9px; border-radius: 4px;
  background: var(--bg3); border: 1px solid var(--border-soft);
  font-family: var(--font-mono);
  cursor: pointer; user-select: none;
  transition: background var(--motion-fast), border-color var(--motion-fast),
              transform var(--motion-fast);
}
.fleet-account:hover { border-color: var(--gold); background: var(--card2); }
.fleet-account:active { transform: scale(0.98); }
.fleet-account:focus { outline: 1px solid var(--gold); outline-offset: 1px; }
.fleet-account.fa-active  {
  border-color: var(--green); background: rgba(34,197,94,0.12);
}
.fleet-account.fa-active .fa-name { color: var(--green2); }
.fleet-account.fa-target  {
  border-color: rgba(34,197,94,0.50); background: rgba(34,197,94,0.05);
}
.fleet-account.fa-inactive { opacity: 0.70; }
.fleet-account.fa-inactive:hover { opacity: 1; }
.fa-name { color: var(--text); flex: 1; font-weight: 500; }
.fa-prof { color: var(--text3); font-size: 9px; }
.fa-env { font-size: 8px; padding: 1px 5px; border-radius: 3px; font-weight: 700; }
.fa-sim  { background: rgba(59,130,246,0.15); color: #60a5fa; }
.fa-live { background: rgba(239,68,68,0.15); color: var(--red2); }
.fa-badge {
  font-size: 8px; padding: 1px 5px; border-radius: 3px;
  background: var(--bg2); color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.fleet-account.fa-active .fa-badge {
  background: var(--gold); color: var(--bg);
}
.fleet-account.fa-target .fa-badge {
  background: rgba(34,197,94,0.20); color: var(--green2);
}
