:root {
      /* ════════════════════════════════════════════════
         AlgoSync design system — Midnight (default dark)
         Electric-indigo accent · token-driven, theme-able.
         New mockup tokens are primary; legacy token names
         are aliased below so existing component CSS keeps
         working across the page-by-page migration.
         ════════════════════════════════════════════════ */

      /* Surfaces */
      --bg:           #0B0D14;
      --bg-mid:       #0E1119;
      --surface:      #131722;
      --surface-hi:   #1A2033;
      --surface-hov:  #1F263A;

      /* Borders / dividers */
      --border:       rgba(255,255,255,0.068);
      --border-str:   rgba(255,255,255,0.14);
      --divider:      rgba(255,255,255,0.048);

      /* Text */
      --text:         #EEF0FA;
      --text-2:       #8A94AA;
      --text-3:       #727C93;

      /* Accent — electric indigo */
      --accent:       #5170FF;
      --accent-dim:   rgba(81,112,255,0.14);
      --accent-glow:  rgba(81,112,255,0.32);

      /* Status — gain / loss / amber */
      --gain:         #34D399;
      --gain-dim:     rgba(52,211,153,0.13);
      --loss:         #F87171;
      --loss-dim:     rgba(248,113,113,0.13);
      --amber:        #FBBF24;
      --amber-dim:    rgba(251,191,36,0.13);

      /* Shadows + radius */
      --sh-sm:        0 1px 4px rgba(0,0,0,0.5);
      --sh-md:        0 4px 24px rgba(0,0,0,0.6);
      --sh-pop:       0 12px 48px rgba(0,0,0,0.7);
      --r:            10px;

      /* ── Typography tokens (Inter UI + DM Mono numerics) ── */
      --font-body:    'Inter', system-ui, sans-serif;
      --font-data:    'DM Mono', ui-monospace, monospace;
      --font-head:    'Inter', system-ui, sans-serif;
      --head-style:   normal;
      --head-track:   -0.025em;
      --head-wt:      600;

      /* ── Canonical type scale (see DESIGN.md §2) ──
         Snap component font-sizes to these; don't invent literals. */
      --fs-display:   34px;
      --fs-h1:        22px;
      --fs-lg:        20px;
      --fs-h2:        18px;
      --fs-md:        16px;
      --fs-h3:        15px;
      --fs-body:      14px;
      --fs-sm:        13px;
      --fs-label:     12px;
      --fs-caption:   11px;
      --fs-micro:     10px;
      --fs-num:       14px;

      /* ════════ Legacy aliases → new system ════════ */
      --bg-raised:    var(--surface);
      --bg-hover:     var(--surface-hov);
      --bg-glass:     rgba(19,23,34,0.72);
      --line:         var(--border);
      --line-strong:  var(--border-str);
      --line-accent:  var(--accent-glow);
      --accent-strong:#6C86FF;
      --accent-line:  var(--accent-glow);
      --gold:         #E8C97A;
      --gold-dim:     rgba(232,201,122,0.14);
      --gold-glow:    rgba(232,201,122,0.08);
      --green:        var(--gain);
      --green-bg:     var(--gain-dim);
      --green-line:   color-mix(in srgb, var(--gain) 30%, transparent);
      --red:          var(--loss);
      --red-bg:       var(--loss-dim);
      --red-line:     color-mix(in srgb, var(--loss) 30%, transparent);
      --amber-bg:     var(--amber-dim);
      --amber-line:   color-mix(in srgb, var(--amber) 30%, transparent);
      --blue:         var(--accent);
      --blue-bg:      var(--accent-dim);
      --blue-line:    var(--accent-glow);
      --grey:         var(--text-3);
      --grey-bg:      var(--surface-hi);
      --grey-line:    var(--border-str);
      --topbar-bg:    rgba(11,13,20,0.90);
      --radius-2xl:   16px;
      --radius-xl:    13px;
      --radius-lg:    var(--r);
      --radius-btn:   8px;
      --radius-md:    9px;
      --radius-sm:    7px;
      --space-1: 4px;  --space-2: 8px;  --space-3: 12px;
      --space-4: 16px; --space-5: 22px; --space-6: 32px;
      --shadow-sm:    var(--sh-sm);
      --shadow-md:    var(--sh-md);
      --shadow-card:  var(--sh-md);
      --shadow-pop:   var(--sh-pop);
      --shadow-accent:0 10px 30px var(--accent-glow);
      --edge-light:   rgba(255,255,255,0.05);
      --sidebar-w:    260px;
      --font:         var(--font-body);
      --mono:         var(--font-data);
      --font-display: var(--font-head);
      --display-spacing: var(--head-track);
    }

    /* ════════ Single font system — Inter (UI) + DM Mono (numbers).
       Font switching removed for consistency (see DESIGN.md §2). ════════ */

    /* ── Light mode (clean — cobalt blue on white) ── */
    :root[data-theme="light"] {
      --bg: #ECF0F8; --bg-mid: #E3E9F4;
      --surface: #FFFFFF; --surface-hi: #F3F6FC; --surface-hov: #E8EDF7;
      --border: rgba(0,0,0,0.085); --border-str: rgba(0,0,0,0.18); --divider: rgba(0,0,0,0.055);
      --accent: #2563EB; --accent-dim: rgba(37,99,235,0.10); --accent-glow: rgba(37,99,235,0.22); --accent-strong: #1D4FD8;
      --text: #090B14; --text-2: #4A5368; --text-3: #8A96AA;
      --gain: #16A34A; --gain-dim: rgba(22,163,74,0.11);
      --loss: #DC2626; --loss-dim: rgba(220,38,38,0.11);
      --amber: #D97706; --amber-dim: rgba(217,119,6,0.11);
      --sh-sm: 0 1px 4px rgba(0,0,0,0.07); --sh-md: 0 4px 16px rgba(0,0,0,0.09); --sh-pop: 0 8px 32px rgba(0,0,0,0.14);
      --bg-glass: rgba(255,255,255,0.72); --topbar-bg: rgba(236,240,248,0.92);
      --gold: #B08524; --edge-light: rgba(255,255,255,0.6);
    }

    /* ════════════════════════════════════════════════
       THEMES — two modes only (see DESIGN.md).
       :root = Dark (Midnight navy).  [data-theme="light"] = Light.
       Ember / Tidal / Parchment removed for consistency.
       ════════════════════════════════════════════════ */


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

    body {
      font-family: var(--font);
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      overflow-x: hidden;
      font-size: var(--fs-body);
      line-height: 1.5;
      -webkit-font-smoothing: antialiased;
    }

    button, input, select { font: inherit; }
    button { border: 0; cursor: pointer; background: transparent; color: inherit; }
    input, select { outline: none; }

    /* ─── Layout ─────────────────────────────────────── */
    .app {
      display: grid;
      grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
      min-height: 100vh;
    }
    body.onboarding-active { overflow: hidden; }

    /* ── First-visit onboarding overlay ── */
    /* CRITICAL: display:flex would override the [hidden] attribute — this rule makes
       hide/show actually work (the "stuck on Connected…" bug). */
    .onboard-overlay[hidden] { display: none !important; }
    .onboard-overlay {
      position: fixed;
      inset: 0;
      z-index: 400;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      background: color-mix(in srgb, var(--bg, #0b0f1c) 76%, transparent);
      backdrop-filter: blur(5px);
      -webkit-backdrop-filter: blur(5px);
      overflow-y: auto;
    }
    .onboard-card {
      width: 100%;
      max-width: 560px;
      background: var(--bg-mid);
      border: 1px solid var(--line);
      border-radius: 22px;
      padding: 34px 34px 26px;
      box-shadow: 0 24px 80px rgba(0,0,0,.35);
    }
    .onboard-brand { display: flex; align-items: center; gap: 12px; }
    .onboard-brand img { width: 42px; height: 42px; border-radius: 11px; }
    .onboard-brand-name { font-size: 19px; font-weight: 800; letter-spacing: .3px; }
    .onboard-brand-sub { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .16em; }
    .onboard-progress { display: flex; align-items: center; margin: 25px 0 22px; }
    .onboard-progress span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 10.5px; font-weight: 700; white-space: nowrap; }
    .onboard-progress span b { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--line-strong, var(--line)); border-radius: 50%; font-size: 10px; }
    .onboard-progress span.active { color: var(--accent, #5b8dff); }
    .onboard-progress span.active b { border-color: var(--accent, #5b8dff); background: rgba(91,141,255,.14); }
    .onboard-progress span.done { color: var(--green, #2ec478); }
    .onboard-progress span.done b { color: #07130d; border-color: var(--green, #2ec478); background: var(--green, #2ec478); }
    .onboard-progress i { flex: 1; height: 1px; margin: 0 8px; background: var(--line); }
    .onboard-step-kicker { color: var(--accent, #5b8dff); font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
    .onboard-title { margin: 7px 0 10px; font-size: 27px; line-height: 1.25; font-weight: 800; }
    .onboard-lead { margin: 0 0 14px; color: var(--text-2); font-size: 14px; line-height: 1.6; }
    .onboard-detail { margin: 0 0 22px; color: var(--text-3); font-size: 12.5px; line-height: 1.55; }
    .onboard-detail:empty { display: none; }
    .onboard-recommended { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
    .onboard-recommended span { padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(120,132,164,.06); }
    .onboard-recommended b { display: block; color: var(--text); font-size: 13px; }
    .onboard-recommended small { display: block; margin-top: 2px; color: var(--text-3); font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; }
    .onboard-capital { display: grid; grid-template-columns: 1fr 140px; align-items: center; gap: 12px; margin-top: 13px; }
    .onboard-capital label { color: var(--text-2); font-size: 12px; line-height: 1.4; }
    .onboard-capital input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: var(--bg); font-family: var(--font-mono); }
    .onboard-cta { width: 100%; padding: 14px; font-size: 15px; border-radius: 13px; }
    .onboard-card .onboard-cta.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff !important; }
    .onboard-settings-summary { margin-top: 13px; text-align: left; }
    .onboard-settings-summary summary { color: var(--text-2); font-weight: 700; cursor: pointer; }
    .onboard-deposit-steps { display: grid; gap: 9px; }
    .onboard-deposit-steps span { display: grid; grid-template-columns: 28px 1fr; gap: 9px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(120,132,164,.06); }
    .onboard-deposit-steps b { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 999px; background: var(--accent-dim); color: var(--accent); }
    .onboard-deposit-steps em { color: var(--text-2); font-style: normal; line-height: 1.45; }
    .onboard-status {
      margin: 0 0 16px;
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 14px;
      font-size: 13px;
      line-height: 1.6;
      color: var(--text-2);
      background: rgba(120,132,164,.06);
    }
    .onboard-status a { color: var(--accent, #5b8dff); font-weight: 700; }
    .onboard-status .mono { font-family: var(--font-mono); font-size: 12px; }
    .onboard-options { display: grid; gap: 12px; }
    .onboard-option {
      padding: 14px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: var(--bg-mid);
    }
    .onboard-option.recommended { border-color: rgba(91,141,255,.42); background: rgba(91,141,255,.07); }
    .onboard-option-head { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
    .onboard-option-number {
      display: grid;
      place-items: center;
      width: 23px;
      height: 23px;
      flex: 0 0 23px;
      border-radius: 50%;
      color: var(--accent, #5b8dff);
      background: rgba(91,141,255,.14);
      font-size: 11px;
      font-weight: 800;
    }
    .onboard-option-title { color: var(--text); font-size: 13px; }
    .onboard-option p { margin: 0 0 10px; color: var(--text-3); font-size: 12px; line-height: 1.5; }
    .onboard-code-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 38px;
      gap: 8px;
      align-items: center;
      margin-bottom: 10px;
    }
    .onboard-code-row code {
      min-width: 0;
      overflow-x: auto;
      padding: 9px 11px;
      border: 1px dashed var(--line-strong, var(--line));
      border-radius: 9px;
      color: var(--text);
      background: rgba(120,132,164,.08);
      font-family: var(--font-mono);
      font-size: 11px;
      white-space: nowrap;
    }
    .onboard-copy {
      display: grid;
      place-items: center;
      width: 38px;
      height: 38px;
      padding: 0;
      border: 1px solid var(--line-strong, var(--line));
      border-radius: 9px;
      background: rgba(120,132,164,.08);
      color: var(--text-2);
      cursor: pointer;
    }
    .onboard-copy:hover { border-color: var(--accent, #5b8dff); color: var(--accent, #5b8dff); }
    .onboard-copy.copied { border-color: var(--green, #2ec478); color: var(--green, #2ec478); background: rgba(46,196,120,.10); }
    .onboard-copy svg { width: 17px; height: 17px; }
    .onboard-option-link { display: inline-flex; align-items: center; min-height: 34px; }
    .onboard-option-cta {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      min-height: 42px;
      border-color: var(--accent, #2563eb) !important;
      background: var(--accent, #2563eb) !important;
      color: #fff !important;
      text-decoration: none;
    }
    .onboard-option-cta:hover {
      border-color: var(--accent-strong, #1d4ed8) !important;
      background: var(--accent-strong, #1d4ed8) !important;
      color: #fff !important;
    }
    .onboard-auto-note { margin: 12px 2px 0; color: var(--text-3); font-size: 11.5px; text-align: center; }
    .onboard-skip[hidden] { display: none !important; }
    .onboard-skip {
      display: block;
      margin: 14px auto 0;
      background: none;
      border: 0;
      color: var(--text-3);
      font-size: 12px;
      cursor: pointer;
      text-decoration: underline;
      text-underline-offset: 3px;
    }
    .onboard-skip:hover { color: var(--text-2); }
    .onboard-install {
      margin-top: 16px;
      padding-top: 14px;
      border-top: 1px dashed var(--line);
      color: var(--text-3);
      font-size: 11.5px;
      line-height: 1.55;
      text-align: center;
    }
    .onboard-coach[hidden] { display: none !important; }
    .onboard-coach {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 18px;
      margin: 14px 24px 0;
      padding: 13px 16px;
      border: 1px solid rgba(91,141,255,.35);
      border-radius: 14px;
      background: linear-gradient(100deg, rgba(91,141,255,.13), rgba(46,196,120,.06));
    }
    .onboard-coach > div { min-width: 0; }
    .onboard-coach b { display: block; font-size: 13px; }
    .onboard-coach span { display: block; margin-top: 2px; color: var(--text-2); font-size: 11.5px; }
    .onboard-coach .btn { flex: 0 0 auto; padding: 9px 13px; white-space: nowrap; }
    @media (max-width: 520px) {
      .onboard-card { padding: 22px 18px 19px; }
      .onboard-title { font-size: 22px; }
      .onboard-progress { margin: 21px 0 19px; }
      .onboard-progress span { gap: 4px; font-size: 9px; }
      .onboard-progress span b { width: 19px; height: 19px; }
      .onboard-progress i { margin: 0 5px; }
      .onboard-recommended { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .onboard-capital { grid-template-columns: 1fr; gap: 7px; }
      .onboard-coach { align-items: stretch; flex-direction: column; gap: 10px; margin: 10px 12px 0; }
      .onboard-coach .btn { width: 100%; }
    }

    /* ─── Sidebar ────────────────────────────────────── */
    .sidebar {
      position: sticky;
      top: 0;
      height: 100vh;
      display: flex;
      flex-direction: column;
      background: var(--bg-mid);
      border-right: 1px solid var(--line);
      overflow-y: auto;
      overflow-x: hidden;
    }

    /* ── Collapsible sidebar (2026-07-11): arrow toggles an icon-only rail; the
       choice persists in localStorage. Desktop only — mobile uses the bottom dock. */
    .nav-collapse-btn {
      position: absolute;
      top: 12px;
      right: 10px;
      width: 26px;
      height: 26px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--bg-mid);
      color: var(--text-3);
      cursor: pointer;
      z-index: 3;
      transition: color .15s ease, border-color .15s ease;
    }
    .nav-collapse-btn:hover { color: var(--text); border-color: var(--line-strong, var(--line)); }
    .nav-collapse-btn svg { width: 14px; height: 14px; transition: transform .2s ease; }
    body.nav-collapsed .nav-collapse-btn svg { transform: rotate(180deg); }
    body.nav-collapsed .app { grid-template-columns: 76px minmax(0, 1fr); }
    body.nav-collapsed .brand { padding: 46px 0 16px; }
    body.nav-collapsed .brand-wordmark { justify-content: center; }
    body.nav-collapsed .brand-name,
    body.nav-collapsed .brand-sub,
    body.nav-collapsed .nav-section-label,
    body.nav-collapsed .nav .nav-btn span { display: none; }
    body.nav-collapsed .nav .nav-btn { justify-content: center; gap: 0; padding: 11px 0; }
    @media (max-width: 1023px) { .nav-collapse-btn { display: none; } }

    .brand {
      padding: 28px 20px 22px;
      border-bottom: 1px solid var(--line);
    }

    .brand-wordmark {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .brand-icon {
      width: 32px;
      height: 32px;
      border-radius: 8px;
      background: #050505;
      border: 1px solid rgba(222,207,153,0.30);
      display: grid;
      place-items: center;
      color: #decf99;
      overflow: hidden;
      padding: 2px;
    }

    .brand-mark {
      width: 100%;
      height: 100%;
      display: block;
      object-fit: contain;
      border-radius: inherit;
    }

    .topbar-btn .brand-mark {
      width: 16px;
      height: 16px;
      flex: 0 0 16px;
      border-radius: 4px;
    }

    .brand-name {
      font-family: var(--font-display);
      font-size: var(--fs-md);
      font-weight: 500;
      letter-spacing: -0.02em;
      color: var(--text);
    }

    .brand-sub {
      margin-top: 6px;
      font-size: var(--fs-caption);
      color: var(--text-3);
      letter-spacing: 0.06em;
      text-transform: uppercase;
      font-weight: 400;
    }

    .nav {
      padding: 16px 12px;
      display: flex;
      flex-direction: column;
      gap: 2px;
      flex: 1;
    }

    .nav-section-label {
      font-size: var(--fs-micro);
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--text-3);
      font-weight: 500;
      padding: 14px 10px 6px;
    }

    .nav-btn {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 9px 10px;
      border-radius: var(--radius-md);
      color: var(--text-2);
      font-size: var(--fs-sm);
      font-weight: 400;
      transition: background 0.15s, color 0.15s;
      white-space: nowrap;
    }

    .nav-btn:hover { background: var(--bg-hover); color: var(--text); }

    .nav-btn.active {
      background: var(--accent-dim);
      color: var(--accent);
      border: 1px solid var(--accent-line);
    }
    .nav-btn.active .nav-icon { opacity: 1; }

    .nav-icon {
      width: 16px;
      height: 16px;
      flex: 0 0 16px;
      stroke: currentColor;
      stroke-width: 1.75;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
      opacity: 0.8;
    }

    .sidebar-footer {
      padding: 16px;
      border-top: 1px solid var(--line);
      margin-top: auto;
    }

    .fleet-pill {
      background: var(--bg-raised);
      border: 1px solid var(--line);
      border-radius: var(--radius-lg);
      padding: 14px 16px;
    }

    .fleet-pill .label {
      font-size: var(--fs-micro);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: var(--text-3);
    }

    .fleet-pill .value {
      font-size: var(--fs-h1);
      font-weight: 500;
      letter-spacing: -0.04em;
      color: var(--text);
      margin-top: 4px;
    }

    .fleet-pill .note {
      font-size: var(--fs-caption);
      color: var(--text-3);
      margin-top: 5px;
      line-height: 1.5;
    }

    /* ─── Main ───────────────────────────────────────── */
    .main {
      min-width: 0;
      display: flex;
      flex-direction: column;
    }

    .topbar {
      position: sticky;
      top: 0;
      z-index: 20;
      padding: 0 28px;
      height: 60px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      background: var(--topbar-bg);
      backdrop-filter: blur(16px);
      border-bottom: 1px solid var(--line);
    }

    .topbar-left {
      display: flex;
      align-items: center;
      gap: 11px;
      min-width: 0;
    }

    .page-glyph {
      flex: 0 0 32px;
      width: 32px;
      height: 32px;
      display: grid;
      place-items: center;
      border-radius: 10px;
      background: var(--accent-dim);
      border: 1px solid var(--accent-line);
      color: var(--accent);
      box-shadow: inset 0 1px 0 var(--edge-light);
    }
    .page-glyph .nav-icon { width: 16px; height: 16px; opacity: 1; }

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

    .topbar-left h2 {
      font-family: var(--font-display);
      font-size: var(--fs-md);
      font-weight: 500;
      letter-spacing: -0.02em;
      line-height: 1.15;
      color: var(--text);
    }

    .topbar-left p {
      font-size: var(--fs-label);
      color: var(--text-3);
      line-height: 1.2;
    }

    .topbar-right {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .status-dot {
      display: flex;
      align-items: center;
      gap: 7px;
      padding: 6px 12px;
      border-radius: 999px;
      border: 1px solid var(--green-line);
      background: var(--green-bg);
      font-size: var(--fs-label);
      color: var(--green);
    }

    .pulse {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--green);
      position: relative;
    }

    .pulse::after {
      content: '';
      position: absolute;
      inset: -3px;
      border-radius: 50%;
      border: 1px solid var(--green);
      animation: pulseRing 2s ease infinite;
    }

    @keyframes pulseRing {
      0%   { opacity: 0.6; transform: scale(0.8); }
      60%  { opacity: 0; transform: scale(1.8); }
      100% { opacity: 0; transform: scale(1.8); }
    }

    .topbar-btn {
      display: flex;
      align-items: center;
      gap: 7px;
      padding: 6px 14px;
      border-radius: 999px;
      border: 1px solid var(--line-strong);
      font-size: var(--fs-label);
      color: var(--text-2);
      transition: border-color 0.15s, color 0.15s, background 0.15s;
    }

    .topbar-btn:hover {
      border-color: var(--line-accent);
      color: var(--text);
      background: var(--bg-raised);
    }

    .avatar-pill {
      display: flex;
      align-items: center;
      gap: 9px;
      padding: 5px 12px 5px 5px;
      border-radius: 999px;
      border: 1px solid var(--line);
      cursor: pointer;
      transition: border-color 0.15s, background 0.15s;
    }

    .avatar-pill:hover { border-color: var(--line-strong); background: var(--bg-raised); }

    .avatar {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background: var(--accent-dim);
      border: 1px solid var(--line-accent);
      display: grid;
      place-items: center;
      font-size: var(--fs-micro);
      font-weight: 600;
      color: var(--accent);
      letter-spacing: 0;
    }

    .avatar-name {
      font-size: var(--fs-label);
      color: var(--text-2);
    }

    /* ─── Content area ───────────────────────────────── */
    /* ─── Signature sync scan-line (under topbar) ─── */
    .sync-bar {
      position: relative;
      height: 2px;
      flex-shrink: 0;
      background: var(--divider);
      overflow: hidden;
    }
    .sync-bar::after {
      content: '';
      position: absolute;
      inset: 0 auto 0 0;
      width: 40%;
      height: 100%;
      background: linear-gradient(90deg, transparent 0%, var(--accent) 45%, var(--accent-glow) 62%, transparent 100%);
      animation: syncScan 3s cubic-bezier(0.4,0,0.2,1) infinite;
    }
    @keyframes syncScan {
      from { transform: translateX(-100%); }
      to   { transform: translateX(350%); }
    }
    @media (prefers-reduced-motion: reduce) { .sync-bar::after { animation: none; opacity: 0.5; } }

    .content {
      padding: 28px;
      flex: 1;
    }

    /* ─── Dashboard main grid (mockup: wide fleet + side column) ─── */
    .dash-main-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 340px;
      gap: 16px;
    }
    .dash-side-col {
      display: flex;
      flex-direction: column;
      gap: 16px;
      min-width: 0;
    }
    @media (max-width: 980px) {
      .dash-main-grid { grid-template-columns: 1fr; }
    }
    .risk-row { padding: 4px 0 10px; }
    .risk-row + .risk-row { border-top: 1px solid var(--divider); padding-top: 12px; }
    .risk-row-head {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 7px; font-size: var(--fs-label); color: var(--text-2);
    }
    .risk-row-head span:last-child {
      font-family: var(--mono); color: var(--text);
      font-variant-numeric: tabular-nums; font-size: var(--fs-label);
    }
    .bar-fill.safe   { background: var(--gain); }
    .bar-fill.warn   { background: var(--amber); }
    .bar-fill.danger { background: var(--loss); }

    /* ─── Pages ──────────────────────────────────────── */
    .page { display: none; }
    .page.active { display: block; }

    /* Native-feeling staggered entrance: cards rise in as you arrive */
    .page.active > * {
      animation: riseIn 0.42s cubic-bezier(0.22, 0.61, 0.36, 1) both;
    }
    .page.active > *:nth-child(1) { animation-delay: 0.01s; }
    .page.active > *:nth-child(2) { animation-delay: 0.05s; }
    .page.active > *:nth-child(3) { animation-delay: 0.09s; }
    .page.active > *:nth-child(4) { animation-delay: 0.13s; }
    .page.active > *:nth-child(n+5) { animation-delay: 0.16s; }

    @keyframes riseIn {
      from { opacity: 0; transform: translateY(10px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    @media (prefers-reduced-motion: reduce) {
      .page.active > *, .card, .metric { animation: none !important; transition: none !important; }
    }

    @keyframes fadeUp {
      from { opacity: 0; transform: translateY(6px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    /* ─── Grid ───────────────────────────────────────── */
    .grid         { display: grid; gap: 18px; }
    .g2           { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .g3           { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .g4           { grid-template-columns: repeat(4, minmax(0,1fr)); }
    .g-main       { grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr); }

    /* ─── Cards ──────────────────────────────────────── */
    .card {
      background: var(--bg-raised);
      border: 1px solid var(--line);
      border-radius: var(--radius-xl);
      overflow: hidden;
      /* depth from light: deep soft drop + a fine top edge-light */
      box-shadow: var(--shadow-md), inset 0 1px 0 var(--edge-light);
      transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    }

    .card-p { padding: 22px; }

    /* ─── Hero card ──────────────────────────────────── */
    .hero-card {
      background: var(--bg-raised);
      border: 1px solid var(--line);
      border-radius: var(--radius-2xl);
      padding: 36px;
      position: relative;
      overflow: hidden;
      box-shadow: var(--shadow-card), inset 0 1px 0 var(--edge-light);
    }

    .hero-mode-row {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 20px;
    }

    /* Bot status stays beside the mode label, so both read as one control state. */
    .hero-power {
      position: static;
      display: inline-flex;
      align-items: center;
      gap: 5px;
      font-size: var(--fs-caption);
      font-weight: 800;
      letter-spacing: 0.08em;
      line-height: 1;
      white-space: nowrap;
    }
    .hero-power::before {
      content: '';
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: currentColor;
      box-shadow: 0 0 8px currentColor;
    }
    .hero-power.on { color: #2ec775; }
    .hero-power.off { color: #ec6b71; }
    .hero-power.checking { color: var(--text-3); font-size: var(--fs-micro); }
    @media (max-width: 720px) {
      .hero-power { font-size: var(--fs-micro); }
      .hero-power::before { width: 6px; height: 6px; }
    }

    /* Interactive surfaces get a gentle native-feeling lift */
    .more-row, .more-quick-tile, .theme-swatch, .exchange-btn, .avatar-pill, .nav-btn {
      transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
    }
    .more-row:hover, .more-quick-tile:hover, .theme-swatch:hover { transform: translateY(-2px); }
    .more-row:active, .more-quick-tile:active, .theme-swatch:active,
    .btn:active, .seg:active, .nav-btn:active { transform: scale(0.98); }


    .hero-eyebrow {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      font-size: var(--fs-caption);
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--text-3);
      margin-bottom: 0;
    }

    .hero-eyebrow-line {
      width: 24px;
      height: 1px;
      background: var(--line-strong);
    }

    .hero-headline {
      font-family: var(--font-display);
      font-size: clamp(30px, 4vw, 52px);
      font-weight: 300;
      letter-spacing: -0.05em;
      line-height: 1.05;
      color: var(--text);
      max-width: 580px;
      margin-bottom: 14px;
    }

    .hero-headline em {
      font-style: italic;
      color: var(--accent);
      font-weight: 300;
    }

    .hero-body {
      font-size: var(--fs-body);
      color: var(--text-2);
      max-width: 480px;
      line-height: 1.7;
      margin-bottom: 28px;
    }

    .hero-actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }

    .hero-actions.api-action-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin-top: 18px;
    }

    .api-action-card {
      min-height: 88px;
      width: 100%;
      border: 1px solid var(--line);
      border-radius: var(--radius-xl);
      padding: 14px;
      background: var(--bg-raised);
      color: var(--text);
      box-shadow: var(--shadow-sm), inset 0 1px 0 var(--edge-light);
      display: grid;
      grid-template-columns: 38px minmax(0, 1fr);
      gap: 11px;
      align-items: center;
      text-align: left;
      transition: transform .18s ease, border-color .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
    }

    .api-action-card:hover {
      transform: translateY(-1px);
      border-color: var(--line-accent);
      background: var(--bg-hover);
    }

    .api-action-card:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 3px;
    }

    .api-action-card:disabled {
      cursor: not-allowed;
      opacity: .72;
      transform: none;
    }

    .api-action-icon {
      width: 38px;
      height: 38px;
      border-radius: 12px;
      display: grid;
      place-items: center;
      background: var(--surface-hi);
      color: var(--accent);
      border: 1px solid var(--line);
    }

    .api-action-icon svg {
      width: 20px;
      height: 20px;
    }

    .api-action-copy {
      display: grid;
      gap: 6px;
      min-width: 0;
    }

    .api-action-copy strong {
      font-size: var(--fs-h3);
      line-height: 1.2;
      font-weight: 700;
      color: inherit;
    }

    .api-action-copy small {
      font-size: var(--fs-label);
      line-height: 1.35;
      color: var(--text-2);
    }

    .api-action-primary.is-running {
      border-color: var(--blue);
      background: linear-gradient(135deg, var(--blue), color-mix(in srgb, var(--blue) 78%, var(--accent) 22%));
      color: #fff;
      box-shadow: 0 18px 36px color-mix(in srgb, var(--blue) 26%, transparent);
    }

    .api-action-primary.is-running .api-action-icon {
      background: rgba(255,255,255,.18);
      border-color: rgba(255,255,255,.28);
      color: #fff;
    }

    .api-action-primary.is-running .api-action-copy small {
      color: rgba(255,255,255,.82);
    }

    .api-action-primary.is-paused {
      border-color: var(--blue-line);
      background: var(--blue-bg);
      color: var(--blue);
    }

    .api-action-connect {
      border-color: var(--accent-line);
      background: var(--accent-dim);
    }

    .api-action-danger {
      border-color: var(--red-line);
      background: var(--red-bg);
      color: var(--red);
    }

    .api-action-danger .api-action-icon {
      color: var(--red);
      background: rgba(240,136,140,.10);
      border-color: var(--red-line);
    }

    .api-action-card.is-busy .api-action-icon svg {
      animation: apiSpin 1s linear infinite;
    }

    @keyframes apiSpin {
      to { transform: rotate(360deg); }
    }

    /* ─── Buttons ────────────────────────────────────── */
    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-height: 40px;            /* canonical button height — DESIGN.md §4 */
      padding: 11px 18px;
      border-radius: var(--radius-btn);
      font-size: var(--fs-sm);
      font-weight: 500;
      border: 1px solid var(--line-strong);
      color: var(--text-2);
      transition: all 0.15s ease;
    }

    .btn:hover { border-color: var(--line-accent); color: var(--text); background: var(--bg-hover); }
    .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    .btn.primary {
      background: var(--accent-dim);
      border-color: var(--accent-line);
      color: var(--accent);
    }

    .btn.primary:hover {
      background: color-mix(in srgb, var(--accent) 22%, transparent);
      border-color: var(--accent);
      color: var(--accent-strong);
    }

    .btn.danger {
      background: var(--red-bg);
      border-color: var(--red-line);
      color: var(--red);
    }

    .btn.danger:hover { background: rgba(240,136,140,0.20); border-color: var(--red); }

    /* ─── Metric tiles ───────────────────────────────── */
    .metric {
      background: var(--bg-raised);
      border: 1px solid var(--line);
      border-radius: var(--radius-xl);
      padding: 20px;
      box-shadow: var(--shadow-sm), inset 0 1px 0 var(--edge-light);
      transition: border-color 0.2s ease, transform 0.2s ease;
    }

    .metric-label {
      font-size: var(--fs-caption);
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-3);
    }

    .metric-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      min-height: 30px;
    }

    .metric-settings-btn {
      width: 30px;
      height: 30px;
      display: inline-grid;
      place-items: center;
      flex: 0 0 30px;
      padding: 0;
      border: 1px solid var(--line);
      border-radius: 50%;
      color: var(--text-3);
      background: var(--bg-mid);
      cursor: pointer;
    }

    .metric-settings-btn:hover {
      color: var(--text);
      border-color: var(--line-accent);
    }

    .metric-settings-btn .nav-icon {
      width: 14px;
      height: 14px;
    }

    .metric-value {
      font-size: 32px;
      font-weight: 300;
      letter-spacing: -0.05em;
      color: var(--text);
      margin-top: 10px;
      line-height: 1;
      font-family: var(--mono);
      font-variant-numeric: tabular-nums;
    }

    .metric-sub {
      font-size: var(--fs-label);
      color: var(--text-3);
      margin-top: 8px;
    }

    .positive { color: var(--green); }
    .negative { color: var(--red); }
    .warning-text { color: var(--amber); }

    /* ─── Section head ───────────────────────────────── */
    .section-head {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 12px;
      margin-bottom: 18px;
    }

    .section-title {
      font-family: var(--font-display);
      font-size: var(--fs-h3);
      font-weight: 500;
      letter-spacing: -0.02em;
      color: var(--text);
    }

    .section-sub {
      font-size: var(--fs-label);
      color: var(--text-3);
      margin-top: 3px;
    }

    /* ─── Badges ─────────────────────────────────────── */
    .badge {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 4px 9px;
      border-radius: var(--radius-sm);
      font-size: var(--fs-micro);
      font-weight: 700;
      letter-spacing: 0.055em;
      text-transform: uppercase;
      border: 1px solid transparent;
      color: var(--text-3);
      background: var(--surface-hi);
    }

    .badge.green { color: var(--green); background: var(--green-bg); border-color: var(--green-line); }
    .badge.red   { color: var(--red);   background: var(--red-bg);   border-color: var(--red-line); }
    .badge.amber { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-line); }
    .badge.blue  { color: var(--blue);  background: var(--blue-bg);  border-color: var(--blue-line); }
    .badge.gold  { color: var(--gold); background: var(--gold-dim); border-color: color-mix(in srgb, var(--gold) 30%, transparent); }
    .badge.grey  { color: var(--grey);  background: var(--grey-bg);  border-color: var(--grey-line); }
    .badge.accent{ color: var(--accent);background: var(--accent-dim);border-color: var(--accent-line); }

    /* Badge with a leading status dot */
    .badge .b-dot {
      width: 6px; height: 6px; border-radius: 50%;
      background: currentColor; flex: 0 0 6px;
      box-shadow: 0 0 6px currentColor;
    }

    /* ─── Mode strip — Paper vs Live clarity ─────────────
       Reusable header band shown on every key page so users
       always know: which mode, bot state, API state, payment. */
    .mode-strip {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      padding: 12px 14px;
      margin-bottom: 16px;
      border-radius: var(--radius-lg);
      border: 1px solid var(--line);
      background: var(--bg-glass);
      backdrop-filter: blur(10px);
    }
    .mode-strip.paper { border-color: var(--accent-line); background: var(--accent-glow); }
    .mode-strip.live  { border-color: var(--blue-line);   background: var(--blue-bg); }
    .mode-strip .mode-lead {
      display: inline-flex; align-items: center; gap: 8px;
      font-size: var(--fs-label); letter-spacing: 0.04em;
      color: var(--text-2); margin-right: auto;
    }
    .mode-strip .mode-lead b { color: var(--text); font-weight: 600; }
    .mode-pill {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 5px 11px; border-radius: 999px;
      font-size: var(--fs-label); font-weight: 500;
      border: 1px solid var(--line); color: var(--text-3);
      background: transparent; white-space: nowrap;
    }
    .mode-pill .b-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
    .mode-pill.on    { color: var(--green); border-color: var(--green-line); background: var(--green-bg); }
    .mode-pill.off   { color: var(--grey);  border-color: var(--grey-line);  background: var(--grey-bg); }
    .mode-pill.warn  { color: var(--amber); border-color: var(--amber-line); background: var(--amber-bg); }
    .mode-pill.info  { color: var(--blue);  border-color: var(--blue-line);  background: var(--blue-bg); }

    /* ─── Bot rows ───────────────────────────────────── */
    /* Live scanner */
    .scan-stage {
      padding: 22px 24px;
      margin-bottom: 18px;
      background: var(--bg-raised);
      border: 1px solid var(--line);
      border-radius: var(--radius-xl);
      box-shadow: var(--shadow-md), inset 0 1px 0 var(--edge-light);
    }

    .scan-stage-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 16px;
    }

    .scan-title {
      display: flex;
      align-items: center;
      gap: 9px;
      color: var(--text);
      font-size: var(--fs-h3);
      font-weight: 500;
    }

    .scan-dot {
      width: 8px;
      height: 8px;
      flex: 0 0 8px;
      border-radius: 50%;
      background: var(--green);
      box-shadow: 0 0 0 4px var(--green-bg);
      animation: scanPulse 1.8s ease-in-out infinite;
    }

    @keyframes scanPulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.35; }
    }

    .scan-sub {
      margin-top: 4px;
      color: var(--text-3);
      font-size: var(--fs-label);
    }

    .scan-track {
      height: 3px;
      margin: 16px 0;
      overflow: hidden;
      background: var(--bg);
      border-radius: 999px;
    }

    .scan-progress {
      position: relative;
      width: 8%;
      height: 100%;
      background: var(--accent);
      border-radius: inherit;
      transition: width 0.35s ease, background 0.2s ease;
      overflow: hidden;
    }
    /* AlgoSyncing — a light sweeps the progress bar while scanning */
    .scan-progress::after {
      content: '';
      position: absolute;
      inset: 0;
      background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
      transform: translateX(-100%);
      animation: scanSweep 1.5s ease-in-out infinite;
    }
    @keyframes scanSweep { to { transform: translateX(220%); } }

    /* ─── Liveliness utilities ───────────────────────────
       sync-pulse: anything live breathes (running bot, live API). */
    @keyframes syncPulse {
      0%, 100% { opacity: 1;   box-shadow: 0 0 0 0 currentColor; }
      50%      { opacity: 0.45; box-shadow: 0 0 7px 1px currentColor; }
    }
    .b-dot.live { animation: syncPulse 1.8s ease-in-out infinite; }

    /* Skeleton shimmer for loading states */
    .skeleton {
      position: relative;
      overflow: hidden;
      background: var(--bg-hover);
      border-radius: var(--radius-sm);
      color: transparent !important;
    }
    .skeleton::after {
      content: '';
      position: absolute;
      inset: 0;
      background: linear-gradient(90deg, transparent, var(--edge-light), transparent);
      transform: translateX(-100%);
      animation: skeletonSweep 1.3s ease-in-out infinite;
    }
    @keyframes skeletonSweep { to { transform: translateX(100%); } }

    .scan-meta {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 14px;
    }

    .scan-meta div {
      min-width: 0;
      padding-right: 12px;
      border-right: 1px solid var(--line);
    }

    .scan-meta div:last-child {
      border-right: 0;
      padding-right: 0;
    }

    .scan-meta span,
    .level-cell span {
      display: block;
      color: var(--text-3);
      font-size: var(--fs-micro);
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }

    .scan-meta strong,
    .level-cell strong {
      display: block;
      min-width: 0;
      margin-top: 4px;
      color: var(--text-2);
      font-family: var(--mono);
      font-size: var(--fs-label);
      font-weight: 500;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .bots-live-grid {
      grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
      align-items: start;
    }

    .market-pulse-list,
    .engine-activity {
      display: grid;
      gap: 7px;
    }

    .market-pulse-row {
      display: grid;
      grid-template-columns: minmax(120px, 1fr) minmax(90px, auto) minmax(64px, auto) auto;
      align-items: center;
      gap: 12px;
      min-height: 48px;
      padding: 8px 10px;
      border: 1px solid var(--line);
      border-radius: var(--radius-sm);
      background: var(--bg-mid);
    }

    .market-symbol {
      display: flex;
      align-items: center;
      gap: 9px;
      min-width: 0;
    }

    .market-symbol .coin-logo {
      width: 30px;
      height: 30px;
      flex: 0 0 30px;
      font-size: var(--fs-micro);
    }

    .market-price,
    .market-change {
      font-family: var(--mono);
      font-size: var(--fs-label);
      text-align: right;
      white-space: nowrap;
    }

    .level-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }

    .level-cell {
      min-width: 0;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: var(--radius-sm);
      background: var(--bg-mid);
    }

    .engine-event {
      display: grid;
      grid-template-columns: 8px minmax(0, 1fr) auto;
      align-items: center;
      gap: 10px;
      min-height: 38px;
      padding: 7px 9px;
      border-bottom: 1px solid var(--line);
    }

    .engine-event:last-child { border-bottom: 0; }

    .engine-event-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: var(--blue);
    }

    .engine-event-dot.green { background: var(--green); }
    .engine-event-dot.amber { background: var(--amber); }
    .engine-event-dot.red { background: var(--red); }

    .engine-event-copy {
      min-width: 0;
      color: var(--text-2);
      font-size: var(--fs-label);
    }

    .engine-event-copy strong {
      color: var(--text);
      font-weight: 500;
    }

    .engine-event time {
      color: var(--text-3);
      font-family: var(--mono);
      font-size: var(--fs-micro);
      white-space: nowrap;
    }

    .bot-row {
      display: grid;
      grid-template-columns: 1.3fr 0.7fr 0.8fr auto;
      gap: 10px;
      align-items: center;
      padding: 14px 16px;
      border: 1px solid var(--line);
      border-radius: var(--radius-lg);
      background: var(--bg-mid);
      margin-bottom: 8px;
      transition: border-color 0.15s;
    }

.bot-row:hover { border-color: var(--line-strong); }
.bot-row:last-child { margin-bottom: 0; }
#botFleet .bot-row {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "coin badge"
    "side score";
  align-items: center;
  gap: 10px 12px;
  overflow: hidden;
}
#botFleet .bot-row .coin {
  grid-area: coin;
  min-width: 0;
}
#botFleet .bot-row > div:nth-child(2) {
  grid-area: side;
  min-width: 0;
}
#botFleet .bot-row > div:nth-child(3) {
  grid-area: score;
  min-width: 84px;
  justify-self: end;
}
#botFleet .bot-row > .badge {
  grid-area: badge;
  justify-self: end;
  max-width: 100%;
  white-space: nowrap;
}

    .coin {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .coin-logo {
      --coin: var(--accent);
      width: 36px;
      height: 36px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      font-size: var(--fs-caption);
      font-weight: 600;
      letter-spacing: 0.01em;
      text-transform: uppercase;
      color: var(--coin);
      background: color-mix(in srgb, var(--coin) 15%, var(--bg-mid));
      border: 1px solid color-mix(in srgb, var(--coin) 40%, transparent);
      box-shadow: inset 0 1px 0 var(--edge-light);
      font-family: var(--font-display);
    }

    .coin-name {
      font-size: var(--fs-sm);
      font-weight: 500;
      letter-spacing: -0.02em;
    }

    .coin-sub {
      font-size: var(--fs-caption);
      color: var(--text-3);
      margin-top: 1px;
    }

    .data-label {
      font-size: var(--fs-micro);
      color: var(--text-3);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      margin-bottom: 4px;
    }

    .data-value {
      font-size: var(--fs-sm);
      font-family: var(--mono);
      font-weight: 500;
    }

    /* ─── Progress bar ───────────────────────────────── */
    .bar-track {
      height: 4px;
      background: var(--bg);
      border-radius: 999px;
      overflow: hidden;
      margin-top: 6px;
    }

    .bar-fill {
      height: 100%;
      border-radius: 999px;
      background: var(--accent);
    }

    /* ─── Table ──────────────────────────────────────── */
    /* Wide tables scroll horizontally at every width (swipe on touch). */
    .table-wrap {
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
      touch-action: pan-x pan-y;
    }
    .table {
      width: 100%;
      border-collapse: collapse;
    }

    .table th {
      font-size: var(--fs-micro);
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-3);
      font-weight: 500;
      padding: 0 12px 12px;
      text-align: left;
      border-bottom: 1px solid var(--line);
    }

    .table td {
      padding: 13px 12px;
      font-size: var(--fs-sm);
      border-bottom: 1px solid var(--line);
      vertical-align: middle;
      white-space: nowrap;
      color: var(--text-2);
    }

    .table td:first-child { color: var(--text); font-weight: 500; }
    .table tr:last-child td { border-bottom: 0; }
    .table tr:hover td { background: var(--bg-hover); }
    .trade-actions {
      display: flex;
      gap: 6px;
      align-items: center;
      flex-wrap: nowrap;
    }
    .icon-btn {
      min-width: 34px;
      height: 30px;
      padding: 0 10px;
      border-radius: 999px;
      border: 1px solid var(--line);
      color: var(--text-2);
      background: var(--bg-mid);
      font-size: var(--fs-caption);
      font-weight: 600;
      cursor: pointer;
    }
    .icon-btn:hover { border-color: var(--line-accent); color: var(--text); }
    .icon-btn.danger {
      color: var(--red);
      border-color: var(--red-line);
      background: var(--red-bg);
    }
    .trade-short td:first-child { color: var(--red); }
    .trade-long td:first-child { color: var(--green); }
    .trade-detail-row td {
      white-space: normal;
      background: rgba(255,255,255,0.025);
      padding-top: 0;
    }
    .trade-detail-panel {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--bg-soft);
      width: min(100%, calc(100vw - 34px));
      max-width: 1120px;
      padding: 12px;
      display: grid;
      gap: 10px;
    }
    .trade-detail-head {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 12px;
    }
    .trade-detail-title {
      color: var(--text);
      font-size: var(--fs-body);
      font-weight: 600;
    }
    .trade-detail-sub {
      color: var(--text-3);
      font-size: var(--fs-label);
      margin-top: 3px;
    }
    .trade-detail-label {
      color: var(--text-3);
      font-size: var(--fs-micro);
      text-transform: uppercase;
      letter-spacing: 0.08em;
      margin-bottom: 7px;
    }
    .trade-detail-list {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
      gap: 6px;
    }
    .trade-detail-list span,
    .trade-detail-note {
      border: 1px solid var(--line);
      border-radius: 999px;
      color: var(--text-2);
      background: var(--bg-mid);
      padding: 6px 9px;
      font-size: var(--fs-label);
      line-height: 1.35;
      min-width: 0;
    }
    .trade-detail-note {
      display: inline-block;
      border-radius: 8px;
      margin-top: 8px;
      color: var(--accent);
    }
    .trade-detail-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
      gap: 8px;
    }
    .trade-detail-metric {
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--surface-hi);
      padding: 8px;
      min-width: 0;
    }
    .trade-detail-metric span {
      display: block;
      color: var(--text-3);
      font-size: var(--fs-micro);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      margin-bottom: 5px;
    }
    .trade-detail-metric strong {
      color: var(--text);
      font-size: var(--fs-sm);
      font-weight: 600;
      overflow-wrap: anywhere;
    }

    /* ─── Form ───────────────────────────────────────── */
    .form-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 14px;
    }

    .field {
      display: grid;
      gap: 7px;
      font-size: var(--fs-label);
      color: var(--text-3);
      letter-spacing: 0.04em;
    }

    .input, select {
      width: 100%;
      padding: 11px 14px;
      border-radius: var(--radius-md);
      color: var(--text);
      background: var(--bg-mid);
      border: 1px solid var(--line);
      font-size: var(--fs-sm);
      transition: border-color 0.15s;
    }

    .input:focus, select:focus {
      border-color: var(--accent-line);
      box-shadow: 0 0 0 3px var(--accent-glow);
    }

    select option { background: var(--bg-raised); color: var(--text); }

    /* ─── Seg controls ───────────────────────────────── */
    .seg-group {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
    }

    .seg {
      padding: 8px 14px;
      border-radius: var(--radius-md);
      border: 1px solid var(--line);
      color: var(--text-3);
      font-size: var(--fs-sm);
      transition: all 0.15s;
    }

    .seg:hover { border-color: var(--line-strong); color: var(--text-2); }

    .seg.active {
      background: var(--accent-dim);
      border-color: var(--accent-line);
      color: var(--accent);
    }

    /* ─── Theme picker ───────────────────────────────── */
    .theme-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
      gap: 10px;
      margin-top: 4px;
    }
    .theme-swatch {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 11px 12px;
      border: 1px solid var(--line);
      border-radius: var(--radius-lg);
      background: var(--bg-mid);
      text-align: left;
      transition: border-color 0.15s, background 0.15s, transform 0.1s;
    }
    .theme-swatch:hover { border-color: var(--line-strong); background: var(--bg-hover); }
    .theme-swatch.active { border-color: var(--accent-line); background: var(--accent-dim); }
    .theme-chips {
      display: inline-grid;
      grid-template-columns: repeat(2, 11px);
      grid-auto-rows: 11px;
      gap: 3px;
      flex: 0 0 auto;
      padding: 5px;
      border-radius: 8px;
      border: 1px solid var(--line);
    }
    .theme-chips i { width: 11px; height: 11px; border-radius: 4px; display: block; }
    .theme-swatch-text { display: grid; gap: 1px; min-width: 0; }
    .theme-swatch-text b {
      font-size: var(--fs-sm); font-weight: 600; color: var(--text);
      letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .theme-swatch-text small { font-size: var(--fs-caption); color: var(--text-3); }
    .theme-swatch.active .theme-swatch-text b { color: var(--accent); }

    /* ─── Font picker ─────────────────────────────────── */
    .font-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
      gap: 10px;
      margin-top: 4px;
    }
    .font-opt {
      display: flex;
      flex-direction: column;
      gap: 2px;
      padding: 11px 13px;
      border: 1px solid var(--line);
      border-radius: var(--radius-lg);
      background: var(--bg-mid);
      text-align: left;
      transition: border-color 0.15s, background 0.15s, transform 0.1s;
    }
    .font-opt:hover { border-color: var(--line-strong); background: var(--bg-hover); transform: translateY(-2px); }
    .font-opt:active { transform: scale(0.98); }
    .font-opt.active { border-color: var(--accent-line); background: var(--accent-dim); }
    .font-opt-name {
      font-family: var(--font-display);
      font-style: var(--head-style);
      letter-spacing: var(--display-spacing);
      font-size: var(--fs-h3); font-weight: var(--head-wt); color: var(--text);
    }
    .font-opt.active .font-opt-name { color: var(--accent); }
    .font-opt-desc { font-size: var(--fs-caption); color: var(--text-3); }

    /* Display headings honour the heading style token */
    .brand-name, .topbar-left h2, .hero-headline, .section-title { font-style: var(--head-style); }

    /* ─── Exchange grid ──────────────────────────────── */
    .exchange-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
      gap: 10px;
      margin-bottom: 18px;
    }

    /* Compact horizontal cards (2026-07-12): logo left, name+status right — half the
       height of the old stacked layout, far less dead space. */
    .exchange-btn {
      padding: 11px 12px;
      border-radius: var(--radius-lg);
      border: 1px solid var(--line);
      background: var(--bg-mid);
      color: var(--text-2);
      text-align: left;
      transition: all 0.15s;
      position: relative;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      column-gap: 11px;
      row-gap: 1px;
      align-items: center;
    }
    .exchange-btn > svg, .exchange-btn .exchange-logo { grid-row: 1 / span 2; }

    .exchange-btn:hover, .exchange-btn.active {
      border-color: var(--line-accent);
      color: var(--text);
      background: var(--accent-dim);
    }

    .exchange-logo {
      width: 26px;
      height: 26px;
      border-radius: 9px;
      display: block;
      object-fit: contain;
      box-shadow: 0 1px 4px rgba(15, 23, 42, .10);
    }
    .exchange-btn strong { display: block; font-size: var(--fs-sm); margin-top: 0; }
    .exchange-btn .exchange-card-status { display: block; font-size: var(--fs-caption); color: var(--text-3); margin-top: 0; }
    .exchange-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .exchange-card-status.active { color: var(--green); font-weight: 700; }
    .exchange-card-status.available { color: var(--text-3); }
    .exchange-card-status.muted { color: var(--text-3); }
    .exchange-active-dot {
      position: absolute;
      top: 10px;
      right: 10px;
      width: 9px;
      height: 9px;
      border-radius: 999px;
      background: var(--green);
      box-shadow: 0 0 0 4px var(--green-bg);
    }

    /* ─── Trading Calendar ───────────────────────────── */
    .cal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 18px;
      flex-wrap: wrap;
      gap: 12px;
    }

    .cal-nav {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .cal-nav-btn {
      width: 32px;
      height: 32px;
      border-radius: var(--radius-md);
      border: 1px solid var(--line);
      color: var(--text-2);
      display: grid;
      place-items: center;
      transition: border-color 0.15s, color 0.15s, background 0.15s;
    }

    .cal-nav-btn:hover { border-color: var(--line-strong); color: var(--text); background: var(--bg-hover); }

    .cal-month-label {
      font-size: var(--fs-md);
      font-weight: 500;
      letter-spacing: -0.03em;
      color: var(--text);
    }

    .cal-this-month {
      padding: 6px 13px;
      border-radius: var(--radius-md);
      border: 1px solid var(--line);
      font-size: var(--fs-label);
      color: var(--text-2);
      background: var(--bg-hover);
      cursor: pointer;
      transition: border-color 0.15s;
    }

    .cal-this-month:hover { border-color: var(--line-strong); color: var(--text); }

    .cal-summary {
      display: flex;
      align-items: center;
      gap: 14px;
      font-size: var(--fs-sm);
      color: var(--text-3);
    }

    .cal-summary strong { color: var(--green); font-family: var(--mono); font-size: var(--fs-h3); }

    /* Calendar grid: 7 day cols + 1 week summary col */
    .cal-grid {
      display: grid;
      grid-template-columns: repeat(7, minmax(0,1fr)) 110px;
      gap: 5px;
    }

    .cal-dow {
      font-size: var(--fs-caption);
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-3);
      text-align: center;
      padding: 0 0 8px;
      font-weight: 500;
    }

    .cal-dow.week-col { color: var(--text-3); }

    .cal-cell {
      border: 1px solid var(--line);
      border-radius: var(--radius-lg);
      background: var(--bg-mid);
      min-height: 90px;
      padding: 10px;
      position: relative;
      transition: border-color 0.15s;
      cursor: default;
    }

    .cal-cell:hover { border-color: var(--line-strong); }

    .cal-cell.empty {
      background: transparent;
      border-color: transparent;
      cursor: default;
    }

    .cal-cell.profit {
      background: rgba(23, 60, 38, 0.55);
      border-color: rgba(109, 179, 132, 0.18);
    }

    .cal-cell.profit-strong {
      background: rgba(12, 72, 36, 0.75);
      border-color: rgba(109, 179, 132, 0.28);
    }

    .cal-cell.loss {
      background: rgba(72, 16, 16, 0.65);
      border-color: rgba(196, 106, 106, 0.22);
    }

    .cal-cell.today {
      border-color: var(--line-accent) !important;
      box-shadow: 0 0 0 1px var(--line-accent);
    }

    .cal-cell.week-cell {
      background: var(--bg-raised);
      border-color: var(--line);
      text-align: right;
    }

    .cal-day-num {
      font-size: var(--fs-caption);
      color: var(--text-3);
      font-family: var(--mono);
      margin-bottom: 6px;
    }

    .cal-cell.week-cell .cal-day-num {
      color: var(--text-3);
      font-size: var(--fs-micro);
      letter-spacing: 0.06em;
      text-transform: uppercase;
      font-family: var(--font);
    }

    .cal-pnl {
      font-size: var(--fs-h3);
      font-weight: 600;
      font-family: var(--mono);
      letter-spacing: -0.02em;
      margin-bottom: 4px;
    }

    .cal-cell.profit .cal-pnl,
    .cal-cell.profit-strong .cal-pnl { color: var(--gain); }
    .cal-cell.loss .cal-pnl           { color: var(--loss); }
    .cal-cell.week-cell .cal-pnl      { font-size: var(--fs-h2); }

    .cal-meta {
      font-size: var(--fs-caption);
      color: var(--text-3);
      line-height: 1.55;
      font-family: var(--mono);
    }

    .cal-cell.profit .cal-meta,
    .cal-cell.profit-strong .cal-meta { color: rgba(109,179,132,0.55); }
    .cal-cell.loss .cal-meta           { color: rgba(196,106,106,0.55); }

    .cal-week-days {
      font-size: var(--fs-caption);
      color: var(--text-3);
      margin-top: 4px;
    }

    /* ─── Notice block ───────────────────────────────── */
    .notice {
      padding: 13px 16px;
      border-radius: var(--radius-md);
      border: 1px solid color-mix(in srgb, var(--amber) 18%, var(--border));
      border-left: 3px solid var(--amber);
      background: color-mix(in srgb, var(--amber) 5%, var(--surface-hi));
      font-size: var(--fs-label);
      color: var(--text-2);
      line-height: 1.6;
    }

    /* ─── Open rows (checklist items, status lines) ──────
       No nested boxes: rows are separated by a hairline + air. */
    .row-panel {
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 13px;
      align-items: center;
      padding: 15px 2px;
      border: 0;
      border-bottom: 1px solid var(--line);
      border-radius: 0;
      background: transparent;
      margin-bottom: 0;
    }

    .row-panel:last-child { border-bottom: 0; padding-bottom: 2px; }
    .row-panel:first-child { padding-top: 2px; }

    .row-panel-title { font-size: var(--fs-body); font-weight: 500; color: var(--text); letter-spacing: -0.01em; }
    .row-panel-sub   { font-size: var(--fs-label); color: var(--text-3); margin-top: 3px; line-height: 1.45; }

    /* ─── Profile ────────────────────────────────────── */
    .profile-header {
      display: flex;
      align-items: center;
      gap: 20px;
      flex-wrap: wrap;
    }

    .profile-avatar {
      width: 72px;
      height: 72px;
      border-radius: 20px;
      background: var(--accent-dim);
      border: 1px solid var(--line-accent);
      display: grid;
      place-items: center;
      font-size: var(--fs-h1);
      font-weight: 500;
      color: var(--accent);
    }

    /* ─── Divider ────────────────────────────────────── */
    .divider {
      height: 1px;
      background: var(--line);
      margin: 20px 0;
    }

    /* ─── Performance bars ───────────────────────────── */
    .perf-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 14px;
    }

    .perf-label { font-size: var(--fs-label); color: var(--text-2); }
    .perf-val   { font-size: var(--fs-sm); font-family: var(--mono); color: var(--text); min-width: 42px; text-align: right; }

    /* ─── Subscription price ─────────────────────────── */
    .price-display {
      font-size: 48px;
      font-weight: 300;
      letter-spacing: -0.06em;
      font-family: var(--mono);
      color: var(--text);
      margin: 14px 0;
    }

    .price-display sup {
      font-size: var(--fs-lg);
      vertical-align: super;
      font-weight: 400;
    }

    .price-display span {
      font-size: var(--fs-h3);
      color: var(--text-3);
      letter-spacing: 0;
      font-family: var(--font);
    }


    /* ─── Profile + install settings ─────────────────── */
    .settings-profile-grid { margin-bottom: 0; }

    .profile-mini {
      display: flex;
      align-items: center;
      gap: 14px;
    }

    .profile-mini-avatar {
      width: 50px;
      height: 50px;
      border-radius: 14px;
      display: grid;
      place-items: center;
      background: var(--accent-dim);
      border: 1px solid var(--line-accent);
      color: var(--accent);
      font-size: var(--fs-h3);
      font-weight: 500;
      letter-spacing: -0.02em;
    }

    .profile-mini-name {
      color: var(--text);
      font-size: var(--fs-h3);
      font-weight: 500;
      letter-spacing: -0.02em;
    }

    .profile-mini-sub {
      color: var(--text-3);
      font-size: var(--fs-label);
      margin-top: 3px;
    }

    .install-device-row {
      display: grid;
      grid-template-columns: repeat(2, minmax(0,1fr));
      gap: 10px;
    }

    .install-device {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 13px 14px;
      border: 0;
      border-radius: var(--radius-lg);
      background: var(--bg-mid);
    }

    .install-device-icon {
      width: 30px;
      height: 30px;
      border-radius: 10px;
      display: grid;
      place-items: center;
      border: 1px solid var(--line-accent);
      color: var(--accent);
      background: var(--accent-dim);
      font-size: var(--fs-h2);
      line-height: 1;
    }

    .install-device b {
      display: block;
      color: var(--text);
      font-size: var(--fs-label);
      font-weight: 500;
    }

    .install-device span:not(.install-device-icon) {
      display: block;
      color: var(--text-3);
      font-size: var(--fs-caption);
      margin-top: 1px;
    }

    .install-help {
      margin-top: 10px;
      color: var(--text-3);
      font-size: var(--fs-label);
      line-height: 1.55;
    }

    .install-card.installed #installAppBtn {
      pointer-events: none;
      opacity: 0.55;
    }

    /* ─── Mobile nav ─────────────────────────────────── */
    .mobile-nav {
      display: none;
      position: fixed;
      left: 12px;
      right: 12px;
      bottom: calc(10px + env(safe-area-inset-bottom));
      z-index: 50;
      padding: 7px 8px;
      background: var(--bg-glass);
      backdrop-filter: blur(22px) saturate(1.4);
      -webkit-backdrop-filter: blur(22px) saturate(1.4);
      border: 1px solid var(--line-strong);
      border-radius: 20px;
      box-shadow: var(--shadow-pop), inset 0 1px 0 var(--edge-light);
      justify-content: space-around;
    }

    .mobile-nav .nav-btn {
      position: relative;
      flex-direction: column;
      gap: 4px;
      padding: 8px 10px;
      font-size: var(--fs-micro);
      min-width: 50px;
      text-align: center;
      border: 0;
      border-radius: 16px;
      color: var(--text-3);
    }
    .mobile-nav .nav-btn .nav-icon { transition: transform 0.18s ease; opacity: 0.7; }

    /* Active item: accent label + a soft tile + a top "sync" indicator */
    .mobile-nav .nav-btn.active {
      background: var(--accent-dim);
      color: var(--accent);
      border: 0;
    }
    .mobile-nav .nav-btn.active .nav-icon { opacity: 1; transform: translateY(-1px) scale(1.06); }
    .mobile-nav .nav-btn.active::before {
      content: '';
      position: absolute;
      top: -7px; left: 50%;
      width: 18px; height: 3px;
      transform: translateX(-50%);
      border-radius: 999px;
      background: var(--accent);
      box-shadow: 0 0 10px var(--accent);
    }

    .mobile-nav .nav-icon { width: 18px; height: 18px; }

    /* ─── Dump Short 2.0 scanner: colorful 2-up card grid ─── */
    .ds2-scan-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .market-coverage-note {
      display: flex;
      align-items: center;
      gap: 8px;
      margin: 0 0 10px;
      padding: 7px 9px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: var(--surface-hi);
      color: var(--text-3);
      font-size: 10.5px;
      line-height: 1.35;
    }
    .market-coverage-note b {
      flex: 0 0 auto;
      color: var(--gain);
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: .04em;
    }
    .ds2-scan-card {
      display: flex;
      flex-direction: column;
      gap: 5px;
      padding: 8px 9px;
      border-radius: 12px;
      background: var(--surface, rgba(255, 255, 255, 0.02));
      border: 1px solid var(--border, rgba(255, 255, 255, 0.07));
      transition: border-color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
    }
    .ds2-scan-card.ready {
      border-color: rgba(240, 136, 140, 0.55);
      box-shadow: 0 0 0 1px rgba(240, 136, 140, 0.16), 0 6px 18px rgba(240, 136, 140, 0.10);
    }
    .ds2-scan-card:active { transform: scale(0.99); }
    .ds2-scan-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }
    .ds2-scan-coin { display: flex; flex-direction: column; min-width: 0; }
    .ds2-scan-coin b {
      font-size: 13px;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .ds2-scan-coin small { color: var(--text-3); font-size: 9px; }
    .ds2-scan-price {
      font-size: 14px;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      letter-spacing: -0.01em;
    }
    .ds2-execution-note {
      color: var(--text-3);
      font-size: 10px;
      line-height: 1.35;
    }
    .ds2-scan-metrics { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
    .ds2-metric,
    .ds2-score,
    .ds2-early-score {
      display: inline-flex;
      align-items: center;
      padding: 2px 7px;
      border-radius: 999px;
      font-size: 10px;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
    }
    .ds2-metric.positive {
      background: color-mix(in srgb, var(--green) 11%, transparent);
      color: var(--green);
      border: 1px solid color-mix(in srgb, var(--green) 30%, transparent);
    }
    .ds2-metric.negative {
      background: color-mix(in srgb, var(--red) 10%, transparent);
      color: var(--red);
      border: 1px solid color-mix(in srgb, var(--red) 28%, transparent);
    }
    .ds2-score {
      background: var(--accent-dim);
      color: var(--accent);
      border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
    }
    .ds2-early-score {
      background: color-mix(in srgb, var(--amber) 10%, transparent);
      color: var(--amber);
      border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
    }
    .ds2-early-score.eligible {
      background: color-mix(in srgb, var(--green) 13%, transparent);
      color: var(--green);
      border-color: color-mix(in srgb, var(--green) 36%, transparent);
      box-shadow: 0 0 0 1px color-mix(in srgb, var(--green) 8%, transparent);
    }
    .ds2-scan-card .badge { padding: 3px 7px; font-size: 9px; }
    @media (min-width: 900px) {
      .ds2-scan-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
    }
    @media (max-width: 560px) {
      .ds2-scan-grid { gap: 6px; }
      .market-coverage-note { align-items: flex-start; flex-direction: column; gap: 2px; }
      .ds2-scan-card { padding: 7px 8px; gap: 4px; border-radius: 10px; }
      .ds2-scan-coin b { font-size: 11.5px; }
      .ds2-scan-price { font-size: 13px; }
      .ds2-metric, .ds2-score { padding: 1px 5px; font-size: 8.5px; }
      .ds2-scan-card .badge { padding: 2px 6px; font-size: 8px; }
    }

    /* Tiny yellow "new" dot on the Referral tab (top-right corner) */
    .mobile-nav .nav-btn .nav-dot {
      position: absolute;
      top: 6px;
      right: 14px;
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #ffcc00;
      box-shadow: 0 0 4px rgba(255, 204, 0, 0.85);
      pointer-events: none;
    }

    /* ─── Responsive ─────────────────────────────────── */
    @media (max-width: 1200px) {
      .g4 { grid-template-columns: repeat(2, 1fr); }
      .g-main { grid-template-columns: 1fr; }
      .exchange-grid { grid-template-columns: repeat(3, 1fr); }
    }

    @media (max-width: 860px) {
      .app { display: block; }
      .sidebar { display: none; }
      .content { padding: 18px 14px 110px; }
      .mobile-nav { display: flex; }
      .topbar { padding: 0 14px; gap: 10px; }
      .page-glyph { display: none; }   /* dock shows active page on mobile */

      /* Keep the live status, theme toggle, and profile in the mobile header,
         but collapse them to compact icon-only controls. */
      .topbar-right { display: flex; gap: 8px; }
      .topbar-left p { display: none; }                 /* hide subtitle to save room */
      .status-dot { font-size: 0; padding: 0; width: 30px; height: 30px;
                    justify-content: center; border-radius: 50%; gap: 0; }
      .status-dot .pulse { width: 7px; height: 7px; }
      #themeBtn { font-size: 0; gap: 0; width: 32px; height: 32px;
                  justify-content: center; padding: 0; border-radius: 50%; }
      #themeBtn .nav-icon { width: 15px !important; height: 15px !important; }
      .avatar-pill { padding: 3px; gap: 0; }
      .avatar-pill .avatar-name { display: none; }

      .g2, .g3, .g4, .form-grid { grid-template-columns: 1fr; }
      /* Bot-page scanner metrics stay 2x2 on small screens instead of 1-per-row. */
      .grid.dump-scan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
      .grid.dump-scan-grid .metric { padding: 14px; }
      .exchange-grid { grid-template-columns: repeat(2, 1fr); }
      .hero-card { padding: 24px; }
      .hero-headline { font-size: 32px; }
      .bot-row { grid-template-columns: 1fr; gap: 8px; }
      .table-wrap { overflow-x: auto; }
      .journal-bars { gap: 4px; }
    }

    @media (max-width: 480px) {
      .exchange-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } /* 2×2 on phones */
      .metric-value { font-size: 26px; }
      .price-display { font-size: 38px; }
    }

    .hide-desktop { display: none !important; }

    @media (max-width: 860px) {
      .hide-desktop { display: inline-flex !important; }
    }


/* ─── Mobile More menu ─────────────────────────────── */
.more-list {
  display: grid;
  gap: 8px;
}

.more-row {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0,1fr) auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-mid);
  transition: border-color 0.15s, background 0.15s;
}

.more-row:hover { border-color: var(--line-strong); background: var(--bg-hover); }
.more-row-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-dim);
  border: 1px solid var(--line-accent);
  color: var(--accent);
}
.more-row-icon .nav-icon { width: 17px; height: 17px; }
.more-row-text b {
  display: block;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.more-row-text small {
  display: block;
  color: var(--text-3);
  font-size: var(--fs-label);
  margin-top: 2px;
}
.more-row-chev {
  color: var(--text-3);
  font-size: 24px;
  line-height: 1;
}

/* More page — profile summary + quick tiles */
.more-profile-main {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}
.more-status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.more-quick-tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.more-quick-tile {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 16px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-mid);
  color: var(--text-2);
  font-size: var(--fs-label);
  font-weight: 500;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.more-quick-tile:hover { border-color: var(--accent-line); background: var(--bg-hover); color: var(--text); }
.more-quick-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
  color: var(--accent);
}
.more-quick-icon .nav-icon { width: 18px; height: 18px; opacity: 1; }
@media (max-width: 720px) {
  .more-quick-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  /* Journal summary cards should not become huge full-width blocks on phone. */
  #journal > .grid.g4 {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 10px;
  }
  #journal > .grid.g4 .metric {
    padding: 16px;
    min-height: 122px;
  }
  #journal > .grid.g4 .metric-value {
    font-size: var(--fs-lg) !important;
    line-height: 1.08;
    white-space: nowrap;
  }

  .cal-header {
    align-items: flex-start;
  }
  .cal-nav {
    width: 100%;
    display: grid;
    grid-template-columns: 44px minmax(0,1fr) 44px;
  }
  .cal-nav .cal-this-month {
    grid-column: 1 / -1;
    justify-self: start;
    margin-top: 8px;
  }
  .cal-month-label {
    text-align: center;
    align-self: center;
    font-size: var(--fs-h1);
  }
  .cal-summary {
    width: 100%;
    gap: 10px;
    flex-wrap: wrap;
    font-size: var(--fs-label);
  }
  .cal-summary strong {
    font-size: var(--fs-h2);
  }

  /* Native mobile calendar: compact day cards, not 8 squeezed columns. */
  .cal-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 10px;
  }
  .cal-dow,
  .cal-cell.empty {
    display: none;
  }
  .cal-cell {
    min-height: 116px;
    padding: 13px;
    border-radius: 16px;
  }
  .cal-day-num {
    font-size: var(--fs-label);
    margin-bottom: 10px;
  }
  .cal-pnl {
    font-size: var(--fs-h2);
    line-height: 1.1;
    white-space: nowrap;
  }
  .cal-meta {
    font-size: var(--fs-label);
    line-height: 1.45;
  }
  .cal-cell.week-cell {
    grid-column: 1 / -1;
    min-height: 82px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    text-align: left;
  }
  .cal-cell.week-cell .cal-day-num {
    margin: 0;
  }
  .cal-cell.week-cell .cal-pnl {
    font-size: 24px;
    margin: 0;
  }
  .cal-week-days {
    grid-column: 1 / -1;
    margin-top: 2px;
  }

  .more-quick-grid { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  #journal > .grid.g4 .metric-value { font-size: var(--fs-h2) !important; }
  .cal-cell { padding: 12px 10px; }
  .cal-pnl { font-size: var(--fs-md); }
}


/* ─── Mobile compact polish v4 ─────────────────────────
   Keeps the approved matte/native direction but fixes cramped pages,
   exchange selector sizing, and the oversized Read + Trade pill. */
.badge { white-space: nowrap; }
.connect-permission-badge { flex: 0 0 auto; }

@media (max-width: 860px) {
  .content { padding: 14px 12px 92px; }
  .topbar { height: 54px; padding: 0 14px; }
  .topbar-left { align-items: center; min-width: 0; }
  .topbar-left h2 { font-size: var(--fs-h3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-left p { display: none; }

  .card,
  .metric,
  .hero-card,
  .exchange-btn,
  .row-panel { border-radius: 16px; }
  .card-p { padding: 16px; }
  .hero-card { padding: 22px; }
  .hero-mode-row { margin-bottom: 14px; gap: 8px; }
  .hero-eyebrow { font-size: var(--fs-micro); }
  .hero-headline { font-size: 30px; line-height: 1.08; margin-bottom: 12px; }
  .hero-body { font-size: var(--fs-sm); line-height: 1.55; margin-bottom: 18px; }
  .hero-actions { gap: 8px; }
  .hero-actions.api-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
  .api-action-card { min-height: 78px; padding: 11px; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; border-radius: 14px; }
  .api-action-icon { width: 32px; height: 32px; border-radius: 10px; }
  .api-action-icon svg { width: 17px; height: 17px; }
  .api-action-copy { gap: 3px; }
  .api-action-copy strong { font-size: var(--fs-label); }
  .api-action-copy small { font-size: var(--fs-micro); line-height: 1.25; }
  .hero-actions .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
  .hero-actions .btn.danger { flex-basis: 100%; }

  .grid { gap: 10px; }
  .g-main,
  .g2,
  .g3,
  .g4,
  .form-grid { grid-template-columns: 1fr; }
  .metric { padding: 15px; }
  .metric-label { font-size: var(--fs-micro); letter-spacing: 0.075em; }
  .metric-value { font-size: var(--fs-h1); margin-top: 8px; }
  .metric-sub { font-size: var(--fs-caption); margin-top: 6px; }

  /* Compact section headers and prevent small pills becoming circular. */
  .section-head { gap: 10px; margin-bottom: 14px; align-items: flex-start; }
  .section-head > div { min-width: 0; }
  .section-title { font-size: var(--fs-body); }
  .section-sub { font-size: var(--fs-label); line-height: 1.45; }
  .section-head .badge { align-self: flex-start; padding: 5px 9px; font-size: var(--fs-caption); line-height: 1; white-space: nowrap; max-width: none; }
  .connect-permission-badge { margin-left: auto; }

  /* Exchange picker: exactly 2 columns on phones, compact native cards. */
  .exchange-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; margin-bottom: 16px; }
  .exchange-btn { min-height: 104px; padding: 14px 12px; display: flex; flex-direction: column; justify-content: space-between; }
  .exchange-btn .nav-icon { width: 17px; height: 17px; }
  .exchange-btn .exchange-logo { width: 24px; height: 24px; border-radius: 8px; }
  .exchange-btn strong { font-size: var(--fs-sm); margin-top: 8px; line-height: 1.2; }
  .exchange-btn span { font-size: var(--fs-caption); line-height: 1.25; }

  .field { font-size: var(--fs-caption); gap: 6px; }
  .input,
  select { padding: 10px 12px; font-size: var(--fs-sm); }
  .btn { min-height: 40px; padding: 9px 13px; border-radius: var(--radius-btn); font-size: var(--fs-label); }
  .seg { padding: 8px 12px; font-size: var(--fs-label); }

  .bot-row { padding: 12px; gap: 8px; }
  .coin-logo { width: 32px; height: 32px; font-size: var(--fs-micro); }
  .coin-name,
  .data-value { font-size: var(--fs-sm); }
  .coin-sub,
  .data-label { font-size: var(--fs-micro); }
  .row-panel { padding: 12px; gap: 9px; }
  .row-panel-title { font-size: var(--fs-sm); }
  .row-panel-sub { font-size: var(--fs-caption); line-height: 1.4; }
  .notice { padding: 12px 13px; font-size: var(--fs-label); line-height: 1.45; }

  .table th { font-size: var(--fs-micro); padding: 0 10px 10px; }
  .table td { padding: 11px 10px; font-size: var(--fs-label); }
  .price-display { font-size: 34px; margin: 10px 0; }

  .mobile-nav { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .mobile-nav .nav-btn { padding: 7px 6px; min-width: 0; font-size: var(--fs-micro); }
  .mobile-nav .nav-icon { width: 17px; height: 17px; }
}

@media (max-width: 480px) {
  /* Keep 2x2 exchange cards even on smaller screens. */
  .exchange-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .exchange-btn { min-height: 96px; padding: 12px 10px; }
  .exchange-btn strong { font-size: var(--fs-label); }
  .exchange-btn span { font-size: var(--fs-micro); }

  .content { padding-left: 10px; padding-right: 10px; }
  .card-p { padding: 15px; }
  .metric { padding: 14px; }
  .metric-value { font-size: var(--fs-lg); }
  .hero-headline { font-size: 28px; }
  .section-head { flex-wrap: nowrap; }
  .section-head .badge { font-size: var(--fs-micro); padding: 5px 8px; }
  .connect-permission-badge { transform: none; }
}

@media (max-width: 720px) {
  .live-map-head {
    align-items: flex-start;
  }
  .live-map-head .btn {
    min-height: 36px;
    padding: 8px 12px;
    white-space: nowrap;
  }
  #botFleet .bot-row {
    padding: 12px;
  }
  #botFleet .bot-row > .badge {
    min-height: 30px;
    padding: 6px 10px;
    font-size: var(--fs-caption);
    line-height: 1;
  }
}

@media (max-width: 520px) {
  .live-map-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
  }
  .live-map-head .section-sub {
    display: none;
  }
  #botFleet .bot-row {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "coin"
      "side"
      "score"
      "badge";
  }
  #botFleet .bot-row > .badge,
  #botFleet .bot-row > div:nth-child(3) {
    justify-self: stretch;
  }
}

@media (max-width: 360px) {
  .exchange-btn { min-height: 90px; padding: 10px 9px; }
  .exchange-btn strong { font-size: var(--fs-label); }
  .exchange-btn span { font-size: var(--fs-micro); }
  .btn { font-size: var(--fs-label); padding-left: 11px; padding-right: 11px; }
  .section-head .badge { display: none; }
}

/* ─── Crypto payment UI ───────────────────────────── */
.payment-method-list {
  display: grid;
  gap: 10px;
}
.payment-method-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-mid);
}
.payment-method-row b {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text);
  font-weight: 500;
}
.payment-method-row small {
  display: block;
  margin-top: 2px;
  color: var(--text-3);
  font-size: var(--fs-caption);
  font-family: var(--mono);
  overflow-wrap: anywhere;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,0.74);
  backdrop-filter: blur(14px);
}
.modal-backdrop.open { display: flex; }
.modal-card {
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  padding: 22px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text-2);
  background: var(--bg-mid);
  font-size: var(--fs-h2);
  line-height: 1;
}

.demo-settings-modal {
  width: min(560px, 100%);
}

.demo-settings-section {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.settings-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.settings-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}
.invoice-box {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}
.invoice-kv {
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--bg-mid);
}
.invoice-kv span {
  display: block;
  font-size: var(--fs-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 5px;
}
.invoice-kv b {
  display: block;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  overflow-wrap: anywhere;
}
.invoice-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
@media (max-width: 860px) {
  .payment-method-row { padding: 11px 12px; }
  .modal-card { padding: 18px; }
  .invoice-actions .btn { width: 100%; justify-content: center; }
}

/* ─── V7 weekly settlement UI ─────────────────────── */
.settlement-card { min-height: 100%; }
.settlement-amount {
  font-size: 46px;
  font-weight: 300;
  letter-spacing: -0.06em;
  font-family: var(--mono);
  color: var(--text);
  margin: 12px 0 10px;
}
.settlement-amount sup { font-size: var(--fs-h2); vertical-align: super; }
.settlement-amount span { font-size: var(--fs-body); color: var(--text-3); font-family: var(--font); letter-spacing: 0; }
.settlement-copy { color: var(--text-3); font-size: var(--fs-sm); line-height: 1.7; margin-bottom: 16px; }
.settlement-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.settlement-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.settlement-grid > div {
  border: 1px solid var(--line);
  background: var(--bg-mid);
  border-radius: var(--radius-lg);
  padding: 13px 14px;
}
.settlement-grid span {
  display: block;
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  margin-bottom: 6px;
}
.settlement-grid b {
  font-family: var(--mono);
  font-weight: 500;
  font-size: var(--fs-md);
  color: var(--text);
}
.settlement-due { border-color: var(--amber-line); }
@media (max-width: 860px) {
  .settlement-amount { font-size: 34px; }
  .settlement-grid { grid-template-columns: 1fr; }
  .settlement-actions .btn { flex: 1; justify-content: center; }
}

@media (max-width: 860px) {
  .bots-live-grid { grid-template-columns: 1fr; }
  .scan-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scan-meta div:nth-child(2) { border-right: 0; padding-right: 0; }
  .market-pulse-row { grid-template-columns: minmax(115px, 1fr) auto auto; }
  .market-pulse-row .badge { display: none; }
  .trade-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .scan-stage { padding: 16px; }
  .scan-stage-head { gap: 10px; }
  .scan-meta { gap: 10px; }
  .scan-meta div { padding-right: 8px; }
  .scan-meta strong { font-size: var(--fs-caption); }
  .market-pulse-row { grid-template-columns: minmax(100px, 1fr) auto; gap: 8px; }
  .market-change { display: none; }
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trade-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Compact mobile metrics and journal layout.
   This intentionally comes late so it wins over older mobile fallbacks. */
@media (max-width: 860px) {
  #dashboard .g-main > .grid,
  #dashboard > .grid.g4,
  #bots > .grid.g3,
  #trades > .grid.g4,
  #performance > .grid.g4,
  #referral > .grid.g3,
  #billing > .grid.g3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #journal > .grid.g4 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .metric {
    min-height: 104px;
    padding: 13px;
  }

  .metric-label {
    font-size: var(--fs-micro);
    line-height: 1.2;
  }

  .metric-value,
  #dashboard .metric-value,
  #bots .metric-value,
  #trades .metric-value,
  #journal .metric-value,
  #performance .metric-value,
  #referral .metric-value,
  #billing .metric-value {
    font-size: clamp(18px, 4.9vw, 22px) !important;
    letter-spacing: 0;
    line-height: 1.05;
    overflow-wrap: anywhere;
  }

  .metric-sub {
    color: var(--text-2);
    font-size: var(--fs-caption);
    line-height: 1.3;
  }

  .cal-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .cal-cell {
    min-height: 92px;
    padding: 11px;
    border-radius: 14px;
  }

  .cal-cell.week-cell {
    grid-column: 1 / -1;
    min-height: 70px;
  }

  .cal-day-num {
    margin-bottom: 8px;
  }

  .cal-pnl {
    font-size: var(--fs-h3);
    letter-spacing: 0;
  }

  .cal-meta {
    font-size: var(--fs-micro);
  }

  .trade-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .trade-detail-metric {
    min-height: 62px;
    padding: 9px;
  }

  .trade-detail-metric span {
    font-size: var(--fs-micro);
    line-height: 1.2;
  }

  .trade-detail-metric strong {
    font-size: clamp(15px, 4.4vw, 18px);
    letter-spacing: 0;
    overflow-wrap: anywhere;
  }

  .trade-detail-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trade-detail-list span,
  .trade-detail-note {
    border-radius: 8px;
    padding: 6px 8px;
    font-size: var(--fs-caption);
  }
}

@media (max-width: 420px) {
  #journal > .grid.g4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 340px) {
  #dashboard .g-main > .grid,
  #dashboard > .grid.g4,
  #bots > .grid.g3,
  #trades > .grid.g4,
  #performance > .grid.g4,
  #referral > .grid.g3,
  #billing > .grid.g3,
  .trade-detail-grid,
  .trade-detail-list {
    grid-template-columns: 1fr;
  }
}

/* ─── Compact public Why / trade detail panel ────────────── */
.sc-why-panel {
  width: 100%;
  max-width: 100%;
  margin: 10px 0 12px;
}

.trade-detail-row td {
  padding: 0 0 10px;
  overflow: visible;
}

.trade-detail-panel {
  width: min(100%, calc(100vw - var(--sidebar-w) - 54px));
  max-width: 920px;
  box-sizing: border-box;
  padding: 10px;
  gap: 8px;
  overflow: hidden;
}

.sc-why-panel .trade-detail-panel {
  width: 100%;
  max-width: 100%;
}

.trade-detail-head {
  gap: 10px;
  align-items: flex-start;
}

.trade-detail-head .badge {
  flex: 0 0 auto;
  font-size: var(--fs-micro);
  padding: 5px 9px;
}

.trade-detail-title {
  font-size: var(--fs-sm);
  line-height: 1.25;
}

.trade-detail-sub {
  font-size: var(--fs-caption);
  line-height: 1.35;
}

.trade-detail-label {
  font-size: var(--fs-micro);
  letter-spacing: 0.075em;
  margin-bottom: 6px;
}

.trade-detail-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.trade-detail-list span,
.trade-detail-note {
  border-radius: 8px;
  padding: 6px 8px;
  font-size: var(--fs-caption);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.trade-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.trade-detail-metric {
  min-height: 54px;
  padding: 8px;
  border-radius: 8px;
}

.trade-detail-metric span {
  font-size: var(--fs-micro);
  line-height: 1.2;
  margin-bottom: 4px;
}

.trade-detail-metric strong {
  font-size: var(--fs-sm);
  line-height: 1.25;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.trade-detail-metric--sl {
  border-color: var(--red-line);
  background: var(--red-bg);
}

.trade-detail-metric--sl span,
.trade-detail-metric--sl strong {
  color: var(--red);
}

.trade-detail-metric--tp {
  border-color: var(--green-line);
  background: var(--green-bg);
}

.trade-detail-metric--tp span,
.trade-detail-metric--tp strong {
  color: var(--green);
}

.strategy-tag {
  display: inline-flex;
  margin-left: 8px;
  vertical-align: middle;
}

:root[data-theme="light"] #journal .metric,
:root[data-theme="light"] #journal .card,
:root[data-theme="light"] #journal .cal-cell {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

:root[data-theme="light"] #journal .metric-sub,
:root[data-theme="light"] #journal .cal-meta,
:root[data-theme="light"] #journal .cal-day-num {
  color: var(--text-2);
}

:root[data-theme="light"] #journal .cal-cell.win {
  background: color-mix(in srgb, var(--gain) 9%, var(--surface));
  border-color: var(--green-line);
}

:root[data-theme="light"] #journal .cal-cell.loss {
  background: color-mix(in srgb, var(--loss) 8%, var(--surface));
  border-color: var(--red-line);
}

@media (max-width: 860px) {
  .trade-detail-panel {
    width: min(100%, calc(100vw - 28px));
    padding: 9px;
  }

  .trade-detail-metric {
    min-height: 50px;
    padding: 7px 8px;
  }

  .trade-detail-metric strong {
    font-size: clamp(12.5px, 3.4vw, 14.5px);
  }

  .trade-detail-list span,
  .trade-detail-note {
    font-size: var(--fs-micro);
  }
}

@media (max-width: 520px) {
  .trade-detail-list {
    grid-template-columns: 1fr;
  }

  .trade-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trade-detail-head {
    flex-direction: column;
  }
}


/* Active trade detail visibility + compact mobile two-column layout */
.trade-detail-row .trade-detail-panel {
  position: sticky;
  left: 0;
}

@media (max-width: 860px) {
  #activeTrades th {
    font-size: var(--fs-micro);
    letter-spacing: 0.075em;
  }

  #activeTrades td {
    font-size: var(--fs-sm);
  }

  #activeTrades .trade-actions .icon-btn,
  #scWhyWrap .icon-btn {
    min-width: 40px;
    height: 32px;
    padding: 0 11px;
    font-size: var(--fs-label);
    line-height: 1;
  }
}

@media (max-width: 520px) {
  .trade-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px;
  }

  .trade-detail-metric {
    min-height: 50px;
  }
}

@media (max-width: 360px) {
  .trade-detail-grid {
    gap: 6px;
  }

  .trade-detail-metric {
    padding: 7px;
  }

  .trade-detail-metric strong {
    font-size: var(--fs-label);
  }
}

/* ─── Super chart TradingView-style layout refresh ───────────── */
.sc-card {
  padding: 16px 18px 14px;
}
.sc-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.sc-symbol-rail,
.sc-tf-rail,
.sc-layer-rail {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: thin;
}
.sc-symbol-rail::-webkit-scrollbar,
.sc-tf-rail::-webkit-scrollbar,
.sc-layer-rail::-webkit-scrollbar { height: 4px; }
.sc-symbol-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 11px;
  border-radius: 12px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}
.sc-symbol-chip strong {
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.01em;
}
.sc-symbol-chip span {
  color: var(--text-3);
  font-size: var(--fs-caption);
  font-family: "DM Mono", monospace;
}
.sc-symbol-chip.active {
  border-color: var(--line-accent);
  background: var(--accent-dim);
  color: var(--accent);
}
.sc-symbol-chip.live-trade {
  border-color: var(--green-line);
  background: rgba(67, 181, 116, 0.13);
  color: var(--green);
}
.sc-symbol-chip.live-trade.active {
  box-shadow: 0 0 0 1px rgba(120, 214, 154, 0.22) inset;
}
.sc-card .seg {
  flex: 0 0 auto;
  padding: 7px 11px;
  min-height: 32px;
  border-radius: 12px;
  font-size: var(--fs-label);
  white-space: nowrap;
}
.sc-chart-stage {
  position: relative;
  width: 100%;
  height: clamp(520px, 62vh, 760px);
  min-height: 520px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-mid);
  border: 1px solid rgba(255, 255, 255, 0.055);
}
.sc-chart-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
.sc-legend {
  margin: 10px 0 0;
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text-3);
  font-size: var(--fs-label);
}
.sc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sc-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 4px;
}
.sc-legend i.entry { background: #decf99; }
.sc-legend i.sl { background: #ee8387; }
.sc-legend i.tp { background: #78d69a; }
.sc-linked-card { padding: 18px; }
.sc-linked-head {
  gap: 12px;
  align-items: flex-start;
}
.sc-linked-head > div { min-width: 0; }
#scWhyWrap {
  margin-left: auto;
  padding-right: 4px;
  flex: 0 0 auto;
}
#scWhyWrap .icon-btn {
  min-width: 54px;
  height: 38px;
  border-radius: 999px;
  font-size: var(--fs-sm);
  font-weight: 700;
}
.sc-trade-fields {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
}
.sc-trade-fields .field > span {
  font-size: var(--fs-caption);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.sc-field-entry > span { color: var(--amber); }
.sc-field-sl > span { color: var(--red); }
.sc-field-tp > span { color: var(--green); }
.sc-trade-fields .input {
  min-height: 44px;
  font-size: var(--fs-body);
  border-radius: 12px;
}
.sc-field-entry .input { border-color: rgba(222, 207, 153, 0.28); }
.sc-field-sl .input { border-color: rgba(238, 131, 135, 0.30); }
.sc-field-tp .input { border-color: rgba(120, 214, 154, 0.30); }

@media (min-width: 1180px) {
  .sc-card { padding: 18px 20px 16px; }
  .sc-chart-stage { height: min(760px, calc(100vh - 235px)); }
}

@media (max-width: 860px) {
  .sc-card { padding: 15px 14px 13px; }
  .sc-toolbar { gap: 9px; }
  .sc-symbol-chip {
    min-height: 33px;
    padding: 7px 10px;
    border-radius: 12px;
  }
  .sc-symbol-chip strong { font-size: var(--fs-caption); }
  .sc-symbol-chip span { font-size: var(--fs-micro); }
  .sc-card .seg {
    padding: 6px 10px;
    min-height: 31px;
    font-size: var(--fs-caption);
  }
  .sc-chart-stage {
    height: clamp(500px, 66vh, 680px);
    min-height: 500px;
    border-radius: 16px;
  }
  .sc-linked-card { padding: 15px; }
  .sc-linked-head {
    flex-wrap: nowrap;
  }
  #scWhyWrap .icon-btn {
    min-width: 48px;
    height: 34px;
    font-size: var(--fs-label);
  }
  .sc-trade-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
  }
}

@media (max-width: 560px) {
  .sc-card {
    padding: 14px 12px 12px;
    border-radius: 20px;
  }
  .sc-chart-stage {
    height: 600px;
    min-height: 600px;
  }
  .sc-symbol-rail,
  .sc-tf-rail,
  .sc-layer-rail {
    gap: 7px;
    margin-left: -2px;
    padding-inline: 2px;
  }
  .sc-symbol-chip strong { font-size: var(--fs-caption); }
  .sc-symbol-chip span { display: none; }
  .sc-card .seg {
    padding: 6px 9px;
    font-size: var(--fs-caption);
  }
  .sc-legend {
    gap: 10px;
    font-size: var(--fs-caption);
  }
  .sc-linked-head {
    align-items: flex-start;
  }
  .sc-linked-head .section-title { font-size: var(--fs-body); }
  .sc-linked-head .section-sub { font-size: var(--fs-caption); }
  #scWhyWrap {
    padding-right: 0;
    margin-left: 8px;
  }
  #scWhyWrap .icon-btn {
    min-width: 44px;
    height: 32px;
    padding: 0 12px;
  }
  .sc-trade-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .sc-trade-fields .input {
    min-height: 42px;
    padding: 9px 11px;
    font-size: var(--fs-sm);
  }
}

@media (max-width: 360px) {
  .sc-chart-stage {
    height: 560px;
    min-height: 560px;
  }
  .sc-symbol-chip {
    padding: 6px 9px;
  }
  .sc-trade-fields {
    gap: 7px;
  }
}

/* ─── Super chart polish: price-scale controls, cleaner rails, floating trade strip ─── */
.sc-control-rail {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
}
.sc-control-rail::-webkit-scrollbar,
.sc-symbol-rail::-webkit-scrollbar,
.sc-tf-rail::-webkit-scrollbar,
.sc-layer-rail::-webkit-scrollbar { display: none; }
.sc-symbol-rail,
.sc-tf-rail,
.sc-layer-rail { scrollbar-width: none; }
.sc-control-rail .sc-tf-rail,
.sc-control-rail .sc-layer-rail {
  flex: 0 0 auto;
  overflow: visible;
  padding-bottom: 0;
}
.sc-card .seg {
  padding: 6px 10px;
  min-height: 30px;
  border-radius: 10px;
  font-size: var(--fs-caption);
}
.sc-chart-stage {
  height: clamp(620px, 72vh, 880px);
  min-height: 620px;
}
.sc-linked-card {
  scroll-margin-bottom: 120px;
}
.sc-linked-action-row {
  display: flex;
  justify-content: flex-end;
  margin: 10px 0 0;
}
.sc-linked-action-row #scWhyWrap {
  margin-left: 0;
  padding-right: 0;
}
.sc-trade-head {
  align-items: center;
  padding: 8px 0 2px;
}
#scFloatingTrade {
  display: none;
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 58;
  border: 1px solid rgba(120, 214, 154, 0.28);
  background: rgba(16, 24, 20, 0.92);
  color: var(--text);
  border-radius: 16px;
  padding: 10px 13px;
  box-shadow: 0 18px 42px rgba(0,0,0,.36);
  backdrop-filter: blur(18px);
  text-align: left;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#scFloatingTrade.show { display: none; }
#scFloatingTrade strong {
  font-size: var(--fs-sm);
  letter-spacing: 0.01em;
}
#scFloatingTrade span {
  font-family: "DM Mono", monospace;
  font-weight: 700;
  font-size: var(--fs-label);
}
#scFloatingTrade .positive { color: var(--green); }
#scFloatingTrade .negative { color: var(--red); }

@media (min-width: 1180px) {
  .sc-chart-stage { height: min(880px, calc(100vh - 178px)); }
}

@media (max-width: 860px) {
  .sc-chart-stage {
    height: calc(100vh - 250px);
    min-height: 610px;
  }
  .sc-card .seg {
    padding: 6px 9px;
    min-height: 30px;
    font-size: var(--fs-caption);
  }
  .sc-toolbar { gap: 8px; margin-bottom: 10px; }
  #scFloatingTrade.show { display: flex; }
  .sc-linked-card { margin-bottom: 96px; }
}

@media (max-width: 560px) {
  .sc-card { padding: 12px 10px 11px; }
  .sc-chart-stage {
    height: calc(100vh - 225px);
    min-height: 590px;
    border-radius: 16px;
  }
  .sc-control-rail { gap: 7px; margin-left: -1px; padding-inline: 1px; }
  .sc-card .seg { padding: 5px 8px; min-height: 29px; font-size: var(--fs-micro); }
  .sc-trade-head {
    position: sticky;
    bottom: calc(94px + env(safe-area-inset-bottom));
    z-index: 4;
    padding: 10px 11px;
    margin: 0 -4px 12px !important;
    border: 1px solid rgba(120,214,154,.16);
    border-radius: 14px;
    background: rgba(15, 20, 18, 0.94);
    box-shadow: 0 14px 34px rgba(0,0,0,.28);
  }
  .sc-trade-head .section-title { font-size: var(--fs-sm); }
  .sc-trade-head .section-sub { font-size: var(--fs-micro); }
  .sc-linked-action-row { justify-content: flex-start; }
  #scFloatingTrade { bottom: calc(78px + env(safe-area-inset-bottom)); }
}

@media (max-width: 360px) {
  .sc-chart-stage {
    height: calc(100vh - 220px);
    min-height: 560px;
  }
}

/* ─── Super chart UX fix: cleaner mobile scale + close control ───────────── */
.sc-chart-close-trade {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--loss) 36%, transparent);
  background: var(--loss-dim);
  color: var(--loss);
  font-size: var(--fs-lg);
  line-height: 1;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(0,0,0,.34);
  backdrop-filter: blur(14px);
}
.sc-chart-close-trade:hover {
  border-color: rgba(238, 131, 135, 0.64);
  background: rgba(70, 26, 30, 0.92);
}
.sc-chart-close-trade[hidden] { display: none !important; }

@media (max-width: 860px) {
  .sc-chart-stage {
    height: clamp(500px, calc(100vh - 255px), 690px);
    min-height: 500px;
  }
}
@media (max-width: 560px) {
  .sc-chart-stage {
    height: clamp(470px, calc(100vh - 238px), 640px);
    min-height: 470px;
  }
  .sc-chart-close-trade {
    right: 10px;
    top: 10px;
    width: 31px;
    height: 31px;
    font-size: var(--fs-h2);
  }
}
@media (max-width: 360px) {
  .sc-chart-stage {
    height: clamp(440px, calc(100vh - 226px), 590px);
    min-height: 440px;
  }
}

/* ─── Super chart requested cleanup: close control belongs in linked trade panel ─── */
.sc-chart-close-trade { display: none !important; }
.sc-trade-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.sc-trade-actions .icon-btn.danger {
  min-width: 76px;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: var(--fs-label);
  font-weight: 800;
  letter-spacing: 0.02em;
}
@media (max-width: 560px) {
  .sc-trade-actions {
    justify-content: flex-start;
    margin-top: 10px;
  }
  .sc-trade-actions .icon-btn.danger {
    width: 100%;
    height: 40px;
  }
}


/* ─── Super chart edge-to-edge canvas space ─────────────────────────────
   Removes the extra card/plot borders and gives the chart more usable width,
   especially on phones where the price scale was taking too much space. */
#chart > .grid:first-of-type {
  margin-left: -6px;
  margin-right: -6px;
}
#chart .sc-card {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0 !important;
  overflow: visible;
}
#chart .sc-toolbar,
#chart .sc-legend {
  padding-left: 6px;
  padding-right: 6px;
}
#chart .sc-chart-stage {
  border: 0;
  border-radius: 0;
  background: var(--bg-mid);
}
#chart .sc-chart-stage canvas {
  border-radius: 0;
}

@media (max-width: 860px) {
  #chart > .grid:first-of-type {
    margin-left: -12px;
    margin-right: -12px;
  }
  #chart .sc-toolbar,
  #chart .sc-legend {
    padding-left: 12px;
    padding-right: 12px;
  }
  #chart .sc-chart-stage {
    height: clamp(480px, calc(100vh - 218px), 660px);
    min-height: 480px;
  }
}

@media (max-width: 560px) {
  #chart .sc-toolbar {
    margin-bottom: 8px;
  }
  #chart .sc-chart-stage {
    height: clamp(460px, calc(100vh - 214px), 625px);
    min-height: 460px;
  }
  #chart .sc-legend {
    margin-top: 8px;
  }
}

@media (max-width: 360px) {
  #chart .sc-chart-stage {
    height: clamp(435px, calc(100vh - 204px), 585px);
    min-height: 435px;
  }
}

/* ─── Super chart mobile scroll + linked trade cleanup ────────────────────
   Removes the duplicate floating strip and lower outer card. The linked trade
   summary itself is the sticky footer handle, with a small scroll grip below
   the chart so users can comfortably swipe down on phones. */
#scFloatingTrade,
#scFloatingTrade.show {
  display: none !important;
  pointer-events: none !important;
}
#chart .grid + .grid {
  margin-top: 8px !important;
}
#chart .sc-linked-card {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
  padding: 0 6px calc(108px + env(safe-area-inset-bottom)) !important;
}
#chart #scTradePanel {
  position: relative;
}
#chart .sc-trade-head {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-hi);
  box-shadow: 0 10px 28px rgba(20, 37, 66, .10);
  padding: 12px 14px;
  margin: 0 0 14px !important;
}
#chart .sc-trade-head .section-title { color: var(--text); }
#chart .sc-trade-head .section-sub { color: var(--text-3); }
.sc-scroll-grip {
  display: none;
}

@media (max-width: 860px) {
  #chart .sc-chart-stage {
    height: clamp(380px, 55svh, 540px) !important;
    min-height: 380px !important;
  }
  #chart .sc-scroll-grip {
    display: flex;
    height: 30px;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
  }
  #chart .sc-scroll-grip::before {
    content: "";
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(238,235,226,0.16);
  }
  #chart .sc-trade-head {
    position: sticky;
    bottom: calc(84px + env(safe-area-inset-bottom));
    z-index: 62;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  #chart .sc-linked-card {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
}

@media (max-width: 560px) {
  #chart .sc-chart-stage {
    height: clamp(350px, 52svh, 485px) !important;
    min-height: 350px !important;
  }
  #chart .sc-scroll-grip {
    height: 34px;
  }
  #chart .sc-trade-head {
    bottom: calc(78px + env(safe-area-inset-bottom));
    padding: 12px 13px;
    border-radius: 16px;
  }
  #chart .sc-trade-head .section-title {
    font-size: var(--fs-sm);
  }
  #chart .sc-trade-head .section-sub {
    font-size: var(--fs-micro);
  }
  #chart .sc-linked-card {
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
}

@media (max-width: 360px) {
  #chart .sc-chart-stage {
    height: clamp(330px, 50svh, 440px) !important;
    min-height: 330px !important;
  }
}

/* ─── Super chart: remove bottom legend/grip and give that space back to chart ─── */
#chart .sc-legend,
#chart .sc-scroll-grip {
  display: none !important;
}
#chart .sc-chart-stage {
  height: clamp(650px, calc(72vh + 36px), 920px);
}
@media (max-width: 860px) {
  #chart .sc-chart-stage {
    height: clamp(420px, calc(55svh + 40px), 590px) !important;
    min-height: 420px !important;
  }
}
@media (max-width: 560px) {
  #chart .sc-chart-stage {
    height: clamp(390px, calc(52svh + 44px), 535px) !important;
    min-height: 390px !important;
  }
}
@media (max-width: 360px) {
  #chart .sc-chart-stage {
    height: clamp(365px, calc(50svh + 42px), 490px) !important;
    min-height: 365px !important;
  }
}

/* V101: Super chart linked-position panel stays compact and left-aligned. */
#chart .sc-trade-fields {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: start;
}
#chart .sc-trade-actions,
#chart .sc-linked-action-row {
  justify-content: flex-start;
}
#chart .sc-trade-actions {
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
#chart .sc-linked-action-row {
  margin-top: 8px;
}
#chart #scWhyWrap {
  margin-left: 0;
  padding-right: 0;
}
#chart #scWhyWrap .icon-btn {
  margin-left: 0;
}
#chart .sc-trade-actions .btn,
#chart .sc-trade-actions .badge,
#chart #scWhyWrap .icon-btn {
  flex: 0 0 auto;
}
@media (max-width: 420px) {
  #chart .sc-trade-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 340px) {
  #chart .sc-trade-fields {
    grid-template-columns: 1fr;
  }
}

/* ─── Launch-readiness polish: bots, referrals, history ───────── */
.referral-policy-note {
  margin-top: 10px;
  color: var(--text-3);
  font-size: var(--fs-label);
  line-height: 1.55;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-mid);
}

.trade-history-groups {
  display: grid;
  gap: 10px;
}

.trade-history-head { align-items: flex-start; }
.trade-history-title-block { min-width: 0; }

.trade-history-overview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-start;
  margin-top: 8px;
}
.trade-history-overview span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-mid);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 650;
}
.trade-history-overview strong { color: var(--text); margin-right: 4px; }

.trade-history-day {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-mid);
  overflow: hidden;
}

.trade-history-day summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 42px 13px 15px;
  color: var(--text);
  font-weight: 500;
}

.trade-history-day summary::-webkit-details-marker { display: none; }

.trade-history-day summary::after {
  content: '›';
  position: absolute;
  top: 13px;
  right: 15px;
  color: var(--text-3);
  transform: rotate(90deg);
  transition: transform 0.16s ease;
}

.trade-history-day:not([open]) summary::after { transform: rotate(0deg); }

.trade-history-day summary small {
  margin-left: auto;
  color: var(--text-3);
  font-weight: 400;
  font-size: var(--fs-label);
  text-align: right;
}

.trade-history-journal-btn {
  display: flex;
  width: fit-content;
  margin: 12px auto 0;
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-dim);
}

.trade-history-inner {
  border-top: 1px solid var(--line);
  border-radius: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}
/* Force the table wider than the screen so it scrolls (swipes) instead of squishing. */
.trade-history-inner .table { min-width: 760px; }
.trade-history-inner th, .trade-history-inner td { white-space: nowrap; }
.trade-history-mobile-list { display: none; }

@media (max-width: 860px) {
  #trades .trade-history-overview { justify-content: flex-start; }
  .trade-history-day summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 6px;
    padding: 11px 38px 11px 12px;
  }
  .trade-history-day summary::after { top: 11px; right: 12px; }
  .trade-history-day summary > span { font-size: var(--fs-sm); }
  .trade-history-day summary small { margin-left: 0; font-size: 10px; line-height: 1.35; text-align: left; }
  .trade-history-journal-btn { width: 100%; justify-content: center; }
  .trade-history-inner { display: none; }
  .trade-history-mobile-list {
    display: grid;
    border-top: 1px solid var(--line);
  }
  .trade-history-mobile-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "main result" "time time";
    gap: 8px 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-mid);
  }
  .trade-history-mobile-row:last-child { border-bottom: 0; }
  .thm-main { grid-area: main; min-width: 0; }
  .thm-main > strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: var(--fs-sm);
    line-height: 1.2;
  }
  .thm-tags {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
  }
  .thm-side,
  .thm-tags .strategy-source-tag {
    display: inline-flex;
    align-items: center;
    min-height: 16px;
    padding: 1px 5px;
    border-radius: 999px;
    font-size: 8.5px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: .025em;
    text-transform: uppercase;
  }
  .thm-side.short { color: var(--loss); border: 1px solid var(--red-line); background: var(--loss-dim); }
  .thm-side.long { color: var(--gain); border: 1px solid var(--green-line); background: var(--gain-dim); }
  .thm-result {
    grid-area: result;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
  }
  .thm-pnl { font-family: var(--mono); font-size: var(--fs-sm); font-weight: 750; white-space: nowrap; }
  .thm-result-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
  }
  .trade-history-mobile-row.win .thm-result-icon { color: var(--gain); background: var(--gain-dim); border: 1px solid var(--green-line); }
  .trade-history-mobile-row.loss .thm-result-icon { color: var(--loss); background: var(--loss-dim); border: 1px solid var(--red-line); }
  .trade-history-mobile-row.flat .thm-result-icon,
  .trade-history-mobile-row.pending .thm-result-icon { color: var(--text-3); background: var(--surface-hi); border: 1px solid var(--line); }
  .thm-time {
    grid-area: time;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding-top: 7px;
    border-top: 1px solid var(--line);
  }
  .thm-time span { min-width: 0; }
  .thm-time i {
    display: block;
    color: var(--text-3);
    font-size: 8px;
    font-style: normal;
    font-weight: 700;
    letter-spacing: .08em;
    line-height: 1;
    text-transform: uppercase;
  }
  .thm-time b {
    display: block;
    margin-top: 3px;
    color: var(--text-2);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 650;
    white-space: nowrap;
  }
}

/* Session target stays full-width above Live Positions. Session Intelligence is
   a separate full-width card below Live Positions in the document flow. */
.session-target-section {
  margin-top: 14px;
  min-width: 0;
}
#sessionTargetProgress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 12px;
  min-width: 0;
}
#sessionTargetProgress > .dtp-card {
  margin-top: 0 !important;
}
.session-target-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 196px;
  padding: 16px;
  overflow: hidden;
}
.session-target-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--gain);
  opacity: .8;
}
.session-target-card.is-off::before { background: var(--line-strong); opacity: .65; }
.session-target-card-body { flex: 1 1 auto; min-width: 0; }
.session-target-card .dtp-head { align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.session-target-card .dtp-title-line { gap: 7px; flex-wrap: wrap; }
.session-target-card .dtp-title { font-size: 13.5px; line-height: 1.25; }
.session-target-card .session-state-pill { min-height: 21px; padding: 2px 7px; border-radius: 7px; font-size: 9px; }
.session-target-card .dtp-status { max-width: 48%; font-size: 11px; line-height: 1.3; text-align: right; }
.session-target-card .dtp-track { height: 8px; }
.session-target-card .dtp-labels { gap: 8px; margin-top: 6px; font-size: 10.5px; }
.session-target-card .dtp-labels span:last-child { text-align: right; }
.session-target-card .session-breakdown { margin-top: 5px; font-size: 10.5px; line-height: 1.35; }
.session-target-card .sc-alloc-note { font-size: 11px; line-height: 1.4; }
.session-target-card .session-summary-row { gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.session-target-card .session-summary-copy { gap: 6px; flex-wrap: wrap; font-size: 11px; line-height: 1.3; white-space: normal; }
.session-target-card .session-summary-copy b { font-size: 12px; }
.session-target-card .session-saved-label { font-size: 11px; }
.session-target-card .session-edit-btn { width: 30px; min-width: 30px; height: 30px; border-radius: 9px; }
.session-target-card .session-edit-btn svg { width: 14px; height: 14px; }
@media (max-width: 1120px) {
  #sessionTargetProgress { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .session-target-section { margin-top: 10px; }
  #sessionTargetProgress { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .session-target-card { min-height: 0; padding: 12px 12px 11px; border-radius: 16px; }
  .session-target-card .dtp-head { align-items: center; margin-bottom: 8px; }
  .session-target-card .dtp-title { font-size: 13px; }
  .session-target-card .dtp-status { max-width: 52%; font-size: 10.5px; }
  .session-target-card .dtp-track { height: 7px; }
  .session-target-card .dtp-labels { margin-top: 5px; font-size: 10px; }
  .session-target-card .session-breakdown { font-size: 10px; }
  .session-target-card .session-summary-row { margin-top: 8px; padding-top: 8px; }
  .session-target-card .session-summary-copy { gap: 5px; font-size: 10.5px; }
  .session-target-card .session-summary-copy b { font-size: 11.5px; }
  .session-target-card .session-saved-label { font-size: 10.5px; }
  .session-target-card .session-edit-btn { width: 28px; min-width: 28px; height: 28px; }
}
.session-intelligence-card {
  overflow: hidden;
  background:
    radial-gradient(circle at 92% 0%, rgba(37, 99, 235, .11), transparent 34%),
    var(--surface);
  border-color: var(--border);
}
.session-intelligence-card.is-empty .sie-metrics,
.session-intelligence-card.is-empty .sie-track,
.session-intelligence-card.is-empty .sie-legend,
.session-intelligence-card.is-empty .sie-session-count { display: none; }
.session-intelligence-card.is-empty .sie-thinking { margin-top: 10px; }
.sie-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.sie-head-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.sie-session-count {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--text-2);
  background: var(--surface-hi);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}
.sie-phase {
  flex: 0 0 auto;
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .055em;
  color: var(--accent-strong);
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
}
.sie-phase.harvest { color: var(--amber); background: var(--amber-dim); border-color: var(--amber-line); }
.sie-phase.finish { color: var(--gain); background: var(--gain-dim); border-color: var(--green-line); }
.sie-phase.protected { color: var(--accent-strong); background: var(--accent-dim); border-color: var(--accent-line); }
.sie-thinking {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid #6f98f8;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-hi));
}
.sie-thinking-text { color: var(--text); font-size: 12px; line-height: 1.42; }
.sie-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.sie-metric {
  min-width: 0;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
}
.sie-metric span, .sie-metric small { display: block; color: var(--text-2); }
.sie-metric span { font-size: 10px; text-transform: uppercase; letter-spacing: .055em; }
.sie-metric strong { display: block; margin-top: 4px; color: var(--text); font-size: 17px; font-variant-numeric: tabular-nums; }
.sie-metric small { margin-top: 3px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sie-track {
  position: relative;
  height: 9px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-hi);
}
.sie-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb 0 40%, #f59e0b 40% 70%, #16a45c 70%);
  transition: width .35s ease;
}
.sie-floor-marker {
  position: absolute;
  z-index: 2;
  top: -2px;
  bottom: -2px;
  width: 2px;
  left: 0;
  background: #6d28d9;
  box-shadow: 0 0 0 2px rgba(109,40,217,.12);
  transition: left .35s ease;
}
.sie-legend { display: flex; justify-content: space-between; margin-top: 7px; color: var(--text-2); font-size: 11px; }
@media (max-width: 760px) {
  .sie-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sie-head { flex-direction: row; align-items: flex-start; gap: 8px; }
  .sie-head-status { justify-content: flex-end; gap: 5px; }
  .sie-session-count { padding: 4px 7px; font-size: 9px; }
  .sie-thinking { padding: 9px 10px; }
}
/* Momentum card: keep the 4 stats as a 2×2 grid at every width. */
#momentumCard .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#momentumCard .metric { padding: 14px 15px; }

/* Scale the "Close all" action down a touch. */
#closeAllTradesBtn { padding: 7px 13px; min-height: 32px; font-size: var(--fs-label); }
#shareProfitCardBtn {
  padding: 7px 13px;
  min-height: 32px;
  font-size: var(--fs-label);
  color: var(--blue);
  border-color: var(--blue-line);
  background: var(--blue-bg);
}
#shareProfitCardBtn:disabled {
  opacity: 0.65;
  cursor: wait;
}
.profit-share-render-host {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 560px;
  pointer-events: none;
  z-index: -1;
}
.live-positions-head { align-items: flex-start; }
.live-position-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.live-positions-total {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  margin-left: auto;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-mid);
  white-space: nowrap;
}
.live-positions-total[hidden] { display: none !important; }
.live-positions-total span {
  color: var(--text-3);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.live-positions-total strong {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  font-weight: 800;
}
.daily-target-mini {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-mid);
}
.daily-target-mini[hidden] { display: none !important; }
.daily-target-mini.is-on {
  border-color: var(--green-line);
  background: var(--green-bg);
}
.daily-target-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 8px;
  color: var(--text-2);
  font-size: var(--fs-label);
  font-weight: 700;
  white-space: nowrap;
}
.daily-target-toggle input {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
}
.daily-target-mini.is-on .daily-target-toggle { color: var(--green); }
.daily-target-percent-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-hi);
  color: var(--text-2);
  font-size: var(--fs-label);
  font-weight: 700;
}
.daily-target-percent-field input {
  width: 64px;
  height: 26px;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-family: var(--font-data);
  font-size: var(--fs-label);
}
.session-field-name {
  color: var(--text-3);
  font-size: var(--fs-micro);
  font-weight: 600;
  white-space: nowrap;
}
.daily-target-save-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: var(--fs-label);
}
.daily-target-status {
  margin: 14px 0 0;
  padding: 13px 15px;
  border: 1px solid var(--green-line);
  border-radius: 12px;
  background: var(--green-bg);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.daily-target-status[hidden] { display: none !important; }
.daily-target-status strong {
  color: var(--green);
  font-weight: 800;
}
.daily-target-status .muted {
  color: var(--text-2);
}

/* In-app confirm/prompt dialog (replaces native confirm/alert/prompt). */
.app-dialog-card { max-width: 440px; width: calc(100% - 36px); }
.app-dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.app-dialog-actions .btn { min-width: 100px; justify-content: center; }
.app-dialog-field .input { margin-top: 4px; }

/* Active-trades ACTIONS buttons: auto-width chips that fit their labels, consistent + clean. */
.trade-actions { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.trade-actions .icon-btn,
#activeTrades .trade-actions .icon-btn {
  width: auto;
  min-width: 0;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: var(--fs-caption);
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.trade-actions .icon-btn:hover {
  background: var(--surface-hov);
  border-color: var(--border-str);
  color: var(--text);
}
.trade-actions .icon-btn.danger {
  color: var(--red);
  background: var(--red-bg);
  border-color: color-mix(in srgb, var(--red) 32%, transparent);
}
.trade-actions .icon-btn.danger:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}
.icon-btn.trade-close-x {
  color: var(--red);
  background: var(--surface-hi);
  border-color: color-mix(in srgb, var(--red) 64%, transparent);
}
.icon-btn.trade-close-x:hover {
  color: var(--red);
  background: var(--surface-hov);
  border-color: var(--red);
}
.trade-close-cell {
  width: 46px;
  min-width: 46px;
  text-align: center;
}
.trade-close-cell .trade-close-x {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
}

@media (max-width: 860px) {
  .live-positions-head {
    flex-wrap: wrap;
  }

  .live-position-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .live-positions-total {
    min-height: 34px;
    padding-inline: 8px;
  }
  .live-positions-total span { display: none; }

  .daily-target-mini {
    flex: 1 1 100%;
    flex-wrap: wrap;
    row-gap: 8px;
  }
  /* Keep the control compact: the % field and the Save button stay their natural width (Save is NOT
     stretched full-width). The row wraps only if it truly can't fit. */
  .daily-target-mini .daily-target-percent-field {
    flex: 0 1 auto;
    min-width: 0;
  }
  .daily-target-mini .daily-target-percent-field input {
    width: 56px;
    min-width: 44px;
  }
  .daily-target-mini .daily-target-save-btn {
    flex: 0 0 auto;
  }

  .daily-target-toggle {
    padding-left: 6px;
  }

  .daily-target-save-btn,
  #shareProfitCardBtn,
  #closeAllTradesBtn {
    min-height: 34px;
  }

  #bots .bot-status-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding-bottom: 2px;
  }

  #bots .bot-status-strip .metric {
    min-width: 0;
  }

  #bots .scan-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #bots .scan-meta div:nth-child(2n) {
    border-right: 0;
    padding-right: 0;
  }

  .trade-history-day summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .trade-history-day summary small {
    margin-left: 0;
    text-align: left;
  }
}

/* ─── Referral education + calculator polish ───────────────────── */
.referral-hero-card,
.referral-how-card,
.referral-apply-card,
.referral-formula-card,
.referral-scenarios-card,
.referral-result-card {
  position: relative;
  overflow: hidden;
}
.referral-hero-card::before,
.referral-formula-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: none;
}
.referral-hero-card > *,
.referral-formula-card > * { position: relative; }
.referral-share-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(180px, 0.5fr);
  gap: 12px;
  margin-top: 14px;
}
.referral-code-display {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
  background: var(--accent-dim);
  border-color: var(--accent-line);
}
.referral-action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.referral-action-row .btn { min-height: 40px; }
.referral-work-grid,
.referral-calc-grid { align-items: stretch; }
.referral-steps {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}
.ref-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.referral-steps .ref-step:last-child { border-bottom: 0; }
.ref-step > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-weight: 700;
  font-size: var(--fs-sm);
  font-family: var(--font-display);
}
.ref-step b {
  display: block;
  color: var(--text);
  font-size: var(--fs-sm);
  margin-bottom: 4px;
}
.ref-step small {
  display: block;
  color: var(--text-3);
  font-size: var(--fs-label);
  line-height: 1.45;
}
.referral-code-apply {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 8px;
}
.formula-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  margin-top: 6px;
}
.formula-flow > div {
  padding: 14px 16px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--bg-mid);
}
.formula-flow span {
  display: block;
  color: var(--text-3);
  font-size: var(--fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.formula-flow b {
  color: var(--text);
  font-size: var(--fs-body);
}
.formula-flow em {
  align-self: center;
  color: var(--text-3);
  font-style: normal;
  font-size: var(--fs-h2);
}
.referral-rule-note {
  margin-top: 12px;
  color: var(--text-3);
  font-size: var(--fs-label);
  line-height: 1.55;
}
.ref-calc-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.ref-calc-results {
  display: grid;
  gap: 9px;
}
.ref-calc-results > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 13px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.ref-calc-results > div:last-child { border-bottom: 0; }
.ref-calc-results span {
  color: var(--text-3);
  font-size: var(--fs-label);
}
.ref-calc-results b {
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--fs-sm);
}
.ref-calc-results .highlight {
  border-color: rgba(95, 227, 161, 0.32);
  background: rgba(95, 227, 161, 0.08);
}
.ref-calc-results .highlight b { color: var(--green); }
.scenario-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 30%);
  gap: 12px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.scenario-card {
  scroll-snap-align: start;
  padding: 16px 18px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--bg-mid);
  min-height: 150px;
}
.scenario-card small {
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--fs-micro);
  font-weight: 700;
}
.scenario-card b {
  display: block;
  color: var(--text);
  font-size: var(--fs-body);
  margin: 8px 0 10px;
  line-height: 1.35;
}
.scenario-card div {
  color: var(--text-3);
  font-size: var(--fs-label);
  margin-top: 5px;
}
.scenario-card strong {
  display: inline-block;
  margin-top: 12px;
  color: var(--green);
  font-size: var(--fs-sm);
}
@media (max-width: 860px) {
  .referral-share-grid,
  .referral-work-grid,
  .referral-calc-grid {
    grid-template-columns: 1fr;
  }
  .formula-flow {
    grid-template-columns: 1fr;
  }
  .formula-flow em {
    display: none;
  }
  .scenario-rail {
    grid-auto-columns: minmax(250px, 85%);
  }
}
@media (max-width: 560px) {
  .referral-action-row .btn {
    flex: 1 1 calc(50% - 8px);
    padding-inline: 10px;
  }
  .referral-code-apply,
  .ref-calc-inputs {
    grid-template-columns: 1fr;
  }
  .scenario-rail {
    grid-auto-columns: minmax(235px, 88%);
  }
}

/* ─── Referral page: permanent code + richer share card ───────────── */
.referral-history-card {
  border-color: var(--line);
  background: var(--bg-raised);
}
.referral-hero-card {
  border-color: var(--line);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
}
.section-kicker {
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: var(--fs-micro);
  font-weight: 700;
  margin-bottom: 4px;
}
.referral-share-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.65fr);
  gap: 14px;
}
.referral-share-field > span {
  display: block;
  margin-bottom: 7px;
}
.ref-copy-shell {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-mid);
  padding: 6px;
}
.ref-copy-shell.code-shell {
  border-color: var(--accent-line);
  background: var(--accent-glow);
}
.ref-copy-shell .input {
  width: 100%;
  padding-right: 52px;
  min-height: 48px;
  border: 0;
  background: var(--bg);
  box-shadow: none;
}
.ref-copy-shell .input:focus {
  box-shadow: inset 0 0 0 1px var(--accent-glow);
}
.referral-link-display {
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--text);
}
.referral-code-display {
  font-size: var(--fs-h3);
  min-height: 48px;
}
.ref-copy-btn {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--accent);
  border-color: rgba(222, 207, 153, 0.35);
  background: rgba(222, 207, 153, 0.08);
  font-size: var(--fs-h3);
}
.ref-copy-btn:hover {
  color: var(--text);
  border-color: rgba(222, 207, 153, 0.55);
}
.referral-share-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.referral-share-actions .btn {
  min-height: 42px;
  justify-content: center;
  background: var(--surface-hi);
}
.referral-share-actions .btn:hover {
  background: var(--surface-hov);
}
.referral-policy-note {
  border: 1px solid var(--border);
  background: var(--surface-hi);
}
@media (max-width: 860px) {
  .referral-share-grid,
  .referral-share-actions {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 560px) {
  .referral-share-actions .btn {
    width: 100%;
  }
  .ref-copy-shell {
    padding: 7px;
    border-radius: 16px;
  }
  .ref-copy-shell .input {
    min-height: 44px;
    font-size: var(--fs-label);
  }
  .referral-code-display {
    font-size: var(--fs-body) !important;
  }
}

/* Bots page launch hierarchy cleanup: compact bot grid + 2x2 policy */
#bots .bots-all-card {
  border-color: var(--line-strong);
}

#allBots.bots-grid-compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#allBots.bots-grid-compact > .notice {
  grid-column: 1 / -1;
}

#allBots.bots-grid-compact .bot-row {
  margin: 0;
  min-width: 0;
  padding: 12px;
  border-radius: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "coin"
    "side"
    "score"
    "badge";
  align-items: stretch;
  gap: 9px;
  background: var(--bg-mid);
  overflow: hidden;
}

#allBots.bots-grid-compact .bot-row .coin {
  grid-area: coin;
  min-width: 0;
  gap: 8px;
  align-items: center;
}

#allBots.bots-grid-compact .bot-row .coin-logo {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  font-size: var(--fs-micro);
}

#allBots.bots-grid-compact .bot-row .coin-name {
  font-size: var(--fs-label);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

#allBots.bots-grid-compact .bot-row .coin-sub {
  font-size: var(--fs-caption);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#allBots.bots-grid-compact .bot-row > div:nth-child(2) {
  grid-area: side;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

#allBots.bots-grid-compact .bot-row > div:nth-child(3) {
  grid-area: score;
  min-width: 0;
}

#allBots.bots-grid-compact .bot-row > .badge {
  grid-area: badge;
  justify-self: stretch;
  align-self: stretch;
  width: 100%;
  max-width: none;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-micro);
  line-height: 1;
  padding: 6px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
}

#allBots.bots-grid-compact .data-label {
  font-size: var(--fs-micro);
  letter-spacing: .07em;
}

#allBots.bots-grid-compact .data-value {
  font-size: var(--fs-sm);
  line-height: 1;
}

#allBots.bots-grid-compact .bar-track {
  height: 5px;
  margin-top: 6px;
}

.policy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.automation-policy-card .metric {
  min-height: 0;
  padding: 14px;
  border-radius: 16px;
}

.automation-policy-card .metric-value {
  font-size: 25px;
  margin-top: 8px;
}

.automation-policy-card .metric-sub {
  font-size: var(--fs-caption);
}

.access-radar-card { border-color: var(--line-strong); }
.bot-decision-log-card { border-color: var(--line-strong); }
.access-radar-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.access-radar-summary { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; margin-bottom:12px; }
.access-radar-summary.is-directional { grid-template-columns:repeat(2,minmax(0,1fr)); }
.access-summary-pill { border:1px solid var(--line); background:var(--bg-mid); border-radius:14px; padding:10px 12px; min-width:0; }
.access-summary-pill span { display:block; color:var(--text-3); font-size: var(--fs-micro); text-transform:uppercase; letter-spacing:.07em; margin-bottom:5px; }
.access-summary-pill strong { display:block; color:var(--text); font-family:var(--mono); font-size: var(--fs-h2); line-height:1; }
.access-summary-pill.long { border-color:var(--green-line); background:var(--green-bg); }
.access-summary-pill.long strong { color:var(--green); }
.access-summary-pill.short { border-color:var(--red-line); background:var(--red-bg); }
.access-summary-pill.short strong { color:var(--red); }
.access-radar-layout { display:grid; grid-template-columns:minmax(280px,.92fr) minmax(0,1.18fr); gap:12px; align-items:start; }
.access-radar-list { display:grid; gap:8px; max-height:620px; overflow:auto; padding-right:2px; }
.access-row { appearance:none; width:100%; border:1px solid var(--line); background:var(--bg-mid); color:var(--text); border-radius:14px; padding:10px; display:grid; grid-template-columns:minmax(0,1fr) minmax(96px,.55fr) auto; gap:10px; align-items:center; text-align:left; cursor:pointer; }
.access-row:hover, .access-row.is-selected { border-color:var(--accent-line); background:var(--accent-dim); }
.access-row-mid { min-width:0; }
.access-row-mid span, .access-row-mid strong { display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.access-row-mid span { color:var(--text-3); font-size: var(--fs-micro); text-transform:uppercase; letter-spacing:.05em; }
.access-row-mid strong { color:var(--text-2); font-size: var(--fs-label); margin-top:3px; }
.access-score { display:grid; gap:6px; justify-items:end; min-width:74px; }
.access-score b { font-family:var(--mono); color:var(--text); font-size: var(--fs-h2); line-height:1; }
.access-detail-card { border:1px solid var(--line); background:var(--bg-mid); border-radius:16px; padding:14px; min-height:260px; }
.access-detail-head { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; margin-bottom:12px; }
.access-detail-title { font-weight:700; font-size: var(--fs-md); line-height:1.2; }
.access-detail-sub { color:var(--text-3); font-size: var(--fs-label); margin-top:4px; }
.access-detail-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; margin-top:10px; }
.access-detail-grid.compact { grid-template-columns:repeat(4,minmax(0,1fr)); }
.access-level-card, .access-detail-grid.compact > div { border:1px solid var(--line); background:var(--bg); border-radius:12px; padding:10px; min-width:0; }
.access-level-card span, .access-detail-grid.compact span { display:block; color:var(--text-3); font-size: var(--fs-micro); text-transform:uppercase; letter-spacing:.07em; margin-bottom:5px; }
.access-level-card strong, .access-detail-grid.compact strong { display:block; font-family:var(--mono); color:var(--text); font-size: var(--fs-label); line-height:1.35; overflow-wrap:anywhere; }
.access-level-card small { display:block; color:var(--text-3); font-size: var(--fs-caption); margin-top:4px; }
.access-detail-note { color:var(--text-2); font-size: var(--fs-label); line-height:1.5; border:1px solid var(--line); background:var(--bg); border-radius:12px; padding:10px; margin-top:10px; }
/* ── Plan card redesign (v105): aligned zones, status banner, plan grid, levels table ── */
.access-detail-score { display:flex; flex-direction:column; align-items:flex-end; gap:6px; }
.access-detail-score .score-bar { width:92px; height:5px; border-radius:5px; background:var(--bg); overflow:hidden; }
.access-detail-score .score-bar i { display:block; height:100%; background:linear-gradient(90deg,var(--accent),var(--accent-strong)); border-radius:5px; }
.access-detail-score small { color:var(--text-3); font-size:var(--fs-micro); font-family:var(--mono); }
.zone-card .zone-rows { margin:2px 0 8px; }
.zone-card .zrow { display:flex; justify-content:space-between; align-items:baseline; padding:2px 0; }
.zone-card .zrow i { font-style:normal; color:var(--text-3); font-size:var(--fs-caption); }
.zone-card .zrow b { font-family:var(--mono); color:var(--text); font-size:var(--fs-sm); font-weight:500; font-variant-numeric:tabular-nums; }
.access-live-plan { margin-top:12px; }
.alp-status { display:flex; gap:10px; align-items:flex-start; padding:11px 12px; border:1px solid var(--line); background:var(--bg); border-radius:var(--radius-md); margin-bottom:11px; }
.alp-status .alp-dot { width:8px; height:8px; border-radius:50%; background:var(--accent); flex:0 0 8px; margin-top:5px; }
.access-live-plan.short .alp-dot { background:var(--red); box-shadow:0 0 8px var(--red-line); }
.access-live-plan.long .alp-dot { background:var(--green); box-shadow:0 0 8px var(--green-line); }
.alp-headline { font-weight:600; font-size:var(--fs-sm); line-height:1.35; }
.alp-context { color:var(--text-2); font-size:var(--fs-label); margin-top:3px; line-height:1.45; }
.alp-grid { display:grid; grid-template-columns:1fr 1fr; gap:1px; background:var(--line); border:1px solid var(--line); border-radius:var(--radius-md); overflow:hidden; margin-bottom:11px; }
.alp-cell { background:var(--bg-mid); padding:11px 12px; min-width:0; }
.alp-label { color:var(--text-3); font-size:var(--fs-micro); text-transform:uppercase; letter-spacing:.06em; margin-bottom:5px; }
.alp-value { color:var(--text); font-size:var(--fs-label); line-height:1.45; }
.alp-note { color:var(--text-2); font-size:var(--fs-label); line-height:1.5; margin-bottom:11px; }
.alp-levels { border:1px solid var(--line); border-radius:var(--radius-md); overflow:hidden; margin-bottom:6px; }
.alp-levels-h { background:var(--bg-mid); padding:7px 12px; color:var(--text-3); font-size:var(--fs-micro); text-transform:uppercase; letter-spacing:.06em; }
.alp-lrow { display:grid; grid-template-columns:1.3fr 1fr 1.1fr; align-items:center; gap:10px; padding:9px 12px; border-top:1px solid var(--line); }
.alp-ln { color:var(--text-2); font-size:var(--fs-label); }
.alp-lp { font-family:var(--mono); font-size:var(--fs-sm); text-align:right; font-variant-numeric:tabular-nums; }
.alp-ld { color:var(--text-3); font-size:var(--fs-caption); text-align:right; }
.alp-lrow.key .alp-lp { color:var(--accent); }
@media (max-width:560px){ .alp-grid { grid-template-columns:1fr; } .access-detail-score .score-bar { width:72px; } }
.access-reasons { display:grid; gap:7px; margin-top:10px; }
.access-reasons span { border-left:3px solid var(--accent); background:var(--bg); border-radius:10px; color:var(--text-2); font-size: var(--fs-label); line-height:1.45; padding:8px 10px; }
.bot-decision-log-card .engine-activity {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.bot-decision-log-card .engine-event {
  min-width: 0;
  align-items: start;
  border: 1px solid var(--line);
  background: var(--bg-mid);
  border-radius: 14px;
  padding: 12px;
}
.bot-decision-log-card .engine-event-copy {
  min-width: 0;
}
.bot-decision-log-card .engine-event-copy strong,
.bot-decision-log-card .engine-event-copy br + * {
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  #allBots.bots-grid-compact {
    gap: 8px;
  }
  #allBots.bots-grid-compact .bot-row {
    padding: 10px;
    border-radius: 16px;
  }
  #allBots.bots-grid-compact .bot-row .coin-logo {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
    font-size: var(--fs-micro);
  }
  #allBots.bots-grid-compact .bot-row > .badge {
    min-height: 26px;
    font-size: var(--fs-micro);
    padding: 5px 7px;
  }
  #allBots.bots-grid-compact .bot-row .coin-name {
    font-size: var(--fs-caption);
  }
  #allBots.bots-grid-compact .bot-row .coin-sub {
    font-size: var(--fs-micro);
  }
  .policy-grid {
    gap: 8px;
  }
  .automation-policy-card .metric {
    padding: 12px;
  }
  .automation-policy-card .metric-value {
    font-size: var(--fs-h1);
  }
  .access-radar-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .access-radar-layout {
    grid-template-columns: 1fr;
  }
  .access-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "coin score"
      "meta score";
    align-items: center;
    gap: 8px 12px;
    padding: 12px;
    overflow: hidden;
  }
  .access-row .market-symbol {
    grid-area: coin;
    min-width: 0;
  }
  .access-row-mid {
    grid-area: meta;
    min-width: 0;
    padding-left: 42px;
  }
  .access-row-mid span,
  .access-row-mid strong {
    max-width: 100%;
    line-height: 1.25;
  }
  .access-score {
    grid-area: score;
    grid-template-columns: 1fr;
    align-items: end;
    justify-items: end;
    min-width: 0;
    gap: 8px;
  }
  .access-score .badge {
    justify-self: end;
    white-space: nowrap;
    text-align: center;
    max-width: 100%;
  }
  .access-score b {
    justify-self: end;
    font-size: 26px;
  }
  .access-detail-grid,
  .access-detail-grid.compact {
    grid-template-columns: 1fr;
  }
  .bot-decision-log-card .engine-activity {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .access-row {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "coin"
      "meta"
      "score";
  }
  .access-score {
    grid-template-columns: 1fr auto;
    align-items: center;
    justify-items: stretch;
  }
  .access-score .badge {
    justify-self: start;
  }
}


/* Live API setup */
.live-setup-hero {
  background: var(--bg-raised);
}
.live-steps-grid {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
  margin-top:16px;
}
.live-step {
  border:0;
  background:transparent;
  border-radius:0;
  padding:4px 0;
  display:grid;
  gap:8px;
}
/* hairline separators between steps instead of boxes */
.live-steps-grid .live-step + .live-step { border-left:1px solid var(--line); padding-left:18px; }
@media (max-width: 720px) {
  .live-steps-grid { grid-template-columns:1fr; gap:0; }
  .live-steps-grid .live-step + .live-step { border-left:0; border-top:1px solid var(--line); padding-left:0; padding-top:14px; margin-top:14px; }
}
.live-step span {
  width:30px;height:30px;border-radius:999px;
  display:inline-grid;place-items:center;
  background:var(--accent-dim);
  border:1px solid var(--accent-line);
  color:var(--accent);
  font-weight:700; font-size: var(--fs-sm);
  font-family:var(--font-display);
}
.live-step b { color:var(--text); font-size: var(--fs-body); letter-spacing:-0.01em; }
.live-step small { color:var(--text-3); line-height:1.4; font-size: var(--fs-label); }
.runner-status-card .copy-field {
  margin-top:0;
}
.copy-field {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  border:0;
  border-bottom:1px solid var(--line);
  background:transparent;
  border-radius:0;
  padding:14px 2px;
}
.copy-field.soft { border-color:var(--line); }
.copy-field small {
  display:block;
  color:var(--text-3);
  font-size: var(--fs-label);
  letter-spacing:.08em;
  text-transform:uppercase;
  margin-bottom:4px;
}
.copy-field strong {
  font-family:var(--mono);
  font-size: var(--fs-h3);
  color:var(--text);
  word-break:break-all;
}
.icon-btn {
  width:38px;height:38px;
  border-radius:12px;
  border:1px solid var(--line);
  background:transparent;
  color:var(--accent);
  cursor:pointer;
  font-weight:800;
}
.runner-health {
  margin-top:12px;
  padding:12px 14px;
  border-radius:14px;
  background:var(--green-bg);
  border:1px solid var(--green-line);
  color:var(--green);
  font-size: var(--fs-sm);
  line-height:1.45;
}
.runner-health.ok {
  background:var(--green-bg);
  border-color:var(--green-line);
  color:var(--green);
}
.runner-health.warn {
  background:var(--amber-bg);
  border-color:var(--amber-line);
  color:var(--amber);
}
.runner-health.off {
  background:var(--red-bg);
  border-color:var(--red-line);
  color:var(--red);
}
@media (max-width: 720px) {
  .live-steps-grid { grid-template-columns:1fr; }
  .copy-field { padding:12px; }
  .copy-field strong { font-size: var(--fs-sm); }
}


/* Setup paywall */
.setup-paywall-card {
  background: var(--bg-raised);
}
.setup-paywall-card.unlocked {
  border-color: var(--green-line);
}
.setup-paywall-grid {
  display: grid;
  grid-template-columns: minmax(170px, .7fr) 1.3fr;
  gap: 12px;
  margin-top: 14px;
}
.setup-price-box {
  border: 0;
  border-left: 2px solid var(--amber-line);
  background: var(--bg-mid);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: grid;
  gap: 4px;
}
.setup-price-box small {
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: var(--fs-caption);
}
.setup-price-box strong {
  font-size: 42px;
  letter-spacing: -.06em;
  color: var(--amber);
  font-family: var(--mono);
}
.setup-price-box span { color: var(--text-3); font-size: var(--fs-sm); line-height: 1.35; }
.setup-paywall-copy { display: grid; gap: 10px; }
.runner-health.amber { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber); }
.api-locked { opacity: .58; position: relative; }
.api-locked::after {
  content: 'Start the 7-day free trial or pay $59 to unlock live API';
  position: absolute;
  inset: auto 16px 16px 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  color: var(--amber);
  font-size: var(--fs-sm);
  line-height: 1.35;
}
button.disabled, input.disabled { cursor: not-allowed; }
@media (max-width: 720px) {
  .setup-paywall-grid { grid-template-columns: 1fr; }
  .setup-price-box strong { font-size: 34px; }
}

/* Account recovery + live/demo split */
.mode-split-grid .mode-card {
  background: var(--bg-raised);
}
.live-mode-card {
  background: var(--bg-raised);
}
.danger-zone-card {
  border-color: var(--red-line);
  background: var(--bg-raised);
}
@media (max-width: 720px) {
  #apiManagementCard .grid.g2,
  .danger-zone-card .grid.g2,
  .mode-split-grid { grid-template-columns: 1fr; }
}


/* Solid app toast: avoids text overlap/transparency on mobile and desktop */
.app-toast {
  position: fixed;
  left: 50%;
  top: calc(82px + env(safe-area-inset-top));
  transform: translate(-50%, -12px);
  z-index: 10050;
  display: block;
  width: min(520px, calc(100vw - 32px));
  max-height: min(42vh, 260px);
  overflow: auto;
  padding: 13px 15px;
  border-radius: 16px;
  border: 1px solid var(--accent-line);
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: var(--shadow-pop), inset 0 1px 0 rgba(255,255,255,.06);
  white-space: pre-line;
  line-height: 1.45;
  font-size: var(--fs-body);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}
.app-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
@media (max-width: 640px) {
  .app-toast {
    top: calc(70px + env(safe-area-inset-top));
    width: calc(100vw - 28px);
    border-radius: 16px;
    font-size: var(--fs-sm);
  }
}


/* API diagnostics */
.api-diagnostic-panel {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  border-radius: 16px;
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.diag-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.diag-head b { display:block; color:var(--text); font-size: var(--fs-h3); }
.diag-head span { display:block; color:var(--text-2); font-size: var(--fs-sm); line-height:1.4; margin-top:3px; }
.diag-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.diag-row:last-child { border-bottom: 0; }
.diag-row strong { display:block; color:var(--text); font-size: var(--fs-sm); }
.diag-row small { display:block; color:var(--text-2); font-size: var(--fs-label); line-height:1.45; margin-top:3px; }
.diag-row em { display:block; color:var(--text-3); font-style:normal; font-size: var(--fs-caption); line-height:1.4; margin-top:4px; font-family:var(--mono); word-break:break-word; }
.diag-row pre, .raw-error-box {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-mid);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: var(--fs-caption);
  line-height: 1.45;
}
.diag-row ul, .diag-next ul { margin:8px 0 0 18px; color:var(--text-2); line-height:1.55; font-size: var(--fs-label); }
.diag-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  font-size: var(--fs-label);
  border: 1px solid var(--line);
}
.diag-dot.green { color: var(--green); background: var(--green-bg); border-color: var(--green-line); }
.diag-dot.red { color: var(--red); background: var(--red-bg); border-color: var(--red-line); }
.diag-next {
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--amber-line);
  background: var(--amber-bg);
}
.diag-next b { color: var(--amber); }
@media (max-width: 640px) {
  .diag-row { grid-template-columns: 24px 1fr; }
  .diag-row > .badge { grid-column: 2; width: fit-content; }
  .diag-head { flex-direction: column; }
}


/* Live execution readiness layer */
.live-execution-card { border-color: rgba(44, 255, 168, 0.14); }
.live-exec-panel .diag-row { margin: 0; }
.live-exec-panel details pre,
.raw-error-box {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 340px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  color: var(--text);
}


/* ─────────────────────────────────────────────
   Demo/API modes now share the active theme accent
   (single-accent design per the mockup). Modes stay
   distinguished by copy, badges, and section visibility.
   ───────────────────────────────────────────── */
body[data-app-mode="demo"] .api-only,
body[data-app-mode="api"] .demo-only { display: none !important; }
body[data-app-mode="demo"] .hero-card {
  border-color: var(--border-str);
  background: var(--surface);
}
body[data-app-mode="api"] .hero-card {
  border-color: var(--accent-glow);
  background:
    radial-gradient(circle at 0% 0%, var(--accent-dim), transparent 46%),
    var(--surface);
  box-shadow: var(--sh-md), inset 0 1px 0 var(--edge-light);
}
.app-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.app-mode-option {
  border: 0;
  min-height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text-3);
  background: transparent;
  font: 600 12.5px/1 var(--font);
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.app-mode-option:hover { color: var(--text); }
.app-mode-option.active {
  color: var(--text);
  background: var(--surface-hi);
  box-shadow: var(--sh-sm);
}
body[data-app-mode="api"] .btn.primary,
body[data-app-mode="api"] .btn.active,
body[data-app-mode="api"] .nav-btn.active,
body[data-app-mode="demo"] .mode-strip.paper {
  border-color: var(--border-str);
  background: var(--surface-hi);
}
body[data-app-mode="api"] .mode-strip.live {
  border-color: var(--accent-glow);
  background: var(--accent-dim);
}
body[data-app-mode="demo"] .nav-btn[data-page-jump="connect"] { display: none !important; }
body[data-app-mode="demo"] .topbar .status-dot,
body[data-app-mode="demo"] .mode-pill.info {
  color: var(--text-2);
  background: var(--surface-hi);
  border-color: var(--border);
}
body[data-app-mode="api"] .status-dot {
  color: var(--blue);
  background: var(--blue-bg);
  border-color: var(--blue-line);
}
@media (max-width: 860px) {
  .app-mode-toggle { padding: 3px; }
  .app-mode-option { min-height: 30px; padding: 0 11px; font-size: var(--fs-label); }
  .topbar-right { gap: 7px; }
}
@media (max-width: 430px) {
  .app-mode-option { padding: 0 9px; }
  .topbar-btn.hide-desktop { max-width: 118px; }
}

/* Accent follows the active theme in both modes (single-accent design). */
body[data-app-mode="api"] .positive,
body[data-app-mode="api"] .trade-long td:first-child,
body[data-app-mode="api"] .trade-row.trade-long td:first-child,
body[data-app-mode="api"] .badge.green {
  color: var(--green) !important;
}
body[data-app-mode="api"] .negative,
body[data-app-mode="api"] .trade-short td:first-child,
body[data-app-mode="api"] .trade-row.trade-short td:first-child,
body[data-app-mode="api"] .badge.red {
  color: var(--red) !important;
}
body[data-app-mode="api"] .badge.green {
  background: var(--green-bg) !important;
  border-color: var(--green-line) !important;
}
body[data-app-mode="api"] .mode-pill.info,
body[data-app-mode="api"] .badge.blue,
body[data-app-mode="api"] .status-dot {
  color: var(--blue);
  background: var(--blue-bg);
  border-color: var(--blue-line);
}
body[data-app-mode="api"] .mode-pill.on {
  color: var(--blue);
  background: var(--blue-bg);
  border-color: var(--blue-line);
}
body[data-app-mode="api"] .bar-fill { background: var(--blue); }
body[data-app-mode="api"] .trade-mobile-card.long .trade-mobile-head span { color: var(--green); }
body[data-app-mode="api"] .trade-mobile-card.short .trade-mobile-head span { color: var(--red); }

/* API bot fleet cards — compact status tiles */
.api-bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
/* Span the full width of the 2-col compact bots grid. */
#allBots.bots-grid-compact > .api-bot-grid { grid-column: 1 / -1; }
.api-bot-card {
  border: 1px solid var(--border);
  background: var(--surface-hi);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}
.api-bot-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 9px;
}
.api-bot-top strong {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.api-bot-card p {
  color: var(--text-3);
  line-height: 1.45;
  margin: 0;
  font-size: var(--fs-label);
}

/* Mobile active trades: table becomes readable cards, no ugly horizontal scrollbar */
.trade-card-list { display: none; }
.trade-mobile-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-mid);
  padding: 10px 12px;
}
.tmc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.tmc-id { display: flex; align-items: center; gap: 7px; min-width: 0; flex-wrap: wrap; }
.tmc-id strong {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: var(--head-track);
  white-space: nowrap;
}
.tmc-tags { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.tmc-tags .badge,
.tmc-tags .strategy-source-tag {
  min-height: 16px;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 8.5px;
  line-height: 1.15;
  letter-spacing: .025em;
}
.tmc-pnl-wrap { display: flex; align-items: center; gap: 7px; }
.tmc-pnl {
  font-family: var(--mono);
  font-weight: 700;
  font-size: var(--fs-body);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.tmc-pnl.positive { color: var(--green); }
.tmc-pnl.negative { color: var(--red); }
.tmc-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.tmc-stats span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tmc-stats i {
  font-style: normal;
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}
.tmc-stats b {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.tmc-edit { width: 24px; min-width: 24px; height: 24px; padding: 0; color: var(--accent); border-radius: 8px; }
.tmc-edit svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.trade-mobile-card .trade-close-x { width: 28px; min-width: 28px; height: 28px; padding: 0; border-radius: 9px; }
.trade-live-api td { background: rgba(104,201,255,0.025); }
.ds2-list-actions {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}
.referral-advanced {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-mid);
  padding: 12px;
}
.referral-advanced > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
  list-style-position: inside;
}
.more-account-tools > summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
  cursor: pointer;
  list-style: none;
}
.more-account-tools > summary::-webkit-details-marker { display: none; }
.more-account-tools > summary span { color: var(--text); font-weight: 700; }
.more-account-tools > summary small { color: var(--text-3); }
.more-account-tools > summary b {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--amber);
  font-size: var(--fs-label);
}
.more-account-tools[open] > summary { margin-bottom: 14px; }

/* Light themes: proper contrast, no faded API/Demo hero */
/* Light-mode hero uses a light card surface, so text is dark via base tokens.
   (Removed the old #f7fbff white-on-white override that made the hero
   headline/eyebrow/body invisible in light mode.) */
:root[data-theme="light"] .hero-card .hero-eyebrow { color: var(--text-3); }
:root[data-theme="light"] .hero-card .hero-headline { color: var(--text); }
:root[data-theme="light"] .hero-card .hero-headline em { color: var(--accent); }
:root[data-theme="light"] .hero-card .hero-body { color: var(--text-2); }

body.light .card,
:root[data-theme="light"] .card,
:root[data-theme="arctic"] .card,
:root[data-theme="linen"] .card {
  background: var(--bg-raised);
  box-shadow: 0 10px 28px rgba(15,23,32,0.08), inset 0 1px 0 rgba(255,255,255,0.65);
}
body.light .sc-chart-stage,
:root[data-theme="light"] .sc-chart-stage,
:root[data-theme="arctic"] .sc-chart-stage,
:root[data-theme="linen"] .sc-chart-stage {
  background: #ffffff;
  border-color: rgba(15,23,32,0.10);
}
body.light .sc-symbol-chip,
:root[data-theme="light"] .sc-symbol-chip,
:root[data-theme="arctic"] .sc-symbol-chip,
:root[data-theme="linen"] .sc-symbol-chip {
  background: #ffffff;
  border-color: rgba(15,23,32,0.12);
  color: var(--text-2);
}
body.light .sc-symbol-chip.active,
:root[data-theme="light"] .sc-symbol-chip.active,
:root[data-theme="arctic"] .sc-symbol-chip.active,
:root[data-theme="linen"] .sc-symbol-chip.active {
  background: var(--blue-bg);
  border-color: var(--blue-line);
  color: var(--blue);
}

/* Mobile dock: less blocking, no thick black outline, safe-area aware */
@media (max-width: 860px) {
  .content { padding-bottom: calc(128px + env(safe-area-inset-bottom)); }
  .mobile-nav {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    padding: 7px 8px;
    border-radius: 20px;
  }
  .mobile-nav .nav-btn {
    min-width: 0;
    flex: 1 1 0;
    padding: 7px 5px;
    border-radius: 16px;
    outline: none !important;
    box-shadow: none !important;
  }
  .mobile-nav .nav-btn.active {
    border: 1px solid var(--accent-line);
    background: var(--accent-dim);
    color: var(--accent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12) !important;
  }
  .mobile-nav .nav-btn.active::before {
    width: 22px;
    height: 4px;
    top: -8px;
    box-shadow: none;
  }
  /* Active trades become readable cards on phones; empty states never create a
     misleading horizontal table or truncate their next-step message. */
  #activeTrades { display: none; }
  #activeTrades + .trade-card-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    overflow: visible;
    padding: 0;
  }
  #activeTrades + .trade-card-list > .trade-mobile-card {
    width: 100%;
    min-width: 0;
  }
  #trades #activeTrades.table { min-width: 0; }
  #trades #activeTrades.table-wrap { overflow: visible; }
  [data-session-bar] { flex-wrap: wrap; width: 100%; }
  .referral-history-card .table-wrap.is-empty { overflow: visible; }
  #refTable.is-empty { min-width: 0; width: 100%; }
  #refTable.is-empty td { white-space: normal; line-height: 1.5; padding: 14px 0; }
  .referral-stat-grid .metric:last-child { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .trade-mobile-grid { grid-template-columns: 1fr; }
  .api-bot-grid { grid-template-columns: 1fr; }
  .hero-card { border-radius: 20px; }
}

/* Status tokens follow the active theme (see :root + [data-theme] blocks). */
body[data-app-mode="demo"],
body[data-app-mode="api"] {
  --green: var(--gain);
  --green-bg: var(--gain-dim);
  --green-line: color-mix(in srgb, var(--gain) 30%, transparent);
  --red: var(--loss);
  --red-bg: var(--loss-dim);
  --red-line: color-mix(in srgb, var(--loss) 30%, transparent);
  --amber-bg: var(--amber-dim);
  --amber-line: color-mix(in srgb, var(--amber) 30%, transparent);
}
body[data-app-mode="api"] {
  --blue: var(--accent);
  --blue-bg: var(--accent-dim);
  --blue-line: var(--accent-glow);
}
.api-bot-card > strong {
  display: block;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.api-bot-card > small {
  display: block;
  color: var(--text-3);
  font-size: var(--fs-caption);
  line-height: 1.4;
}

/* API safety/UI final guards */
.skeleton-line {
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}
.exchange-btn.is-disabled,
.exchange-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.25);
}
.exchange-btn.is-disabled:hover,
.exchange-btn:disabled:hover {
  border-color: var(--line);
  color: var(--text-2);
  background: var(--bg-mid);
}
body[data-app-mode="api"] #startPauseBtn {
  display: none !important;
}

/* Strategy controls: independent on/off, start/pause, and fund allocation */
.strategy-allocation-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 12px 0 14px;
}
.capital-strategy-list {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--surface-hi);
}
.capital-strategy-list { display: grid; gap: 9px; }
.capital-strategy-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.capital-strategy-row + .capital-strategy-row { border-top: 1px solid var(--line); padding-top: 9px; }
.capital-strategy-row > span { color: var(--text-2); font-weight: 650; }
.capital-strategy-row > strong { color: var(--text); font-family: var(--mono); }
.capital-strategy-row small { color: var(--text-3); font-family: var(--body); font-weight: 600; margin-left: 5px; }
.capital-strategy-row.capital-available { color: var(--text-3); }
.sc-stats.sc-stats-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.strategy-summary-pill {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--surface-hi);
}
.strategy-summary-pill small {
  display: block;
  color: var(--text-3);
  font-size: var(--fs-caption);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 5px;
}
.strategy-summary-pill strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--fs-h2);
}
/* Vertical stack — one strategy per full-width row. */
.strategy-control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
/* Merged Journal — strategy/coin performance rows + trade log */
.jx-list { display: grid; gap: 2px; }
.jx-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.jx-row:last-child { border-bottom: 0; }
.jx-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.jx-row-main strong { color: var(--text); font-size: var(--fs-body); }
.jx-sub { color: var(--text-3); font-size: var(--fs-caption); }
.jx-row-val { font-family: var(--mono); font-weight: 700; font-size: var(--fs-h3); flex: 0 0 auto; }
.jx-row-val.positive { color: var(--gain); }
.jx-row-val.negative { color: var(--loss); }

/* Trading mode confirmation modal */
.am-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 12, 20, 0.55); backdrop-filter: blur(3px); padding: 20px;
}
.am-modal {
  width: min(460px, 100%); background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.5);
}
.am-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); background: var(--accent-dim); }
.am-modal-head.aggr { background: var(--loss-dim); }
.am-modal-title { font-weight: 800; font-size: var(--fs-md); }
.am-modal-x { border: 0; background: transparent; color: var(--text-3); font-size: var(--fs-h1); line-height: 1; cursor: pointer; padding: 0 4px; }
.am-modal-x:hover { color: var(--text); }
.am-modal-list { margin: 0; padding: 14px 20px 6px 34px; display: grid; gap: 8px; }
.am-modal-list li { font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2); }
.am-modal-field { display: grid; gap: 4px; padding: 8px 18px 4px; font-size: var(--fs-label); font-weight: 700; color: var(--text-2); }
.am-modal-field .am-hint { font-weight: 400; font-size: var(--fs-caption); color: var(--text-3); line-height: 1.35; }
.am-modal-field input { margin-top: 4px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-hi); color: var(--text); padding: 9px 11px; font-family: var(--mono); outline: none; }
.am-modal-warn { margin: 8px 18px 0; padding: 9px 11px; border: 1px solid color-mix(in srgb, var(--loss) 32%, transparent); background: var(--loss-dim); color: var(--loss); border-radius: 10px; font-size: var(--fs-caption); line-height: 1.45; }
.am-modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 18px 18px; }
.am-modal-actions .btn { min-height: 40px; padding: 9px 16px; border-radius: var(--radius-btn); font-weight: 600; }

/* Trading mode toggle (Standard / Aggressive) + live regime chip in the section header. */
.sc-mode-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.sc-mode-wrap.compact { flex: 0 1 auto; }
.sc-mode-toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-hi); padding: 2px; max-width: 100%; overflow: hidden; }
.sc-mode-btn {
  border: 0; background: transparent; cursor: pointer;
  color: var(--text-3); font-weight: 700; font-size: var(--fs-label);
  padding: 6px 14px; border-radius: 999px; transition: background .14s ease, color .14s ease;
  min-width: 86px; text-align: center; white-space: nowrap;
}
.sc-mode-btn:hover { color: var(--text); }
.sc-mode-btn.is-active { color: #fff; background: var(--accent); }
.sc-mode-toggle.is-aggressive .sc-mode-btn.is-active { background: var(--loss); }
.sc-regime-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-caption); font-weight: 700; letter-spacing: .03em;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface-hi); color: var(--text-2);
}
.sc-regime-chip.long { color: var(--gain); border-color: var(--green-line); background: var(--gain-dim); }
.sc-regime-chip.short { color: var(--loss); border-color: color-mix(in srgb, var(--loss) 32%, transparent); background: var(--loss-dim); }
.sc-regime-chip.none { color: var(--amber); border-color: var(--amber-line); background: var(--amber-dim); }
.sc-regime-chip:empty { display: none; }

/* Launch mobile fix: keep Strategy controls header clean and prevent the
   Standard/Aggressive selector from clipping inside Telegram mobile webview. */
@media (max-width: 640px) {
  .strategy-control-card .section-head {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
  }
  .strategy-control-card .section-head > div:first-child {
    min-width: 0;
    flex: 1 1 100%;
  }
  .strategy-control-card #strategyControlSub {
    display: none;
  }
  .strategy-control-card .sc-mode-wrap {
    width: 100%;
    justify-content: stretch;
    gap: 8px;
  }
  .strategy-control-card .sc-mode-toggle {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .strategy-control-card .sc-mode-btn {
    min-width: 0;
    width: 100%;
    padding: 9px 8px;
    font-size: var(--fs-label);
  }
  .strategy-control-card #strategyAllocationBadge {
    display: none;
  }
}

/* Strategy card — hero redesign. Strategy name + banked P/L are the headline; capital,
   trades, uptime, allocation and actions live in a clean 2-column grid that stacks on
   mobile. Every colour is a theme token so it works in every palette (light + dark). */
.strategy-control-item {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(268px, 0.85fr);
  grid-template-areas:
    "head   head"
    "hero   alloc"
    "stats  alloc"
    "warn   warn"
    "fire   fire"
    "actions actions";
  gap: 14px 18px;
  align-items: start;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px 18px 20px;
  background: var(--surface);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.strategy-control-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent);
}
.strategy-control-item.is-running { box-shadow: 0 10px 30px -22px var(--gain); }
.strategy-control-item.is-running::before { background: var(--gain); }
.strategy-control-item.is-paused::before  { background: var(--amber); }
.strategy-control-item.is-off::before      { background: var(--loss); }

/* Header — identity + status + uptime timer */
.sc-head {
  grid-area: head;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.sc-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.sc-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; background: var(--accent); }
.is-running .sc-dot { background: var(--gain); box-shadow: 0 0 0 4px var(--gain-dim); animation: scPulse 2.2s ease-in-out infinite; }
.is-paused  .sc-dot { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-dim); }
.is-off     .sc-dot { background: var(--loss); box-shadow: 0 0 0 4px var(--loss-dim); }
@keyframes scPulse { 0%,100% { box-shadow: 0 0 0 3px var(--gain-dim); } 50% { box-shadow: 0 0 0 7px transparent; } }
.sc-idtext { min-width: 0; }
.sc-name { font-weight: 800; font-size: var(--fs-lg); letter-spacing: -.01em; color: var(--text); line-height: 1.1; }
.sc-desc { color: var(--text-3); font-size: var(--fs-label); line-height: 1.35; margin-top: 2px; }
.sc-head-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.sc-status {
  font-size: var(--fs-caption); font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-strong);
  color: var(--text-2); background: var(--surface-hi);
}
.sc-status-green { color: var(--gain); border-color: var(--green-line); background: var(--gain-dim); }
.sc-status-amber { color: var(--amber); border-color: var(--amber-line); background: var(--amber-dim); }
.sc-status-red   { color: var(--loss); border-color: color-mix(in srgb, var(--loss) 32%, transparent); background: var(--loss-dim); }
.sc-timer {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-label); color: var(--gain);
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--green-line); background: var(--gain-dim);
}
.sc-timer b { font-family: var(--mono); font-weight: 700; letter-spacing: .02em; }
.sc-timer.paused { color: var(--text-3); border-color: var(--line-strong); background: var(--surface-hi); }

/* Collapse / expand — the whole header row is the toggle */
.sc-head { cursor: pointer; border-radius: 10px; margin: -4px -6px; padding: 4px 6px; transition: background .14s ease; outline: none; }
.sc-head:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.sc-head:focus-visible { box-shadow: 0 0 0 2px var(--accent-line); }
.sc-chevron { display: inline-flex; color: var(--text-3); transition: transform .2s ease; }
.strategy-control-item.is-collapsed .sc-chevron { transform: rotate(-90deg); }
.sc-collapsed-pnl { display: none; font-family: var(--mono); font-weight: 800; font-size: var(--fs-md); }
.sc-collapsed-pnl.sc-hero-pos { color: var(--gain); }
.sc-collapsed-pnl.sc-hero-neg { color: var(--loss); }
/* When collapsed the card shows only its header row + a compact P/L. */
.strategy-control-item.is-collapsed { display: block; padding-bottom: 15px; }
.strategy-control-item.is-collapsed .sc-hero,
.strategy-control-item.is-collapsed .sc-stats,
.strategy-control-item.is-collapsed .sc-alloc,
.strategy-control-item.is-collapsed .strategy-control-warning,
.strategy-control-item.is-collapsed .strategy-fire-settings,
.strategy-control-item.is-collapsed .sc-actions { display: none; }
.strategy-control-item.is-collapsed .sc-collapsed-pnl { display: inline-block; }

/* Hero P/L — the headline */
.sc-hero {
  grid-area: hero;
  border-radius: 14px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-hi), var(--surface));
}
.sc-hero-pos { border-color: var(--green-line); background: linear-gradient(160deg, var(--gain-dim), var(--surface) 72%); }
.sc-hero-neg { border-color: color-mix(in srgb, var(--loss) 30%, transparent); background: linear-gradient(160deg, var(--loss-dim), var(--surface) 72%); }
.sc-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sc-hero-label { font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; }
.sc-reset-stats {
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text-2);
  padding: 6px 10px;
  font: 700 10px/1 var(--body, inherit);
  letter-spacing: .02em;
  cursor: pointer;
}
.sc-reset-stats:hover:not(:disabled) { border-color: var(--amber-line); color: var(--amber); background: var(--amber-bg); }
.sc-reset-stats:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.sc-reset-stats:disabled { cursor: not-allowed; opacity: .45; }
.sc-hero-value { font-family: var(--mono); font-size: 34px; font-weight: 800; line-height: 1.05; margin: 5px 0 7px; color: var(--text); }
.sc-hero-pos .sc-hero-value { color: var(--gain); }
.sc-hero-neg .sc-hero-value { color: var(--loss); }
.sc-hero-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; font-size: var(--fs-label); color: var(--text-2); font-family: var(--mono); }
.sc-hero-sub .pos { color: var(--gain); }
.sc-hero-sub .neg { color: var(--loss); }
.sc-hero-sub .sc-muted { color: var(--text-3); font-family: var(--body, inherit); }
.sc-reset-since { margin-top: 8px; color: var(--text-3); font-size: 10.5px; line-height: 1.4; }
.sc-dot-sep { color: var(--text-3); }

/* Stat chips */
.sc-stats {
  grid-area: stats;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.sc-stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: var(--surface-hi);
}
.sc-stat span { display: block; font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: 3px; }
.sc-stat strong { font-family: var(--mono); font-size: var(--fs-md); color: var(--text); }
.sc-alloc {
  grid-area: alloc;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-hi);
}
.sc-alloc-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: var(--fs-label);
  font-weight: 700;
}
.sc-alloc-head > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sc-autoinvest {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2, rgba(120,130,150,.06));
  cursor: pointer;
}
.sc-autoinvest.is-on { border-color: var(--green-line, #6fce9a); background: var(--green-bg, rgba(20,184,116,.08)); }
.sc-autoinvest input { width: 18px; height: 18px; accent-color: #16a34a; flex: 0 0 auto; cursor: pointer; }
.sc-autoinvest-text { font-size: 13px; font-weight: 700; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.sc-autoinvest-text small { font-weight: 400; font-size: 11.5px; color: var(--text-3); }
.sc-autoinvest-btn[disabled] { opacity: 1; cursor: default; color: var(--good, #1d9e75); border-color: var(--green-line, #6fce9a); background: var(--green-bg, rgba(20,184,116,.08)); }
.sc-pct-badge {
  justify-self: end;
  color: #fff;
  font-family: var(--mono);
  font-size: var(--fs-label);
  line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent);
}
.strategy-save-hint {
  grid-column: 1 / -1;
  justify-self: start;
  color: var(--amber);
  border: 1px solid var(--amber-line);
  background: var(--amber-dim);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.strategy-saved-hint {
  grid-column: 1 / -1;
  justify-self: start;
  color: var(--green);
  border: 1px solid var(--green-line);
  background: var(--green-dim);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.sc-alloc input[type="range"] {
  width: 100%;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}
.sc-scale {
  display: flex;
  justify-content: space-between;
  color: var(--text-3);
  font-size: var(--fs-micro);
  font-family: var(--mono);
}
.sc-alloc-note {
  color: var(--text-3);
  font-size: var(--fs-caption);
  line-height: 1.45;
}
.sc-alloc-note b { color: var(--text-2); font-family: var(--mono); }
.sc-alloc .btn { justify-self: end; }

/* Actions — big, clear on/off + start/pause */
.sc-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.sc-actions .btn {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 800;
  font-size: var(--fs-body);
  justify-content: center;
}
.sc-actions .btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
/* Allocation-too-high warning takes a full-width row. */
.strategy-control-warning {
  grid-area: warn;
  margin: 0;
  border: 1px solid var(--amber-line);
  border-radius: 10px;
  padding: 8px 11px;
  background: var(--amber-dim);
  color: var(--amber);
  font-size: var(--fs-caption);
  line-height: 1.45;
}
/* Fire Ants profit-target panel */
.strategy-fire-settings.sc-fire {
  grid-area: fire;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: stretch;
  padding: 13px 15px;
  border: 1px solid var(--amber-line);
  border-radius: 14px;
  background: var(--amber-dim);
}
.sc-fire-row {
  display: grid;
  grid-template-columns: minmax(0, 240px) 1fr;
  gap: 8px 16px;
  align-items: end;
}
.strategy-fire-settings label {
  display: grid;
  gap: 5px;
  color: var(--text-2);
  font-size: var(--fs-caption);
  line-height: 1.25;
}
.strategy-fire-settings input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  font-family: var(--mono);
  outline: none;
}
.sc-fire-meta { display: grid; gap: 4px; align-content: end; }
.sc-fire-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sc-fire-foot .btn { flex: 0 0 auto; }
/* Strategy source tag (AGS / Ants / MoBr) on live positions and scanned candidates. */
.strategy-source-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-hi);
  color: var(--text-2);
  font-size: var(--fs-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  vertical-align: middle;
}
.strategy-source-tag.ags  { color: var(--accent); border-color: var(--accent-line); background: var(--accent-dim); }
.strategy-source-tag.ants { color: var(--gain);   border-color: var(--green-line); background: var(--gain-dim); }
.strategy-source-tag.mobr { color: var(--amber);  border-color: var(--amber-line); background: var(--amber-dim); }
.strategy-source-tag.scalp { color: #fff; border-color: transparent; background: var(--accent); }
.strategy-source-tag.manual { color: var(--text-3); border-color: var(--line); background: transparent; }
/* Demo/paper mode removed — hide the Demo/API toggle and any demo-only mode strips. */
#appModeToggle { display: none !important; }
.mode-strip.paper { display: none !important; }
.strategy-source-tag.untracked { color: var(--text-2); border-color: var(--line-strong); background: var(--surface-hi); }
.strategy-source-tag.dumpshort { color: var(--loss, #d33); border-color: var(--red-line, var(--line-strong)); background: var(--loss-dim, var(--surface-hi)); }
.strategy-source-tag.squeeze { color: var(--gain, #0a6); border-color: var(--green-line, var(--line-strong)); background: var(--gain-dim, var(--surface-hi)); }
.ds2-scan-card.squeeze.ready { border-color: color-mix(in srgb, var(--green) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--green) 14%, transparent), 0 6px 18px color-mix(in srgb, var(--green) 10%, transparent); }
/* Tablet / mobile: the 3-column layout can't fit, so stack every section into a
   single column in a clean reading order (identity → stats → allocation → actions). */
@media (max-width: 860px) {
  .strategy-control-item {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "hero"
      "stats"
      "alloc"
      "warn"
      "fire"
      "actions";
    gap: 12px;
    padding: 14px 14px 16px 18px;
  }
  .sc-hero-value { font-size: 30px; }
}
@media (max-width: 560px) {
  .strategy-allocation-summary { grid-template-columns: 1fr; }
  .sc-fire-row { grid-template-columns: 1fr; }
  .sc-name { font-size: var(--fs-h2); }
  .sc-hero-value { font-size: 27px; }
  .strategy-control-card { overflow: hidden; }
  .strategy-control-grid,
  .strategy-control-item,
  .strategy-control-item > *,
  .sc-identity,
  .sc-idtext,
  .sc-hero,
  .sc-stats,
  .sc-alloc,
  .dumpshort-settings,
  .ds-grid,
  .sniper-risk-field { min-width: 0; max-width: 100%; }
  .strategy-control-item { width: 100%; padding: 12px 10px 14px 14px; gap: 10px; }
  .sc-head { margin-inline: -3px; padding-inline: 3px; }
  .sc-desc { overflow-wrap: anywhere; }
  .sc-hero { padding: 13px 14px; }
  .sc-hero-top { align-items: flex-start; }
  .sc-reset-stats { max-width: 132px; white-space: normal; line-height: 1.2; text-align: center; }
  .sc-stats.sc-stats-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .sc-stat { padding: 8px; }
  .sc-stat span { font-size: 9px; letter-spacing: .035em; }
  .sc-stat strong { font-size: var(--fs-h3); }
  .sc-alloc { padding: 12px; gap: 7px; }
  .sc-alloc-head { font-size: var(--fs-caption); gap: 6px; }
  .sc-pct-badge { padding: 4px 7px; font-size: var(--fs-caption); }
  .sc-autoinvest { padding: 9px 10px; gap: 8px; }
  .sc-autoinvest-text { min-width: 0; font-size: 12.5px; }
  .sc-autoinvest-text small { font-size: 10.5px; line-height: 1.3; }
  .sc-scale { font-size: 9px; }
}
@media (max-width: 400px) {
  .sc-stat { padding: 8px 9px; }
  .sc-stat strong { font-size: var(--fs-h3); }
  .sc-head-right { width: 100%; }
  .sc-stats.sc-stats-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Connection page guided API setup */
#connect .connect-hero .compact-flow {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
#connect .connect-exchange-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  margin-bottom: 14px;
}
#connect .exchange-btn {
  min-height: 92px;
}
.exchange-mode-panel {
  margin-top: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-mid);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.exchange-mode-panel[hidden],
.connect-selection-detail[hidden],
#apiManagementCard[hidden],
#liveExecutionCard[hidden] {
  display: none !important;
}
.connect-code-panel {
  margin: 16px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-mid);
}
.connect-code-panel > summary {
  color: var(--text-2);
  font-weight: 700;
  cursor: pointer;
}
.api-step-list {
  display: grid;
  gap: 12px;
}
.api-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-mid);
}
.api-step-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 800;
}
.api-step-body { min-width: 0; }
.api-step-title {
  display: block;
  margin: 2px 0 3px;
  color: var(--text);
  font-weight: 700;
}
.api-step-help {
  display: block;
  margin-bottom: 9px;
  color: var(--text-3);
  font-size: var(--fs-small);
  line-height: 1.45;
}
.api-step-title + .input { margin-top: 9px; }
.api-final-step { margin-top: 12px; }
.api-safety-checklist {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}
.api-safety-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--text-2);
  cursor: pointer;
}
.api-safety-item input { width: 17px; height: 17px; accent-color: var(--accent); }
.api-advanced-checks { margin-top: 12px; }
.api-advanced-checks summary { color: var(--text-3); cursor: pointer; }
.api-advanced-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.api-permission-note {
  grid-column: 1 / -1;
  margin-top: 2px;
  padding-block: 10px;
  font-size: var(--fs-small);
}
.exchange-feedback {
  margin-top: 12px;
  padding: 14px 16px;
}
.exchange-feedback-title {
  color: var(--text);
  font-weight: 700;
  line-height: 1.35;
}
.exchange-feedback-message {
  margin-top: 4px;
  color: var(--text-2);
  line-height: 1.5;
}
.exchange-coming-soon {
  margin: -2px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-mid);
}
.exchange-coming-soon summary {
  color: var(--text-2);
  font-weight: 600;
  cursor: pointer;
}
.exchange-coming-soon .section-sub { margin-top: 8px; }
.exchange-mode-panel.is-disabled {
  opacity: .68;
}
.exchange-mode-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mode-pill {
  min-width: 132px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-raised);
  color: var(--text-2);
  padding: 11px 13px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.mode-pill:hover,
.mode-pill.active {
  border-color: var(--accent-line);
  background: var(--accent-dim);
  color: var(--text);
}
.mode-pill:active {
  transform: scale(.98);
}
.mode-pill b,
.mode-pill small {
  display: block;
}
.mode-pill b {
  font-size: var(--fs-sm);
  line-height: 1.2;
}
.mode-pill small {
  margin-top: 3px;
  color: var(--text-3);
  font-size: var(--fs-caption);
  line-height: 1.3;
}
.setup-guide-card .guide-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.setup-step-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: setupStep;
}
.setup-step-list li {
  counter-increment: setupStep;
  position: relative;
  padding: 12px 14px 12px 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-mid);
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.setup-step-list li::before {
  content: counter(setupStep);
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-weight: 800;
  font-size: var(--fs-label);
  font-family: var(--font-display);
}
.strong-notice {
  border-color: var(--amber-line) !important;
  background: var(--amber-bg) !important;
  color: var(--amber) !important;
}
.runner-ip-field strong {
  font-size: var(--fs-h2);
}
@media (max-width: 920px) {
  #connect .connect-exchange-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 720px) {
  #connect .connect-hero .compact-flow {
    grid-template-columns: 1fr !important;
  }
  #connect .connect-exchange-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .exchange-mode-panel {
    align-items: stretch;
  }
  .exchange-mode-tabs,
  .mode-pill {
    width: 100%;
  }
}
@media (max-width: 360px) {
  #connect .connect-exchange-grid { grid-template-columns: 1fr !important; }
}

/* Algo Radar — Pump & Dump Sniper */
.legacy-hidden[hidden] {
  display: none !important;
}
.risk-tabs {
  margin: 4px 0 16px;
  flex-wrap: wrap;
}
.risk-tab-panel {
  display: none;
}
.risk-tab-panel.active {
  display: block;
}
.risk-lab-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.risk-lab-form label {
  display: grid;
  gap: 6px;
  color: var(--text-2);
  font-size: var(--fs-caption);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.risk-lab-form input,
.strategy-health-controls select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.9);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  outline: none;
}
.risk-lab-form input {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
.risk-lab-form input:focus,
.strategy-health-controls select:focus {
  border-color: rgba(91,141,255,.55);
  box-shadow: 0 0 0 3px rgba(91,141,255,.12);
}
.strategy-health-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.strategy-health-controls select {
  min-width: 150px;
}
#riskLabWarnings {
  white-space: normal;
}
@media (max-width: 720px) {
  .strategy-health-controls {
    width: 100%;
    justify-content: stretch;
  }
  .strategy-health-controls select,
  .strategy-health-controls .btn {
    width: 100%;
  }
}

#algo-radar > .grid.g2 {
  grid-template-columns: minmax(0, 1fr) !important;
  align-items: start;
}
#algo-radar .card { min-width: 0; }

.algo-radar-stack { display:grid; grid-template-columns: minmax(0, 1fr); gap:16px; }
.radar-price-map-card { order:1; }
.radar-scanner-card { order:2; }
.radar-signal { display:flex; flex-direction:column; align-items:flex-start; gap:6px; }
.radar-signal-pill { display:inline-flex; align-items:center; justify-content:center; min-width:72px; padding:6px 10px; border-radius:999px; font-weight: 800; font-size: var(--fs-label); letter-spacing:.06em; text-transform:uppercase; }
.radar-signal.long .radar-signal-pill { color:#079455; background:rgba(20,184,116,.12); border:1px solid rgba(20,184,116,.28); }
.radar-signal.short .radar-signal-pill { color:#dc2626; background:rgba(239,68,68,.12); border:1px solid rgba(239,68,68,.28); }
.radar-signal.watch .radar-signal-pill { color:var(--text-2); background:rgba(100,116,139,.10); border:1px solid var(--line); }
/* ── Dump Short "Top Losing Coins" table (2026-07-12): compact type, wider Reason
   column (SHORT pill removed — everything here is a short), and a ~6-row scroll
   window so long scans don't stretch the page. ── */
#dumpShortTable {
  max-height: 600px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
}
#dumpShortTable::-webkit-scrollbar { width: 8px; }
#dumpShortTable::-webkit-scrollbar-thumb { background: var(--line-strong, var(--line)); border-radius: 8px; }
#dumpShortTable .radar-table-head,
#dumpShortTable .radar-row {
  grid-template-columns:
    minmax(120px, 1.05fr)
    minmax(92px, .62fr)
    minmax(66px, .48fr)
    minmax(76px, .52fr)
    minmax(92px, .62fr)
    minmax(160px, 1.1fr)
    minmax(160px, 1.1fr);
  gap: 10px;
}
#dumpShortTable .radar-row b { font-size: 13px; }
#dumpShortTable .radar-row small { font-size: 10.5px; }
/* Dump Short 2.0 obfuscated scanner (2026-07-14): 4 neutral columns — Coin / Signal / Ref price /
   Status. Deliberately reveals no timeframes, EMA, exposure ladder or exit rule. */
#dumpShort2Table .radar-table-head,
#dumpShort2Table .radar-row {
  grid-template-columns:
    minmax(150px, 1.4fr)
    minmax(120px, .9fr)
    minmax(110px, .8fr)
    minmax(160px, 1.3fr);
  gap: 12px;
  min-width: 640px;
}
@media (max-width: 860px) {
  #dumpShort2Table .radar-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; min-width: 0; }
  #dumpShort2Table .radar-row > .radar-reason { grid-column: 1 / -1; }
}
#dumpShortTable .radar-coin b { font-size: 13.5px; }
/* Responsive scanner (2026-07-12): on small screens show the FULL row — coin, status, signal,
   24h, volume, plan and reason — as a stacked card instead of hiding Volume/Plan/Reason. */
@media (max-width: 860px) {
  #dumpShortTable .radar-row {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px 10px;
    align-items: start;
    padding: 14px 16px;
  }
  #dumpShortTable .radar-row > span { display: block !important; overflow: visible; }
  #dumpShortTable .radar-row > .radar-coin { grid-column: 1 / 3; min-width: 0; }
  #dumpShortTable .radar-row > .radar-signal { grid-column: 3 / 4; align-items: flex-end; text-align: right; }
  #dumpShortTable .radar-row > .radar-plan,
  #dumpShortTable .radar-row > .radar-reason {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    padding-top: 8px;
    margin-top: 2px;
  }
  #dumpShortTable .radar-row b,
  #dumpShortTable .radar-row small { white-space: normal; overflow-wrap: anywhere; text-overflow: clip; }
}
/* Live positions pair cell (2026-07-12): Bybit-style — pair on top, SHORT · leverage
   small underneath. Side and Size columns removed; leverage/direction live here. */
/* Daily target progress bar (2026-07-12) */
.dtp-card { }
.dtp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.dtp-title-line { display: flex; align-items: center; gap: 9px; min-width: 0; }
.dtp-title { font-weight: 800; font-size: 14px; }
.session-state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .05em;
}
.session-state-pill.on { color: var(--gain); border-color: var(--green-line); background: var(--gain-dim); }
.session-state-pill.off { color: var(--text-3); background: var(--surface-hi); }
.dtp-status { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.dtp-status.hit { color: var(--gain, #16a34a); }
.dtp-status.neg { color: var(--loss, #dc2626); }
.dtp-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: var(--surface-hi, rgba(120,132,164,.14));
  overflow: hidden;
}
/* Zero line sits where P&L = 0 within the min..target range (only visible when today is negative). */
.dtp-zero { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--line-strong, rgba(120,132,164,.5)); z-index: 2; }
.dtp-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; transition: left .3s ease, width .3s ease, background .3s ease; }
.dtp-fill.pos { background: var(--gain, #16a34a); }
.dtp-fill.neg { background: var(--loss, #dc2626); }
.dtp-fill.hit { background: var(--gain, #16a34a); }
.dtp-labels { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--text-2); font-family: var(--font-mono); }
.session-breakdown {
  display: flex;
  flex-wrap: wrap;
  margin-top: 5px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.45;
}
.session-booked-value { font-weight: 700; }
.session-booked-value.positive { color: var(--gain); }
.session-booked-value.negative { color: var(--loss); }
.session-booked-value.neutral { color: var(--text-2); }
.session-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
.session-summary-copy {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
}
.session-summary-copy b { color: var(--text); font-family: var(--mono); font-size: 14px; font-weight: 500; }
.session-summary-copy i { color: var(--text-3); font-style: normal; }
.session-saved-label { color: var(--gain); font-size: 13.5px; font-weight: 800; }
.session-edit-btn {
  flex: 0 0 auto;
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  color: var(--blue);
  border: 1px solid var(--blue-line);
  background: var(--blue-bg);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--blue) 5%, transparent);
}
.session-edit-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

body.session-sheet-open { overflow: hidden; }
.session-settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 2400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(8, 12, 20, .52);
  backdrop-filter: blur(4px);
}
.session-settings-sheet {
  width: min(460px, 100%);
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 70px -24px rgba(0, 0, 0, .62);
}
.session-sheet-handle { display: none; }
.session-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.session-sheet-head small { display: block; color: var(--text-3); font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.session-sheet-head h3 { margin: 3px 0 0; font-size: 20px; line-height: 1.2; }
.session-sheet-close { width: 34px; min-width: 34px; height: 34px; padding: 0; border-radius: 10px; font-size: 22px; color: var(--text-3); }
.session-sheet-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "copy switch";
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-mid);
  cursor: pointer;
}
.session-sheet-toggle > span { grid-area: copy; }
.session-sheet-toggle b { display: block; font-size: 13px; }
.session-sheet-toggle small { display: block; margin-top: 3px; color: var(--text-3); font-size: 11px; line-height: 1.35; }
.session-sheet-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.session-sheet-toggle > i {
  grid-area: switch;
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background .16s ease;
}
.session-sheet-toggle > i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .22);
  transition: transform .16s ease;
}
.session-sheet-toggle.is-on { border-color: var(--green-line); background: var(--gain-dim); }
.session-sheet-toggle.is-on > i { background: var(--gain); }
.session-sheet-toggle.is-on > i::after { transform: translateX(18px); }
.session-sheet-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.session-sheet-fields > label { display: block; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-mid); }
.session-sheet-fields > label > span { display: block; font-size: 12px; font-weight: 750; }
.session-sheet-fields > label > small { display: block; min-height: 30px; margin-top: 3px; color: var(--text-3); font-size: 10px; line-height: 1.35; }
.session-sheet-fields > label > div { display: flex; align-items: center; gap: 5px; margin-top: 9px; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-hi); }
.session-sheet-fields input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; font-family: var(--mono); font-size: 16px; font-weight: 700; }
.session-sheet-fields em { color: var(--text-3); font-size: 11px; font-style: normal; font-weight: 700; }
.session-sheet-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.session-sheet-actions .btn { min-height: 40px; justify-content: center; }

@media (max-width: 640px) {
  .session-settings-overlay { align-items: flex-end; padding: 0; }
  .session-settings-sheet { width: 100%; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); border-width: 1px 0 0; border-radius: 22px 22px 0 0; }
  .session-sheet-handle { display: block; width: 38px; height: 4px; margin: 0 auto 12px; border-radius: 999px; background: var(--line-strong); }
  .session-sheet-actions .btn { flex: 1 1 0; }
  .session-summary-copy { gap: 7px; row-gap: 4px; flex-wrap: wrap; white-space: normal; font-size: 12px; }
  .session-summary-copy b { font-size: 13px; }
  .session-saved-label { font-size: 12.5px; }
  .session-breakdown { font-size: 11.5px; }
}
.trade-pair-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: max-content;
  max-width: 100%;
}
.trade-pair-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  line-height: 1;
}
.trade-pair-meta .strategy-source-tag,
.trade-pair-meta .badge {
  min-height: 14px;
  width: auto;
  max-width: max-content;
  padding: 1px 4px;
  border-radius: 5px;
  font-size: 8px;
  line-height: 1;
  letter-spacing: .015em;
}
.trade-pair-click { cursor: pointer; border-radius: 8px; transition: background .12s ease; }
.trade-pair-click:hover { background: rgba(120,132,164,.10); }
.trade-pair-click:focus-visible { outline: 2px solid var(--accent, #5b8dff); outline-offset: 2px; }
.trade-pair-meta .trade-side-sub {
  font-size: 8.5px;
  font-weight: 750;
  line-height: 1;
  letter-spacing: .015em;
  opacity: .9;
}
.radar-warning-line { margin-top:8px; color:var(--amber, #b7791f); font-size: var(--fs-label); }
.radar-block-line { margin-top:8px; color:var(--red, #dc2626); font-size: var(--fs-label); }

.algo-radar-hero { position: relative; overflow: hidden; }
.algo-radar-hero::after {
  content:""; position:absolute; inset:-60px -80px auto auto; width:220px; height:220px;
  background: radial-gradient(circle, rgba(58,132,255,.18), transparent 62%);
  pointer-events:none;
}
.radar-source-stack { display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end; }
.radar-rule-strip { display:flex; gap:8px; flex-wrap:wrap; margin-top:14px; }
.radar-tabs { margin: 2px 0 14px; flex-wrap:wrap; }
.algo-radar-table {
  display:grid;
  gap:10px;
  overflow-x:auto;
  overflow-y:visible;
  padding-bottom:4px;
}
.radar-table-head, .radar-row {
  display:grid;
  grid-template-columns:
    minmax(150px, 1.25fr)
    minmax(138px, .95fr)
    minmax(78px, .5fr)
    minmax(105px, .72fr)
    minmax(118px, .82fr)
    minmax(96px, .62fr)
    minmax(108px, .72fr);
  gap:14px;
  align-items:center;
  min-width:900px;
}
.radar-table-head { color:var(--text-3); font-size: var(--fs-caption); text-transform:uppercase; letter-spacing:.08em; padding:0 16px; }
.radar-row {
  width:100%; text-align:left; border:1px solid var(--line); border-radius:20px;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.032));
  color:var(--text); padding:14px 16px; cursor:pointer; min-height:78px;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.radar-row:hover { transform: translateY(-1px); border-color:rgba(91,141,255,.5); background:rgba(91,141,255,.08); box-shadow:0 12px 24px rgba(15,23,42,.08); }
.radar-row span { min-width:0; overflow:hidden; }
.radar-row b, .radar-row small, .radar-coin b, .radar-coin small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.radar-row small, .radar-coin small { display:block; color:var(--text-3); font-size: var(--fs-caption); margin-top:5px; line-height:1.25; }
.radar-coin b { display:block; font-family:var(--font-mono); letter-spacing:.02em; font-size: var(--fs-h3); }
.radar-row .badge { display:inline-flex; width:max-content; max-width:100%; justify-content:center; padding:6px 11px; line-height:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
/* Plan + Reason cells wrap fully (2026-07-12): no truncation. Plan stacks
   Entry / SL / TP on their own lines; Reason shows plain-English text in full. */
.radar-row { align-items: start; }
.radar-plan, .radar-reason { overflow: visible; }
.radar-plan b, .radar-plan small, .radar-plan-line,
.radar-reason b, .radar-reason small {
  overflow: visible; white-space: normal; text-overflow: clip;
  overflow-wrap: anywhere; word-break: normal;
}
.radar-plan b, .radar-reason b { display: block; line-height: 1.3; }
.radar-plan-line {
  display: block; font-family: var(--font-mono); font-size: 12px;
  color: var(--text-2); margin-top: 3px; line-height: 1.3;
}
/* Strategy Lab (Dump Short analytics) */
.dl-block { margin-top: 14px; }
.dl-block-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }
.dl-bar-row { display: grid; grid-template-columns: 150px 1fr 84px; align-items: center; gap: 10px; margin: 6px 0; }
.dl-bar-label { font-size: 12.5px; color: var(--text-2); }
.dl-bar-track { height: 10px; border-radius: 999px; background: rgba(120,130,150,.14); overflow: hidden; }
.dl-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent, #5b8dff); }
.dl-bar-val { font-size: 12px; font-family: var(--font-mono); color: var(--text); text-align: right; }
.dl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dl-table th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.dl-table td { padding: 10px; border-bottom: 1px solid var(--line); }
.dl-table tr:last-child td { border-bottom: 0; }
.dl-table code { font-size: 12px; word-break: break-all; }
.pill-live { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .05em; color: #fff; background: var(--good, #1d9e75); padding: 1px 6px; border-radius: 999px; vertical-align: middle; }
/* Compact 2-up scorecard/exit grids — stay 2 columns even on mobile (no 1-per-row). */
#dumpLabScorecard, #dumpLabExits {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 900px) {
  #dumpLabScorecard, #dumpLabExits { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
#dump-lab .card { padding: 16px; }
#dump-lab .dl-metric { padding: 11px 12px; min-height: 0; }
#dump-lab .dl-metric .metric-label { font-size: 10.5px; letter-spacing: .05em; margin-bottom: 2px; }
#dump-lab .dl-metric .metric-value { font-size: 19px !important; margin-top: 2px; line-height: 1.15; }
#dump-lab .dl-metric .metric-sub { font-size: 10.5px; margin-top: 3px; line-height: 1.25; }
#dump-lab .section-title { font-size: 15px; }
@media (max-width: 560px) {
  .dl-bar-row { grid-template-columns: 96px 1fr 60px; gap: 8px; }
  .dl-bar-label { font-size: 11.5px; }
  #dump-lab .dl-metric .metric-value { font-size: 18px !important; }
}
.radar-sources { display:flex; gap:5px; flex-direction:column; align-items:flex-start; justify-content:center; }
.radar-sources i { font-style:normal; font-size: var(--fs-caption); padding:3px 8px; border-radius:999px; background:rgba(255,255,255,.06); color:var(--text-2); max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.radar-detail-head { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; margin-bottom:12px; }
.radar-price-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap:10px; }
.radar-price-card { border:1px solid var(--line); border-radius: 16px; padding:12px; background:rgba(255,255,255,.035); }
.radar-price-card.is-bybit { border-color:var(--green-line); background:var(--green-bg); }
.rpc-ex { display:flex; justify-content:space-between; align-items:center; gap:8px; color:var(--text-2); font-size: var(--fs-label); }
.rpc-price { margin-top:8px; font-family:var(--font-mono); font-size: var(--fs-h2); font-weight:800; color:var(--text); }
.rpc-sub { margin-top:4px; font-size: var(--fs-label); color:var(--text-3); }
.pump-sniper-settings { border-color:rgba(91,141,255,.28); background:rgba(91,141,255,.06); }
@media (max-width: 860px) {
  .radar-table-head { display:none; }
  .radar-row { grid-template-columns:1fr 1fr; min-width:0; }
  .radar-row > span:nth-child(n+5) { display:none; }
  .radar-detail-head { flex-direction:column; }
}

.radar-trade-plan { margin-top:14px; border:1px solid var(--line); border-radius:20px; padding:14px; background:rgba(91,141,255,.07); }
.radar-plan-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap:10px; margin:12px 0; }
.radar-plan-grid > div { border:1px solid var(--line); border-radius:14px; padding:10px; background:rgba(255,255,255,.04); }
.radar-plan-grid span { display:block; color:var(--text-3); font-size: var(--fs-caption); text-transform:uppercase; letter-spacing:.07em; margin-bottom:4px; }
.radar-plan-grid b { font-family:var(--font-mono); color:var(--text); }

.sniper-risk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
/* ── Dump Short settings redesign (2026-07-11) ── */
.strategy-fire-settings.sc-fire.dumpshort-settings {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid var(--blue-line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--blue) 5%, var(--surface)), color-mix(in srgb, var(--blue) 2%, var(--surface)));
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 65%, transparent);
}
/* Keep every strategy-owned settings panel inside the card's collapse state. This selector is
   intentionally more specific than the redesigned settings display rule above. */
.strategy-control-item.is-collapsed .strategy-fire-settings.sc-fire { display: none; }
.ds-head { display: block; }
.ds-head-text { min-width: 0; }
.ds-title { font-weight: 800; font-size: 15px; }
.ds-sub { color: var(--text-2); font-size: 12.5px; line-height: 1.55; margin-top: 4px; max-width: 560px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.ds-mode { flex: 0 1 240px; min-width: 210px; }
.ds-mode select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255,255,255,.055); color: var(--text);
  padding: 10px 11px; font-size: var(--fs-sm); outline: none;
}
.ds-mode select:focus { border-color: rgba(91,141,255,.55); box-shadow: 0 0 0 3px rgba(91,141,255,.12); }
.ds-mode-note {
  border-left: 3px solid var(--blue);
  background: color-mix(in srgb, var(--blue) 6%, var(--surface));
  border-radius: 0 10px 10px 0;
  padding: 9px 12px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.55;
}
.ds-mode-note b { color: var(--text); }
.ds-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ds-grid > * { min-width: 0; }
@media (max-width: 900px) { .ds-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ds-daily {
  border-top: 1px dashed var(--line);
  padding-top: 15px;
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) minmax(220px, 1fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 760px) { .ds-daily { grid-template-columns: 1fr; } }
.ds-switch { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.ds-switch input {
  appearance: none; -webkit-appearance: none;
  width: 42px; height: 23px; flex: 0 0 42px;
  border-radius: 999px; background: var(--line);
  position: relative; cursor: pointer; transition: background .15s ease; margin-top: 1px; outline: none;
}
.ds-switch input:checked { background: var(--gain, #22c55e); }
.ds-switch input::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: left .15s ease;
}
.ds-switch input:checked::after { left: 22px; }
.ds-switch-text b { display: block; font-size: 13.5px; color: var(--text); }
.ds-switch-text small { display: block; color: var(--text-2); font-size: 11.5px; line-height: 1.5; margin-top: 3px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.ds-daily-fields { display: grid; gap: 8px; }
.ds-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  border-top: 1px solid var(--line); padding-top: 14px; flex-wrap: wrap;
}
.ds-summary { color: var(--text-2); font-size: 12px; line-height: 1.5; }
.ds-foot .ds-save { flex: 0 0 auto; min-width: 200px; margin: 0; transition: background .15s ease, color .15s ease; }
.btn.is-saved { background: var(--gain-dim) !important; border-color: var(--green-line) !important; color: var(--gain) !important; opacity: 1 !important; }
.sniper-risk-field {
  display: grid;
  gap: 6px;
  color: var(--text-2);
  font-size: var(--fs-caption);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.sniper-risk-field small { font-size: 9px; letter-spacing: .03em; }
.sniper-risk-field input {
  min-width: 0;
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.055);
  color: var(--text);
  padding: 10px 11px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  outline: none;
}
.ds-session-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--text-2);
  cursor: pointer;
}
.strategy-fire-settings .ds-session-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  padding: 0;
  accent-color: var(--accent);
}
.ds-session-toggle b { font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: .06em; }
.ds-cost-preview {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--blue) 24%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--blue) 4%, var(--surface));
}
.ds-cost-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.ds-cost-title { color: var(--text); font-size: 13.5px; font-weight: 800; }
.ds-cost-sub { margin-top: 3px; color: var(--text-2); font-size: 11.5px; line-height: 1.45; }
.ds-cost-assumptions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.ds-cost-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.ds-cost-stat {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.ds-cost-stat > span,
.ds-cost-stat > small {
  display: block;
  color: var(--text-2);
  font-size: 10px;
  line-height: 1.4;
}
.ds-cost-stat > span { text-transform: uppercase; letter-spacing: .045em; font-weight: 700; }
.ds-cost-stat > strong {
  display: block;
  margin: 5px 0 3px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.ds-cost-outcome {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.ds-cost-outcome-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  color: var(--text-2);
  font-size: 11.5px;
}
.ds-cost-outcome-row + .ds-cost-outcome-row { border-top: 1px solid var(--line); }
.ds-cost-outcome-row strong { color: var(--text); text-align: right; font-family: var(--font-mono); font-size: 11.5px; }
.ds-cost-outcome-row strong.pos { color: var(--gain); }
.ds-cost-outcome-row strong.neg { color: var(--loss); }
.ds-cost-verdict {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11.5px;
  line-height: 1.5;
}
.ds-cost-verdict.is-positive {
  border-color: var(--green-line);
  background: var(--gain-dim);
  color: var(--gain);
}
.ds-cost-verdict.is-warning {
  border-color: var(--amber-line);
  background: var(--amber-bg);
  color: var(--amber);
}
.ds-cost-preview.is-disabled .ds-cost-outcome,
.ds-cost-preview.is-disabled .ds-cost-verdict { opacity: .6; }
.ds-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--blue) 14%, var(--line));
}
.ds-actions .btn {
  width: 100%;
  min-height: 40px;
  justify-content: center;
}
.ds-actions .ds-reset {
  color: var(--text-2);
  border-color: var(--blue-line);
  background: color-mix(in srgb, var(--blue) 3%, var(--surface));
}
@media (max-width: 560px) {
  .strategy-fire-settings.sc-fire.dumpshort-settings { padding: 13px 11px; gap: 11px; border-radius: 14px; }
  .ds-head { gap: 8px; }
  .ds-title { font-size: 14px; }
  .ds-sub { font-size: 11px; line-height: 1.4; }
  .ds-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .sniper-risk-field { gap: 5px; font-size: 10px; letter-spacing: .04em; }
  .sniper-risk-field input { padding: 9px; border-radius: 11px; }
  .ds-mode-note { padding: 8px 10px; font-size: 11px; line-height: 1.45; }
  .ds-session { margin-top: 4px !important; padding-top: 10px !important; }
  .ds-cost-preview { padding: 11px; }
  .ds-cost-head { align-items: flex-start; }
  .ds-cost-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-cost-outcome-row { align-items: flex-start; flex-direction: column; gap: 3px; }
  .ds-cost-outcome-row strong { text-align: left; }
}
@media (max-width: 360px) {
  .ds-grid { grid-template-columns: 1fr; }
  .ds-cost-assumptions,
  .ds-cost-grid { grid-template-columns: 1fr; }
}
.dashboard-community-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.dashboard-community-copy {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.dashboard-community-copy > div { min-width: 0; }
.dashboard-community-copy strong {
  display: block;
  color: var(--text);
  font-size: var(--fs-sm);
}
.dashboard-community-copy small {
  display: block;
  margin-top: 2px;
  color: var(--text-2);
  font-size: var(--fs-caption);
  line-height: 1.45;
}
.dashboard-community-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  color: var(--accent);
  background: var(--accent-dim);
}
.dashboard-community-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dashboard-community-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding-inline: 16px;
  text-decoration: none;
}
.dashboard-risk-note {
  margin: 8px 4px 0;
  color: var(--text-3);
  font-size: var(--fs-micro);
  line-height: 1.45;
  text-align: center;
}
@media (max-width: 560px) {
  .dashboard-community-card {
    align-items: stretch;
    flex-direction: column;
    gap: 11px;
    padding: 13px;
  }
  .dashboard-community-button {
    width: 100%;
    justify-content: center;
  }
  .dashboard-risk-note { margin-inline: 10px; }
}
.sniper-risk-field input:focus {
  border-color: rgba(91,141,255,.55);
  box-shadow: 0 0 0 3px rgba(91,141,255,.12);
}

/* Owner Arb Radar */
#arb-radar .card { min-width:0; }
.arb-hero { position:relative; overflow:hidden; }
.arb-control-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:10px; }
.arb-control-grid label, #arb-radar .form-grid label { display:flex; flex-direction:column; gap:6px; color:var(--text-3); font-size: var(--fs-caption); text-transform:uppercase; letter-spacing:.07em; }
.arb-control-grid input, #arb-radar .form-grid input { width:100%; border:1px solid var(--line); background:rgba(255,255,255,.8); border-radius:14px; padding:12px; color:var(--text); font:inherit; text-transform:none; letter-spacing:0; }
.arb-rule-list { display:grid; gap:10px; }
.arb-rule-list > div { border:1px solid var(--line); border-radius:16px; padding:12px; background:rgba(91,141,255,.06); }
.arb-rule-list b { display:block; margin-bottom:4px; }
.arb-rule-list span { color:var(--text-2); font-size: var(--fs-sm); }
.arb-table { display:grid; gap:10px; overflow-x:auto; }
.arb-table-head, .arb-row { display:grid; grid-template-columns:1.1fr 1.45fr .8fr .8fr .9fr .85fr; gap:14px; align-items:center; min-width:940px; }
.arb-table-head { color:var(--text-3); font-size: var(--fs-caption); text-transform:uppercase; letter-spacing:.08em; padding:0 16px; }
.arb-row { border:1px solid var(--line); border-radius: 16px; padding:14px 16px; background:rgba(255,255,255,.7); }
.arb-row.tradable { border-color:rgba(20,184,116,.32); background:rgba(20,184,116,.06); }
.arb-row b { display:block; color:var(--text); }
.arb-row small { display:block; color:var(--text-3); margin-top:5px; line-height:1.25; }
.btn.mini { padding:7px 10px; border-radius:12px; font-size: var(--fs-label); }
@media (max-width:720px) {
  .arb-table-head { display:none; }
  .arb-row { grid-template-columns:1fr 1fr; min-width:0; }
  .arb-row > span:nth-child(n+5) { display:none; }
  #arb-radar .grid.g2 { grid-template-columns:1fr; }
}
#arb-radar select { width:100%; border:1px solid var(--line); background:rgba(255,255,255,.9); border-radius:14px; padding:12px; color:var(--text); font:inherit; text-transform:none; letter-spacing:0; }
.arb-balance-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.arb-balance-card { border:1px solid var(--line); border-radius:16px; padding:12px; background:rgba(91,141,255,.06); min-height:82px; }
.arb-balance-card b { display:block; color:var(--text); margin-bottom:6px; }
.arb-balance-card strong { display:block; font-size: var(--fs-lg); color:var(--text); }
.arb-balance-card span, .arb-balance-card small { display:block; color:var(--text-2); line-height:1.35; }
.arb-balance-card.ok { border-color:rgba(20,184,116,.24); background:rgba(20,184,116,.06); }
.arb-balance-card.bad { border-color:rgba(239,68,68,.24); background:rgba(239,68,68,.06); }
@media(max-width:760px){ .arb-balance-grid { grid-template-columns:1fr; } }

/* Arb Radar live status panels */
#arb-radar .btn.success { border-color: rgba(20,184,116,.35); background: rgba(20,184,116,.12); color: #149452; }
.arb-active-panel, .arb-event-log { display:grid; gap:10px; }
.arb-active-card { border:1px solid rgba(20,184,116,.28); background:rgba(20,184,116,.06); border-radius:16px; padding:12px; display:grid; grid-template-columns:1.25fr .75fr .85fr .85fr .75fr .75fr .75fr auto; gap:10px; align-items:center; }
.arb-active-card b { display:block; color:var(--text); }
.arb-active-card span, .arb-active-card small { display:block; color:var(--text-3); line-height:1.35; }
.arb-active-card small { grid-column:1/-1; margin-top:2px; }
.arb-target-editor { grid-column:1/-1; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; align-items:end; padding:10px; border:1px solid rgba(91,141,255,.18); border-radius:14px; background:rgba(255,255,255,.54); }
.arb-target-editor label { display:grid; gap:5px; color:var(--text-3); font-size: var(--fs-label); font-weight:800; }
.arb-target-editor input, .arb-target-editor select { width:100%; border:1px solid var(--line); background:rgba(255,255,255,.9); border-radius:12px; padding:9px 10px; color:var(--text); font:inherit; }
.arb-target-editor .target-note { grid-column:1/-1; color:var(--text-3); font-size: var(--fs-label); line-height:1.35; }
.ghost-btn.small { min-height:34px; padding:8px 12px; font-size: var(--fs-label); border-radius:12px; }
.ghost-btn.danger { color:#dc2626; border-color:rgba(220,38,38,.28); background:rgba(254,242,242,.9); }
.arb-event-row { border:1px solid var(--line); background:rgba(255,255,255,.72); border-radius:14px; padding:10px 12px; display:grid; grid-template-columns:1fr 1fr auto; gap:8px; align-items:center; }
.arb-event-row.bad { border-color:rgba(239,68,68,.24); background:rgba(239,68,68,.06); }
.arb-event-row b { color:var(--text); font-size: var(--fs-label); }
.arb-event-row span, .arb-event-row small, .arb-event-row em { color:var(--text-3); font-style:normal; font-size: var(--fs-label); }
.arb-event-row em { grid-column:1/-1; }
@media(max-width:760px){
  .arb-active-card { grid-template-columns:1fr 1fr; }
  .arb-active-card .ghost-btn { grid-column:1/-1; }
  .arb-target-editor { grid-template-columns:1fr 1fr; }
  .arb-event-row { grid-template-columns:1fr; }
}

/* V16 strategy control hardening: locked capital, typed USDT allocation and clear busy states. */
.strategy-locked-hint {
  color: var(--gain);
  border: 1px solid var(--green-line);
  background: var(--gain-dim);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.sc-alloc.is-locked {
  border-color: var(--green-line);
  background: linear-gradient(180deg, var(--gain-dim), var(--surface-hi));
}
.sc-amount-field {
  display: grid;
  gap: 5px;
  color: var(--text-2);
  font-size: var(--fs-caption);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.sc-amount-field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  outline: none;
}
.sc-amount-field input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.sc-alloc input:disabled,
.sniper-risk-field input:disabled {
  opacity: .62;
  cursor: not-allowed;
}
.btn.is-loading,
.btn:disabled.is-loading {
  position: relative;
  opacity: .78;
  cursor: wait;
}
.btn.is-loading::after {
  content: '';
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: algosyncBtnSpin .75s linear infinite;
}
@keyframes algosyncBtnSpin { to { transform: rotate(360deg); } }

/* V96: Super chart bounds and compact Why sheet. */
#chart .sc-why-panel,
#chart .sc-why-panel * {
  box-sizing: border-box;
  min-width: 0;
}
#chart .sc-why-panel {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
#chart .sc-why-panel .trade-detail-panel,
.trade-detail-row .trade-detail-panel {
  width: 100%;
  max-width: 100%;
  overflow: visible;
}
/* V125: keep the trades-page Why sheet fully responsive at every width so
   text never runs past the right edge (matches the #chart sheet behaviour). */
#activeTrades .trade-detail-row td {
  box-sizing: border-box;
}
#activeTrades .trade-detail-row .trade-detail-panel,
#activeTrades .trade-detail-row .trade-detail-panel * {
  box-sizing: border-box;
  min-width: 0;
}
#activeTrades .trade-detail-row .trade-detail-panel {
  overflow-wrap: anywhere;
}
#activeTrades .trade-detail-row .trade-detail-title,
#activeTrades .trade-detail-row .trade-detail-sub,
#activeTrades .trade-detail-row .trade-detail-label,
#activeTrades .trade-detail-row .trade-detail-list span,
#activeTrades .trade-detail-row .trade-detail-note,
#activeTrades .trade-detail-row .trade-detail-metric span,
#activeTrades .trade-detail-row .trade-detail-metric strong {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
#activeTrades .trade-detail-row .trade-detail-list {
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  gap: 6px;
}
#activeTrades .trade-detail-row .trade-detail-list span,
#activeTrades .trade-detail-row .trade-detail-note {
  display: block;
  width: 100%;
  max-width: 100%;
}
#activeTrades .trade-detail-row .trade-detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 6px;
}
#chart .trade-detail-head {
  min-width: 0;
}
#chart .trade-detail-title,
#chart .trade-detail-sub,
#chart .trade-detail-label,
#chart .trade-detail-list span,
#chart .trade-detail-note,
#chart .trade-detail-metric span,
#chart .trade-detail-metric strong {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
#chart .trade-detail-list {
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  gap: 6px;
}
#chart .trade-detail-list span,
#chart .trade-detail-note {
  display: block;
  border-radius: 8px;
  padding: 7px 9px;
}
#chart .trade-detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 6px;
}
#chart .trade-detail-metric {
  min-height: 46px;
  padding: 7px 8px;
}
#chart .trade-detail-metric span {
  margin-bottom: 3px;
}
@media (max-width: 760px) {
  #activeTrades .trade-detail-row td {
    position: sticky;
    left: 0;
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
  }
  #activeTrades .trade-detail-row .trade-detail-panel {
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
    grid-template-columns: minmax(0, 1fr);
    white-space: normal;
  }
  #activeTrades .trade-detail-row .trade-detail-list,
  #activeTrades .trade-detail-row .trade-detail-grid,
  #activeTrades .trade-detail-row .trade-detail-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    white-space: normal;
  }
  #activeTrades .trade-detail-row .trade-detail-list {
    grid-template-columns: 1fr;
  }
  #activeTrades .trade-detail-row .trade-detail-list span,
  #activeTrades .trade-detail-row .trade-detail-note {
    width: 100%;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #chart .sc-why-panel .trade-detail-panel {
    padding-inline: 8px;
  }
  #chart .trade-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  #chart .trade-detail-list {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 390px) {
  #chart .trade-detail-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Aegis Intelligence Lab */
.aegis-lab-hero { position: relative; overflow: hidden; }
.aegis-lab-hero::after {
  content:""; position:absolute; inset:-70px -80px auto auto; width:240px; height:240px;
  background: radial-gradient(circle, rgba(91,141,255,.16), transparent 62%);
  pointer-events:none;
}
.aegis-lab-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.aegis-lab-rule-strip { display:flex; gap:8px; flex-wrap:wrap; margin-top:14px; }
.aegis-lab-form { grid-template-columns: 1.1fr .8fr 1.2fr 2fr; }
.risk-lab-form select,
.risk-lab-form input {
  width: 100%;
}
.risk-lab-form select {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.9);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  outline: none;
}
.risk-lab-form select:focus {
  border-color: rgba(91,141,255,.55);
  box-shadow: 0 0 0 3px rgba(91,141,255,.12);
}
.aegis-lab-run-log {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255,255,255,.72);
  color: var(--text-2);
  font-size: var(--fs-sm);
  overflow-x: auto;
}

.aegis-explain-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.aegis-explain-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.68);
  padding: 12px 13px;
  min-height: 104px;
}
.aegis-explain-box b {
  display: block;
  color: var(--text);
  font-size: var(--fs-sm);
  margin-bottom: 6px;
}
.aegis-explain-box span {
  display: block;
  color: var(--text-2);
  font-size: var(--fs-caption);
  line-height: 1.45;
}
.aegis-explain-copy {
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.aegis-explain-copy.compact { margin-top: 12px; }
.aegis-explain-copy h4 {
  margin: 14px 0 6px;
  color: var(--text);
  font-size: var(--fs-sm);
}
.aegis-explain-copy p { margin: 0; }
.aegis-explain-copy ul { margin: 6px 0 0 18px; padding: 0; }
.aegis-explain-copy li { margin: 5px 0; }
.aegis-model-row { cursor: pointer; }
.aegis-model-row:hover td { background: rgba(91,141,255,.08); }
.aegis-model-row.selected td { background: rgba(91,141,255,.12); }
.aegis-detail-head {
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
  margin-bottom:12px;
}
.aegis-detail-title {
  font-weight:700;
  color:var(--text);
  font-size:var(--fs-h3);
}
.aegis-detail-sub {
  margin-top:5px;
  color:var(--text-2);
  font-size:var(--fs-sm);
  line-height:1.5;
}
.aegis-lab-mini-grid {
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:10px;
  margin:12px 0;
}
.aegis-lab-mini-metric {
  border:1px solid var(--line);
  border-radius:14px;
  background:rgba(255,255,255,.62);
  padding:11px 12px;
}
.aegis-lab-mini-metric small {
  display:block;
  color:var(--text-3);
  text-transform:uppercase;
  letter-spacing:.06em;
  font-size:var(--fs-micro);
}
.aegis-lab-mini-metric b {
  display:block;
  color:var(--text);
  font-family:var(--mono);
  font-size:var(--fs-h3);
  margin-top:4px;
}
.aegis-lab-mini-metric span {
  display:block;
  color:var(--text-2);
  font-size:var(--fs-caption);
  margin-top:4px;
  line-height:1.35;
}
@media (max-width: 900px) {
  .aegis-explain-grid,
  .aegis-lab-mini-grid { grid-template-columns: 1fr; }
  .aegis-detail-head { flex-direction:column; }
}
@media (max-width: 900px) {
  .aegis-lab-form { grid-template-columns: 1fr; }
  .aegis-lab-actions { justify-content:flex-start; }
}

/* Admin-only Dump Short 2.0 order-flow explanation sheet. */
.ds2-scan-card.admin-clickable {
  cursor: pointer;
}
.ds2-scan-card.admin-clickable:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
}
.ds2-scan-card.admin-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ds2-scan-card.diagnostics-open {
  grid-column: 1 / -1;
  cursor: default;
  padding: 14px;
  border-color: color-mix(in srgb, var(--accent) 52%, var(--border));
  box-shadow: 0 12px 32px rgba(17, 24, 39, .12);
}
.ds2-private-hint {
  margin-left: auto;
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .02em;
}
.ds2-diagnostic-sheet {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  cursor: text;
}
.ds2-diag-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.ds2-diag-title span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.ds2-diag-title b {
  color: var(--text);
  font-size: 12px;
}
.ds2-diag-summary {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.ds2-diag-summary p,
.ds2-diagnostic-sheet > p {
  margin: 0;
  color: var(--text-2);
  font-size: 11px;
  line-height: 1.48;
}
.ds2-diag-summary p.positive {
  color: var(--green);
  font-weight: 700;
}
.ds2-diag-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
  gap: 10px;
  margin-top: 10px;
}
.ds2-diag-block {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.ds2-diag-block h4 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 11px;
}
.ds2-diag-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.ds2-diag-total b {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 20px;
}
.ds2-diag-total span {
  color: var(--text-3);
  font-size: 10px;
}
.ds2-diag-score-row {
  display: grid;
  grid-template-columns: minmax(105px, 1fr) minmax(70px, 1.35fr) 42px;
  align-items: center;
  gap: 7px;
  min-height: 24px;
  color: var(--text-2);
  font-size: 10px;
}
.ds2-diag-score-row b {
  color: var(--text);
  font-family: var(--mono);
  font-size: 9px;
  text-align: right;
}
.ds2-diag-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}
.ds2-diag-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--green));
}
.ds2-diag-gates {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ds2-diag-gate {
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
}
.ds2-diag-gate.pass {
  color: var(--green);
  border: 1px solid color-mix(in srgb, var(--green) 30%, transparent);
  background: color-mix(in srgb, var(--green) 9%, transparent);
}
.ds2-diag-gate.fail {
  color: var(--red);
  border: 1px solid color-mix(in srgb, var(--red) 26%, transparent);
  background: color-mix(in srgb, var(--red) 8%, transparent);
}
.ds2-diag-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.ds2-diag-facts span {
  padding: 7px 8px;
  border-radius: 9px;
  background: var(--surface-2);
}
.ds2-diag-facts small,
.ds2-diag-facts b {
  display: block;
}
.ds2-diag-facts small {
  color: var(--text-3);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ds2-diag-facts b {
  margin-top: 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
}
.ds2-diag-note {
  margin: 9px 0 0;
  color: var(--text-3);
  font-size: 9px;
  line-height: 1.45;
}
@media (max-width: 700px) {
  .ds2-scan-card.diagnostics-open { padding: 10px; }
  .ds2-diag-title { align-items: flex-start; flex-direction: column; gap: 4px; }
  .ds2-diag-grid { grid-template-columns: 1fr; }
  .ds2-diag-score-row { grid-template-columns: minmax(100px, 1fr) minmax(62px, 1fr) 38px; }
}

.squeeze-long-settings {
  background: color-mix(in srgb, var(--blue) 5%, var(--card));
  border-color: color-mix(in srgb, var(--blue) 28%, var(--line));
}
.squeeze-rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.squeeze-rule-grid span {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--card) 86%, transparent);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}
.squeeze-rule-grid b {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 13px;
}
@media (max-width: 520px) {
  .squeeze-rule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
