/* ============ theme tokens ============
   Registered custom properties interpolate, so switching data-mode on .app
   crossfades the whole theme — including colors inside gradients. */
@property --accent   { syntax: "<color>"; inherits: true; initial-value: #7c8bff; }
@property --accent-2 { syntax: "<color>"; inherits: true; initial-value: #a78bfa; }
@property --tint     { syntax: "<color>"; inherits: true; initial-value: #1d2748; }
@property --glow     { syntax: "<color>"; inherits: true; initial-value: #4c5fd7; }

:root {
  --bg0: #090d18; --bg1: #111828;
  --glass: rgba(255,255,255,0.045); --glass-border: rgba(255,255,255,0.09);
  --text: #e8edf7; --muted: #93a0bd; --up: #34d399; --down: #f87171;
  --danger: #f43f5e; --warn: #fbbf24; --on-accent: #0a0e1a;   /* text/glyphs sitting on an accent-filled surface */
  --mode-paper: #93a0bd; --mode-shadow: #60a5fa; --mode-live: #f59e0b; --mode-halted: #f87171;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

/* mode themes — paper (indigo, default), live (amber: real money), halted (red) */
.app {
  --accent: #7c8bff; --accent-2: #a78bfa; --tint: #1d2748; --glow: #4c5fd7;
  transition: --accent 0.9s var(--ease-out), --accent-2 0.9s var(--ease-out),
              --tint 0.9s var(--ease-out), --glow 0.9s var(--ease-out);
}
.app[data-mode="live"]   { --accent: #f5a623; --accent-2: #fb923c; --tint: #32230f; --glow: #b45309; }
.app[data-mode="halted"] { --accent: #f87171; --accent-2: #fb7185; --tint: #371220; --glow: #b91c1c; }

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--glass-border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
html, body, #root { margin: 0; padding: 0; min-height: 100vh; }
body {
  background: var(--bg0);
  color: var(--text);
  font: 15px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ============ app shell + ambience ============ */
.app {
  display: flex; height: 100vh; overflow: hidden; position: relative;
  background: radial-gradient(1200px 620px at 82% -12%, var(--tint) 0%, transparent 62%),
              radial-gradient(900px 500px at -10% 110%, color-mix(in srgb, var(--tint) 55%, transparent) 0%, transparent 60%),
              linear-gradient(160deg, var(--bg0), var(--bg1));
}
/* slow drifting glow orb — the "alive" ambience layer */
.app::before {
  content: ""; position: fixed; z-index: 0; pointer-events: none;
  width: 860px; height: 860px; left: -220px; top: -320px; border-radius: 50%;
  background: radial-gradient(circle, var(--glow), transparent 65%);
  opacity: 0.22; filter: blur(48px);
  animation: drift 42s ease-in-out infinite alternate;
}
/* fine film grain — kills flat-gradient banding, adds texture */
.app::after {
  content: ""; position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: 0.028;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(42vw, 14vh, 0) scale(1.18); }
}
.main { flex: 1; min-width: 0; padding: 28px 32px 56px; overflow-y: auto; position: relative; z-index: 1; }

/* ============ view + card entrance animations ============ */
.view { animation: view-in 0.45s var(--ease-out); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.kpi-row > .card, .grid > .card, .view > .card {
  animation: card-in 0.55s var(--ease-out) backwards;
}
.kpi-row > .card:nth-child(2), .grid > .card:nth-child(2) { animation-delay: 0.06s; }
.kpi-row > .card:nth-child(3), .grid > .card:nth-child(3) { animation-delay: 0.12s; }
.kpi-row > .card:nth-child(4), .grid > .card:nth-child(4) { animation-delay: 0.18s; }
.kpi-row > .card:nth-child(5), .grid > .card:nth-child(5) { animation-delay: 0.24s; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.view > .grid:first-child { margin: 0; }
/* minmax(0,1fr) clamps the track to the container — an auto track lets wide content (charts) blow the card out sideways */
.grid { display: grid; gap: 18px; margin-top: 20px; grid-template-columns: minmax(0, 1fr); }
/* 2-col only when main is actually wide enough: 240px sidebar + ~2×420px columns */
@media (min-width: 1100px) { .grid { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); } }
.grid .span-full { grid-column: 1 / -1; }

/* ============ cards ============ */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.022));
  border: 1px solid var(--glass-border); border-radius: 16px;
  padding: 18px 20px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.055),   /* top edge catch-light */
              0 12px 34px rgba(0,0,0,0.32);
  max-height: calc(100vh - 88px); overflow-y: auto;   /* tall content scrolls inside the card, not the page */
  transition: border-color 0.25s, box-shadow 0.25s;
}
.card:hover {
  border-color: rgba(255,255,255,0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 14px 40px rgba(0,0,0,0.38);
}
.card h2 { margin: 0 0 12px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); }

.kpi-row { display: grid; gap: 18px; margin: 20px 0 18px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi-row .card.kpi { padding: 16px 20px; position: relative; overflow: hidden; }
.kpi::before {   /* faint accent bloom in the corner of each KPI */
  content: ""; position: absolute; top: -40px; right: -40px; width: 130px; height: 130px;
  border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%);
  pointer-events: none;
}
/* one line, so every card's value sits at the same height */
.kpi .label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.9px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; margin-top: 4px; }

/* circled-i hint — CSS-drawn (the ⓘ glyph falls back to an ugly system font) */
.info-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%; flex: none; margin-left: 5px;
  border: 1.5px solid currentColor; color: var(--accent); opacity: 0.7;
  font-size: 9px; font-weight: 700; font-style: italic; font-family: Georgia, serif;
  cursor: help; line-height: 1; user-select: none; vertical-align: middle; position: relative; top: -1px;
}
.info-dot:hover, .info-dot:focus-visible { opacity: 1; }
.info-dot.warn { opacity: 1; }
/* Styled replacement for the native title tooltip; portaled into .app, positioned above the dot. */
.info-tip {
  position: fixed; z-index: 1000;
  max-width: 260px; padding: 8px 10px; border-radius: 8px;
  background: var(--bg1); color: var(--text);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  font-size: 12px; line-height: 1.4; font-style: normal; font-weight: 400;
  text-transform: none; letter-spacing: normal; white-space: pre-line;
  pointer-events: none;
}
/* Wrapper that carries hover/focus tooltip handlers; inline-flex so it hugs its content
   and doesn't distort the chip row layout (e.g. health chips in the agents panel). */
.hover-tip-anchor { display: inline-flex; min-width: 0; }

/* ============ tables ============ */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid rgba(255,255,255,0.055); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; }
tbody tr { transition: background 0.15s; }
tbody tr:hover td { background: rgba(255,255,255,0.028); }
.bt-history-wrap { margin-top: 22px; overflow-x: auto; }
.bt-history { margin-top: 4px; }
.bt-history .num { text-align: right; }
.bt-history th.num { text-align: right; }
.bt-history .muted { color: var(--muted); }
.bt-history tbody tr { cursor: pointer; }
.bt-history tbody tr:hover td { background: rgba(255,255,255,0.035); }
.bt-history tr.selected td { background: color-mix(in srgb, var(--accent) 13%, transparent); }
.bt-history tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.best-star { color: var(--accent); }
.bt-history-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.bt-history-header h2 { margin: 0; }
.bt-clear { background: none; border: 1px solid var(--glass-border); color: var(--muted); font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 8px; cursor: pointer; transition: color 0.15s, border-color 0.15s; }
.bt-clear:hover { color: var(--down); border-color: var(--down); }
.bt-rerun-cell { text-align: right; }
.bt-rerun { background: none; border: 1px solid var(--glass-border); color: var(--muted); font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 8px; cursor: pointer; transition: color 0.15s, border-color 0.15s; }
.bt-rerun:hover { color: var(--text); border-color: var(--accent); }
.bt-rerun:disabled { opacity: 0.5; cursor: default; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.buy { background: rgba(52,211,153,0.14); color: var(--up); box-shadow: inset 0 0 0 1px rgba(52,211,153,0.22); }
.badge.sell { background: rgba(248,113,113,0.14); color: var(--down); box-shadow: inset 0 0 0 1px rgba(248,113,113,0.22); }
.badge.hold { background: rgba(147,160,189,0.12); color: var(--muted); box-shadow: inset 0 0 0 1px rgba(147,160,189,0.18); }
.muted { color: var(--muted); } .right { text-align: right; } .center { text-align: center; }
.empty { color: var(--muted); padding: 18px 0; }
.chartbox { height: 280px; }

/* TRAD-17 trade-review tables */
.tr-table-wrap { overflow-x: auto; }
.tr-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.tr-table th { text-align: left; padding: 4px 8px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--glass-border); white-space: nowrap; }
.tr-table td { padding: 4px 8px; border-bottom: 1px solid rgba(255,255,255,0.04); white-space: nowrap; }

/* charts follow the theme accent */
.ln-accent .recharts-line-curve, .ln-accent .recharts-area-curve { stroke: var(--accent); transition: stroke 0.9s var(--ease-out); }
#eq stop { stop-color: var(--accent); transition: stop-color 0.9s var(--ease-out); }
.recharts-legend-item-text { color: var(--muted) !important; }

/* ============ sentiment ============ */
.sent-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sent-note { margin-top: 14px; line-height: 1.6; font-size: 12px; }
.sent-note code { background: var(--glass); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.sent-row { padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.055); }
.sent-row:last-of-type { border-bottom: none; }
.sent-head { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
.gauge { position: relative; height: 8px; border-radius: 999px; margin: 8px 0;
  background: linear-gradient(90deg, var(--down), var(--muted) 50%, var(--up)); }
.gauge-marker { position: absolute; top: -2px; width: 3px; height: 12px; border-radius: 2px;
  background: var(--text); transform: translateX(-50%); box-shadow: 0 0 6px rgba(255,255,255,0.45);
  transition: left 0.7s var(--ease-out); }
.sent-sources { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.sent-src b { color: var(--text); font-weight: 600; }
.sent-strategy { margin-top: 12px; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px;
        background: var(--glass); border: 1px solid var(--glass-border); border-radius: 10px;
        transition: border-color 0.2s, transform 0.2s; }
.chip:hover { border-color: rgba(255,255,255,0.16); transform: translateY(-1px); }
.chip-k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.chip-v { font-size: 14px; font-weight: 600; }

/* ============ sidebar rail ============ */
.sidebar { width: 240px; flex: 0 0 240px; height: 100vh; position: sticky; top: 0; z-index: 2;
  display: flex; flex-direction: column; gap: 16px; padding: 22px 18px;
  border-right: 1px solid var(--glass-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.012));
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 9px;
  /* Matches build/icon.svg's navy gradient so the in-app mark = taskbar/window icon. */
  background: linear-gradient(140deg, #1b2440, #0a0e1a);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 2px 14px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: box-shadow 0.9s var(--ease-out); }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.rail-link { display: flex; align-items: center; gap: 11px; text-align: left; background: none; border: none;
  color: var(--muted); font: inherit; font-size: 14px; padding: 9px 12px; border-radius: 8px; cursor: pointer;
  position: relative; transition: background 0.2s, color 0.2s; }
.rail-link::before {   /* active indicator bar — scales in */
  content: ""; position: absolute; left: 0; top: 22%; bottom: 22%; width: 2.5px; border-radius: 2px;
  background: var(--accent); transform: scaleY(0); transition: transform 0.28s var(--ease-out); }
.rail-ic { flex: none; transition: transform 0.2s var(--ease-out); }
/* Unread count on a rail item. margin-left:auto parks it at the right edge of the flex row. */
.rail-badge { margin-left: auto; flex: none; min-width: 18px; padding: 1px 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent);
  font-size: 11px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent); }
.rail-link:hover { background: var(--glass); color: var(--text); }
.rail-link:hover .rail-ic { transform: translateX(1.5px); }
.rail-link.active { background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--text); font-weight: 600; }
.rail-link.active::before { transform: scaleY(1); }
.rail-link.active .rail-ic { color: var(--accent); }
@media (max-width: 820px) {
  .app { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }   /* mobile: let the page scroll */
  .main { overflow-y: visible; }
  .card { max-height: none; overflow: visible; }
  .sidebar { width: auto; flex: none; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 14px;
    border-right: none; border-bottom: 1px solid var(--glass-border); }
  .rail-nav { flex-direction: row; flex-wrap: wrap; margin-top: 0; width: 100%; }
}
.exec-yes { color: var(--up); font-weight: 600; }
.exec-no { color: var(--muted); }
.rail-controls { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--glass-border);
  display: flex; flex-direction: column; gap: 16px; }
.rail-account { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 8px 10px; background: var(--glass);
  border: 1px solid var(--glass-border); border-radius: 8px; cursor: pointer; text-align: left; font: inherit;
  transition: border-color 0.2s; }
.rail-account:hover { border-color: color-mix(in srgb, var(--accent, #7c8bff) 45%, var(--glass-border)); }
.rail-account-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.rail-account-row { display: flex; align-items: center; gap: 8px; }
.rail-account-name { color: var(--text); font-size: 12px; font-weight: 600; flex: 1 1 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-account .net-badge { flex: 0 0 auto; }
.rail-toggle-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.seg { display: flex; gap: 2px; padding: 2px; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 8px; }
.seg-btn { flex: 1; background: none; border: none; color: var(--muted); font: inherit; font-size: 12px; padding: 6px 4px; border-radius: 6px; cursor: pointer;
  transition: background 0.25s, color 0.25s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); font-weight: 600;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 35%, transparent); }
/* dim only when inactive — an active (amber) pill keeps its dark high-contrast text */
.seg-btn.locked:not(.active) { color: var(--muted); opacity: 0.75; }
.seg-btn.locked:not(.active):hover { color: var(--muted); }
.rail-toggle-hint { color: var(--muted); font-size: 11px; margin-top: 6px; }
.rail-toggle-hint.rail-err { color: var(--down); }
.rail-inline-link { background: none; border: none; padding: 0; color: var(--accent); font: inherit; font-size: 11px; cursor: pointer; text-decoration: underline; }
.rail-select { width: 100%; background: var(--glass); border: 1px solid var(--glass-border); color: var(--text); font: inherit; font-size: 12px; padding: 7px 8px; border-radius: 8px; cursor: pointer; transition: border-color 0.2s; }
.rail-select:hover { border-color: rgba(255,255,255,0.18); }
.rail-select option { background: var(--bg1); color: var(--text); }   /* dark-theme the native option popup */
@media (max-width: 820px) { .rail-controls { margin-top: 0; padding-top: 0; border-top: none; } }
@keyframes soft-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* mode badges — LIVE and HALTED pulse for attention */
.rail-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.mode-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.8px; padding: 3px 8px;
  border-radius: 999px; border: 1px solid currentColor; }
.tone-paper { color: var(--mode-paper); }
.tone-live { color: var(--mode-live); animation: badge-pulse 2.4s ease-in-out infinite; }
.tone-halted { color: var(--mode-halted); animation: badge-pulse-fast 1.3s ease-in-out infinite; }
/* MYH-245 Slice 2 (PR-A): kill switch */
.killswitch { margin-top: 8px; width: 100%; font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
  padding: 7px 10px; border-radius: 6px; cursor: pointer; border: 1px solid currentColor;
  background: transparent; }
.killswitch:disabled { opacity: 0.5; cursor: default; }
.killswitch.stop { color: var(--mode-halted); }
.killswitch.stop:hover:not(:disabled) { background: color-mix(in srgb, var(--mode-halted) 14%, transparent); }
.killswitch.resume { color: var(--mode-live); animation: badge-pulse-fast 1.3s ease-in-out infinite; }
.killswitch.resume:hover:not(:disabled) { background: color-mix(in srgb, var(--mode-live) 14%, transparent); }
@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 40%, transparent); }
  50%      { box-shadow: 0 0 10px 1px color-mix(in srgb, currentColor 28%, transparent); }
}
@keyframes badge-pulse-fast {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); }
  50%      { box-shadow: 0 0 12px 2px color-mix(in srgb, currentColor 35%, transparent); }
}

/* live-price marker on the Now header — pulses while the ticker is streaming, even when the price hasn't moved */
.live-dot { display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 999px;
  background: var(--up); vertical-align: middle; animation: soft-blink 1.8s ease-in-out infinite; }
.dup-count { color: var(--accent); font-weight: 600; }
/* Overview "why is nothing happening" strip (#226 cooldown / all-hold pass) */
.ai-status-strip { margin: 10px 0 0; padding: 7px 12px; border-radius: 8px; font-size: 12.5px;
  color: var(--mode-paper); border: 1px solid color-mix(in srgb, var(--mode-paper) 35%, transparent);
  background: color-mix(in srgb, var(--mode-paper) 8%, transparent); }
/* MYH-245 Slice 3: structured cap-breach numbers under a blocked decision's reason */
.breach-detail { display: block; margin-top: 2px; font-size: 11px; color: var(--mode-halted); }

/* ============ forms + buttons ============ */
.bt-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin-bottom: 16px; }
.bt-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.bt-form input { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 8px;
  color: var(--text); font: inherit; padding: 7px 10px; color-scheme: dark; transition: border-color 0.2s, box-shadow 0.2s; }
.bt-form select { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 8px;
  color: var(--text); font: inherit; padding: 7px 10px; cursor: pointer; transition: border-color 0.2s; }
.bt-form select option { background: var(--bg1); color: var(--text); }
.bt-run { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); border: 1px solid transparent; border-radius: 8px; font: inherit;
  font-weight: 650; padding: 8px 16px; cursor: pointer;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: filter 0.15s, transform 0.15s, box-shadow 0.2s, border-color 0.15s, color 0.15s, background 0.15s; }
.bt-run:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px);
  box-shadow: 0 6px 22px color-mix(in srgb, var(--accent) 42%, transparent); }
.bt-run:active:not(:disabled) { transform: translateY(0) scale(0.98); }
.bt-run:disabled { opacity: 0.5; cursor: not-allowed; }
/* secondary/ghost button: pairs with .bt-run for shared sizing (e.g. Test, Run now) */
.bt-run.bt-secondary { background: transparent; color: var(--text); border-color: var(--glass-border); box-shadow: none; }
.bt-run.bt-secondary:hover:not(:disabled) { filter: none; border-color: var(--accent); color: var(--accent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 18%, transparent); }
.bt-result { width: 100%; font-size: 13px; color: var(--muted); margin-top: 4px; }
.bt-error { color: var(--down); }
.bt-ok { color: var(--up); }
.bt-result pre { white-space: pre-wrap; font-size: 12px; margin: 6px 0 0; color: var(--muted); }
.settings-actions { display: flex; gap: 10px; }
.settings-summary { font-size: 13px; color: var(--muted); line-height: 1.5; }
.settings-warn { color: var(--warn); }

/* Settings page — tabbed sections + toggle switches */
/* the card itself is clamped + centered (not the content inside a full-width card) */
.card--settings { max-width: 1040px; width: 100%; margin-inline: auto; }
.settings { display: flex; flex-direction: column; gap: 24px; }
.settings-tabs { display: flex; flex-wrap: nowrap; gap: 6px; border-bottom: 1px solid var(--glass-border);
  overflow-x: auto; scrollbar-width: none; }
.settings-tabs::-webkit-scrollbar { display: none; }  /* one clean row; scrolls silently if the window is very narrow */
.settings-tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; padding: 9px 10px; margin-bottom: -1px; cursor: pointer;
  white-space: nowrap; flex: 0 0 auto; transition: color 0.15s, border-color 0.15s; }
.settings-tab:hover { color: var(--text); }
.settings-tab:focus-visible { outline: none; color: var(--text); border-bottom-color: var(--glass-border); }
.settings-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.settings-group { display: flex; flex-direction: column; gap: 14px; }
.settings-group + .settings-group { padding-top: 24px; border-top: 1px solid var(--glass-border); }
.settings-group-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.switch-row { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch { position: relative; flex: none; width: 38px; height: 22px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch-slider { position: absolute; inset: 0; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-border); transition: background 0.2s, border-color 0.2s, box-shadow 0.2s; }
.switch-slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; border-radius: 50%; background: var(--muted); transition: transform 0.25s var(--ease-out), background 0.2s; }
.switch input:checked + .switch-slider { background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 35%, transparent); }
.switch input:checked + .switch-slider::before { transform: translateX(16px); background: var(--on-accent); }
.switch-label { display: flex; flex-direction: column; gap: 3px; }
.switch-name { font-size: 14px; color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.switch-help { font-size: 12px; color: var(--muted); line-height: 1.5; }
/* Gated control (e.g. perp "Coming soon"): dim it, kill the pointer, freeze the slider grey. */
.switch-row.disabled { cursor: default; opacity: 0.55; }
.switch-row.disabled .switch input, .switch-row.disabled .switch-slider { cursor: default; }
/* Locked toggle (e.g. an AI agent while Manual mode is on): grey the slider, no pointer. */
.switch input:disabled + .switch-slider { opacity: 0.4; cursor: not-allowed; }
/* Inert-in-manual signals: a note line inside a card, and a shrinkable chip in a row (never
   let it collapse the agent name — see .ag-name overflow-wrap:anywhere). */
.ag-inert-note { font-size: 11px; font-weight: 600; color: var(--accent); opacity: 0.9; margin: 2px 0 4px; line-height: 1.35; }
.ag-inert-chip { color: var(--accent); flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-disabled { opacity: 0.7; }
.ag-principal.disabled { opacity: 0.6; }
.soon-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-2) 32%, transparent);
  padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.field-row { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.field-label { font-size: 12px; color: var(--muted); }
.field-row input { width: 100%; background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 8px; color: var(--text); font: inherit; padding: 7px 10px; transition: border-color 0.15s, box-shadow 0.15s; }
/* number inputs (e.g. interval seconds) stay compact rather than stretching full width */
.field-row input[type="number"] { width: 160px; align-self: flex-start; }   /* fixed, not auto — uniform column in the Risk tab */
/* A <select> in a settings field-row must match the number inputs above it: .rail-select is
   sized for the sidebar rail (full-width, 12px, tighter padding), which left the Risk tab's
   Shorting control stretched across the card while every input beside it sat at 160px. */
.settings-group .field-row .rail-select { width: 160px; align-self: flex-start;
  font-size: inherit; padding: 7px 10px; }
.field-row input:focus, .rail-select:focus, .symbol-input:focus, .bt-form input:focus, .bt-form select:focus, .order-row input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.cred-input { font-family: ui-monospace, monospace; letter-spacing: 1px; }
/* Native <select>s (backtest form, strategy rail, etc.): dark box + dark option popup. The open
   popup's selected-row highlight still follows the OS on Linux — the AI model picker uses the
   custom .sel dropdown below to fully control that. */
.field-row select { width: 100%; background: var(--glass); border: 1px solid var(--glass-border);
  color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit; }
select option { background: var(--bg1); color: var(--text); }
select option:checked, select option:hover { background: var(--accent); color: var(--on-accent); }

/* Custom themed dropdown (Select.tsx) — full control over the closed box AND the open list. */
.sel { position: relative; width: 100%; }
.sel-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  background: var(--glass); border: 1px solid var(--glass-border); color: var(--text); border-radius: 8px;
  padding: 9px 11px; cursor: pointer; text-align: left; transition: border-color 0.2s; }
.sel-btn:hover { border-color: rgba(255,255,255,0.18); }
.sel.open .sel-btn { border-color: var(--accent); }
.sel-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-caret { opacity: 0.6; font-size: 11px; flex: none; }
.sel-list { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px;
  list-style: none; max-height: 260px; overflow-y: auto; background: var(--bg1);
  border: 1px solid var(--glass-border); border-radius: 8px; box-shadow: 0 12px 28px rgba(0,0,0,0.4); }
.sel-list.up { top: auto; bottom: calc(100% + 4px); }   /* flip up near the bottom of a scroll area */
.sel-opt { padding: 7px 9px; border-radius: 6px; cursor: pointer; font-family: ui-monospace, monospace;
  font-size: 13px; letter-spacing: 0.5px; color: var(--text); }
.sel-opt:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.sel-opt.active { background: var(--accent); color: var(--on-accent); }
.cred-note { border-left: 2px solid var(--accent); padding-left: 10px; }
.symbol-x { background: none; border: none; color: var(--muted); font: inherit; font-size: 15px;
  line-height: 1; cursor: pointer; padding: 0 4px; transition: color 0.15s, transform 0.15s; }
.symbol-x:hover:not(:disabled) { color: var(--down); transform: scale(1.15); }
.symbol-x:disabled { opacity: 0.35; cursor: not-allowed; }
.pair-rows { display: flex; flex-direction: column; gap: 8px; }
.pair-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 8px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s; }
.pair-row:hover { border-color: rgba(255,255,255,0.16); transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.pair-sym { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.pair-price { font-weight: 500; font-size: 12px; color: var(--muted); }
.pair-flag { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  border-radius: 999px; padding: 1px 7px; color: var(--muted); background: rgba(147,160,189,0.12); }
.pair-flag.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
  animation: soft-blink 1.8s ease-in-out infinite; }
.pair-links { display: flex; align-items: center; gap: 6px; }
.pair-link { display: inline-flex; align-items: center; gap: 5px; background: none;
  border: 1px solid var(--glass-border); color: var(--muted); font: inherit; font-size: 12px;
  padding: 4px 10px; border-radius: 8px; cursor: pointer; transition: color 0.15s, border-color 0.15s; }
.pair-link:hover { color: var(--text); border-color: var(--accent); }
.link-ic { opacity: 0.8; }
.pairs-panel { display: flex; flex-direction: column; gap: 14px; }
.pairs-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pairs-header h2 { margin: 0; }
.pairs-add { display: flex; gap: 10px; position: relative; }
/* Strategies page — filterable, rankable strategy cards */
.strat-list { display: flex; flex-direction: column; gap: 12px; }
.strat-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.strat-controls .field-row { flex: none; }
.strat-controls .rail-select { width: auto; }
.strat-rank-btn { margin-left: auto; align-self: flex-end; }
.rank-progress { height: 4px; border-radius: 999px; background: var(--glass); overflow: hidden; }
.rank-progress-fill { height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s var(--ease-out); }
.strat-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill { background: var(--glass); border: 1px solid var(--glass-border); color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s; }
.filter-pill:hover { color: var(--text); border-color: rgba(255,255,255,0.18); }
.filter-pill.active { color: var(--text); border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); }
.filter-pill:disabled { opacity: 0.4; cursor: default; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 12px 0 4px; }
.pill-count { opacity: 0.6; font-weight: 500; margin-left: 2px; }
.strat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.provider-grid { display: grid; gap: 10px; margin-bottom: 4px;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
/* Uniform height + vertically-centred content so a longer label can't make a row ragged. */
.provider-grid .strat-card { min-height: 58px; justify-content: center; }
.provider-grid .strat-name { line-height: 1.25; }
.strat-card { display: flex; flex-direction: column; gap: 5px; text-align: left;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 12px;
  padding: 13px 15px; color: var(--text); font: inherit; cursor: pointer;
  animation: card-in 0.4s var(--ease-out) backwards;
  transition: border-color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s; }
.strat-card:hover { border-color: var(--accent); transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.28); }
.strat-card:focus-visible { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.strat-card.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.strat-card.testing { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.strat-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.strat-grid .strat-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }   /* provider cards keep wrapping (uniform-height rule above) */
.strat-name { font-size: 14px; font-weight: 600; }
.strat-head-right { flex: none; }
.kind-chip { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  border: 1px solid currentColor; border-radius: 999px; padding: 1px 7px; opacity: 0.85; }
.kind-ai { color: var(--accent); }
.kind-trend { color: var(--mode-shadow); }
.kind-reversion { color: #c084fc; }
.kind-breakout { color: var(--warn); }
.kind-sentiment { color: #2dd4bf; }
.cap-chip { font-size: 10px; font-weight: 600; letter-spacing: 0.3px; border-radius: 999px;
  padding: 1px 7px; border: 1px solid currentColor; opacity: 0.8; }
.cap-long { color: var(--muted); }
.cap-short { color: var(--up); }
.cap-perp { color: var(--warn); }
/* TRAD-16 decay-watchdog health chip. Severity climbs monitoring -> decayed -> disabled;
   decayed/disabled are click-to-reset (cap-chip's own border/text-via-currentColor pattern). */
.health-chip { cursor: default; }
.health-monitoring { color: var(--warn); }
.health-decayed { color: var(--down); cursor: pointer; }
.health-disabled { color: var(--danger); cursor: pointer; }
.strat-warn { background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: 10px; color: var(--text); }
.rank-badge { font-size: 11px; font-weight: 800; border-radius: 999px; padding: 2px 7px; color: var(--on-accent); }
.rank-1 { background: linear-gradient(135deg, var(--warn), var(--mode-live)); }
.rank-2 { background: linear-gradient(135deg, #cbd5e1, #94a3b8); }
.rank-3 { background: linear-gradient(135deg, #d8a47f, #b07d4f); }
.strat-head-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.strat-active { font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--on-accent); background: var(--accent); border-radius: 999px; padding: 2px 8px; }
.strat-testing { font-size: 11px; font-weight: 600; color: var(--accent);
  animation: soft-blink 1.2s ease-in-out infinite; }
.strat-bt { padding: 4px 12px; font-size: 12px; }
.strat-desc { font-size: 13px; color: var(--muted); line-height: 1.5; }
.strat-bt-res { font-size: 12px; margin-top: 2px; }
.strat-result { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.res-return { font-size: 17px; font-weight: 750; letter-spacing: -0.01em; }
.res-return.up { color: var(--up); } .res-return.down { color: var(--down); }
.res-detail { font-size: 12px; color: var(--muted); }
.res-verdict { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  border-radius: 999px; padding: 2px 8px; margin-left: auto; }
.res-verdict.ok { color: var(--up); background: rgba(52,211,153,0.13); }
.res-verdict.bad { color: var(--down); background: rgba(248,113,113,0.13); }
.verdict-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
                 padding: 1px 6px; border-radius: 4px; cursor: help; white-space: nowrap; }
.verdict-robust { color: var(--up); background: rgba(52,211,153,0.13); }
.verdict-fragile { color: #f59e0b; background: rgba(245,158,11,0.13); }
.verdict-unvalidated { color: var(--muted); background: rgba(148,163,184,0.13); }
.res-bar { width: 100%; height: 4px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; }
.res-bar-fill { height: 100%; border-radius: 999px; transition: width 0.6s var(--ease-out); }
.res-bar-fill.up { background: linear-gradient(90deg, color-mix(in srgb, var(--up) 55%, transparent), var(--up)); }
.res-bar-fill.down { background: linear-gradient(90deg, color-mix(in srgb, var(--down) 55%, transparent), var(--down)); }
.symbol-input { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 8px;
  color: var(--text); font: inherit; padding: 7px 10px; width: 150px; transition: border-color 0.15s, box-shadow 0.15s; }
.error-fallback .muted { color: var(--muted); margin: 4px 0 0; }
.error-fallback pre { white-space: pre-wrap; color: var(--down); font-size: 13px; margin: 10px 0; }
/* Lives inside the Positions card's "Pending" tab — the card frames it, so no border of
   its own; the intro just replaces the heading it used to carry. */
.pending-intro { margin: 14px 0 10px; }
.pending-working { font-size: 12px; align-self: center; }
/* Principal heartbeat / cooldown strip — same language as .ai-status-strip, amber when paused
   (the strip exists to answer "when will the principal review?" without opening any logs). */
.pending-principal-strip { margin: 0 0 10px; padding: 7px 12px; border-radius: 8px; font-size: 12.5px;
  color: var(--muted); border: 1px solid var(--glass-border);
  background: color-mix(in srgb, var(--glass-border) 30%, transparent); }
.pending-principal-strip.paused { color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
  background: color-mix(in srgb, var(--warn) 8%, transparent); }
/* Summary/filter chips + bulk dismiss. Wraps at 375px — chips left, bulk action right. */
.pending-filter-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; margin: 0 0 10px; }
.pending-filter-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pending-filter-chip { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  color: var(--muted); background: transparent; border: 1px solid var(--glass-border); cursor: pointer; }
.pending-filter-chip:hover { color: var(--text); border-color: var(--accent); }
.pending-filter-chip.active { color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pending-bulk-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  justify-content: flex-end; margin-left: auto; }

/* Sticky tab bar (Positions view). The scroll container is .main, so top:0 pins the row at the
   scrollport edge; the pending list runs 12+ rows and the tabs used to scroll away with it.
   Opt-in modifier — Settings reuses .settings-tabs and must keep scrolling normally.
   The card is translucent, so the bar needs its own opaque-ish backdrop or rows show through. */
/* A card whose first child is a .tabs-sticky bar. Its top padding MUST come off the card and go
   onto the bar: a sticky element is clamped to its containing block (the card's CONTENT box), so
   card padding-top leaves a strip between the scrollport top and the bar that rows scroll through
   in full view. Sides/bottom keep the normal card padding. */
.tabs-host { padding-top: 0; }
.tabs-sticky { position: sticky; top: 0; z-index: 2;
  /* Opaque: rows scroll UNDER this bar, and a translucent backdrop shows them through. */
  background: var(--bg1);
  /* Owns the card's top padding (see .tabs-host) — and a bit more, so the tab row doesn't sit
     flush against the card's top edge. It's inside the bar, so it scrolls away with nothing. */
  padding-top: 26px;
  /* Full-bleed sideways so the opaque backdrop reaches the card's edges — otherwise rows scroll
     through the 20px side padding either side of the bar. HORIZONTAL margins only: a negative
     margin-TOP resolves against the sticky margin box and re-opens the gap above the bar. */
  margin-left: -20px; margin-right: -20px;
  padding-left: 20px; padding-right: 20px;
  /* Air below the bar — MARGIN, not padding: padding-bottom would push the tab underline
     (border-bottom on .settings-tabs, same element) away from the tab labels. */
  margin-bottom: 14px;
}
.pending-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; flex-wrap: wrap; border-top: 1px solid var(--glass-border); }
.pending-row:first-of-type { border-top: none; }
.pending-info { display: flex; align-items: center; gap: 10px; flex: 1 1 300px; min-width: 0; flex-wrap: wrap; }
.pending-sym { font-weight: 600; min-width: 92px; }
.pending-side { font-weight: 700; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.pending-side.buy { color: var(--up); background: color-mix(in srgb, var(--up) 12%, transparent); }
.pending-side.sell { color: var(--down); background: color-mix(in srgb, var(--down) 12%, transparent); }
.pending-reason { color: var(--muted); font-size: 13px; }
.pending-meta { white-space: nowrap; }
.pending-actions { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto;
  /* narrow screens: the status text + two buttons exceed 375px — wrap inside the block
     (right-aligned) instead of pushing the row past the viewport */
  flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
.verdict-chip { font-size: 11px; font-weight: 650; padding: 1px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.6px; border: 1px solid var(--glass-border); }
.verdict-chip.verdict-approved { color: var(--up); border-color: color-mix(in srgb, var(--up) 45%, transparent); }
.verdict-chip.verdict-rejected { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, transparent); }
.verdict-chip.verdict-expired  { color: var(--mode-live); border-color: color-mix(in srgb, var(--mode-live) 45%, transparent); }
.verdict-chip.verdict-pending  { color: var(--muted); }
/* MYH-277: position-review pass — a pending row raised by the review (not a fresh proposal), and
   the per-position "already reviewed" badge in PositionsTable. Same pill language as verdict-chip. */
.review-chip { font-size: 11px; font-weight: 650; padding: 1px 8px; border-radius: 999px;
  color: var(--mode-live); border: 1px solid color-mix(in srgb, var(--mode-live) 45%, transparent);
  white-space: nowrap; margin-left: 4px; }
.pending-row.verdict-rejected { opacity: 0.55; }        /* dimmed — not actionable, only dismissible */
.pending-agent { font-size: 12px; }
.pending-verdict-reason { font-size: 12px; font-style: italic; }
.pending-await { font-size: 12px; }
.ag-hist-verdicts { margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--glass-border); }
.ag-hist-list { display: flex; flex-direction: column; }
.ag-hist-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; flex-wrap: wrap;
  border-top: 1px solid var(--glass-border); }
.ag-hist-row:first-child { border-top: none; }
.ag-hist-reason { color: var(--muted); font-size: 13px; flex: 1 1 auto; min-width: 0; }
.ag-hist-time { white-space: nowrap; font-size: 12px; }

/* Reworked history rows: day separators, one aligned header line, click-to-expand reasons. */
.ag-hist-day { margin: 14px 0 2px; font-size: 11px; font-weight: 650; letter-spacing: 0.08em;
               text-transform: uppercase; color: var(--muted); }
.ag-hist-day:first-child { margin-top: 0; }
.ag-hist-row2 { padding: 9px 0; border-top: 1px solid var(--glass-border); }
.ag-hist-day + .ag-hist-row2 { border-top: none; }
.ag-hist-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ag-hist-head .ag-hist-time { margin-left: auto; }
.ag-hist-price { font-size: 12px; white-space: nowrap; }
.ag-hist-by { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exec-chip { font-size: 11px; font-weight: 650; padding: 1px 8px; border-radius: 999px;
             color: var(--up); border: 1px solid color-mix(in srgb, var(--up) 45%, transparent); }
.ag-hist-reason2 { color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 4px;
                   display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
                   overflow: hidden; cursor: pointer; }
.ag-hist-reason2.open { -webkit-line-clamp: unset; display: block; }
.bt-ghost { background: transparent; border: 1px solid var(--glass-border); color: var(--muted);
            border-radius: 8px; padding: 6px 12px; cursor: pointer; transition: color 0.15s, border-color 0.15s; }
.bt-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.bt-ghost:disabled { opacity: 0.5; cursor: default; }
/* Account tab rows: avatar / email / action on one aligned line */
.account-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.account-email { color: var(--muted); font-size: 13px; margin-right: auto; }

/* ============ overview extras ============ */
.kpi-delta { font-size: 12px; margin-top: 4px; }
.cycle-strip { margin-top: 16px; font-size: 13px; }
.cycle-strip > summary { cursor: pointer; list-style: none; user-select: none; padding: 4px 0; }
.cycle-strip > summary::-webkit-details-marker { display: none; }
.cycle-strip > summary::before { content: "▸"; display: inline-block; margin-right: 8px;
  transition: transform 0.15s ease; }
.cycle-strip[open] > summary::before { transform: rotate(90deg); }
.cycle-items { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.cycle-item { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.range-pills { display: flex; gap: 4px; }
.card-link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 6px; border-radius: 6px; transition: color 0.12s, background 0.12s; }
.card-link:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.range-pills .filter-pill { padding: 3px 10px; font-size: 11px; }

/* ============ positions + activity ============ */
.table-wrap { overflow-x: auto; }
.table-wrap th, .table-wrap td { white-space: nowrap; }
.table-wrap td.wrap { white-space: normal; min-width: 240px; }   /* long text (decision reasons) flows instead of one giant row */
.side-chip { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.side-chip.long { color: var(--up); background: rgba(52,211,153,0.12); }
.side-chip.short { color: var(--down); background: rgba(248,113,113,0.12); }
/* Closed-positions "closed by" chip — same geometry as side-chip, semantic coloring */
.close-chip { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 7px; border-radius: 999px; white-space: nowrap;
  color: var(--muted); background: rgba(147,160,189,0.12); }
.close-chip.bad { color: var(--down); background: rgba(248,113,113,0.12); }
.close-chip.good { color: var(--up); background: rgba(52,211,153,0.12); }
.num-up { color: var(--up); font-weight: 650; }
.num-down { color: var(--down); font-weight: 650; }
/* Flash the "Now" price cell on each live tick: green up, red red down, fading back. */
@keyframes tick-up { from { background: rgba(52,211,153,0.32); color: var(--up); } to { background: transparent; } }
@keyframes tick-down { from { background: rgba(248,113,113,0.32); color: var(--down); } to { background: transparent; } }
.price-now { border-radius: 4px; }
.price-now.tick-up { animation: tick-up 0.8s ease-out; }
.price-now.tick-down { animation: tick-down 0.8s ease-out; }
@media (prefers-reduced-motion: reduce) { .price-now.tick-up, .price-now.tick-down { animation: none; } }
.stop-away { display: block; font-size: 11px; }   /* own line, so the Stop column fits narrow cards */
.cell-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }   /* quiet second line under a cell's main number */
.table-wrap th, .table-wrap td { padding: 10px 12px; }   /* roomier than the 9/8 default; these tables carry dense numbers */
/* Sits ABOVE the positions table (was a footer): the account-level number reads first,
   per-row detail below. */
.pos-total { margin: 0 0 10px; font-size: 13px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pos-total b { font-weight: 700; }
.pos-total-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
/* small ghost close button, per-row and the footer "Close all"; tints red on hover */
.bt-close { background: transparent; color: var(--muted); border: 1px solid var(--glass-border); border-radius: 8px;
  font: inherit; font-size: 12px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.bt-close:hover:not(:disabled) { color: var(--down); border-color: var(--down); }
.bt-close:disabled { opacity: 0.5; cursor: not-allowed; }
.pos-close-err { margin-top: 8px; font-size: 12px; color: var(--down); }
/* un-sellable dust (spot balances below the venue's $10 min): a collapsed line, never a Close button */
.pos-dust { margin-top: 10px; }
.dust-toggle { background: transparent; border: 0; padding: 0; font: inherit; font-size: 12px;
  color: var(--muted); cursor: pointer; text-align: left; }
.dust-toggle:hover { color: var(--text); }
.dust-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; }
.dust-list li { display: flex; align-items: center; gap: 12px; padding: 6px 2px;
  border-top: 1px solid var(--glass-border); }
.dust-list li > span:nth-child(2) { margin-left: auto; }
.dust-note { color: var(--muted); font-size: 11px; white-space: nowrap; }
.activity-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.activity-filters .rail-select { width: auto; margin-left: auto; }
/* Inside a tabbed card there's no .grid/h2 around the row to space it — it butts against the
   table (and, on the Audit tab, against the second filter row) without this. */
.tabs-host .activity-filters { margin-bottom: 12px; }

/* ============ themed confirm dialog (replaces native window.confirm) ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px;
  background: rgba(5, 8, 16, 0.55);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  animation: overlay-in 0.22s ease-out;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(440px, 100%);
  max-height: calc(100vh - 40px); overflow-y: auto;   /* tall forms (Add agent) scroll instead of clipping past the viewport */
  background: linear-gradient(180deg, #1a2136, #131a2c);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 16px; padding: 20px 22px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 24px 60px rgba(0,0,0,0.55),
              0 0 40px color-mix(in srgb, var(--accent) 10%, transparent);
  animation: modal-in 0.3s var(--ease-out);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal.lg { width: min(560px, 100%); }   /* wide forms (Add/Edit agent) */
.switch-row-gap { margin-top: 10px; }
.modal-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.modal-body { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.bt-run.bt-danger { background: linear-gradient(135deg, #ef4444, var(--danger)); color: #fff;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--danger) 35%, transparent); }
.bt-run.bt-danger:hover:not(:disabled) { box-shadow: 0 6px 22px color-mix(in srgb, var(--danger) 50%, transparent); }
.bt-run:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.bt-run.bt-danger:focus-visible { box-shadow: 0 0 0 3px rgba(239,68,68,0.4); }

/* Rank-all symbol picker dialog */
.rank-all-row {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  font-size: 13px; color: var(--text); margin-bottom: 10px;
}
.rank-all-row input { flex: none; margin-top: 2px; }
.rank-symbol-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 260px; overflow-y: auto; padding: 2px;
  border: 1px solid var(--glass-border); border-radius: 10px;
  background: var(--glass);
}
.rank-symbol-list.disabled { opacity: 0.45; pointer-events: none; }
.rank-symbol-row {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 6px 10px; border-radius: 7px; font-size: 13px;
  transition: background 0.12s;
}
.rank-symbol-row:hover { background: rgba(255,255,255,0.035); }
.rank-symbol-row input { flex: none; }
.rank-symbol-count { margin-top: 10px; font-size: 12px; color: var(--muted); }
.rank-ai-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--glass-border); font-size: 12px; }
.rank-ai-row input { flex: none; margin-top: 2px; }
.rank-quickpick { display: flex; gap: 8px; margin-bottom: 10px; }
.rank-quickpick .bt-run { padding: 4px 12px; font-size: 12px; }
.rank-quickpick .bt-run.active { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

/* TRAD-11 bulk-edit agent picker */
.bulk-agent-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 300px; overflow-y: auto; padding: 4px;
  border: 1px solid var(--glass-border); border-radius: 10px; background: var(--glass);
}
.bulk-kind-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 4px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}
.bulk-kind-pick {
  background: none; border: none; cursor: pointer; padding: 0;
  font-size: 11px; color: var(--accent);
}
.bulk-agent-row {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 6px 10px; border-radius: 7px; font-size: 13px; transition: background 0.12s;
}
.bulk-agent-row:hover { background: rgba(255,255,255,0.035); }
.bulk-agent-row input { flex: none; }
.bulk-agent-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk-agent-strat { font-size: 11px; color: var(--muted); }
.bulk-agent-state { font-size: 11px; color: var(--muted); min-width: 62px; text-align: right; }
.bulk-agent-state.on { color: var(--accent); }
.bulk-change { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.bulk-change .field-row { flex: 1; min-width: 180px; }

/* accessibility: kill motion for users who ask for it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* First-run nudge banner (missing AI key while an LLM strategy is active) */
.nudge { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 10px 14px;
  background: var(--glass); border: 1px solid var(--accent); border-radius: 8px;
  font-size: 13px; color: var(--text); }
.nudge span { flex: 1; line-height: 1.4; }
.nudge .bt-run { flex-shrink: 0; }
.nudge-x { background: none; border: none; color: var(--muted); font: inherit; font-size: 15px;
  line-height: 1; cursor: pointer; padding: 0 4px; transition: color 0.15s; }
.nudge-x:hover { color: var(--text); }

/* Silent launch update check banner */
.update-banner { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: #1e3a5f; color: #cfe3ff; font-size: 13px; margin-bottom: 14px; border-radius: 8px; }
.update-banner-x { margin-left: auto; background: none; border: none; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; }

/* Headless live-orders-blocked banner (vps-phase2c): mirrors the Settings -> Exchange banner's
   wording, surfaced app-wide since an operator won't necessarily open Settings to see it. No
   dismiss control — it reflects a live fact (control.json mode) and clears itself when the
   operator switches back to Paper. Never renders on desktop; see App.tsx's getExchangeConfig type comment. */
.live-blocked-banner { display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--warn); font-size: 13px; margin-bottom: 14px; border-radius: 8px; }

/* Pairs-tab catalog — the full Hyperliquid pair list, filtered live by the search box */
.catalog { margin-top: 16px; }
.catalog-title { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
                 display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.catalog-add-all { flex: none; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px;
  max-height: 300px; overflow-y: auto; padding: 2px; }
.catalog-chip { background: var(--glass); border: 1px solid var(--glass-border); color: var(--text);
  font: inherit; font-size: 12px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color 0.15s, color 0.15s; }
.catalog-chip:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.catalog-chip.added { opacity: 0.45; cursor: default; }

/* Exchange accounts (multi-account switcher) */
.acct-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.acct-card { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--glass-border); border-radius: 10px; background: var(--glass); }
.acct-card.active { border-color: color-mix(in srgb, var(--mode-live) 55%, var(--glass-border)); }
.acct-pick { display: flex; align-items: center; gap: 10px; cursor: pointer; flex: 1; min-width: 0; }
.acct-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acct-name { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.acct-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.net-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.6px; padding: 1px 6px; border-radius: 999px;
  text-transform: uppercase; border: 1px solid var(--glass-border); }
.net-badge.testnet { color: var(--mode-shadow); }
.net-badge.mainnet { color: var(--mode-live); border-color: color-mix(in srgb, var(--mode-live) 45%, transparent); }
.acct-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.bt-link { background: none; border: none; color: var(--muted); font: inherit; font-size: 12px;
  cursor: pointer; padding: 2px 4px; transition: color 0.15s; }
.bt-link:hover:not(:disabled) { color: var(--text); }
.bt-link.danger:hover:not(:disabled) { color: var(--down); }
.bt-link:disabled { opacity: 0.4; cursor: default; }
.acct-form { border-top: 1px solid var(--glass-border); padding-top: 12px; margin-top: 4px; }

/* Backtest coverage callout — backtested-vs-traded gaps */
.bt-coverage { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; font-size: 13px; line-height: 1.6; }
.bt-coverage-title { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.bt-coverage-line { display: flex; flex-wrap: wrap; gap: 2px 6px; }
.bt-coverage-strategy { font-weight: 600; white-space: nowrap; }
.bt-coverage-warn { color: var(--warn); }
.bt-coverage-explainer { font-size: 12px; }

/* ============ Agents tab (roster grid) ============ */
.agents-panel { display: flex; flex-direction: column; gap: 16px; }

/* Attribution panel — collapsible section above agent cards */
.attribution-panel.card { padding: 0; }   /* own padding on the toggle button instead */
.attribution-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; color: var(--text); font: inherit; font-size: 14px;
  padding: 14px 18px; cursor: pointer; text-align: left; border-radius: 16px;
  transition: background 0.15s;
}
.attribution-toggle:hover { background: rgba(255,255,255,0.03); }
.attribution-arrow { flex: none; width: 12px; color: var(--accent); }
.attribution-title { font-weight: 600; }
.attribution-status { padding: 0 18px 14px; font-size: 13px; }
.attribution-table-wrap { padding: 0 0 6px; }
.attribution-table th,
.attribution-table td {
  padding: 6px 10px; white-space: nowrap;
}
.attribution-table th:first-child,
.attribution-table td:first-child { padding-left: 18px; }
.attribution-table th:last-child,
.attribution-table td:last-child { padding-right: 18px; }
.attribution-sort-th {
  cursor: pointer; user-select: none;
}
.attribution-sort-th:hover { color: var(--text); }
.attribution-retired {
  display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; padding: 1px 6px; border-radius: 999px;
  color: var(--muted); border: 1px solid var(--glass-border); vertical-align: middle;
  line-height: 1.3;
}
.attribution-unattributed td {
  border-top: 1.5px solid var(--glass-border); padding-top: 10px; font-style: italic;
}
.attribution-explainer { padding: 6px 18px 12px; font-size: 12px; }

.ag-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ag-eyebrow { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.ag-flow { font-size: 13px; color: var(--muted); margin-top: -4px; }
.ag-flow b { color: var(--accent); font-weight: 600; }

/* Principal — the decision-maker, visually elevated */
.ag-principal {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 15px 18px 15px 22px; border-radius: 12px; flex-wrap: wrap;
  background: radial-gradient(680px 220px at 0% -50%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%), var(--glass);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--glass-border));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.ag-principal::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: linear-gradient(var(--accent), var(--accent-2)); }
.ag-p-badge { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; font-size: 18px; color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.ag-p-main { display: flex; flex-direction: column; gap: 3px; }
.ag-p-title { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; }
.ag-p-sub { font-size: 13px; color: var(--muted); }
.ag-p-note { margin-left: auto; font-size: 12px; color: var(--muted); max-width: 260px; text-align: right; }

/* Agent roster */
/* align-items:start so a taller AI card (Model + Usage rows) doesn't stretch its rules-only
   row-mates into dead whitespace — each card hugs its own content. */
.ag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 14px; align-items: start; }
.ag-card {
  display: flex; flex-direction: column; gap: 11px; padding: 14px 15px; border-radius: 12px;
  background: var(--glass); border: 1px solid var(--glass-border);
  transition: transform .2s var(--ease-out), border-color .2s var(--ease-out), box-shadow .2s var(--ease-out), opacity .2s var(--ease-out);
}
.ag-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 30%, var(--glass-border)); box-shadow: 0 12px 34px -16px var(--glow); }
.ag-card.on { border-color: color-mix(in srgb, var(--accent) 38%, var(--glass-border)); }
.ag-card.off { opacity: .6; }
/* one line, always: chips shrink/ellipsize so the enable toggle never wraps to a second row */
/* wrap: the health chip (TRAD-16) can make name+chips+menu exceed a narrow card — chips flow to a second line instead of pushing the menu off-canvas */
.ag-card-head { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
/* Wrap instead of ellipsizing — "AI (discretiona…" hid exactly the words that distinguish agents. */
.ag-name { font-weight: 650; font-size: 15px; min-width: 0; flex: 1 1 auto; overflow-wrap: break-word; line-height: 1.25; }
.ag-card-head .kind-chip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 40%; flex: 0 1 auto; }
.ag-card-head .cap-chip { flex: none; }   /* "own key" is short — never truncate it into noise */
.ag-head-right { margin-left: auto; display: flex; align-items: center; flex: none; }

.ag-meta { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; }
.ag-meta dt { color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: .08em; align-self: center; font-weight: 600; }
.ag-meta dd { margin: 0; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }

.ag-usage { display: flex; flex-direction: column; gap: 5px; }
.ag-usage-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.ag-usage-row b { color: var(--text); font-weight: 500; }
.ag-bar { height: 6px; border-radius: 4px; background: color-mix(in srgb, var(--glass-border) 70%, transparent); overflow: hidden; }
.ag-bar > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s var(--ease-out); }
.ag-bar.over > i { background: var(--down); }

/* Running-now pulse on agent cards: subtle ring breathing while the engine executes the
   agent's cycle. No layout shift — box-shadow only. Reuses --warn (the theme's existing
   amber token, also used by tone-live/badge-pulse) rather than a one-off color. */
.ag-card.pulse { border-color: color-mix(in srgb, var(--warn) 55%, var(--glass-border)); animation: ag-pulse 1.6s ease-in-out infinite; }
@keyframes ag-pulse {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50%      { box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
}
.run-live { color: var(--warn); }

.ag-warn { font-size: 12px; color: var(--mode-live); background: color-mix(in srgb, var(--mode-live) 12%, transparent); border: 1px solid color-mix(in srgb, var(--mode-live) 28%, transparent); padding: 6px 9px; border-radius: 8px; }

.ag-btn { font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--text); background: transparent; border: 1px solid var(--glass-border); transition: color .15s, border-color .15s, background .15s; }
.ag-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ag-btn.primary { font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: color-mix(in srgb, var(--accent) 38%, transparent); }
.ag-btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.ag-btn.danger:hover:not(:disabled) { border-color: var(--down); color: var(--down); }
.ag-btn:disabled { opacity: .5; cursor: default; }

.ag-add {
  display: grid; place-items: center; gap: 6px; min-height: 152px; font: inherit; color: var(--muted);
  border: 1.5px dashed color-mix(in srgb, var(--accent) 26%, var(--glass-border)); border-radius: 12px; background: transparent; cursor: pointer;
  transition: color .18s, border-color .18s, background .18s;
}
.ag-add:hover { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.ag-add .plus { font-size: 24px; line-height: 1; }

/* Agents tab — Active/Available split (compact disabled rows) */
.ag-section { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 6px 0 -2px; }

.ag-list { display: flex; flex-direction: column; gap: 6px; }
.ag-row {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--glass) 60%, transparent); border: 1px solid var(--glass-border);
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.ag-row:hover { background: var(--glass); border-color: color-mix(in srgb, var(--accent) 26%, var(--glass-border)); }
.ag-row-name { font-weight: 600; font-size: 14px; white-space: nowrap; }
.ag-row-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.ag-btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; }

.ag-add-row {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 12px; margin-top: 2px;
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 26%, var(--glass-border)); border-radius: 10px; background: transparent;
  transition: color .18s, border-color .18s, background .18s;
}
.ag-add-row:hover { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.ag-add-row .plus { font-size: 17px; line-height: 1; }

/* Agents tab — kind subheaders + onboarding hint */
.ag-kind { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); opacity: .68; font-weight: 700; margin: 12px 0 3px 3px; }
.ag-list > .ag-kind:first-child { margin-top: 2px; }
.ag-hint {
  font-size: 13px; color: var(--text); padding: 9px 13px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Agents tab — toolbar (add / enable-all / disable-all / layout toggle) + kind groups */
.ag-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* Wraps for the same reason .ag-card-head does: this row grew a button (TRAD-11 "Bulk edit") and
   at 375px its five children no longer fit, which scrolled the whole page sideways. Wrapping keeps
   every control reachable instead of shrinking or hiding one. */
.ag-toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* overflow:hidden zeroes a flex item's automatic minimum size, so without flex:none the segment
   gets squeezed narrower than its own two buttons and clips the grid toggle away. */
.ag-seg { display: inline-flex; flex: none; border: 1px solid var(--glass-border); border-radius: 8px; overflow: hidden; }
.ag-seg button { font: inherit; font-size: 14px; line-height: 1; padding: 6px 11px; background: transparent; border: 0; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.ag-seg button + button { border-left: 1px solid var(--glass-border); }
.ag-seg button.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.ag-seg button:not(.on):hover { color: var(--text); }

.ag-group { display: flex; flex-direction: column; gap: 6px; }
.ag-group + .ag-group { margin-top: 4px; }

/* Agents tab — Active section header with Run-all action */
.ag-active-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 0; }
.ag-active-head .ag-section { margin: 0; }

/* Card action kebab (⋯) — replaces the 4-button row on agent cards */
.ag-menu { position: relative; flex: none; }
.ag-menu-btn { font: inherit; font-size: 17px; line-height: 1; padding: 3px 8px 7px; margin-left: 6px;
  border-radius: 8px; cursor: pointer; color: var(--muted); background: transparent;
  border: 1px solid transparent; transition: color .15s, border-color .15s; }
.ag-menu-btn:hover, .ag-menu.open .ag-menu-btn { color: var(--text); border-color: var(--glass-border); }
.ag-menu-list { position: absolute; z-index: 20; top: calc(100% + 4px); right: 0; min-width: 132px;
  display: flex; flex-direction: column; padding: 4px; background: var(--bg1);
  border: 1px solid var(--glass-border); border-radius: 8px; box-shadow: 0 12px 28px rgba(0,0,0,0.4); }
.ag-menu-item { font: inherit; font-size: 13px; text-align: left; padding: 7px 10px; border-radius: 6px;
  cursor: pointer; color: var(--text); background: transparent; border: none; transition: background .15s; }
.ag-menu-item:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.ag-menu-item.danger { color: var(--down); }
.ag-menu-item.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--down) 14%, transparent); }
.ag-menu-item:disabled { opacity: .5; cursor: default; }

/* One-click connect: advanced manual-entry disclosure */
.settings-actions .rail-select { width: auto; }   /* network picker: intrinsic width, don't stretch the row */
.acct-advanced { margin-top: 8px; }
.acct-advanced summary { cursor: pointer; font-size: 0.85rem; opacity: 0.75; }
.acct-advanced summary:hover { opacity: 1; }
.connect-wait { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--muted); line-height: 1.5; padding: 10px 12px; border: 1px solid var(--glass-border); border-radius: 8px; }
.connect-wait-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent, #e8a33d); animation: soft-blink 1.6s ease-in-out infinite; flex: none; }
.connect-url { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
.connect-url code { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }

/* ============ Graph view (TRAD-24) ============ */
.graph-view { position: relative; width: 100%; height: calc(100vh - 132px); min-height: 420px;
              border: none; border-radius: 20px; overflow: hidden;
              /* full-bleed field, not a card: a visible frame competes with the map inside it */
              background: radial-gradient(120% 90% at 50% 40%,
                            color-mix(in srgb, var(--tint) 55%, transparent), transparent 70%),
                          var(--bg0); }
.graph-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.graph-canvas:active { cursor: grabbing; }
.graph-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.graph-header { position: absolute; top: 14px; left: 18px; z-index: 2; pointer-events: none; }
.graph-eyebrow { font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
                 color: var(--muted); font-weight: 700; }
.graph-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.graph-controls { position: absolute; top: 14px; right: 14px; z-index: 2; display: flex;
                  align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end;
                  max-width: calc(100% - 28px); }
.graph-search { background: color-mix(in srgb, var(--bg0) 78%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--glass-border); border-radius: 999px;
                color: var(--text); font: inherit; font-size: 13px; padding: 6px 12px; min-width: 150px; }
.graph-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.graph-matches { font-size: 12px; color: var(--muted); }
/* D-11: a typo must not grey the world — the counter turns warn instead. */
.graph-matches-warn { color: var(--warn); }
.graph-advanced { flex-basis: 100%; display: flex; justify-content: flex-end; font-size: 12px;
                  color: var(--muted); gap: 8px; }
.graph-advanced label { display: flex; align-items: center; gap: 6px; }

.graph-legend { position: absolute; left: 14px; bottom: 14px; z-index: 2; display: flex;
                flex-wrap: wrap; align-items: center; gap: 6px; max-width: calc(100% - 28px); }
.graph-chip { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12px;
              color: var(--text); background: color-mix(in srgb, var(--bg0) 72%, transparent);
              backdrop-filter: blur(8px); border: 1px solid var(--glass-border);
              border-radius: 999px; padding: 4px 10px; cursor: pointer;
              transition: border-color .15s, opacity .15s; }
.graph-chip:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--glass-border)); }
.graph-chip.off { opacity: 0.45; text-decoration: line-through; }
.graph-swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.graph-swatch-agent { background: var(--accent); }
.graph-swatch-strategy { background: transparent; border: 2px solid var(--accent-2); }
.graph-swatch-symbol { background: var(--text); }
/* round trips carry BOTH colours — the swatch is a gradient so the chip decodes ▲/▼ too */
.graph-swatch-roundtrip { background: linear-gradient(90deg, var(--up) 50%, var(--down) 50%); }
.graph-swatch-backtest { background: var(--muted); border-radius: 2px; }
.graph-edge-key { font-size: 11px; }

.graph-card { position: absolute; right: 14px; bottom: 14px; z-index: 3; width: min(280px, calc(100% - 28px));
              background: color-mix(in srgb, var(--bg1) 88%, transparent); backdrop-filter: blur(14px);
              box-shadow: 0 18px 50px rgba(0,0,0,.45); border: 1px solid var(--glass-border); border-radius: 14px;
              padding: 12px 14px; font-size: 13px; max-height: 46%; overflow-y: auto; }
.graph-card-title { font-weight: 650; overflow-wrap: break-word; }
.graph-card-type { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.graph-card-stats { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
.graph-card-stats > div { display: contents; }
.graph-card-stats dt { color: var(--muted); font-size: 12px; }
.graph-card-stats dd { margin: 0; font-size: 12px; overflow-wrap: anywhere; text-align: right; }
.graph-card-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.graph-state { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px;
               align-items: center; justify-content: center; text-align: center; padding: 24px; }
.graph-empty-title { font-weight: 650; font-size: 15px; color: var(--text); }
.graph-hint { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); z-index: 2;
              font-size: 12px; background: var(--glass); border: 1px solid var(--glass-border);
              border-radius: 999px; padding: 4px 12px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
           clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* D-8: the graph supplies its own motion — quiet the app's ambient layers underneath it. */
.app.graph-active::before { animation: none; opacity: 0.1; }
.app.graph-active::after { opacity: 0.011; }

/* D-9: below 640px the card becomes a bottom sheet so it can't cover the canvas. */
@media (max-width: 640px) {
  .graph-view { height: calc(100vh - 120px); }
  .graph-card { left: 0; right: 0; bottom: 0; width: 100%; max-height: 40%;
                border-radius: 14px 14px 0 0; }
  .graph-legend { bottom: auto; top: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  .app.graph-active::before { animation: none; }
}

/* Global snackbar / toast stack — bottom-right, above modals (z 60), below info-tip (z 1000). */
.snackbar-host {
  position: fixed; z-index: 900; right: 18px; bottom: 18px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  max-width: min(380px, calc(100vw - 36px)); pointer-events: none;
}
.snackbar {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; font-size: 13px; color: var(--text);
  background: linear-gradient(180deg, #1a2136, #131a2c);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  animation: snackbar-in 0.22s var(--ease-out);
}
.snackbar-success { border-left: 3px solid var(--up); }
.snackbar-error   { border-left: 3px solid var(--danger); }
.snackbar-info    { border-left: 3px solid var(--accent); }
.snackbar-warn { border-left: 3px solid var(--warn); }
.snackbar-msg { flex: 1; line-height: 1.4; word-break: break-word; }
.snackbar-x { flex-shrink: 0; background: none; border: none; color: var(--muted);
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; transition: color 0.15s; }
.snackbar-x:hover { color: var(--text); }
@keyframes snackbar-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Notification bell + inbox panel */
.brand { position: relative; }
.notif-wrap { margin-left: auto; }
.notif-bell { position: relative; background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 4px; border-radius: 7px; display: inline-flex; transition: color 0.15s, background 0.15s; }
.notif-bell:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.notif-badge { position: absolute; top: -2px; right: -2px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  line-height: 15px; text-align: center; }
.notif-scrim { position: fixed; inset: 0; z-index: 40; }
.notif-panel { position: fixed; z-index: 41; left: 12px; top: 56px; width: min(340px, calc(100vw - 24px));
  max-height: 70vh; overflow-y: auto; background: linear-gradient(180deg, #1a2136, #131a2c);
  border: 1px solid var(--glass-border); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  animation: modal-in 0.18s var(--ease-out); }
.notif-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--glass-border); }
.notif-clear { background: none; border: none; color: var(--muted); font: inherit; font-size: 11.5px;
  font-weight: 600; cursor: pointer; padding: 2px 6px; border-radius: 6px; transition: color 0.15s, background 0.15s; }
.notif-clear:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.notif-empty { padding: 22px 14px; color: var(--muted); font-size: 13px; text-align: center; }
.notif-list { list-style: none; margin: 0; padding: 4px; }
.notif-item { display: flex; gap: 9px; padding: 8px 10px; border-radius: 8px; }
.notif-item:hover { background: rgba(255,255,255,0.03); }
.notif-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
.notif-error { background: var(--danger); } .notif-warn { background: var(--warn); } .notif-info { background: var(--accent); }
.notif-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-title { font-size: 13px; color: var(--text); line-height: 1.35; }
.notif-time { font-size: 11px; color: var(--muted); }

/* TRAD-21 manual order ticket */
.pos-toolbar { display: flex; justify-content: flex-end; margin: 0 0 8px; }
.order-ticket { max-width: 420px; width: calc(100vw - 32px); }
/* --order-label-col keeps helper text lined up with the INPUTS rather than the labels:
   it is the label column (min-width) plus the row gap. Change them together. */
.order-form { --order-label-col: 90px; display: flex; flex-direction: column; gap: 10px; margin: 8px 0 14px; }
.order-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.order-row label { min-width: 82px; font-size: 12px; opacity: 0.75; }
/* Helper lines describe the field ABOVE them, so pull them up out of the form's even gap —
   otherwise they float equidistant between two fields and read as belonging to neither. */
.order-hint, .order-conv, .order-warn, .order-err { margin-left: var(--order-label-col); margin-top: -5px; }
.order-row input { flex: 1; min-width: 0; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 8px; color: var(--text); font: inherit; padding: 7px 10px; transition: border-color 0.15s, box-shadow 0.15s; }
.order-side { display: flex; gap: 6px; }
.order-side .on { outline: 2px solid currentColor; }
.order-hint { font-size: 12px; opacity: 0.7; line-height: 1.45; }
/* The exit plan is a separate concern from the order itself — rule it off instead of letting
   it run on from the size field. */
.order-adv { border-top: 1px solid var(--glass-border); padding-top: 10px; margin-top: 4px; }
.order-adv summary { cursor: pointer; font-size: 12px; opacity: 0.8; margin: 0 0 10px; }
.order-adv .order-row + .order-row { margin-top: 10px; }
.order-err { color: var(--down); font-size: 12px; white-space: pre-wrap; }
/* The engine refuses a ticket opposing a held position — warn, don't error: nothing failed yet. */
.order-warn { color: var(--warn); font-size: 12px; line-height: 1.4; }
.order-conv { font-size: 14px; color: var(--text); }
.order-pair-wrap { position: relative; flex: 1; min-width: 0; }
/* the wrap is a block, so the input's own flex:1 is inert here — it needs an explicit width
   or it falls back to the default ~20-char size and renders narrow. */
.order-pair-wrap input { width: 100%; }
.order-pair-list { position: absolute; z-index: 20; top: calc(100% + 2px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none; max-height: 200px; overflow-y: auto; background: var(--bg1); border: 1px solid var(--glass-border); border-radius: 8px; box-shadow: 0 12px 28px rgba(0,0,0,0.4); }
.order-pair-opt { padding: 6px 9px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.order-pair-opt:hover, .order-pair-opt.active { background: var(--accent); color: var(--on-accent); }

/* ============ web dashboard login gate (botd, Phase 2b) ============
   Only ever mounted when the app is served by botd over plain HTTP, not inside the desktop app --
   see WebLoginGate.tsx / main.tsx for the gating. Reuses the same theme tokens/background as the
   rest of the app so it doesn't look like a bolted-on page. */
.web-login-screen {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100%;
  background: radial-gradient(1200px 620px at 82% -12%, var(--tint) 0%, transparent 62%),
              linear-gradient(160deg, var(--bg0), var(--bg1));
  color: var(--text); padding: 24px;
}
.web-login-checking { font-size: 14px; color: var(--muted); }
.web-login-card {
  width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 14px;
  padding: 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.web-login-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.web-login-sub { font-size: 13px; line-height: 1.5; color: var(--muted); }
.web-login-sub code { font-size: 12px; background: var(--bg0); border-radius: 4px; padding: 1px 5px; }
.web-login-input {
  background: var(--bg0); border: 1px solid var(--glass-border); border-radius: 8px;
  color: var(--text); font: 16px/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 11px 12px; text-align: center;
}
.web-login-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.web-login-submit { width: 100%; padding: 11px; font-size: 14px; font-weight: 600; }
.web-login-error { color: var(--down); font-size: 13px; line-height: 1.4; }
@media (max-width: 480px) {
  .web-login-card { padding: 22px 18px; }
}
/* Shimmering placeholders shown while a view's data is loading (first snapshot,
   or a mode switch whose world hasn't arrived yet). Theme-aware via the same
   glass vars as .card; static under prefers-reduced-motion. */
.skel {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--glass, rgba(255, 255, 255, 0.04));
}
.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: skel-sweep 1.4s ease-in-out infinite;
}
@keyframes skel-sweep {
  to { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .skel::after { animation: none; }
}

.skel-title  { height: 26px; width: 40%; }
.skel-kpi    { height: 96px; }
.skel-chart  { height: 280px; }
.skel-row    { height: 38px; margin-top: 10px; }
