/* ============================================================
   Crypto Garage v2 — mobile-first redesign stylesheet.
   Visual language ported from the design handoff (terminal/neon/daylight
   themes + 5 accents). Theme/accent tokens are injected on :root by
   js/core/theme.js; this file consumes the variables. Layout is mobile-first:
   fixed header -> step indicator -> scrollable screen -> sticky run-bar ->
   fixed bottom tab-bar. Safe areas via env(safe-area-inset-*). No device bezel.
   ============================================================ */

:root {
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --ff: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --fm: "JetBrains Mono", ui-monospace, "SF Mono", "Roboto Mono", monospace;

  /* Fallback token values (overwritten at runtime by theme.js for "terminal"). */
  --bg: #080b11;
  --stage: #04060a;
  --surface: #121826;
  --surface-2: #1a2231;
  --surface-3: #232d3e;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #e9edf3;
  --text-muted: #92a0b3;
  --text-faint: #5d6b7e;
  --pos: #16c784;
  --neg: #f6465d;
  --warn: #f0b90b;
  --field-bg: #0b1016;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --accent: #16c784;
  --accent-soft: rgba(22, 199, 132, 0.14);
  --accent-line: rgba(22, 199, 132, 0.45);
  --accent-contrast: #04130c;
  --accent-glow: rgba(22, 199, 132, 0.35);

  /* Safe-area insets (0 on non-notched devices). */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 76px; /* tab-bar content height incl. its own bottom padding */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Long symbols / IDs / URLs must never blow out a flex/grid track or force a
   horizontal scroll. Applied broadly; mono-number cells opt back into nowrap
   where alignment matters (.kv .v, table cells). */
body { overflow-wrap: anywhere; word-break: break-word; }

/* ---- Global personal background (cross-device, server-stored) ----
   Two fixed layers sit behind everything: an image layer and a readability
   scrim that blurs the image (not the UI). Driven by CSS vars set in
   js/core/background.js; hidden unless body.has-user-bg is present. */
:root {
  --user-bg-image: none;
  --user-bg-overlay: 0.34;
  --user-bg-blur: 10px;
  --user-bg-size: cover;
  --user-bg-pos-x: 50%;
  --user-bg-pos-y: 50%;
}
.user-bg-img,
.user-bg-scrim { position: fixed; inset: 0; z-index: -1; pointer-events: none; display: none; }
body.has-user-bg .user-bg-img {
  display: block;
  background: var(--user-bg-image) var(--user-bg-pos-x) var(--user-bg-pos-y) / var(--user-bg-size) no-repeat;
}
body.has-user-bg .user-bg-scrim {
  display: block;
  background: rgba(5, 8, 12, var(--user-bg-overlay));
  backdrop-filter: blur(var(--user-bg-blur));
  -webkit-backdrop-filter: blur(var(--user-bg-blur));
}
/* When a background is active, let the surfaces breathe a little so the image
   reads through the chrome without hurting contrast. */
body.has-user-bg { background: transparent; }
/* Fallback: browsers without backdrop-filter just get a stronger flat scrim. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  body.has-user-bg .user-bg-scrim { background: rgba(5, 8, 12, calc(var(--user-bg-overlay) + 0.25)); }
}

/* Keyboard focus ring — visible only for keyboard users (not on mouse/touch
   press), so the existing :active/hover feedback stays clean. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

.hidden { display: none !important; }
.mono { font-family: var(--fm); letter-spacing: -0.01em; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.tag-link { color: var(--accent); font-size: 13px; font-weight: 500; cursor: pointer; }

/* ============================================================
   App shell (mobile-first full viewport)
   ============================================================ */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app-header {
  flex: 0 0 auto;
  padding: calc(14px + var(--safe-top)) 20px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  position: relative;
  z-index: 5;
}
.app-header .h-eyebrow {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 4px;
}
.app-header h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 0; line-height: 1.05; }
.app-header .h-sub { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; }

.header-pill {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted); white-space: nowrap; cursor: pointer;
}
.header-pill svg { width: 15px; height: 15px; }
.header-avatar {
  width: 34px; height: 34px; border-radius: 999px; flex: none; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--fm); font-weight: 600; font-size: 13px;
  color: var(--accent-contrast); background: var(--accent);
}

/* Screen scroll region */
.screen {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 4px 16px 20px;
  scroll-behavior: smooth;
}
.screen::-webkit-scrollbar { width: 0; }
.screen.has-runbar { padding-bottom: calc(96px + var(--safe-bottom)); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px; margin-bottom: 14px;
}
.card.tight { padding: 14px; }
.card-head { margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; }
.card-sub { font-size: 12.5px; color: var(--text-faint); margin-top: 4px; line-height: 1.45; }
.card-ic {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.card-ic svg { width: 15px; height: 15px; }

.section-label {
  font-family: var(--fm); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-faint); margin: 22px 4px 10px;
}

/* ============================================================
   Fields & inputs
   ============================================================ */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 7px;
}
.field-label .req { color: var(--accent); margin-left: 2px; }
.field-action-accent { color: var(--accent); font-size: 13px; }
.field-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; line-height: 1.4; }
/* Taker-fee exchange selector: keep the active-fee readout and the (Custom-only)
   manual input visually grouped under the segmented control. */
.taker-fee-note { font-weight: 500; color: var(--text-muted); }
.taker-fee-manual { margin-top: 12px; }
.taker-fee-manual .field { margin-bottom: 0; }
.field-status { font-size: 12.5px; color: var(--text-faint); margin: 8px 2px 0; min-height: 1em; }
.field-status.is-error { color: var(--neg); }
.field-status.is-success { color: var(--pos); }
.field-status.is-info { color: var(--text-muted); }

.input, .select, input[type="search"], input[type="text"], input[type="password"],
input[type="number"], input[type="datetime-local"], textarea.input {
  width: 100%; height: 50px; background: var(--field-bg);
  border: 1px solid var(--border); border-radius: var(--r); color: var(--text);
  font-family: var(--ff); font-size: 15.5px; padding: 0 14px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-appearance: none; appearance: none;
}
.input.mono, input.mono { font-family: var(--fm); letter-spacing: -0.01em; }
.input::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, input:focus, textarea.input:focus {
  border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface-2);
}
textarea.input { height: auto; padding: 12px 14px; line-height: 1.5; resize: vertical; }

/* native multi-line select (symbol list) */
select[size] { height: auto; padding: 6px; }
select[size] option { padding: 6px 8px; border-radius: 8px; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 9px; height: 9px;
  border-right: 2px solid var(--text-faint); border-bottom: 2px solid var(--text-faint);
  transform: translateY(-65%) rotate(45deg); pointer-events: none;
}
.select-wrap .select { padding-right: 40px; }

.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .input, .input-affix input { padding-right: 52px; }
.input-affix .affix {
  position: absolute; right: 14px; font-family: var(--fm); font-size: 13px;
  color: var(--text-faint); pointer-events: none; display: flex; align-items: center;
}
.input-affix .affix.left { left: 14px; right: auto; }
.input-affix .affix.left svg { width: 16px; height: 16px; }
.input-affix.has-left .input, .input-affix.has-left input { padding-left: 40px; padding-right: 14px; }

/* ============================================================
   Segmented control
   ============================================================ */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  background: var(--field-bg); border: 1px solid var(--border); border-radius: var(--r); padding: 4px;
}
.seg.wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); }
.seg-btn {
  appearance: none; border: 0; background: transparent; color: var(--text-muted);
  font-family: var(--ff); font-size: 14px; font-weight: 500; height: 40px; border-radius: 10px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.15s; white-space: nowrap;
}
.seg-btn svg { width: 15px; height: 15px; }
.seg-btn:hover { color: var(--text); }
/* iOS Safari never fires :hover on tap, so an inactive seg button gave no press
   feedback on mobile. :active provides an immediate visible response on tap.
   :not(.active) keeps the selected button's accent fill untouched. */
.seg-btn:not(.active):active { background: var(--surface-3); color: var(--text); }
.seg-btn.active { background: var(--accent); color: var(--accent-contrast); font-weight: 600; box-shadow: 0 2px 10px var(--accent-glow); }
.seg.subtle .seg-btn.active { background: var(--surface-3); color: var(--text); box-shadow: none; }

/* ============================================================
   Stepper / slider / toggle
   ============================================================ */
.stepper {
  display: flex; align-items: center; background: var(--field-bg); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; height: 50px; min-width: 0;
}
.stepper button {
  width: 46px; height: 100%; flex: none; border: 0; cursor: pointer; background: transparent;
  color: var(--text-muted); font-size: 22px; line-height: 1; display: flex; align-items: center;
  justify-content: center; transition: background 0.12s, color 0.12s;
}
.stepper button:hover { background: var(--surface-3); color: var(--text); }
.stepper button:active { background: var(--accent-soft); color: var(--accent); }
.stepper input {
  flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; background: transparent;
  text-align: center; color: var(--text); font-family: var(--fm); font-size: 16px; outline: none;
}

/* Track + value stacked vertically: the readout sits on its own line above the
   track, so it can never overlap the thumb or clip off-screen — even in the
   narrow two-up Position X/Y columns. */
.slider-row { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.slider-head { display: flex; justify-content: flex-end; align-items: baseline; min-height: 16px; }
.slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px;
  background: var(--surface-3); outline: none;
  /* Let vertical page scroll pass through the range; horizontal drag/tap still moves the thumb. */
  touch-action: pan-y;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 999px; background: var(--accent);
  cursor: pointer; border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent-line), 0 2px 8px var(--accent-glow);
}
.slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 999px; background: var(--accent); border: 3px solid var(--bg); cursor: pointer; }
.slider-val { text-align: right; white-space: nowrap; font-family: var(--fm); font-size: 14px; color: var(--text); }

.toggle {
  width: 50px; height: 30px; border-radius: 999px; flex: none; background: var(--surface-3);
  border: 1px solid var(--border); position: relative; cursor: pointer; transition: background 0.18s; padding: 0;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 999px;
  background: var(--text-faint); transition: transform 0.18s, background 0.18s;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle.on::after { transform: translateX(20px); background: var(--accent-contrast); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .tr-label { font-size: 14.5px; font-weight: 500; }
.toggle-row .tr-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; line-height: 1.4; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  appearance: none; cursor: pointer; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-family: var(--ff); font-size: 14.5px; font-weight: 500; height: 46px;
  padding: 0 18px; border-radius: var(--r); display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-3); }
/* Tap feedback for touch devices: iOS Safari does not fire :hover on tap, so
   buttons felt dead on press. :active gives an immediate visible press state. */
.btn:active:not(:disabled) { filter: brightness(0.92); transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; box-shadow: 0 4px 16px var(--accent-glow); }
.btn--primary:hover { background: var(--accent); filter: brightness(1.06); border-color: var(--accent); }
.btn--primary:active:not(:disabled) { filter: brightness(0.9); transform: translateY(1px); }
.btn--danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 35%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--neg) 12%, transparent); }
.btn--danger:active:not(:disabled) { background: color-mix(in srgb, var(--neg) 20%, transparent); transform: translateY(1px); }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn--lg { height: 54px; font-size: 16px; }
.btn--sm { height: 38px; font-size: 13px; padding: 0 14px; border-radius: 10px; }
.btn--sm svg { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* ============================================================
   Chips
   ============================================================ */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; font-family: var(--fm); letter-spacing: 0.01em;
  background: var(--surface-3); color: var(--text-muted);
}
.chip .dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.chip strong { font-weight: 700; }
.chip--pos { background: color-mix(in srgb, var(--pos) 16%, transparent); color: var(--pos); }
.chip--neg { background: color-mix(in srgb, var(--neg) 16%, transparent); color: var(--neg); }
.chip--warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip--info { background: var(--accent-soft); color: var(--accent); }

/* ============================================================
   Stats grid
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; }
.stat-label { font-size: 11.5px; color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
.stat-label svg { width: 13px; height: 13px; }
.stat-val { font-family: var(--fm); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; }
.stat-val.pos { color: var(--pos); }
.stat-val.neg { color: var(--neg); }

/* ============================================================
   Wizard steps + run-bar
   ============================================================ */
/* Step-navbar: anchor links to the four single-page sections + scroll-spy
   highlight. It sits OUTSIDE the .screen scroll region (a flex sibling above it),
   so it stays pinned at the top while the form scrolls beneath — effectively
   sticky. The background + bottom hairline make it read as a sticky bar over the
   scrolling content. On mobile the row scrolls horizontally if the four steps
   don't fit (scroll-snap to each step). */
.steps {
  display: flex; gap: 6px; padding: 2px 16px 8px; position: sticky; top: 0; z-index: 6;
  flex: 0 0 auto; background: var(--bg); border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  /* Keep horizontal nav scroll; let vertical gestures pass through to page scroll. */
  touch-action: pan-x;
}
.steps::-webkit-scrollbar { height: 0; width: 0; }
.step {
  flex: 1 1 0; min-width: 64px; scroll-snap-align: start;
  cursor: pointer; border: 0; background: transparent; display: flex; flex-direction: column;
  gap: 7px; align-items: stretch; font-family: var(--ff); padding: 0;
  text-decoration: none; color: inherit;
}
.step .bar { height: 4px; border-radius: 999px; background: var(--surface-3); transition: background 0.2s; }
.step .lbl { font-size: 11.5px; color: var(--text-faint); text-align: left; transition: color 0.2s; display: flex; align-items: center; gap: 5px; }
.step.active .bar { background: var(--accent); }
.step.active .lbl { color: var(--text); font-weight: 600; }
.step.done .bar { background: var(--accent-line); }
.step.done .lbl { color: var(--text-muted); }
.step .num {
  width: 16px; height: 16px; border-radius: 999px; font-size: 9.5px; font-family: var(--fm);
  display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--text-faint);
}
.step .num svg { width: 9px; height: 9px; }
.step.active .num { background: var(--accent); color: var(--accent-contrast); }
.step.done .num { background: var(--accent-line); color: var(--accent-contrast); }

.runbar {
  position: absolute; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 10px 16px 12px; background: linear-gradient(0deg, var(--bg) 55%, transparent);
  z-index: 8; display: flex; gap: 10px; align-items: center;
}
.runbar .runbar-main { flex: 1; }
.runbar .runbar-back { flex: 0 0 auto; width: 52px; padding: 0; }
.runbar .btn--primary { box-shadow: 0 6px 20px var(--accent-glow); }

/* ============================================================
   Single-page form anchor sections (Data / Strategy / Advanced / Run). Each is
   a full-width band with a numbered heading that the step-navbar scrolls to.
   scroll-margin-top keeps the heading clear of the sticky navbar after a jump.
   ============================================================ */
.bt-section { scroll-margin-top: 8px; padding-top: 6px; outline: none; }
.bt-section + .bt-section { margin-top: 6px; border-top: 1px dashed var(--border); padding-top: 18px; }
.bt-section-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.bt-section-num {
  width: 24px; height: 24px; border-radius: 999px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--fm); font-size: 12px; font-weight: 600;
  background: var(--accent-line); color: var(--accent-contrast);
}
.bt-section.active-anchor .bt-section-num { background: var(--accent); }
.bt-section-title {
  display: flex; align-items: center; gap: 7px; margin: 0;
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--text);
}
.bt-section-title .card-ic { color: var(--text-muted); }
/* On the desktop grid the section body should still flow its own cards in a
   single readable column (the four bands stack; cards inside don't fan out). */
.bt-section-body { display: flex; flex-direction: column; gap: 14px; }

/* ============================================================
   Progress card
   ============================================================ */
.progress-card { background: var(--surface); border: 1px solid var(--accent-line); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; }
.progress-bar, .progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 12px 0 8px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s ease; box-shadow: 0 0 12px var(--accent-glow); }
.progress-meta { display: flex; justify-content: space-between; font-family: var(--fm); font-size: 12px; color: var(--text-muted); }

/* ============================================================
   Tab bar
   ============================================================ */
.tabbar {
  flex: 0 0 auto; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 10px calc(10px + var(--safe-bottom));
  background: var(--surface); border-top: 1px solid var(--border); position: relative; z-index: 9;
}
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0;
  color: var(--text-faint); font-family: var(--ff); font-size: 10.5px; font-weight: 500; transition: color 0.15s;
}
.tab svg { width: 23px; height: 23px; }
/* Tap feedback on the bottom tab-bar for touch (no :hover on iOS). */
.tab:not(.active):active { color: var(--text-muted); }
.tab.active { color: var(--accent); }
.tab-badge {
  position: absolute; top: 2px; left: 50%; margin-left: 6px; min-width: 16px; height: 16px;
  border-radius: 999px; padding: 0 4px; background: var(--neg); color: #fff; font-size: 9px;
  font-family: var(--fm); display: flex; align-items: center; justify-content: center; font-weight: 700;
}

/* ============================================================
   Charts
   ============================================================ */
.chart-wrap { position: relative; margin: 4px 0 2px; }
.equity-svg { width: 100%; display: block; height: 200px; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }

/* Interactive equity chart: cursor + floating tooltip on hover/touch. */
.chart-wrap--interactive { touch-action: pan-y; cursor: crosshair; }
.equity-tip {
  position: absolute;
  top: 4px;
  left: 0;
  pointer-events: none;
  padding: 6px 9px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  white-space: nowrap;
  z-index: 2;
}
.equity-tip.is-on { opacity: 1; transform: translateY(0); }
.equity-tip-val { font-size: 13px; font-weight: 600; color: var(--text); }
.equity-tip-date { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-muted); }
.legend-swatch { width: 12px; height: 12px; border-radius: 4px; }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; padding: 0 2px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar-col-val { font-size: 11px; color: var(--text-muted); }
.bar-col-bar { width: 100%; background: var(--accent); border-radius: 6px 6px 3px 3px; transition: height 0.5s ease; }
.bar-col-label { font-size: 10.5px; color: var(--text-faint); }

/* ============================================================
   Hero (results / admin) + risk summary
   ============================================================ */
.hero-card { background: linear-gradient(160deg, var(--accent-soft), transparent 70%); }
.hero-eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.hero-value { font-size: 38px; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; }
.hero-roi { font-size: 15px; font-weight: 600; margin-top: 2px; }
.hero-roi.pos { color: var(--pos); }
.hero-roi.neg { color: var(--neg); }
.hero-from { font-weight: 400; }
.hero-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.hero-period { font-size: 12px; margin-top: 10px; letter-spacing: 0.01em; }
.hero-period .hero-period-label { text-transform: uppercase; letter-spacing: 0.1em; font-size: 10px; }

.risk-summary { border-left: 3px solid var(--border-strong); }
.risk-summary--pos { border-left-color: var(--pos); }
.risk-summary--neg { border-left-color: var(--neg); }
.risk-summary--warn { border-left-color: var(--warn); }
.risk-headline { font-size: 15px; font-weight: 600; }
.risk-sub { font-size: 13px; margin-top: 6px; line-height: 1.5; }
.risk-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Min-notional advisory (renders only when count > 0). Soft amber, not alarming. */
.min-notional-notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 36%, transparent);
  font-size: 12.5px;
  line-height: 1.5;
}
.min-notional-notice .mnn-ic {
  flex: 0 0 auto;
  display: inline-flex;
  margin-top: 1px;
  color: var(--warn);
}
.min-notional-notice .mnn-text { min-width: 0; }
.min-notional-notice strong { color: var(--text); font-weight: 600; }

/* ============================================================
   Risk analytics (BacktestResponse.risk) — hero verdict + metric grid.
   Rendered only when the run carries a `risk` block; omitted for older runs.
   ============================================================ */
.risk-analytics .card-title { margin-bottom: 14px; }

/* Hero verdict: large strategy status (OK | RISKY | DEAD), toned by the
   backend's strategy_status_tone. A soft tinted panel + a left accent rail. */
.risk-verdict {
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
}
.risk-verdict--pos { border-left-color: var(--pos); background: color-mix(in srgb, var(--pos) 8%, var(--surface-2)); }
.risk-verdict--warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--surface-2)); }
.risk-verdict--neg { border-left-color: var(--neg); background: color-mix(in srgb, var(--neg) 8%, var(--surface-2)); }
.rv-eyebrow { font-size: 11px; letter-spacing: 0.08em; }
.rv-status {
  font-size: 28px; font-weight: 700; letter-spacing: -0.01em;
  line-height: 1.1; margin-top: 4px;
}
.rv-status.pos { color: var(--pos); }
.rv-status.warn { color: var(--warn); }
.rv-status.neg { color: var(--neg); }
.rv-reason { font-size: 13px; line-height: 1.5; margin-top: 8px; }

/* Metric grid: 2-up on mobile, the card sits in a single grid column so this
   stays readable on every breakpoint. */
.risk-metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.risk-cell {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  min-width: 0;
}
.risk-cell-label {
  display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap;
  font-size: 11.5px; font-weight: 500; color: var(--text-muted);
  line-height: 1.3;
}
.risk-cell-marker {
  font-size: 9px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--text-faint); background: color-mix(in srgb, var(--text-faint) 18%, transparent);
  padding: 1px 4px; border-radius: 5px; top: 0; vertical-align: middle;
}
.risk-cell[title] { cursor: help; }
.risk-cell-info { font-size: 11px; color: var(--text-faint); }
.risk-cell-val {
  font-size: 19px; font-weight: 600; letter-spacing: -0.01em; margin-top: 6px;
  color: var(--text); overflow-wrap: anywhere;
}
.risk-cell-val.pos { color: var(--pos); }
.risk-cell-val.warn { color: var(--warn); }
.risk-cell-val.neg { color: var(--neg); }
.risk-cell-sub { font-size: 11.5px; margin-top: 3px; }

/* Narrow phones: drop to a single column so long values ("breaks at −42.0%")
   don't get clipped. */
@media (max-width: 360px) {
  .risk-metric-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Chains / list rows / kv
   ============================================================ */
.chain { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.chain-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chain-steps { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.chain-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--accent); opacity: 0.9; }
.chain-dot.ins { background: var(--warn); }
.chain-dot.sl { background: var(--neg); }
.chain-steps-label { font-size: 13px; font-weight: 600; margin-left: 6px; }
.chain-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chain-meta .m-label { font-size: 10.5px; color: var(--text-faint); }
.chain-meta .m-val { font-size: 14px; margin-top: 2px; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 10px; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-size: 14.5px; font-weight: 500; }
.list-row .lr-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.list-row .lr-ic { width: 38px; height: 38px; border-radius: 11px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.list-row.selected { border-color: var(--accent-line); background: var(--accent-soft); }
/* Clickable history rows (Account → Backtest history): the whole row is a
   button that opens the results sheet. Give it a hover/active affordance and a
   keyboard focus ring (the global :focus-visible rule supplies the outline). */
.list-row.is-clickable { transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease; }
.list-row.is-clickable:hover { border-color: var(--accent-line); background: var(--surface-2); filter: brightness(1.04); }
.list-row.is-clickable:active { transform: scale(0.995); }
/* Event rows (SL closes / trade log details): align to the top so multi-line
   note clusters read as a card, and let the breakdown wrap on narrow screens. */
.list-row.event-row { align-items: flex-start; }
.list-row.event-row .lr-ic { margin-top: 1px; }
.event-notes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.event-note {
  font-size: 11px; color: var(--text-muted); background: var(--surface-3);
  border: 1px solid var(--border); border-radius: 7px; padding: 2px 7px; white-space: nowrap;
}
.trade-list { display: flex; flex-direction: column; }
.kv { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-muted); flex: none; }
.kv .v { white-space: nowrap; text-align: right; }

/* ============================================================
   Empty state
   ============================================================ */
.empty { text-align: center; padding: 34px 18px; color: var(--text-faint); }
.empty .e-ic { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-faint); }
.empty .e-title { font-size: 15px; color: var(--text-muted); font-weight: 500; }
.empty .e-sub { font-size: 12.5px; margin-top: 5px; line-height: 1.5; }

/* ============================================================
   RSI inset (advanced step)
   ============================================================ */
.rsi-inset { margin-top: 4px; padding: 14px; background: var(--field-bg); border-radius: var(--r); border: 1px solid var(--border); }

/* ============================================================
   Required-capital block (auto deposit)
   ============================================================ */
.reqcap-card { padding: 16px; }
.reqcap-inset { background: var(--field-bg); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; margin-bottom: 16px; }
.reqcap { display: flex; flex-direction: column; gap: 6px; }
.reqcap-head { display: flex; align-items: center; justify-content: space-between; }
.reqcap-label { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--fm); }
.reqcap-spinner { font-size: 11px; color: var(--text-faint); }
.reqcap-value-row { display: flex; align-items: baseline; gap: 8px; }
.reqcap-value { font-family: var(--fm); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.reqcap-value--muted { color: var(--text-faint); }
.reqcap--loading .reqcap-value { opacity: 0.55; }
.reqcap-unit { font-family: var(--fm); font-size: 14px; color: var(--text-muted); }
.reqcap-hint, .reqcap-note { font-size: 11.5px; color: var(--text-faint); line-height: 1.45; margin: 2px 0 0; }
.reqcap-note--error { color: var(--neg); }
.reqcap-warn { display: flex; gap: 10px; margin-top: 8px; padding: 10px 12px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 34%, transparent); }
.reqcap-warn-icon { color: var(--warn); font-size: 16px; }
.reqcap-warn-text { font-size: 12.5px; color: var(--text); margin: 0; line-height: 1.45; }
.reqcap-warn-adjusted { font-size: 12.5px; color: var(--text-muted); margin: 4px 0 0; }
.reqcap-breakdown { margin-top: 8px; }
.reqcap-breakdown summary { font-size: 12.5px; color: var(--accent); cursor: pointer; }
.reqcap-breakdown-table { width: 100%; border-collapse: collapse; font-family: var(--fm); font-size: 11.5px; margin-top: 8px; }
.reqcap-breakdown-table th, .reqcap-breakdown-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.reqcap-breakdown-table tr.is-reject td { color: var(--neg); }
.reqcap-breakdown-wrap { overflow-x: auto; overscroll-behavior: contain; }

/* Stop-loss level spliced into the order ladder — a price LEVEL, not an order.
   Warning accent + dashed left border + shield icon set it apart from rows. */
.reqcap-breakdown-table tr.reqcap-sl-row td {
  background: color-mix(in srgb, var(--neg) 9%, transparent);
  border-top: 1px dashed color-mix(in srgb, var(--neg) 55%, transparent);
  border-bottom: 1px dashed color-mix(in srgb, var(--neg) 55%, transparent);
  color: var(--neg);
}
.reqcap-breakdown-table tr.reqcap-sl-row td:first-child {
  border-left: 3px solid var(--neg);
  font-weight: 600;
}
.reqcap-sl-icon { margin-right: 5px; }
.reqcap-sl-label { letter-spacing: 0.2px; }
.reqcap-sl-price { margin-left: 6px; color: var(--text-muted); font-weight: 500; }
.reqcap-sl-status { color: var(--neg); }

/* ============================================================
   Grid preview (averaging ladder)
   ============================================================ */
.preview-head h3 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.preview-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
.preview-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px; }
.preview-stat-value { font-family: var(--fm); font-size: 18px; font-weight: 600; }
.preview-stat-label { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.preview-stat--warn .preview-stat-value { color: var(--warn); }
.preview-table-wrap { overflow-x: auto; overscroll-behavior: contain; }
.preview-table { width: 100%; border-collapse: collapse; font-family: var(--fm); font-size: 12px; }
.preview-table th, .preview-table td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.preview-table th:first-child, .preview-table td:first-child { text-align: left; }
.preview-table tr.is-base td { color: var(--accent); }

/* ============================================================
   Data-source controls (step 1) — styled to the v2 design system:
   dark/rounded fields, accent selection, custom scrollbar, dark-scheme
   date pickers and a custom file-picker button. Logic/IDs unchanged.
   ============================================================ */
.field-grid { display: flex; flex-direction: column; gap: 0; }
.field-grid > .field { margin-bottom: 16px; }
.download-tools { margin-top: 4px; }
.symbol-field { margin-bottom: 0; }
.symbol-field .input-affix { margin-bottom: 8px; }
.symbol-field .symbol-list { margin-bottom: 6px; }

/* Trading-pair popover: the symbol combobox reuses the .dropdown-menu shell, but
   instead of plain option rows it holds the search box + scrollable list + status.
   The menu itself does NOT scroll (overflow visible); the inner .symbol-list owns
   the scrolling so the search box and status stay pinned. */
.symbol-menu { max-height: none; overflow: visible; }
.symbol-menu .symbol-list {
  height: 216px; margin-bottom: 6px;
  border-color: var(--border-strong); background: var(--field-bg);
}
.symbol-menu .symbol-list:last-child { margin-bottom: 0; }
.symbol-menu #symbolsStatus { margin: 0; }
/* On narrow screens the popover already spans the field width (left:0/right:0);
   clamp its inner list a touch shorter so it never runs off a short viewport. */
@media (max-width: 560px) {
  .symbol-menu .symbol-list { height: 188px; }
}

/* Search input: neutralise the native search-clear/decoration so the field
   reads as a plain v2 text input with our own leading magnifier icon. */
.symbol-field input[type="search"]::-webkit-search-decoration,
.symbol-field input[type="search"]::-webkit-search-cancel-button,
.symbol-field input[type="search"]::-webkit-search-results-button,
.symbol-field input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none; appearance: none;
}
.symbol-field .affix.left svg { color: var(--text-faint); }

/* Trading-pair list: fully custom scrollable listbox (replaces the native
   multi-line <select size>, which renders as an unstyleable OS widget on Android
   Chrome). Dark field background, rounded, slim custom scrollbar; rows are
   <button role=option> styled below. */
.symbol-list {
  width: 100%; max-width: 100%; height: 216px; overflow-y: auto;
  background: var(--field-bg); border: 1px solid var(--border); border-radius: var(--r);
  padding: 6px; outline: none;
  scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.symbol-list:focus, .symbol-list:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.symbol-option {
  display: block; width: 100%; text-align: left; appearance: none; border: 0;
  background: transparent; color: var(--text); cursor: pointer;
  font-family: var(--fm); font-size: 14px; letter-spacing: -0.01em;
  padding: 9px 12px; border-radius: 8px; transition: background 0.12s, color 0.12s;
}
.symbol-option:hover { background: var(--surface-2); }
.symbol-option:active { background: var(--surface-3); }
.symbol-option.is-active {
  background: var(--accent); color: var(--accent-contrast); font-weight: 600;
}
.symbol-list-empty { padding: 14px 12px; color: var(--text-faint); font-size: 13px; }
.symbol-list::-webkit-scrollbar { width: 8px; }
.symbol-list::-webkit-scrollbar-track { background: transparent; }
.symbol-list::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid var(--field-bg); }
.symbol-list::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Custom exchange dropdown: a v2 trigger button + a popover listbox. Replaces
   the native <select> whose popup can't be themed on mobile Chrome. */
.dropdown { position: relative; }
.dropdown-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; height: 50px; background: var(--field-bg);
  border: 1px solid var(--border); border-radius: var(--r); color: var(--text);
  font-family: var(--ff); font-size: 15.5px; padding: 0 14px; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s; outline: none;
}
.dropdown-trigger:hover { border-color: var(--border-strong); }
.dropdown-trigger:focus, .dropdown-trigger[aria-expanded="true"] {
  border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface-2);
}
.dropdown-trigger-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-chevron { display: flex; flex: none; color: var(--text-faint); transition: transform 0.15s; }
.dropdown-chevron svg { width: 18px; height: 18px; }
.dropdown-trigger[aria-expanded="true"] .dropdown-chevron { transform: rotate(180deg); }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  max-height: 280px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r); padding: 6px; box-shadow: var(--shadow);
  scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent;
}
.dropdown-option {
  display: block; width: 100%; text-align: left; appearance: none; border: 0;
  background: transparent; color: var(--text); cursor: pointer;
  font-family: var(--ff); font-size: 15px; padding: 10px 12px; border-radius: 8px;
  transition: background 0.12s, color 0.12s;
}
.dropdown-option:hover { background: var(--surface-3); }
.dropdown-option.is-active { background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.dropdown-menu::-webkit-scrollbar { width: 8px; }
.dropdown-menu::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }

/* Date/time pickers: the native field is wrapped in a .datetime-field shell so
   its resting state matches the v2 dark/rounded inputs. The native control keeps
   its calendar popup (good on mobile); we only theme its surface + indicator. */
.datetime-field { position: relative; }
.download-tools input[type="datetime-local"] { color-scheme: dark; }
.download-tools input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.55) opacity(0.7); cursor: pointer; transition: filter 0.15s;
}
.download-tools input[type="datetime-local"]:hover::-webkit-calendar-picker-indicator { filter: invert(0.75) opacity(0.9); }

/* CSV picker: hide the native file input, drive it from a styled label that
   carries a v2 "button" + the chosen filename. */
.file-field {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--field-bg); border: 1px solid var(--border); border-radius: var(--r);
  padding: 8px 8px 8px 8px; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.file-field:hover { border-color: var(--border-strong); }
.file-field:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.file-field__input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.file-field__btn {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font-family: var(--ff); font-size: 14px; font-weight: 500;
  padding: 9px 14px; transition: background 0.15s, border-color 0.15s;
}
.file-field:hover .file-field__btn { background: var(--surface-3); border-color: var(--border-strong); }
.file-field__btn svg { width: 16px; height: 16px; color: var(--text-muted); }
.file-field__name {
  flex: 1; min-width: 0; color: var(--text-muted); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============================================================
   Auth
   ============================================================ */
.auth-shell, .pending-shell { min-height: 100vh; }
.auth {
  position: relative; min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
  padding: calc(40px + var(--safe-top)) 26px calc(40px + var(--safe-bottom));
  background: radial-gradient(120% 80% at 50% -10%, var(--accent-soft), transparent 60%), var(--bg);
  color: var(--text);
}
.auth-brand { text-align: center; margin-bottom: 30px; }
.auth-logo {
  width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 16px; display: flex; align-items: center;
  justify-content: center; background: var(--accent); color: var(--accent-contrast); box-shadow: 0 10px 30px var(--accent-glow);
}
.auth-brand h1 { font-size: 27px; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
.auth-brand p { font-size: 13px; color: var(--text-faint); margin: 6px 0 0; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 22px; max-width: 420px; width: 100%; margin: 0 auto; }
.auth-tabs { display: flex; gap: 4px; background: var(--field-bg); border: 1px solid var(--border); border-radius: var(--r); padding: 4px; margin-bottom: 20px; }
.auth-tabs button { flex: 1; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--text-muted); font-family: var(--ff); font-size: 14px; font-weight: 500; cursor: pointer; }
.auth-tabs button.active { background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); margin: 4px 0 18px; cursor: pointer; }
.check { width: 22px; height: 22px; border-radius: 7px; border: 1px solid var(--border-strong); flex: none; display: flex; align-items: center; justify-content: center; background: var(--field-bg); }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

/* ============================================================
   Appearance: accent dots
   ============================================================ */
.accent-row { display: flex; gap: 12px; }
.accent-dot { width: 34px; height: 34px; border-radius: 999px; border: 2px solid transparent; cursor: pointer; padding: 0; transition: transform 0.12s, border-color 0.12s; }
.accent-dot:hover { transform: scale(1.08); }
.accent-dot.is-active { border-color: var(--text); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ============================================================
   Background customiser preview
   ============================================================ */
.bg-preview { height: 150px; border-radius: var(--r); overflow: hidden; position: relative; border: 1px solid var(--border); margin-bottom: 14px; background: var(--surface-2); }
.bg-img-layer { position: absolute; inset: 0; background-repeat: no-repeat; }
.bg-scrim { position: absolute; inset: 0; }
.bg-content { position: relative; z-index: 2; padding: 16px; }
.bg-content .t1 { font-size: 16px; font-weight: 600; }
.bg-content .t2 { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.bg-drop {
  position: absolute; z-index: 3; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
  background: rgba(0,0,0,0.45); border: 1px solid var(--border-strong); color: #fff; font-size: 11.5px; cursor: pointer; max-width: 90%;
}
.bg-preview.has-image .bg-drop { background: rgba(0,0,0,0.35); }

/* ============================================================
   Bottom sheet
   ============================================================ */
.sheet { position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.24s ease; }
.sheet.is-open .sheet-scrim { opacity: 1; }
.sheet-panel {
  position: relative; background: var(--surface); border-top: 1px solid var(--border-strong);
  border-radius: 24px 24px 0 0; max-height: 82%; display: flex; flex-direction: column;
  box-shadow: 0 -20px 50px rgba(0,0,0,0.4); transform: translateY(100%); transition: transform 0.26s cubic-bezier(0.22,1,0.36,1);
  padding-bottom: var(--safe-bottom);
}
.sheet.is-open .sheet-panel { transform: translateY(0); }
.sheet-grip-wrap { display: flex; justify-content: center; padding: 10px 0 2px; }
.sheet-grip { width: 40px; height: 4px; border-radius: 99px; background: var(--border-strong); }
.sheet-head { padding: 8px 18px 12px; }
.sheet-title { font-size: 17px; font-weight: 600; }
.sheet-close { width: 38px; padding: 0; }
.sheet-body { overflow-y: auto; padding: 0 18px 18px; flex: 1; }
.sheet-footer { padding: 12px 18px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--border); }

/* ============================================================
   Toast
   ============================================================ */
.toast-stack { position: absolute; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); z-index: 40; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--r);
  padding: 13px 15px; font-size: 13.5px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(14px); transition: opacity 0.22s ease, transform 0.22s ease; pointer-events: auto;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast-ic { color: var(--accent); display: flex; }
.toast--error .toast-ic { color: var(--neg); }
.toast--warn .toast-ic { color: var(--warn); }

/* ============================================================
   Onboarding overlay
   ============================================================ */
.onboarding-overlay { position: absolute; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,0.55); }
.onboarding-card { max-width: 420px; width: 100%; margin: 0; }
.onboarding-card h2 { margin: 0 0 8px; font-size: 20px; }
.onboarding-steps { margin: 12px 0 16px; padding-left: 20px; color: var(--text-muted); font-size: 13.5px; line-height: 1.6; }

/* ============================================================
   Details (results)
   ============================================================ */
.results-details summary { font-size: 13px; color: var(--accent); cursor: pointer; padding: 8px 0; }

/* ============================================================
   Small-phone guard (≤360px): trim horizontal padding + headline so nothing
   clips on a 320px viewport. Tab labels can get tight — keep them readable.
   ============================================================ */
@media (max-width: 360px) {
  .screen { padding-left: 12px; padding-right: 12px; }
  .app-header { padding-left: 14px; padding-right: 14px; }
  .steps { padding-left: 12px; padding-right: 12px; }
  .runbar { padding-left: 12px; padding-right: 12px; }
  .app-header h1 { font-size: 23px; }
  .hero-value { font-size: 32px; }
  .tab { font-size: 10px; }
}

/* ============================================================
   Phone (≤480px): a 2-up field row (.row / twoUp) crushes each input below a
   usable width — most visibly the account Position X/Y sliders, where the half-
   width columns leave no room. Stack the pair vertically across all phone
   widths (incl. iPhone 390/393px); tablet ≥768px keeps the two columns.
   .row is only used for paired fields + the Position X/Y sliders — both read
   fine stacked full-width.
   ============================================================ */
@media (max-width: 480px) {
  .row { flex-direction: column; gap: 0; }
  .row > * { margin-bottom: 16px; }
  .row > *:last-child { margin-bottom: 0; }
}

/* ============================================================
   TABLET (≥768px) — the design is mobile-first; from tablet up we centre the
   shell, give it a comfortable max-width and start using the extra horizontal
   room. The wizard/results/account/admin content (a vertical stack of .card
   sections inside .screen) flows into a responsive multi-column masonry-ish
   grid so the narrow mobile column never stretches edge-to-edge.
   ============================================================ */
@media (min-width: 768px) {
  .app {
    max-width: 720px;
    margin: 0 auto; left: 50%; transform: translateX(-50%); right: auto; width: 100%;
    border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  }
  .toast-stack { max-width: 420px; left: auto; right: 24px; transform: none; width: auto; min-width: 280px; }

  .app-header { padding-left: 28px; padding-right: 28px; }
  .steps { padding-left: 28px; padding-right: 28px; }
  .runbar { padding-left: 28px; padding-right: 28px; }
  .screen { padding-left: 28px; padding-right: 28px; }

  /* Two-column content grid. Direct children of .screen flow into two balanced
     columns; full-width items (section-labels, the run progress card and the
     equity chart) span both. align-items:start keeps cards from stretching to
     match the tallest sibling. */
  .screen {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
    align-content: start;
    align-items: start;
  }
  .screen > .section-label,
  .screen > .empty,
  .screen > .hero-card,
  .screen > .progress-card,
  .screen > #runStatus,
  .screen > .full-span { grid-column: 1 / -1; }

  /* The wizard re-renders raw cards (no section wrapper) into .screen; keep the
     equity-curve card and the data-source card full width for readability. */
  .screen > .card.preview-card { grid-column: 1 / -1; }
}

/* ============================================================
   DESKTOP (≥1280px) — wider centred container, three content columns for the
   dense screens, mouse-friendly hit areas. The fixed shell stays a single
   app surface but no longer feels like a phone stranded on a monitor.
   ============================================================ */
@media (min-width: 1280px) {
  .app { max-width: 1080px; }
  .app-header { padding-left: 40px; padding-right: 40px; }
  .steps { padding-left: 40px; padding-right: 40px; max-width: 760px; }
  .runbar { padding-left: 40px; padding-right: 40px; }
  .screen { padding-left: 40px; padding-right: 40px; gap: 0 22px; }

  /* Three columns on desktop for the card-heavy screens. */
  .screen { grid-template-columns: repeat(3, 1fr); }

  /* Hero + equity chart read best spanning two of three columns, leaving the
     risk verdict / chips beside them rather than a lone wide banner. */
  .screen > .hero-card { grid-column: span 2; }
  .screen > .risk-summary { grid-column: span 1; align-self: stretch; }
  .screen > .card.preview-card { grid-column: 1 / -1; }

  /* The runbar should not stretch a single CTA across the whole width. */
  .runbar { max-width: 760px; left: 50%; transform: translateX(-50%); right: auto; width: 100%; }

  /* Bigger, mouse-friendly tap targets relax to comfortable sizes; hover is
     already wired. Center the tab-bar items so they don't float far apart. */
  .tabbar { max-width: 760px; margin: 0 auto; width: 100%; }
}

/* ============================================================
   WIDE DESKTOP (≥1600px) — cap so line lengths stay readable.
   ============================================================ */
@media (min-width: 1600px) {
  .app { max-width: 1200px; }
}

/* ============================================================
   Sheets / modals on wider screens — a full-width bottom sheet looks stranded
   on a tablet/desktop shell, so centre the panel and cap its width. Still
   slides up from the bottom (the design's signature motion).
   ============================================================ */
@media (min-width: 768px) {
  .sheet { justify-content: flex-end; align-items: center; }
  .sheet-panel {
    width: 100%; max-width: 560px; margin: 0 auto;
    border-radius: 24px 24px 0 0;
  }
}

/* ============================================================
   Overflow / wrapping safety — long values must wrap instead of forcing a
   horizontal scroll. KV rows keep numbers on the right but allow them to wrap
   on a tiny viewport; the key label can shrink so the value never clips.
   ============================================================ */
.kv { gap: 12px; align-items: baseline; }
.kv .k { min-width: 0; overflow-wrap: anywhere; }
.kv .v { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-title, .lr-sub, .card-title { overflow-wrap: anywhere; }
.app-header h1 { overflow-wrap: anywhere; }
/* Native multi-line symbol list must not push the layout wider than its column. */
select[size] { max-width: 100%; }

/* ============================================================
   Touch targets — guarantee the small icon-only buttons clear the 44px
   recommended minimum on touch (pointer:coarse) without bloating mouse UIs.
   ============================================================ */
@media (pointer: coarse) {
  .btn--sm { min-height: 40px; }
  .sheet-close, .header-pill { min-height: 40px; }
  .accent-dot { width: 38px; height: 38px; }
  .tab { padding-top: 8px; padding-bottom: 8px; }
}

/* ============================================================
   Reduced motion — content is always visible at rest.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .toast { opacity: 1; transform: none; }
  .sheet-panel { transition: none; }
  .progress-fill, .bar-col-bar { transition: none; }
  .term-spinner-dot { animation: none !important; }
}

/* ============================================================
   Terminal tab — multi-exchange balance dashboard.
   ============================================================ */
.terminal-intro-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin: 2px 0 4px;
}
.link-btn {
  appearance: none; background: none; border: none; cursor: pointer; padding: 0;
  color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { filter: brightness(1.1); }

/* Onboarding / risk sheet body */
.terminal-risk-box {
  margin-top: 14px; padding: 14px; border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--warn) 9%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
}
.terminal-risk-title {
  display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px;
  color: var(--warn); margin-bottom: 8px;
}
.terminal-risk-title svg { width: 16px; height: 16px; }
.terminal-risk-list {
  margin: 0; padding-left: 20px; color: var(--text); font-size: 13px; line-height: 1.6;
}
.terminal-risk-list li { margin-bottom: 4px; }

/* Add-key form: read-only acknowledgement + passphrase reveal */
.terminal-ack-row {
  display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 16px;
  font-size: 13px; color: var(--text-muted); line-height: 1.4; cursor: pointer;
}
.terminal-ack-box {
  width: 18px; height: 18px; margin-top: 1px; flex: none; accent-color: var(--accent);
}

/* Balances header row (section-label + refresh button) */
.terminal-balances-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Total balance card */
.terminal-total-card { text-align: center; padding: 20px 16px; }
.term-total-label { font-size: 11px; letter-spacing: 0.08em; }
.term-total-value { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 2px; font-family: var(--fm); }
.term-total-meta { font-size: 12px; }

/* Empty state */
.terminal-empty { text-align: center; padding: 26px 18px; }
.terminal-empty-ic { color: var(--text-faint); margin-bottom: 8px; }
.terminal-empty-ic svg { width: 26px; height: 26px; }
.terminal-empty-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }

/* Account card */
.term-acct { margin-bottom: 14px; }
.term-acct-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.term-acct-id { min-width: 0; flex: 1; }
.term-acct-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.term-acct-exchange { font-weight: 600; font-size: 15px; }
.term-acct-label { font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }
.term-acct-sub { font-size: 12px; margin-top: 3px; }
.term-acct-actions { display: flex; gap: 6px; flex: none; }
.term-acct-actions .btn--sm { width: 38px; padding: 0; }

.term-acct-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 2px; }
.term-perm { height: 24px; font-size: 11px; padding: 0 9px; }
.term-perm svg { width: 12px; height: 12px; }

.term-acct-invalid {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px;
  border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.4;
  background: color-mix(in srgb, var(--neg) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--neg) 34%, transparent); color: var(--text);
}
.term-acct-invalid svg { width: 15px; height: 15px; color: var(--neg); flex: none; }

.term-acct-body { margin-top: 12px; }
.term-balances-muted { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.term-balances-error {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--warn); line-height: 1.4;
}
.term-balances-error svg { width: 15px; height: 15px; flex: none; }
.term-balances-error.sm { font-size: 12px; }

/* Wallet rollup */
.term-wallets { display: flex; flex-direction: column; gap: 12px; }
.term-wallet { border-top: 1px solid var(--border); padding-top: 10px; }
.term-wallet:first-child { border-top: none; padding-top: 0; }
.term-wallet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.term-wallet-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.term-wallet-total { font-size: 13px; font-weight: 600; }
.term-wallet-empty { font-size: 12px; }

.term-assets { display: flex; flex-direction: column; gap: 2px; }
.term-asset { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 4px 0; }
.term-asset-sym { font-size: 13px; font-weight: 600; }
.term-asset-amounts { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.term-asset-total { font-size: 13px; }
.term-asset-locked { font-size: 10.5px; }
.term-asset-usd { font-size: 13px; min-width: 72px; text-align: right; color: var(--text-muted); }

.term-acct-total {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px;
}
.term-acct-total-val { font-weight: 700; font-size: 15px; }

.term-spinner-dot {
  width: 8px; height: 8px; border-radius: 999px; background: var(--accent);
  display: inline-block; animation: term-pulse 1s ease-in-out infinite;
}
@keyframes term-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

/* Unavailable wallet (margin/funding not present) — neutral, never alarming. */
.term-wallet--na { opacity: 0.72; }
.term-wallet-na { font-size: 11.5px; font-style: italic; }

/* ── Aggregate wallets (Bitget bots / earn) ── */
.term-wallet--agg .term-agg-total {
  font-size: 22px; font-weight: 700; line-height: 1.1; margin: 2px 0 2px;
}
.term-agg-note { font-size: 11px; }

/* Bots semi-manual Margin/Profit split */
.term-bots-margin {
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.term-bots-split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.term-bots-split-item {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 11px;
}
.term-bots-split-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.term-bots-split-val { font-size: 16px; font-weight: 700; }
.term-bots-split-val.is-pos { color: var(--pos); }
.term-bots-split-val.is-neg { color: var(--neg); }
.term-bots-warn {
  display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--warn);
  line-height: 1.35;
}
.term-bots-warn svg { width: 12px; height: 12px; flex: none; }
.term-bots-hint { font-size: 12.5px; line-height: 1.4; }

.term-bots-margin-form { display: flex; flex-direction: column; gap: 6px; }
.term-bots-margin-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.term-bots-margin-row { display: flex; align-items: center; gap: 8px; }
.term-bots-margin-affix { flex: 1; min-width: 0; }
.term-bots-margin-input { width: 100%; }
.term-bots-margin-row .btn { flex: none; }
.term-bots-foot { font-size: 10.5px; line-height: 1.35; }

@media (max-width: 480px) {
  .term-bots-split { grid-template-columns: 1fr; }
  .term-bots-margin-row { flex-wrap: wrap; }
  .term-bots-margin-affix { flex-basis: 100%; }
}

/* ── Phase 2: section tabs (Balances | Positions | Bots) ── */
.term-tabs {
  display: flex; gap: 4px; margin: 14px 0 4px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
}
.term-tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  appearance: none; cursor: pointer; border: none; background: none;
  padding: 7px 6px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: var(--text-muted); white-space: nowrap; transition: background 0.15s, color 0.15s;
}
.term-tab svg { width: 14px; height: 14px; }
.term-tab:hover { color: var(--text); }
.term-tab.is-active { background: var(--accent); color: var(--accent-contrast); }
.term-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Mini empty/soft-error blocks reused by Positions / Bots / Trades */
.term-empty-mini { padding: 14px 4px; text-align: center; font-size: 13px; }
.term-soft-error {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; line-height: 1.4;
  padding: 4px 0; color: var(--text-muted);
}
.term-soft-error svg { width: 14px; height: 14px; flex: none; }

/* Side chip (LONG/SHORT) + coloured PnL */
.term-side {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; padding: 2px 6px;
  border-radius: 5px; line-height: 1;
}
.term-side--long { background: color-mix(in srgb, var(--pos) 18%, transparent); color: var(--pos); }
.term-side--short { background: color-mix(in srgb, var(--neg) 18%, transparent); color: var(--neg); }
.term-pnl { font-weight: 700; font-size: 14px; display: inline-flex; align-items: baseline; gap: 5px; }
.term-pnl .term-pnl-pct { font-size: 11px; font-weight: 600; opacity: 0.85; }
.term-pnl.is-pos, .is-pos { color: var(--pos); }
.term-pnl.is-neg, .is-neg { color: var(--neg); }
.term-pnl.is-flat, .is-flat { color: var(--text-muted); }

/* Positions list */
.term-pos-list { display: flex; flex-direction: column; gap: 10px; }
.term-pos, .term-bot {
  width: 100%; text-align: left; appearance: none; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px; transition: border-color 0.15s, background 0.15s;
  display: flex; flex-direction: column; gap: 10px;
}
.term-pos:hover, .term-bot:hover { border-color: var(--border-strong); }
.term-pos:focus-visible, .term-bot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.term-pos-top, .term-bot-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.term-pos-symwrap, .term-bot-symwrap { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.term-pos-sym, .term-bot-sym { font-size: 14px; font-weight: 700; }
.term-pos-lev { font-size: 11px; }

.term-pos-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px;
}
.term-pos-stat, .term-bot-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.term-pos-stat-k, .term-bot-stat-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.term-pos-stat-v, .term-bot-stat-v { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.term-pos-liq { color: var(--warn); }
.term-pos-cta, .term-bot-cta {
  display: flex; align-items: center; gap: 5px; font-size: 11px; padding-top: 2px;
  border-top: 1px dashed var(--border);
}
.term-pos-cta svg, .term-bot-cta svg { width: 12px; height: 12px; }

/* Bots list */
.term-bot-list { display: flex; flex-direction: column; gap: 12px; }
.term-bot-openpill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px;
}
.term-bot-openpill .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--accent); }
.term-bot-flatpill { font-size: 11px; }
.term-bot-open, .term-bot-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px;
  padding: 10px; border-radius: var(--r-sm); background: var(--surface);
  border: 1px solid var(--border);
}
.term-bot-summary { background: none; border: none; padding: 0 2px; }
.term-bot-ambiguous {
  display: flex; align-items: center; gap: 6px; font-size: 11.5px; line-height: 1.4;
}
.term-bot-ambiguous svg { width: 12px; height: 12px; flex: none; }

/* Trades sheet */
.term-trades-host { margin-top: 4px; }
.term-trades { display: flex; flex-direction: column; }
.term-trade {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-top: 1px solid var(--border);
}
.term-trade:first-child { border-top: none; }
.term-trade-l { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.term-trade-side { display: flex; align-items: center; gap: 6px; }
.term-trade-sidetag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 5px; line-height: 1;
}
.term-trade-sidetag.is-buy { background: color-mix(in srgb, var(--pos) 18%, transparent); color: var(--pos); }
.term-trade-sidetag.is-sell { background: color-mix(in srgb, var(--neg) 18%, transparent); color: var(--neg); }
.term-trade-oc { font-size: 11px; text-transform: capitalize; }
.term-trade-when { font-size: 11px; }
.term-trade-r { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.term-trade-px { font-size: 13px; font-weight: 600; }
.term-trade-qty { font-size: 11px; font-weight: 400; }
.term-trade-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; }

@media (max-width: 380px) {
  .term-asset-usd { min-width: 60px; }
  .term-total-value { font-size: 30px; }
  .term-tab { font-size: 11.5px; padding: 7px 4px; }
  .term-pos-grid, .term-bot-open, .term-bot-summary { grid-template-columns: repeat(2, 1fr); }
}
