    :root {
      --bg: #08080a;
      --bg-surface: #0f0f12;
      --bg-elevated: #16161b;
      --bg-hot: #1a1a20;
      --border: #1e1e24;
      --text: #e8e8ea;
      --text-dim: #a0a0a8;
      --text-mute: #65656d;
      --gold: #c9a961;
      --gold-soft: #d4bc87;
      --bull: #5cb88a;
      --bear: #e05d5d;
      --liq: #f2b33d;
      --warn: #f2b33d;
    }

    * { margin: 0; padding: 0; box-sizing: border-box; }
    html { scroll-behavior: smooth; }
    body {
      background: var(--bg);
      color: var(--text);
      font-family: 'Geist', system-ui, sans-serif;
      font-size: 14px;
      line-height: 1.6;
      font-weight: 300;
    }

    /* ═══════════════════════════════════
       AUTOPILOT TOP BAR
    ═══════════════════════════════════ */
    .autopilot-bar {
      position: fixed;
      top: 0; left: 0; right: 0;
      height: 52px;
      background: rgba(8,8,10,0.96);
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 0;
      z-index: 100;
      backdrop-filter: blur(12px);
    }

    .ap-segment {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 0 20px;
      height: 100%;
      border-right: 1px solid var(--border);
      font-family: 'JetBrains Mono', monospace;
      font-size: 12px;
    }

    .ap-label {
      color: var(--text-mute);
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.1em;
    }

    .ap-value {
      font-weight: 600;
      color: var(--gold);
    }

    .session-badge {
      padding: 3px 10px;
      border-radius: 4px;
      font-size: 11px;
      font-weight: 700;
      font-family: 'JetBrains Mono', monospace;
    }

    .sync-dot {
      width: 7px; height: 7px;
      border-radius: 50%;
      background: var(--bull);
      animation: pulse 2s infinite;
    }
    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.3; }
    }

    .ap-brand {
      flex: 1;
      padding: 0 20px;
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .ap-brand .logo {
      font-family: 'Instrument Serif', serif;
      font-size: 18px;
      color: var(--gold);
    }
    .ap-brand .v { color: var(--text-mute); font-size: 11px; font-family: 'JetBrains Mono', monospace; }

    /* ═══════════════════════════════════
       LAYOUT
    ═══════════════════════════════════ */
    .shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; padding-top: 52px; }

    nav.side {
      position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto;
      background: var(--bg-surface);
      border-right: 1px solid var(--border);
      padding: 20px 0;
      z-index: 10;
      /* Hide the bright system scrollbar — it clashes with the dark theme.
         Firefox uses scrollbar-width/scrollbar-color; WebKit (Chrome / Edge /
         Safari / Brave) uses ::-webkit-scrollbar pseudos. Both kept the
         scrolling functional, just visually quiet. */
      scrollbar-width: thin;
      scrollbar-color: rgba(201,169,97,0.20) transparent;
    }
    nav.side::-webkit-scrollbar { width: 6px; }
    nav.side::-webkit-scrollbar-track { background: transparent; }
    nav.side::-webkit-scrollbar-thumb {
      background: rgba(201,169,97,0.20);
      border-radius: 3px;
    }
    nav.side::-webkit-scrollbar-thumb:hover { background: rgba(201,169,97,0.40); }

    .brand {
      padding: 0 20px 20px;
      border-bottom: 1px solid var(--border);
      margin-bottom: 12px;
    }
    .brand .logo {
      font-family: 'Instrument Serif', serif;
      font-size: 22px;
      color: var(--gold);
    }
    .brand .sub {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      color: var(--text-mute);
      margin-top: 4px;
      letter-spacing: 0.15em;
      text-transform: uppercase;
    }

    .side-nav button {
      width: calc(100% - 24px);
      margin: 0 12px 4px;
      padding: 11px 14px;
      background: transparent;
      border: 1px solid transparent;
      border-radius: 6px;
      color: var(--text-dim);
      font-size: 13px;
      text-align: left;
      cursor: pointer;
      transition: all 0.2s;
    }
    .side-nav button:hover {
      background: var(--bg-hot);
      color: var(--text);
    }
    .side-nav button.active {
      background: rgba(201, 169, 97, 0.1);
      border-color: rgba(201, 169, 97, 0.4);
      color: var(--gold);
    }

    /* Expandable Live Chart section in sidebar */
    .side-nav-section { display: block; }
    .side-nav-toggle::after {
      content: '▸';
      float: right;
      font-size: 10px;
      opacity: 0.6;
      transition: transform 0.2s;
      margin-top: 2px;
    }
    .side-nav-toggle.expanded::after { transform: rotate(90deg); }
    .side-nav-children {
      display: none;
      margin: 0 12px 8px;
      padding: 6px 0;
      border-left: 1px solid var(--border);
    }
    .side-nav-children.expanded { display: block; }

    /* Compact toolbar inside dropdown */
    .side-toolbar {
      display: flex;
      gap: 4px;
      padding: 0 0 8px 10px;
      margin-bottom: 6px;
      border-bottom: 1px dashed var(--border);
    }
    /* Override .side-nav button cascade for compact toolbar buttons */
    .side-nav .side-toolbar-btn {
      flex: 1;
      width: auto;
      margin: 0;
      padding: 6px 0;
      background: transparent;
      border: 1px solid var(--border);
      border-radius: 5px;
      color: var(--text-dim);
      font-size: 13px;
      line-height: 1;
      text-align: center;
      cursor: pointer;
      transition: all 0.15s;
    }
    .side-nav .side-toolbar-btn:hover {
      background: rgba(201,169,97,0.08);
      color: var(--gold);
      border-color: rgba(201,169,97,0.4);
    }

    /* Asset row in sidebar dropdown — scoped under .side-nav to override the
       broad .side-nav button cascade. */
    .side-nav .side-asset-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 6px;
      width: calc(100% - 10px);
      margin: 0 0 2px 10px;
      padding: 7px 10px;
      background: transparent;
      border: 1px solid transparent;
      border-radius: 5px;
      color: var(--text-dim);
      font-size: 12px;
      text-align: left;
      cursor: pointer;
      transition: all 0.15s;
      font-family: inherit;
    }
    .side-nav .side-asset-row:hover {
      background: var(--bg-hot);
      color: var(--text);
    }
    .side-nav .side-asset-row.active {
      background: rgba(201,169,97,0.12);
      border-color: rgba(201,169,97,0.4);
      color: var(--gold);
    }
    /* Mobile picker rows are outside .side-nav, so re-state base styles */
    .mobile-asset-picker .side-asset-row {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 12px;
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text-dim);
      font-size: 12px;
      cursor: pointer;
      flex: 0 0 auto;
      white-space: nowrap;
    }
    .mobile-asset-picker .side-asset-row.active {
      background: rgba(201,169,97,0.12);
      border-color: rgba(201,169,97,0.4);
      color: var(--gold);
    }
    .side-asset-row .sym {
      font-family: 'JetBrains Mono', monospace;
      font-weight: 700;
      font-size: 12px;
      letter-spacing: 0.04em;
    }
    .side-asset-row .meta {
      display: flex;
      gap: 4px;
      align-items: center;
    }
    .side-asset-row .meta .asset-bias,
    .side-asset-row .meta .asset-grade,
    .side-asset-row .meta .side-mode-badge,
    .side-asset-row .meta .side-zone-badge {
      font-size: 8px;
      padding: 2px 6px;
      margin: 0;
      line-height: 1.3;
      border-radius: 3px;
      font-weight: 700;
      letter-spacing: 0.04em;
    }
    .side-mode-badge.mode-fut {
      background: rgba(92,184,138,0.15);
      color: var(--bull);
    }
    .side-mode-badge.mode-spot {
      background: rgba(101,101,109,0.15);
      color: var(--text-mute);
    }
    /* AT BUY / AT SELL pulse so the user notices the actionable moments
       without needing the futures-style overlay; NEAR is calmer. */
    .side-zone-badge.zone-buy-at {
      background: rgba(201,169,97,0.28);
      color: var(--gold);
      animation: zone-pulse 1.6s ease-in-out infinite;
    }
    .side-zone-badge.zone-buy-near {
      background: rgba(201,169,97,0.12);
      color: var(--gold);
    }
    .side-zone-badge.zone-sell-at {
      background: rgba(92,184,138,0.28);
      color: var(--bull);
      animation: zone-pulse 1.6s ease-in-out infinite;
    }
    .side-zone-badge.zone-sell-near {
      background: rgba(92,184,138,0.12);
      color: var(--bull);
    }
    @keyframes zone-pulse {
      0%, 100% { opacity: 1; }
      50%      { opacity: 0.55; }
    }

    /* Live-trading kill-switch — always-visible button anchored to the
       top-right of the page so it lives in the same spot as the rest of
       the status bar. OFF state is green/calm; ON state is red with a
       slow pulse so it's impossible to miss while auto-execution can fire. */
    #liveKillSwitch {
      position: fixed;
      right: 16px;
      top: 9px;
      z-index: 5000;
      padding: 8px 16px;
      border-radius: 999px;
      border: 2px solid var(--bull);
      background: rgba(92,184,138,0.18);
      color: var(--bull);
      font-family: 'JetBrains Mono', monospace;
      font-size: 12px;
      font-weight: 800;
      letter-spacing: 0.06em;
      cursor: pointer;
      box-shadow: 0 4px 14px rgba(0,0,0,0.35);
      user-select: none;
      transition: transform 0.12s ease, background 0.12s ease;
    }
    #liveKillSwitch:hover { transform: translateY(-2px); }
    #liveKillSwitch:active { transform: translateY(0); }
    #liveKillSwitch.live-on {
      background: rgba(224,93,93,0.92);
      border-color: var(--bear);
      color: white;
      box-shadow: 0 6px 28px rgba(224,93,93,0.55);
      animation: kill-switch-pulse 1.4s ease-in-out infinite;
    }
    @keyframes kill-switch-pulse {
      0%, 100% { box-shadow: 0 6px 28px rgba(224,93,93,0.55); }
      50%      { box-shadow: 0 6px 36px rgba(224,93,93,0.95); }
    }

    /* Mobile-only asset picker (horizontal scroll chips on live-chart tab) */
    .mobile-asset-picker {
      display: none;
      gap: 6px;
      overflow-x: auto;
      padding: 8px 4px 12px;
      margin-bottom: 12px;
      border-bottom: 1px solid var(--border);
      scrollbar-width: none;
    }
    .mobile-asset-picker::-webkit-scrollbar { display: none; }
    @media (max-width: 900px) {
      .mobile-asset-picker { display: flex; }
    }

    /* Live-chart empty hint state */
    .live-chart-empty {
      background: var(--bg-surface);
      border: 1px dashed var(--border);
      border-radius: 12px;
      padding: 80px 24px;
      text-align: center;
      margin-bottom: 20px;
    }
    .live-chart-empty .icon {
      font-size: 56px;
      opacity: 0.4;
      margin-bottom: 16px;
    }
    .live-chart-empty .title {
      font-family: 'Instrument Serif', serif;
      font-size: 22px;
      color: var(--gold);
      margin-bottom: 8px;
    }
    .live-chart-empty .sub {
      font-size: 13px;
      color: var(--text-mute);
      max-width: 400px;
      margin: 0 auto;
      line-height: 1.6;
    }

    main { padding: 32px 36px; overflow-x: hidden; }

    .tab-content { display: none; }
    .tab-content.active { display: block; }

    /* ═══════════════════════════════════
       SECTION HEADER
    ═══════════════════════════════════ */
    .page-header {
      margin-bottom: 28px;
      padding-bottom: 20px;
      border-bottom: 1px solid var(--border);
    }
    .page-header h1 {
      font-family: 'Instrument Serif', serif;
      font-size: 28px;
      color: var(--gold);
    }
    .page-header p {
      color: var(--text-dim);
      font-size: 13px;
      margin-top: 6px;
    }

    /* ═══════════════════════════════════
       AUTOPILOT TAB
    ═══════════════════════════════════ */
    .ap-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
      margin-bottom: 24px;
    }

    .ap-card {
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 20px;
    }

    .ap-card.full { grid-column: 1 / -1; }
    .ap-card.gold-border { border-color: rgba(201,169,97,0.4); }

    .ap-card-title {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      color: var(--text-mute);
      text-transform: uppercase;
      letter-spacing: 0.15em;
      margin-bottom: 14px;
    }

    /* Sessions timeline */
    .session-timeline {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .session-row {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 8px 12px;
      border-radius: 6px;
      background: var(--bg);
      border: 1px solid var(--border);
      transition: all 0.3s;
    }

    .session-row.active-session {
      background: rgba(92,184,138,0.08);
      border-color: var(--bull);
    }

    .session-row.dead-zone {
      background: rgba(224,93,93,0.06);
      border-color: rgba(224,93,93,0.3);
    }

    .session-row.macro-session {
      background: rgba(242,179,61,0.08);
      border-color: rgba(242,179,61,0.4);
    }

    .session-dot {
      width: 8px; height: 8px;
      border-radius: 50%;
      flex-shrink: 0;
    }

    .session-name {
      flex: 1;
      font-size: 13px;
      color: var(--text-dim);
    }

    .session-time {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      color: var(--text-mute);
    }

    .session-status-label {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      font-weight: 700;
      padding: 2px 8px;
      border-radius: 3px;
    }

    /* Signal cards */
    .signals-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
      gap: 10px;
    }

    .signal-card {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 14px;
      cursor: pointer;
      transition: all 0.25s;
    }
    .signal-card:hover { border-color: var(--gold); transform: translateY(-2px); }
    .signal-card.enter { border-color: var(--bear); background: rgba(224,93,93,0.07); animation: enterPulse 1.5s infinite; }
    .signal-card.armed { border-color: var(--bull); background: rgba(92,184,138,0.05); }
    .signal-card.watch { border-color: var(--liq); background: rgba(242,179,61,0.05); }
    .signal-card.skip { opacity: 0.5; }
    @keyframes enterPulse { 0%,100% { box-shadow: 0 0 0 rgba(224,93,93,0); } 50% { box-shadow: 0 0 14px rgba(224,93,93,0.35); } }

    .sig-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
    .sig-symbol { font-family: 'Instrument Serif', serif; font-size: 20px; color: var(--gold); }
    .sig-badge {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      font-weight: 700;
      padding: 3px 8px;
      border-radius: 3px;
    }
    .badge-enter { background: rgba(224,93,93,0.25); color: var(--bear); font-weight:900; letter-spacing:.04em; animation: enterPulse 1.2s infinite; }
    .badge-armed { background: rgba(92,184,138,0.2); color: var(--bull); }
    .badge-watch { background: rgba(242,179,61,0.2); color: var(--liq); }
    .badge-wait { background: rgba(101,101,109,0.2); color: var(--text-mute); }
    .badge-skip { background: rgba(224,93,93,0.2); color: var(--bear); }

    .sig-price {
      font-family: 'JetBrains Mono', monospace;
      font-size: 15px;
      font-weight: 500;
      margin-bottom: 4px;
    }

    .sig-entry { font-size: 11px; color: var(--text-mute); margin-bottom: 6px; }
    .sig-dist {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      font-weight: 600;
    }

    .sig-reasoning {
      font-size: 11px;
      color: var(--text-mute);
      margin-top: 8px;
      line-height: 1.5;
      border-top: 1px solid var(--border);
      padding-top: 8px;
    }

    /* Countdown ring */
    .countdown-big {
      text-align: center;
      padding: 10px 0;
    }
    .countdown-big .ct-label { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.1em; }
    .countdown-big .ct-name { font-family: 'Instrument Serif', serif; font-size: 20px; color: var(--gold); margin: 4px 0; }
    .countdown-big .ct-time {
      font-family: 'JetBrains Mono', monospace;
      font-size: 36px;
      font-weight: 600;
      color: var(--text);
      letter-spacing: 0.05em;
    }

    /* ═══════════════════════════════════
       DASHBOARD TAB (asset tiles)
    ═══════════════════════════════════ */
    .assets-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
      gap: 14px;
    }

    .asset-tile {
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 18px;
      cursor: pointer;
      transition: all 0.3s;
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
    }
    .asset-tile:hover {
      border-color: var(--gold);
      box-shadow: 0 10px 30px -10px rgba(201,169,97,0.3);
      transform: translateY(-4px);
    }
    .asset-tile.enter-tile { border-color: var(--bear); animation: enterPulse 1.5s infinite; }
    .asset-tile.armed-tile { border-color: var(--bull); }
    .asset-tile.watch-tile { border-color: rgba(242,179,61,0.5); }

    .asset-symbol {
      font-family: 'Instrument Serif', serif;
      font-size: 26px;
      color: var(--gold);
      margin-bottom: 6px;
    }

    .asset-platform {
      font-size: 10px;
      color: var(--text-mute);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 8px;
    }

    .asset-price {
      font-family: 'JetBrains Mono', monospace;
      font-size: 16px;
      font-weight: 500;
      margin-bottom: 6px;
    }

    .asset-change {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      margin-bottom: 8px;
    }

    .asset-bias {
      font-size: 10px;
      font-weight: 700;
      padding: 3px 10px;
      border-radius: 3px;
      margin-bottom: 6px;
    }
    .bias-bull { background: rgba(92,184,138,0.15); color: var(--bull); }
    .bias-bear { background: rgba(224,93,93,0.15); color: var(--bear); }
    .bias-flux { background: rgba(242,179,61,0.15); color: var(--liq); }

    .asset-grade {
      font-size: 10px;
      font-weight: 600;
      padding: 3px 10px;
      border-radius: 3px;
      background: rgba(201,169,97,0.12);
      color: var(--gold);
    }

    /* Inline level editor on asset tiles */

    .enter-indicator {
      position: absolute;
      top: 8px; right: 8px;
      background: var(--bear);
      color: #fff;
      font-size: 9px;
      padding: 2px 7px;
      border-radius: 9999px;
      font-weight: 900;
      letter-spacing: .04em;
      animation: enterPulse 1.2s infinite;
    }
    .armed-indicator {
      position: absolute;
      top: 8px; right: 8px;
      background: var(--bull);
      color: #000;
      font-size: 9px;
      padding: 2px 7px;
      border-radius: 9999px;
      font-weight: 700;
    }

    /* Sync bar */
    .sync-bar {
      display: flex;
      gap: 10px;
      margin-bottom: 20px;
      flex-wrap: wrap;
      align-items: center;
    }
    .sync-btn {
      padding: 7px 14px;
      font-size: 12px;
      background: transparent;
      border: 1px solid rgba(201,169,97,0.3);
      border-radius: 4px;
      color: var(--gold);
      cursor: pointer;
      transition: all 0.2s;
      font-family: 'Geist', sans-serif;
    }
    .sync-btn:hover { background: rgba(201,169,97,0.15); border-color: var(--gold); }
    .sync-status-text {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      color: var(--text-mute);
    }

    /* ═══════════════════════════════════
       TOP SETUP TAB
    ═══════════════════════════════════ */
    .filter-buttons { display: flex; gap: 10px; margin-bottom: 20px; }
    .filter-btn {
      padding: 8px 18px;
      background: transparent;
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text-dim);
      cursor: pointer;
      font-weight: 500;
      transition: all 0.2s;
    }
    .filter-btn:hover { border-color: var(--gold); color: var(--text); }
    .filter-btn.active { background: rgba(201,169,97,0.15); border-color: var(--gold); color: var(--gold); }

    /* Top Setup uses same tile grid as Dashboard */
    .setup-list {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
      gap: 14px;
    }

    .setup-card {
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 20px;
      cursor: pointer;
      transition: all 0.3s;
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
    }
    .setup-card:hover {
      border-color: var(--gold);
      box-shadow: 0 10px 30px -10px rgba(201,169,97,0.3);
      transform: translateY(-4px);
    }
    .setup-card.near-armed { border-color: var(--bull); background: rgba(92,184,138,0.04); }
    .setup-card.near-watch { border-color: rgba(242,179,61,0.5); }

    .setup-symbol { font-family: 'Instrument Serif', serif; font-size: 28px; color: var(--gold); margin-bottom: 4px; }
    .setup-platform { font-size: 10px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
    .setup-price { font-family: 'JetBrains Mono', monospace; font-size: 17px; font-weight: 500; margin-bottom: 4px; }
    .setup-dist-badge {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      font-weight: 700;
      padding: 3px 10px;
      border-radius: 3px;
      margin-bottom: 8px;
    }
    .setup-levels { font-size: 11px; color: var(--text-mute); line-height: 1.6; margin-bottom: 8px; }
    .setup-grade {
      padding: 4px 12px;
      border-radius: 4px;
      font-size: 11px;
      font-weight: 600;
      background: rgba(201,169,97,0.15);
      color: var(--gold);
    }
    .setup-entry-indicator {
      position: absolute;
      top: 8px; right: 8px;
      font-size: 9px;
      font-weight: 700;
      padding: 2px 7px;
      border-radius: 9999px;
    }

    /* ═══════════════════════════════════
       ICT METHODS
    ═══════════════════════════════════ */
    .methods-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
      gap: 14px;
    }
    .method-card {
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: 10px;
      overflow: hidden;
      cursor: pointer;
      transition: all 0.3s;
    }
    .method-card:hover { border-color: var(--gold); transform: translateY(-4px); }
    .method-visual { height: 130px; background: var(--bg); display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border); padding: 12px; }
    .method-info { padding: 14px; }
    .method-info h3 { font-family: 'Instrument Serif', serif; color: var(--gold); font-size: 14px; margin-bottom: 5px; }
    .method-info p { color: var(--text-dim); font-size: 12px; line-height: 1.5; }

    /* ═══════════════════════════════════
       RULES TAB
    ═══════════════════════════════════ */
    .rules-section {
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 22px;
      margin-bottom: 20px;
    }
    .rules-section h3 { font-family: 'Instrument Serif', serif; font-size: 17px; color: var(--gold); margin-bottom: 10px; }
    .rules-section p { color: var(--text-dim); font-size: 13px; line-height: 1.8; margin-bottom: 7px; }
    .rules-section ul { margin-left: 18px; color: var(--text-dim); font-size: 13px; line-height: 1.8; }
    .rules-section li { margin-bottom: 5px; }

    /* ═══════════════════════════════════
       MODAL
    ═══════════════════════════════════ */
    .modal {
      display: none;
      position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(8,8,10,0.92);
      z-index: 1000;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }
    .modal.active { display: flex; }
    .modal-content {
      background: var(--bg-elevated);
      border: 1px solid var(--gold);
      border-radius: 12px;
      max-width: 680px;
      width: 100%;
      max-height: 90vh;
      overflow-y: auto;
      box-shadow: 0 25px 50px -12px rgb(201 169 97 / 0.2);
    }
    .modal-header {
      padding: 22px 26px;
      border-bottom: 1px solid var(--border);
      display: flex;
      justify-content: space-between;
      align-items: center;
      position: sticky; top: 0;
      background: var(--bg-elevated);
      z-index: 10;
    }
    .modal-header h2 { font-family: 'Instrument Serif', serif; color: var(--gold); font-size: 26px; }
    .modal-close { background: none; border: none; font-size: 26px; color: var(--text-mute); cursor: pointer; }
    .modal-body { padding: 26px; }
    .setup-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
    .setup-row:last-child { border-bottom: none; }
    .setup-label { color: var(--text-mute); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
    .setup-value { color: var(--gold); font-family: 'JetBrains Mono', monospace; }
    .grade-section { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin: 18px 0; }
    .grade-title { color: var(--gold); font-weight: 600; margin-bottom: 10px; font-size: 13px; }
    .checklist { display: grid; gap: 5px; }
    .check-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 12px; color: var(--text-dim); }
    .check-item.yes { color: var(--bull); }
    .check-item.no { opacity: 0.5; }
    .check-icon { font-weight: 700; min-width: 16px; }

    /* Old tablet rule — now handled by new mobile blocks above */
    @media (max-width: 900px) {
      .shell { grid-template-columns: 1fr; }
      main { padding: 20px; }
    }

  /* ═══════════════════════════════════
     ARMED ALERT OVERLAY
  ═══════════════════════════════════ */
  .alert-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(10px);
    animation: overlayIn .25s ease-out;
  }
  @keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

  .alert-box {
    background: #0f0f13;
    border: 2px solid var(--bull);
    border-radius: 20px;
    padding: 40px 44px;
    max-width: 520px; width: 92%;
    /* Cap height + scroll inside the box. Without this, tall modals (Live
       Trading config + diagnostics panel) get cut off below the viewport on
       small displays — the Test Fire / Save buttons become unreachable. */
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 0 80px rgba(92,184,138,0.25), 0 32px 80px rgba(0,0,0,0.9);
    text-align: center;
    animation: alertIn .4s cubic-bezier(.34,1.56,.64,1);
    /* Quiet, theme-matched scrollbar (same look as the sidebar). */
    scrollbar-width: thin;
    scrollbar-color: rgba(201,169,97,0.20) transparent;
  }
  .alert-box::-webkit-scrollbar { width: 6px; }
  .alert-box::-webkit-scrollbar-track { background: transparent; }
  .alert-box::-webkit-scrollbar-thumb {
    background: rgba(201,169,97,0.20);
    border-radius: 3px;
  }
  .alert-box::-webkit-scrollbar-thumb:hover { background: rgba(201,169,97,0.40); }
  @keyframes alertIn {
    0% { transform: scale(0.7) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
  }
  .alert-beacon {
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(92,184,138,0.15);
    border: 2px solid var(--bull);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    font-size: 26px;
    animation: beaconPulse 1.2s infinite;
  }
  @keyframes beaconPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(92,184,138,0.5); }
    50% { box-shadow: 0 0 0 16px rgba(92,184,138,0); }
  }
  .alert-label {
    font-size: 11px; letter-spacing: .18em; color: var(--bull);
    font-family: 'JetBrains Mono', monospace; font-weight: 700;
    text-transform: uppercase; margin-bottom: 6px;
  }
  .alert-symbol-big {
    font-family: 'JetBrains Mono', monospace;
    font-size: 36px; font-weight: 700; color: var(--text);
    margin-bottom: 4px;
  }
  .alert-grade-badge {
    display: inline-block; padding: 3px 14px; border-radius: 20px;
    background: rgba(201,169,97,0.15); color: var(--gold);
    font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700;
    border: 1px solid rgba(201,169,97,0.35); margin-bottom: 24px;
  }
  .alert-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 10px; margin-bottom: 24px; text-align: left;
  }
  .alert-row {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 14px;
  }
  .alert-row-label { font-size: 10px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 3px; }
  .alert-row-val { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; color: var(--text); }
  .alert-analysis {
    background: rgba(92,184,138,0.05);
    border: 1px solid rgba(92,184,138,0.2);
    border-radius: 10px; padding: 12px 16px;
    font-size: 12px; color: var(--text-dim); text-align: left;
    line-height: 1.7; margin-bottom: 22px;
  }
  .alert-dismiss-btn {
    background: var(--bull); color: #08080a;
    border: none; border-radius: 10px; padding: 13px 40px;
    font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700;
    cursor: pointer; letter-spacing: .08em; width: 100%;
    transition: opacity .2s;
  }
  .alert-dismiss-btn:hover { opacity: 0.85; }

  /* ═══════════════════════════════════
     ALERT LOG (in AutoPilot tab)
  ═══════════════════════════════════ */
  .alert-log-section { margin-top: 32px; }
  .alert-log-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
  }
  .alert-log-title { font-size: 11px; letter-spacing: .14em; color: var(--text-mute); text-transform: uppercase; }
  .alert-log-clear { font-size: 11px; color: var(--text-mute); cursor: pointer; background: none; border: none; font-family: inherit; }
  .alert-log-clear:hover { color: var(--text); }
  .alert-log-list { display: flex; flex-direction: column; gap: 8px; }
  .alert-log-item {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 12px 16px;
    display: grid; grid-template-columns: auto 1fr auto;
    align-items: center; gap: 14px;
  }
  .alert-log-item.armed-entry { border-left: 3px solid var(--bull); }
  .alert-log-item.watch-entry { border-left: 3px solid var(--liq); }
  .log-sym { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; }
  .log-detail { font-size: 12px; color: var(--text-dim); }
  .log-time { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-mute); white-space: nowrap; }
  .log-empty { color: var(--text-mute); font-size: 13px; padding: 20px 0; text-align: center; }

  /* ═══════════════════════════════════
     ANALYSIS PANEL (Phase 3)
  ═══════════════════════════════════ */
  .analysis-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 16px; }
  .analysis-card {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px 18px;
    transition: border-color .2s;
  }
  .analysis-card.armed-analysis { border-color: var(--bull); }
  .analysis-card.watch-analysis { border-color: var(--liq); }
  .analysis-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .analysis-sym { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 600; }
  .analysis-sig-badge { font-size: 10px; font-weight: 700; font-family: 'JetBrains Mono', monospace; padding: 2px 9px; border-radius: 4px; }
  .analysis-text { font-size: 12px; color: var(--text-dim); line-height: 1.75; }
  .analysis-score-bar { height: 3px; border-radius: 2px; background: var(--border); margin-top: 12px; overflow: hidden; }
  .analysis-score-fill { height: 100%; border-radius: 2px; background: var(--bull); transition: width .4s; }

  /* ═══════════════════════════════════
     ADD ASSET GATEWAY MODAL
  ═══════════════════════════════════ */
  .gateway-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 8000;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(8px);
    animation: overlayIn .2s ease-out;
  }
  .gateway-box {
    background: #0f0f13;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px 36px;
    width: 560px; max-width: 95vw;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 32px 80px rgba(0,0,0,0.8);
    animation: alertIn .35s cubic-bezier(.34,1.56,.64,1);
  }
  .gateway-title {
    font-size: 18px; font-weight: 600; color: var(--text);
    margin-bottom: 4px;
  }
  .gateway-sub { font-size: 12px; color: var(--text-mute); margin-bottom: 24px; }
  .gw-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
  .gw-row.three { grid-template-columns: 1fr 1fr 1fr; }
  .gw-row.full { grid-template-columns: 1fr; }
  .gw-field { display: flex; flex-direction: column; gap: 5px; }
  .gw-label { font-size: 10px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .1em; font-family: 'JetBrains Mono', monospace; }
  .gw-input {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 8px; padding: 9px 12px;
    color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 13px;
    outline: none; transition: border-color .2s;
    width: 100%;
  }
  .gw-input:focus { border-color: var(--gold); }
  .gw-input.valid { border-color: var(--bull); }
  .gw-input.invalid { border-color: var(--bear); }
  .gw-select {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 8px; padding: 9px 12px;
    color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 12px;
    outline: none; cursor: pointer; width: 100%;
  }
  .gw-price-preview {
    padding: 10px 14px; border-radius: 8px;
    background: rgba(92,184,138,0.06);
    border: 1px solid rgba(92,184,138,0.25);
    font-family: 'JetBrains Mono', monospace; font-size: 12px;
    color: var(--bull); margin-bottom: 16px; display: none;
  }
  .gw-price-err {
    padding: 10px 14px; border-radius: 8px;
    background: rgba(224,93,93,0.06);
    border: 1px solid rgba(224,93,93,0.25);
    font-size: 12px; color: var(--bear); margin-bottom: 16px; display: none;
  }
  .gw-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
  .gw-triggers-label { font-size: 10px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 10px; font-family: 'JetBrains Mono', monospace; }
  .gw-triggers { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 18px; }
  .gw-trigger-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 7px;
    background: var(--bg-elevated); border: 1px solid var(--border);
    cursor: pointer; transition: border-color .15s;
    font-size: 11px; color: var(--text-dim);
  }
  .gw-trigger-item:hover { border-color: var(--gold); }
  .gw-trigger-item.checked { border-color: var(--bull); background: rgba(92,184,138,0.06); color: var(--text); }
  .gw-trigger-cb { width: 14px; height: 14px; accent-color: var(--bull); flex-shrink: 0; }
  .gw-actions { display: flex; gap: 10px; margin-top: 20px; }
  .gw-btn-add {
    flex: 1; background: var(--bull); color: #08080a;
    border: none; border-radius: 10px; padding: 12px;
    font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700;
    cursor: pointer; transition: opacity .2s;
  }
  .gw-btn-add:hover { opacity: 0.85; }
  .gw-btn-add:disabled { opacity: 0.4; cursor: not-allowed; }
  .gw-btn-cancel {
    background: transparent; color: var(--text-mute);
    border: 1px solid var(--border); border-radius: 10px; padding: 12px 20px;
    font-family: 'JetBrains Mono', monospace; font-size: 13px; cursor: pointer;
    transition: border-color .2s;
  }
  .gw-btn-cancel:hover { border-color: var(--text-dim); color: var(--text); }
  .asset-custom-badge {
    position: absolute; top: 8px; left: 8px;
    font-size: 9px; font-weight: 700; font-family: 'JetBrains Mono', monospace;
    background: rgba(201,169,97,0.2); color: var(--gold);
    border: 1px solid rgba(201,169,97,0.35); border-radius: 4px; padding: 1px 6px;
    letter-spacing: .08em;
  }
  .gw-remove-btn {
    position: absolute; top: 8px; right: 8px;
    background: transparent; border: none; color: var(--text-mute);
    font-size: 14px; cursor: pointer; padding: 2px 5px; border-radius: 4px;
    transition: color .15s, background .15s; z-index: 2; display: none;
  }
  .asset-tile:hover .gw-remove-btn { display: block; }
  .gw-remove-btn:hover { color: var(--bear); background: rgba(224,93,93,0.1); }

  /* ═══════════════════════════════════════════════════
     MOBILE BOTTOM NAV
  ═══════════════════════════════════════════════════ */
  .mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: rgba(8,8,10,0.97);
    border-top: 1px solid var(--border);
    z-index: 200;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
  }
  .mob-nav-items {
    display: flex;
    height: 100%;
    align-items: stretch;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .mob-nav-items::-webkit-scrollbar { display: none; }
  .mob-nav-btn {
    flex: 1;
    min-width: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: transparent;
    border: none;
    color: var(--text-mute);
    cursor: pointer;
    padding: 6px 2px 8px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }
  .mob-nav-btn.active { color: var(--gold); }
  .mob-nav-btn.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: var(--gold);
    border-radius: 0 0 2px 2px;
  }
  .mob-nav-btn .mob-icon { font-size: 18px; line-height: 1; }
  .mob-nav-btn .mob-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
  }

  /* ═══════════════════════════════════════════════════
     MOBILE RESPONSIVE ( ≤640px )
  ═══════════════════════════════════════════════════ */
  @media (max-width: 640px) {

    /* Show bottom nav, hide sidebar */
    .mobile-bottom-nav { display: block; }
    nav.side { display: none !important; }

    /* Shell: full width + room for bottom nav */
    .shell {
      grid-template-columns: 1fr;
      padding-top: 44px;
      padding-bottom: 64px;
    }

    /* Top-right kill-switch shrinks slightly on phones so it fits the
       44px AP bar and leaves room for the timing segments on the left. */
    #liveKillSwitch {
      top: 6px;
      right: 10px;
      padding: 5px 12px;
      font-size: 10px;
      letter-spacing: 0.04em;
    }

    /* Compact top bar. Brand collapses to flex:0 so the timing segments
       (Clock, Session, Next KZ) take their natural width and fit on a
       375px phone. Sync stays hidden — debug surface, not actionable. */
    .autopilot-bar { height: 44px; }
    .ap-brand { padding: 0 10px; flex: 0 1 auto; min-width: 0; }
    .ap-brand .logo { font-size: 13px; white-space: nowrap; }
    .ap-brand .v { display: none; }
    .ap-segment { padding: 0 10px; font-size: 11px; gap: 6px; }
    .ap-label { font-size: 9px; }
    .ap-seg-sync { display: none; }
    /* Next KZ is the most actionable mobile info during sessions —
       gold value + slightly bolder so it pops when scanning fast. */
    .ap-seg-nextkz .ap-value { color: var(--gold); font-weight: 700; }

    /* Main content padding */
    main { padding: 14px 12px; }

    /* Page header smaller */
    .page-header { margin-bottom: 14px; padding-bottom: 12px; }
    .page-header h1 { font-size: 19px; }
    .page-header p { font-size: 11px; }

    /* AutoPilot cards grid */
    .ap-grid { grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
    .ap-card { padding: 14px; }
    .countdown-big .ct-time { font-size: 28px; }

    /* Signal cards: 2-column */
    .signals-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .signal-card { padding: 10px; }
    .sig-symbol { font-size: 16px; }

    /* Asset tiles: 2-column */
    .assets-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .asset-tile { padding: 12px 10px; }
    .asset-tile:hover { transform: none; }
    .asset-symbol { font-size: 20px; }
    .asset-price { font-size: 13px; }

    /* Remove button: always show on mobile (no hover) */
    .asset-tile .gw-remove-btn { display: none; } /* keep hidden — use modal to remove */

    /* Sync bar wraps */
    .sync-bar { flex-wrap: wrap; gap: 8px; }
    .sync-btn { font-size: 11px; padding: 8px 12px; min-height: 38px; }

    /* Asset modal: bottom sheet */
    .modal {
      align-items: flex-end !important;
      padding: 0 !important;
    }
    .modal-content {
      max-width: 100% !important;
      width: 100% !important;
      border-radius: 20px 20px 0 0 !important;
      max-height: 88vh;
      border-left: none !important;
      border-right: none !important;
      border-bottom: none !important;
    }
    .modal-header { padding: 16px 18px; }
    .modal-header h2 { font-size: 20px; }
    .modal-body { padding: 16px 18px 32px; }

    /* Add asset gateway modal: bottom sheet */
    #addAssetModal {
      align-items: flex-end !important;
      padding: 0 !important;
    }
    .gw-modal {
      border-radius: 20px 20px 0 0 !important;
      width: 100% !important;
      max-width: 100% !important;
      max-height: 90vh;
      overflow-y: auto;
      border-left: none !important;
      border-right: none !important;
      border-bottom: none !important;
    }

    /* Alert overlay: full screen */
    .alert-box {
      width: 95% !important;
      padding: 28px 20px !important;
    }

    /* Journal filters */
    .journal-filters { flex-wrap: wrap; gap: 6px; }

    /* Paper trading stats: 2-col */
    #paperStats { display: grid !important; grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }

    /* Backtest */
    #btControls { flex-wrap: wrap !important; }

    /* ICT Methods table */
    .methods-table { font-size: 11px; }

    /* Session timeline rows */
    .session-row { padding: 7px 10px; }
    .session-name { font-size: 12px; }
    .session-time { font-size: 10px; }

    /* MTF alignment */
    #mtfAlignCard { padding: 12px; }

    /* Forms/inputs */
    input, select, textarea {
      font-size: 16px !important; /* prevents iOS zoom */
    }
  }

  /* ═══ Tablet breakpoint ═══ */
  @media (max-width: 900px) and (min-width: 641px) {
    .mobile-bottom-nav { display: block; }
    nav.side { display: none !important; }
    .shell { grid-template-columns: 1fr; padding-bottom: 64px; }
    main { padding: 24px 20px; }
    .assets-grid { grid-template-columns: repeat(3, 1fr); }
    .signals-grid { grid-template-columns: repeat(3, 1fr); }
    .ap-grid { grid-template-columns: 1fr; }
  }

  /* ── iOS Safari fixes ───────────────────────────────────────────────
     1. font-size: 16px on text-style inputs prevents auto-zoom on focus
        (iOS auto-zooms whenever a focused input's font-size is < 16px).
     2. -webkit-tap-highlight-color: transparent kills the gray flash on
        every button tap.
     3. body padding uses safe-area-inset for notched iPhones (works only
        when viewport-fit=cover is set in the meta tag, which we do). */
  input[type="text"], input[type="number"], input[type="email"],
  input[type="search"], input[type="password"], textarea, select {
    font-size: 16px;
  }
  * { -webkit-tap-highlight-color: transparent; }
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
