/* Binloops — Modern trading terminal aesthetic */
/* 3-level elevation: Base #0D0F17 → Surface #12141E → Elevated #1A1D2E */

:root {
    /* — Foundation: 3-level elevation — */
    --bg-primary: #0D0F17;
    --bg-surface: #12141E;
    --bg-elevated: #1A1D2E;
    --bg-input: #0F1119;
    --border-subtle: #1E2235;
    --border-medium: #252840;
    --border-active: #363B5E;
    --text-primary: #E2E4EF;
    --text-secondary: #7B82A0;
    --text-muted: #454B66;

    /* — Accent system — amber for brand, use sparingly — */
    --tier1-teal: #67E8F9;
    --tier2-blue: #4F8EF7;
    --tier3-steel: #94a3b8;
    --color-paper: #4F8EF7;
    --polymarket-blue: #2563eb;

    --accent-primary: #F59E0B;
    --accent-secondary: #4F8EF7;
    --color-up: #00C076;
    --color-down: #FF4D6A;
    --color-warning: #F59E0B;
    --badge-paper: var(--color-paper);
    --badge-live: #F59E0B;
    --badge-shadowed: #5A6070;
    --badge-scanning: #F59E0B;
    --badge-confirmed: #F59E0B;
    --badge-traded: var(--color-up);
    --amber: #F59E0B;

    /* — Legacy aliases (JS-dependent — do not rename) — */
    --bg-root: var(--bg-primary);
    --bg-panel: var(--bg-surface);
    --bg-card: var(--bg-elevated);
    --bg-card-hover: #1F2336;
    --border: var(--border-subtle);
    --border-light: var(--border-medium);
    --accent: var(--accent-primary);
    --accent-hover: #D4860A;
    --accent-dim: rgba(245, 158, 11, 0.10);
    --accent-glow: rgba(245, 158, 11, 0.20);
    --green: var(--color-up);
    --green-dim: rgba(0, 192, 118, 0.10);
    --red: var(--color-down);
    --red-dim: rgba(255, 77, 106, 0.10);
    --blue: var(--tier2-blue);
    --blue-dim: rgba(79, 142, 247, 0.10);

    /* — Depth — */
    --card-highlight: rgba(255, 255, 255, 0.02);
    --card-highlight-hover: rgba(255, 255, 255, 0.04);

    /* — Typography — Inter for UI, mono for data — */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    --text-xs: 0.6875rem;   /* 11px */
    --text-sm: 0.75rem;     /* 12px */
    --text-base: 0.8125rem; /* 13px */
    --text-lg: 0.9375rem;   /* 15px */
    --text-xl: 1.5rem;      /* 24px */

    /* — Layout — */
    --topbar-h: 48px;
    --radius: 6px;
    --radius-sm: 4px;
}

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

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-root);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

body { display: flex; flex-direction: column; }

/* — Global: uppercase labels — */
.strategy-badge, .window-status-badge, .th-col, .t-badge,
.hs-label, .hs-mode-label, .pill, .nav-tab, .strategy-tab {
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ================================================================
   TOP BAR
   ================================================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-h);
    padding: 0 1.25rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--polymarket-blue);
    letter-spacing: -0.02em;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.logo-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
}

.logo-tag {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0;
}

.logo-powered {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 400;
}

.polymarket-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-decoration: none;
    padding: 0.2rem 0.5rem 0.2rem 0.3rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    transition: border-color 0.12s, background 0.12s;
}

.polymarket-badge:hover {
    border-color: var(--border-light);
    background: rgba(255,255,255,0.04);
}

.polymarket-logo {
    flex-shrink: 0;
    filter: brightness(0) invert(1) sepia(1) saturate(10) hue-rotate(205deg) brightness(0.7);
}

.polymarket-badge span {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0;
    white-space: nowrap;
}

/* ---- Header stat items ---- */
.hs-item {
    display: flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.hs-label {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-muted);
}

.hs-val {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.hs-sub {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-left: 2px;
}

.hs-mode-label {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
}
.hs-mode-label.live { color: var(--badge-live); }
.hs-mode-label.paper { color: var(--color-paper); }

.hs-sep {
    border-left: 1px solid var(--border);
    padding-left: 12px;
}

/* ---- Stats strip (below nav) ---- */
.stats-strip {
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 1.25rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.stats-strip::-webkit-scrollbar { display: none; }
.stats-strip .hs-item {
    padding: 0 1rem;
    position: relative;
}
.stats-strip .hs-item + .hs-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 1px;
    background: var(--border-subtle);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.utc-clock {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-muted);
    white-space: nowrap;
}

.connection-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    align-self: center;
}

.connection-dot.connected { background: var(--green); box-shadow: 0 0 6px rgba(0, 192, 118, 0.4); }
.connection-dot.disconnected { background: var(--red); }

.wallet-btn {
    padding: 0.4rem 1rem;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 5px;
    font-weight: 600;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: filter 0.12s;
    white-space: nowrap;
    font-family: var(--font-sans);
}

.wallet-btn:hover {
    filter: brightness(1.1);
}

.wallet-btn.connected {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: var(--text-xs);
    transition: border-color 0.12s, background 0.12s;
}

.wallet-btn.connected:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

/* ================================================================
   WALLET BANNER — dismissable, not blocking
   ================================================================ */
.wallet-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.45rem 1rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.wallet-banner.hidden { display: none; }

.wallet-banner .dismiss-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.25rem;
}

.wallet-banner .dismiss-btn:hover { color: var(--text-primary); }

/* ================================================================
   MAIN LAYOUT — split panel
   ================================================================ */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ---- LEFT PANEL (strategies + trades) ~42% ---- */
.panel-left {
    width: 42%;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.panel-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-section.strategies { flex: none; height: 45%; }
.panel-section.trades { flex: 1; min-height: 0; }

/* ---- Draggable divider ---- */
.panel-divider {
    height: 4px;
    cursor: row-resize;
    background: var(--border-medium);
    flex-shrink: 0;
    position: relative;
    transition: background 0.15s;
}
.panel-divider:hover,
.panel-divider.dragging {
    background: var(--accent);
}
.panel-divider::after {
    content: '';
    position: absolute;
    top: -4px;
    bottom: -4px;
    left: 0;
    right: 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 38px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.section-title {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.section-count {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-left: 0.6rem;
}

.section-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.panel-section.strategies .section-body {
    padding: 0 0.4rem 0.4rem;
}

/* ---- Strategy cards ---- */
.strategy-skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.sk-line {
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-surface) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: skPulse 1.4s ease-in-out infinite;
}

.sk-name  { height: 14px; width: 55%; }
.sk-meta  { height: 10px; width: 40%; }
.sk-stats { height: 10px; width: 70%; }

@keyframes skPulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.strategy-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.65rem;
    margin-bottom: 0.2rem;
    cursor: default;
    transition: border-color 0.12s, background 0.12s;
    border-left: 3px solid transparent;
}

.strategy-card:hover {
    border-color: var(--border-light);
    border-left-color: inherit;
    background: var(--bg-card-hover);
}

/* Strategy card left border by status */
.strategy-card:has(.badge-live) { border-left-color: var(--green); }
.strategy-card:has(.badge-paper) { border-left-color: var(--blue); }
.strategy-card:has(.badge-shadowed) { border-left-color: var(--badge-shadowed); }
.strategy-card:has(.badge-ml) { border-left-color: rgb(168, 85, 247); }

.strategy-card-top {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0;
    line-height: 1.2;
}

.strategy-name {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0;
}

.strategy-meta-inline {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.strategy-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 100px;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
}

.badge-live {
    background: rgba(245, 158, 11, 0.12);
    color: var(--badge-live);
    border: 1px solid rgba(245, 158, 11, 0.18);
}
.badge-paper {
    background: rgba(79, 142, 247, 0.12);
    color: var(--badge-paper);
    border: 1px solid rgba(79, 142, 247, 0.18);
}
.badge-ml {
    background: rgba(168, 85, 247, 0.12);
    color: rgb(168, 85, 247);
    border: 1px solid rgba(168, 85, 247, 0.18);
}
.badge-shadowed { background: rgba(90, 96, 112, 0.2); color: var(--badge-shadowed); border: 1px solid rgba(90, 96, 112, 0.15); }
.badge-active { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(245, 158, 11, 0.15); }

.badge-clickable { cursor: pointer; position: relative; }
.badge-clickable:hover { filter: brightness(1.2); }
.badge-clickable:hover::after {
    content: ' \25BE';
    font-size: 0.5rem;
}

.badge-toggle { cursor: pointer; }
.badge-toggle:hover { filter: brightness(1.2); }

.strategy-card-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
}

.three-dot-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    line-height: 1;
    transition: color 0.12s, background 0.12s;
    position: relative;
}
.three-dot-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

/* Strategy card expand */
.strategy-card .strat-chevron {
    font-size: 0.55rem;
    color: var(--text-muted);
    transition: transform 0.15s;
    margin-right: 0.15rem;
}
.strategy-card.expanded .strat-chevron { transform: rotate(90deg); }
.strategy-card.expanded { background: var(--bg-card); }
.strategy-card:not(.strategy-card-dimmed) .strategy-card-top { cursor: pointer; }

.strategy-expanded-body {
    border-top: 1px solid var(--border);
    padding: 0.5rem 0.65rem 0.4rem;
    margin-top: 0.3rem;
}
.strat-indicators {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.4rem;
}
.strat-indicator-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    font-size: var(--text-xs);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.strat-indicator-pill .ind-name { color: var(--text-primary); font-weight: 500; }
.strat-indicator-pill .ind-params { color: var(--text-muted); font-size: 0.65rem; }
.strat-indicator-pill .ind-tf { color: rgba(79, 142, 247, 0.50); font-size: 0.6rem; font-weight: 600; margin-left: 4px; }
.strat-vote-up { color: var(--color-up); font-weight: 600; font-size: 0.6rem; }
.strat-vote-dn { color: var(--color-down); font-weight: 600; font-size: 0.6rem; }
.strat-vote-both { color: var(--text-muted); font-weight: 600; font-size: 0.6rem; }
.strat-vote-cond { font-size: 0.6rem; font-weight: 600; white-space: nowrap; }
.strat-vote-cond .cond-up { color: var(--color-up); }
.strat-vote-cond .cond-dn { color: var(--color-down); }
.strat-vote-cond .cond-sep { color: var(--text-muted); margin: 0 3px; }
.strat-config-row {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}
.strat-config-row .strat-label { color: var(--text-muted); margin-right: 0.3rem; }
.strat-config-row .strat-val { color: var(--text-primary); font-weight: 500; }
.strat-description {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.3rem;
    line-height: 1.4;
}
.strat-clone-link {
    display: inline-block;
    margin-top: 0.4rem;
    font-size: var(--text-xs);
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}
.strat-clone-link:hover { text-decoration: underline; }

/* ML expanded card details */
.ml-expand-loading { font-size: var(--text-xs); color: var(--text-muted); padding: 0.3rem 0; }
.ml-expand-asset { margin-top: 0.5rem; }
.ml-expand-asset-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.ml-expand-asset-label { font-size: var(--text-sm); font-weight: 700; color: var(--text-primary); text-transform: uppercase; }
.ml-expand-trained { font-size: 10px; color: var(--text-muted); margin-left: auto; }
.ml-expand-no-model { font-size: var(--text-xs); color: var(--text-muted); font-style: italic; }
.ml-expand-thresh { font-size: 10px; color: var(--text-muted); font-weight: 400; }
.ml-acc-good { color: var(--color-up); font-size: var(--text-xs); font-weight: 600; }
.ml-acc-warn { color: var(--accent-primary); font-size: var(--text-xs); font-weight: 600; }
.ml-acc-bad { color: var(--color-down); font-size: var(--text-xs); font-weight: 600; }

.strategy-meta {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-wrap: nowrap;
    line-height: 1.3;
    overflow: hidden;
}

.kh-badge {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--red);
    background: var(--red-dim);
    border: 1px solid rgba(255, 77, 106, 0.15);
    border-radius: 100px;
    padding: 0.05rem 0.35rem;
    cursor: default;
}

.strategy-description {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.2rem;
}

.strategy-info-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: var(--text-base);
    cursor: pointer;
    padding: 0 0.15rem;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.12s;
}
.strategy-info-btn:hover,
.strategy-info-btn.active {
    opacity: 1;
    color: var(--text-secondary);
}

.strategy-description-dropdown {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: 1.5;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.2s ease, opacity 0.12s ease, padding 0.2s ease;
    padding: 0 0.5rem;
}
.strategy-description-dropdown.open {
    max-height: 80px;
    opacity: 1;
    padding: 0.25rem 0.5rem 0.15rem;
}

.strategy-activate-btn {
    display: block;
    width: 100%;
    margin-top: 0.4rem;
    padding: 0.5rem 0.6rem;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 5px;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.12s;
}
.strategy-activate-btn:hover {
    filter: brightness(1.1);
}
.strategy-activate-btn:disabled { opacity: 0.5; cursor: default; }

.tf-badge {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 500;
    font-family: var(--font-mono);
    letter-spacing: 0;
}
.tf-5m  { background: rgba(96, 165, 250, 0.1); color: #60A5FA; }
.tf-15m { background: rgba(20, 184, 166, 0.1); color: #14B8A6; }
.tf-1h  { background: rgba(167, 139, 250, 0.1); color: #A78BFA; }

.bet-size-label {
    color: var(--text-muted);
    font-weight: 400;
    font-size: var(--text-xs);
    margin-right: 2px;
}
.bet-size-clickable {
    cursor: pointer;
    color: var(--accent-primary);
    font-weight: 600;
    transition: color 0.12s;
}
.bet-size-clickable .bet-size-pencil {
    font-size: 0.7em;
    margin-left: 3px;
    opacity: 0.5;
    transition: opacity 0.12s;
}
.bet-size-clickable:hover {
    color: var(--accent-hover);
}
.bet-size-clickable:hover .bet-size-pencil {
    opacity: 1;
}

/* Shared size editor dropdown panel */
.size-editor-panel {
    position: fixed;
    z-index: 9999;
    padding: 0.45rem 0.55rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}
.size-editor-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
}
.size-editor-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}
.size-editor-hint {
    font-size: 0.6rem;
    color: var(--text-muted);
}
.size-editor-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.size-editor-prefix {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}
.size-editor-input {
    width: 60px;
    padding: 3px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
    outline: none;
}
.size-editor-input:focus {
    border-color: var(--accent);
}
.size-editor-save {
    font-size: 0.6rem;
    padding: 3px 10px;
    border-radius: 3px;
    cursor: pointer;
    background: var(--accent);
    color: #000;
    border: 1px solid var(--accent);
    font-weight: 600;
    font-family: var(--font-mono);
}
.size-editor-save:hover { filter: brightness(1.2); }
.size-editor-cancel {
    font-size: 0.6rem;
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-weight: 600;
}
.size-editor-cancel:hover { filter: brightness(1.2); }
.size-editor-option {
    font-size: var(--text-xs);
    padding: 4px 12px;
    border-radius: 3px;
    cursor: pointer;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-weight: 600;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.size-editor-option:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}
.size-editor-option.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.status-menu {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    min-width: 100px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.status-menu-item {
    padding: 0.45rem 0.75rem;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    font-family: var(--font-sans);
}

.status-menu-item:hover {
    background: var(--accent-dim);
    color: var(--text-primary);
}

.status-menu-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.status-menu-item:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.status-menu-item:only-child { border-radius: var(--radius); }

.status-menu-item-primary {
    color: var(--green);
    font-weight: 600;
}
.status-menu-item-primary:hover {
    background: var(--green-dim);
    color: var(--green);
}
.status-menu-item-paper {
    color: var(--blue, #4F8EF7);
    font-weight: 600;
}
.status-menu-item-paper:hover {
    background: rgba(79, 142, 247, 0.1);
    color: var(--blue, #4F8EF7);
}
.status-menu-item-danger {
    color: var(--red, #ef4444);
}
.status-menu-item-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red, #ef4444);
}

.badge-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-left: 0.25rem;
    opacity: 0.6;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.confirm-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.confirm-message {
    font-size: var(--text-base);
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.confirm-btn {
    padding: 0.45rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.12s;
    font-family: var(--font-sans);
}

.confirm-cancel {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-light);
}

.confirm-cancel:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.confirm-ok {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.confirm-ok:hover {
    filter: brightness(1.1);
}

.strategy-tooltip {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: var(--text-sm);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.strategy-tooltip.visible { opacity: 1; }

.strategy-stats-row {
    display: flex;
    gap: 0.75rem;
    font-size: 0.7rem;
}

.strategy-stats-row .s-val {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
}

.strategy-stats-row .s-lbl {
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.sc-stats-block {
    display: flex;
    flex-wrap: wrap;
    gap: 0.1rem 0.35rem;
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border);
}

.sc-stat-row {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    white-space: nowrap;
}
.sc-stat-row + .sc-stat-row::before {
    content: '\00b7';
    color: var(--text-muted);
    margin-right: 0.15rem;
    opacity: 0.5;
}

.sc-stat-badge {
    font-size: var(--text-xs);
    font-weight: 500;
    flex-shrink: 0;
    font-family: var(--font-sans);
}

.sc-badge-live   { color: rgba(245, 158, 11, 0.6); }
.sc-badge-paper  { color: rgba(79, 142, 247, 0.6); }
.sc-badge-all    { color: rgba(37, 99, 235, 0.6); }

.sc-stat {
    display: inline-block;
    padding: 1px 5px;
    margin-left: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.sc-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    margin-left: 5px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.6rem;
    color: var(--text-primary);
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.sc-pill-live {
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.10);
}
.sc-pill-paper {
    background: rgba(79, 142, 247, 0.05);
    border: 1px solid rgba(79, 142, 247, 0.10);
}
.sc-pill-all {
    background: rgba(160, 174, 192, 0.06);
    border: 1px solid rgba(160, 174, 192, 0.12);
}
.sc-pill-label {
    font-weight: 700;
    font-size: 0.55rem;
    letter-spacing: 0.03em;
    margin-right: 1px;
}
.sc-pill-live .sc-pill-label { color: rgba(245, 158, 11, 0.45); }
.sc-pill-paper .sc-pill-label { color: rgba(79, 142, 247, 0.45); }
.sc-pill-all .sc-pill-label { color: rgba(160, 174, 192, 0.55); }

.sc-pill-live .sc-stat-text { color: rgba(245, 158, 11, 0.35); }
.sc-pill-paper .sc-stat-text { color: rgba(79, 142, 247, 0.35); }
.sc-pill-all .sc-stat-text { color: rgba(160, 174, 192, 0.45); }

.sc-stat-text {
    color: var(--text-secondary);
}

.sc-stat-muted {
    color: var(--text-muted);
    font-style: italic;
    font-size: var(--text-xs);
}

.strategy-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg-surface);
}

.strategy-tab {
    flex: 1;
    padding: 0.5rem 0.5rem;
    background: none;
    border: none;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.12s, border-color 0.12s;
}

.strategy-tab:hover {
    color: var(--text-secondary);
}

.strategy-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

/* ---- Strategy sort/filter controls ---- */
.strat-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: sticky;
    top: 30px;
    z-index: 2;
    background: var(--bg-surface);
}
.strat-filters {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.strat-pill {
    padding: 0.15rem 0.45rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    border-radius: 100px;
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s;
    line-height: 1.3;
}
.strat-pill:hover { color: var(--text-secondary); border-color: var(--border-medium); }
.strat-pill.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}
.strat-sort-trigger {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s;
    white-space: nowrap;
}
.strat-sort-trigger:hover { border-color: var(--accent); color: var(--text-primary); }
.strat-sort-panel {
    position: fixed;
    z-index: 9999;
    padding: 0.4rem 0.45rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.strat-sort-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0 4px 2px;
}
.strat-sort-option {
    font-size: var(--text-xs);
    padding: 4px 12px;
    border-radius: 3px;
    cursor: pointer;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-weight: 600;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    text-align: left;
}
.strat-sort-option:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}
.strat-sort-option.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* Strategy card glow on trade */
@keyframes strategyGlowPaper {
    0%   { box-shadow: 0 0 0 1px rgba(79, 142, 247, 0.4); }
    100% { box-shadow: none; }
}
@keyframes strategyGlowLive {
    0%   { box-shadow: 0 0 0 1px rgba(0, 192, 118, 0.4); }
    100% { box-shadow: none; }
}
.strategy-glow-paper { animation: strategyGlowPaper 2.5s ease-out forwards; }
.strategy-glow-live  { animation: strategyGlowLive 2.5s ease-out forwards; }

/* Strategy card breathing pulse with open position */
@keyframes strategyBreathePaper {
    0%, 100% { border-color: var(--border); }
    50%      { border-color: rgba(79, 142, 247, 0.35); }
}
@keyframes strategyBreatheLive {
    0%, 100% { border-color: var(--border); }
    50%      { border-color: rgba(0, 192, 118, 0.35); }
}
.strategy-breathe-paper { animation: strategyBreathePaper 2.5s ease-in-out infinite; }
.strategy-breathe-live  { animation: strategyBreatheLive 2.5s ease-in-out infinite; }

.strategy-card-dimmed {
    opacity: 0.45;
}

.strategy-card-dimmed:hover { border-color: var(--border); }

.strategy-shadowed-note {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
}

.strategy-unshadow-btn {
    padding: 0.15rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.12s;
}
.strategy-unshadow-btn:hover {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}
.strategy-unshadow-btn:disabled { opacity: 0.5; cursor: default; }

.strategy-connect-prompt {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 0.3rem;
    padding: 0.25rem 0;
    border-top: 1px solid var(--border);
    font-style: italic;
}

.strategy-connect-btn {
    display: block;
    width: 100%;
    margin-top: 0.4rem;
    padding: 0.5rem 0.6rem;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
}
.strategy-connect-btn:hover { filter: brightness(1.1); }

/* ================================================================
   PAIR ACCUMULATOR CARD
   ================================================================ */
.pair-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.pair-card-summary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.65rem;
    cursor: pointer;
    transition: background 0.12s;
    flex-wrap: wrap;
}
.pair-card-summary:hover { background: var(--bg-card-hover); }

.pair-chevron {
    font-size: 0.55rem;
    color: var(--text-muted);
    transition: transform 0.15s;
    margin-right: 0.15rem;
}
.pair-card.expanded .pair-chevron { transform: rotate(90deg); }

.pair-card-title {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.pair-summary-stats {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.pair-summary-stats .pair-stat-sep { color: var(--text-muted); }
.pair-summary-pnl { font-weight: 600; }

.pair-three-dot-btn {
    margin-left: auto;
    flex-shrink: 0;
}

.pair-enable-btn {
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s;
    border: 1px solid;
    background: var(--accent-dim);
    color: var(--accent);
    border-color: rgba(245, 158, 11, 0.2);
}
.pair-enable-btn:hover { background: var(--accent); color: #000; }

.pair-description {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.4rem;
    padding: 0 0.15rem;
}

.pair-badge-paper {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(79, 142, 247, 0.12);
    color: var(--badge-paper);
    border: 1px solid rgba(79, 142, 247, 0.18);
}
.pair-badge-live {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(245, 158, 11, 0.12);
    color: var(--badge-live);
    border: 1px solid rgba(245, 158, 11, 0.18);
}

.pair-expanded-body {
    border-top: 1px solid var(--border);
    padding: 0.5rem 0.65rem;
}

.pair-stats-row {
    display: flex;
    gap: 1rem;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}
.pair-stats-row .pair-stat-label { color: var(--text-muted); }
.pair-stats-row .pair-stat-val { color: var(--text-primary); font-weight: 500; }

.pair-attempts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
    margin-bottom: 0.35rem;
}
.pair-attempts-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.2rem 0.3rem;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.pair-attempts-table td {
    padding: 0.2rem 0.3rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.pair-leg-filled { color: var(--green); font-weight: 600; }
.pair-leg-resting { color: var(--amber); }
.pair-leg-sim { color: var(--text-muted); font-style: italic; }
.pair-leg-cancelled { color: var(--text-muted); text-decoration: line-through; }

.pair-section-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.25rem;
    margin-top: 0.4rem;
}

.pair-history-scroll {
    max-height: 160px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) transparent;
}
.pair-history-scroll::-webkit-scrollbar { width: 4px; }
.pair-history-scroll::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 2px;
}

.pair-status-merged { color: var(--green); font-weight: 600; }
.pair-status-cancelled { color: var(--text-muted); }
.pair-status-stop-loss { color: var(--red); }
.pair-status-active { color: var(--amber); }
.pair-status-failed { color: var(--red); }

/* pair-leg-size-clickable removed — pair now uses shared .bet-size-clickable */
.pair-badge-dn {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(139, 148, 186, 0.06);
    color: rgba(139, 148, 186, 0.50);
    border: 1px solid rgba(139, 148, 186, 0.12);
}

.pair-badge-experimental {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    background: rgba(139, 148, 186, 0.06);
    color: rgba(139, 148, 186, 0.50);
    border: 1px solid rgba(139, 148, 186, 0.12);
}

.pair-setup-cta {
    padding: 0.6rem 0.65rem;
    text-align: center;
}
.pair-setup-cta .pair-enable-btn {
    padding: 0.4rem 1rem;
    font-size: var(--text-sm);
}

.pair-no-attempts {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
    padding: 0.3rem 0;
}

@media (max-width: 768px) {
    .pair-summary-stats { display: none; }
    .pair-stats-row { gap: 0.5rem; }
}
@media (max-width: 480px) {
    .pair-card-summary { padding: 0.35rem 0.5rem; gap: 0.3rem; }
    .pair-expanded-body { padding: 0.35rem 0.5rem; }
}

.wr-good { color: var(--green); }
.wr-mid { color: var(--accent); }
.wr-bad { color: var(--red); }
.pnl-pos { color: var(--green); }
.pnl-amber { color: var(--amber); font-weight: 600; }
.pnl-zero { color: var(--text-secondary); font-weight: 600; }
.pnl-neg { color: var(--red); font-weight: 600; }

.strategy-live-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.live-indicator {
    color: var(--green);
    font-size: var(--text-xs);
    font-weight: 500;
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Window state badges */
.window-status-badge {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    padding: 0.1rem 0.4rem;
    border-radius: 100px;
}

.window-status-badge.idle {
    background: rgba(90, 96, 112, 0.12);
    color: var(--text-muted);
}

.window-status-badge.scanning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--badge-scanning);
}

.window-status-badge.traded {
    background: rgba(0, 192, 118, 0.1);
    color: var(--badge-traded);
}

.window-status-badge.confirming {
    background: rgba(245, 158, 11, 0.1);
    color: var(--badge-scanning);
}

.window-status-badge.skipped {
    background: rgba(90, 96, 112, 0.12);
    color: var(--text-muted);
}

.window-no-market {
    color: var(--text-muted);
    font-weight: 400;
}

.window-prices {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
}

.window-prices .price-up { color: var(--green); }
.window-prices .price-down { color: var(--red); }
.window-prices .price-sep { color: var(--text-muted); font-size: var(--text-xs); font-weight: 400; }

/* ---- Trade Log — Bloomberg-style dense rows ---- */
.trade-filters {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.6rem;
    flex-wrap: wrap;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.feed-strategy-filter {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    padding: 0.15rem 0.4rem;
    min-width: 0;
    cursor: pointer;
    outline: none;
    transition: border-color 0.12s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%236B7280' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    padding-right: 1.4rem;
}
.feed-strategy-filter:focus {
    border-color: var(--accent);
}
.feed-strategy-filter option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.pill {
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 100px;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s;
}

.pill:hover, .pill.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.pill-sep {
    color: var(--border);
    font-size: var(--text-xs);
    display: flex;
    align-items: center;
}

.trade-list {
    flex: 1;
    overflow-y: auto;
}

/* ---- Trade log grid — dense monospace data ---- */
.trade-header,
.trade-card {
    display: grid;
    grid-template-columns: 40px 1fr 42px 36px 24px 28px 52px 48px 56px 60px;
    gap: 6px;
    align-items: center;
    padding: 0 10px;
    font-family: var(--font-mono);
    white-space: nowrap;
}

.trade-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding-top: 6px;
    padding-bottom: 6px;
}
.th-col {
    font-size: var(--text-xs);
    font-family: var(--font-sans);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.th-pnl      { text-align: right; }

.trade-card {
    border-bottom: 1px solid var(--border-subtle);
    border-left: 2px solid transparent;
    font-size: var(--text-xs);
    transition: background 0.1s;
    padding-top: 5px;
    padding-bottom: 5px;
}

.trade-card:nth-child(even) { background: transparent; }
.trade-card:hover { background: var(--bg-card-hover); }

.trade-card.pending-row { border-left-color: var(--color-warning); }
.trade-card.win-row     { border-left-color: var(--green); }
.trade-card.loss-row    { border-left-color: var(--red); }

.trade-card .tc-time     { color: var(--text-muted); }
.trade-card .tc-strategy { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; }
.trade-card .tc-type     { }
.trade-card .tc-asset    { text-transform: uppercase; color: var(--text-primary); }
.trade-card .tc-tf       { color: var(--text-muted); }
.trade-card .tc-dir      { font-weight: 600; }
.trade-card .tc-dir.up   { color: var(--green); }
.trade-card .tc-dir.down { color: var(--red); }
.trade-card .tc-price    { color: var(--text-secondary); }
.trade-card .tc-cost     { color: var(--text-secondary); }

.trade-card .t-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 500;
    padding: 1px 5px;
    border-radius: 100px;
    vertical-align: middle;
    font-family: var(--font-sans);
}
.trade-card .t-badge-paper {
    color: var(--color-paper);
    background: rgba(79, 142, 247, 0.1);
}
.trade-card .t-badge-live {
    color: var(--badge-live);
    background: rgba(245, 158, 11, 0.1);
}

.trade-card .t-result { font-weight: 600; }
.trade-card .t-result-pending { color: var(--color-warning); }
.trade-card .t-result-win     { color: var(--green); }
.trade-card .t-result-loss    { color: var(--red); }

.trade-card .tc-pnl { font-weight: 600; text-align: right; }
.trade-card .tc-pnl-pending { color: var(--text-muted); }
.trade-card .tc-pnl-win     { color: var(--green); }
.trade-card .tc-pnl-loss    { color: var(--red); }

/* ---- RIGHT PANEL (active windows) ---- */
.panel-right {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

.panel-right-markets {
    width: 35%;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-subtle);
    overflow: hidden;
}

.panel-right-chart {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ---- Chart panel ---- */
.chart-panel-header {
    height: 38px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
}

.chart-panel-asset {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--text-base);
}

.chart-panel-tf {
    /* Inherits .window-tf + .tf-{5m,15m,1h} via JS class assignment */
}

.chart-panel-price {
    color: var(--text-secondary);
    font-size: var(--text-xs);
}

.chart-panel-trade {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.chart-panel-strat {
    color: var(--text-secondary);
    font-weight: 400;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    border-left: 1px solid var(--border-subtle);
    padding-left: 0.6rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 30%;
}

.chart-panel-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-panel-actions a {
    display: inline-flex;
    align-items: center;
    opacity: 0.5;
    transition: opacity 0.12s;
}
.chart-panel-actions a:hover { opacity: 0.9; }

.chart-panel-body {
    flex: 1;
    min-height: 0;
    position: relative;
}

.chart-panel-empty {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* ---- Chart panel footer — strategy activity ---- */
.chart-panel-footer {
    display: none;
    align-items: center;
    gap: 0.6rem;
    padding: 0 1rem;
    height: 0;
    overflow: hidden;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    flex-shrink: 0;
    transition: height 0.15s ease;
}
.chart-panel-footer.active {
    display: flex;
    height: 34px;
}
.footer-strat {
    color: var(--accent);
    font-weight: 500;
    font-family: var(--font-sans);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 35%;
}
.footer-direction {
    font-weight: 600;
    white-space: nowrap;
}
.footer-direction.up { color: var(--color-up); }
.footer-direction.down { color: var(--color-down); }
.footer-mode {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 100px;
    font-weight: 500;
    text-transform: uppercase;
    font-family: var(--font-sans);
}
.footer-mode.paper { background: rgba(79,142,247,0.1); color: var(--color-paper); }
.footer-mode.live { background: rgba(245,158,11,0.1); color: var(--badge-live); }
.footer-prices {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
}
.footer-price {
    font-weight: 600;
}
.footer-price.up { color: var(--color-up); }
.footer-price.down { color: var(--color-down); }
.footer-price.neutral { color: var(--accent-secondary); }
.footer-price.strike {
    color: var(--text-secondary);
    font-weight: 500;
}
.footer-price-label {
    font-size: 9px;
    font-family: var(--font-sans);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.7;
    margin-right: 0.15rem;
}

/* ---- Window card selected state ---- */
.window-card.selected {
    background: rgba(245, 158, 11, 0.08);
    border-left-width: 3px;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.25), 0 0 12px rgba(245, 158, 11, 0.08);
}
.window-card.window-card.selected {
    border-left-color: var(--accent);
    border-color: rgba(245, 158, 11, 0.30);
}

.windows-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 38px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.windows-grid {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.window-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.window-group-header {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.25rem 0.3rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.1rem;
    color: var(--text-muted);
    background: none;
}
.window-group-header.tf-5m  { color: #60A5FA; border-bottom-color: rgba(96, 165, 250, 0.25); }
.window-group-header.tf-15m { color: #14B8A6; border-bottom-color: rgba(20, 184, 166, 0.25); }
.window-group-header.tf-1h  { color: #A78BFA; border-bottom-color: rgba(167, 139, 250, 0.25); }

/* ---- Window Card ---- */
.window-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.12s;
}

.window-card.status-win { border-color: var(--green); }
.window-card.status-loss { border-color: var(--red); }

.window-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.window-top-left {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.window-top-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    min-width: 0;
}

.window-poly-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
    transition: opacity 0.12s;
    line-height: 0;
}

.window-poly-link:hover {
    opacity: 0.8;
}

.window-poly-link img {
    border-radius: var(--radius-sm);
    filter: brightness(0) invert(1) sepia(1) saturate(10) hue-rotate(205deg) brightness(0.7);
}

.window-asset {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
}

.window-tf {
    font-size: var(--text-xs);
    padding: 0.1rem 0.35rem;
    border-radius: 100px;
    font-family: var(--font-mono);
    font-weight: 500;
}
.window-tf.tf-5m  { background: rgba(96, 165, 250, 0.1); color: #60A5FA; }
.window-tf.tf-15m { background: rgba(20, 184, 166, 0.1); color: #14B8A6; }
.window-tf.tf-1h  { background: rgba(167, 139, 250, 0.1); color: #A78BFA; }

.window-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.window-status-badge.open { background: var(--blue-dim); color: var(--blue); }
.window-status-badge.win { background: var(--green-dim); color: var(--green); }
.window-status-badge.loss { background: var(--red-dim); color: var(--red); }

.confirming-dots span {
    animation: dotPulse 1.4s ease-in-out infinite;
    opacity: 0.3;
}
.confirming-dots span:nth-child(2) { animation-delay: 0.2s; }
.confirming-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

.window-body {
    display: none;
}

.window-dir {
    font-size: var(--text-lg);
    font-weight: 700;
    font-family: var(--font-mono);
}

.window-dir.up { color: var(--green); }
.window-dir.down { color: var(--red); }

.window-price {
    font-family: var(--font-mono);
    font-size: var(--text-base);
    color: var(--text-secondary);
}

.window-countdown {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.window-countdown.urgent {
    color: var(--red);
    font-weight: 600;
}

.window-card.flash-win-card {
    animation: windowFlashWin 1.5s ease-out;
}
.window-card.flash-loss-card {
    animation: windowFlashLoss 1.5s ease-out;
}

@keyframes windowFlashWin {
    0%   { background: rgba(0, 192, 118, 0.15); border-color: var(--green); }
    40%  { background: rgba(0, 192, 118, 0.06); }
    100% { background: var(--bg-card); border-color: var(--border); }
}

@keyframes windowFlashLoss {
    0%   { background: rgba(255, 77, 106, 0.15); border-color: var(--red); }
    40%  { background: rgba(255, 77, 106, 0.06); }
    100% { background: var(--bg-card); border-color: var(--border); }
}

/* State glow — amber scanning, teal confirming, green traded */
@keyframes scanningGlow {
    0%, 100% { border-top-color: var(--border); border-right-color: var(--border); border-bottom-color: var(--border); box-shadow: none; }
    50%      { border-top-color: #F59E0B60; border-right-color: #F59E0B60; border-bottom-color: #F59E0B60; box-shadow: 0 0 6px #F59E0B40; }
}
.window-card.scanning-active {
    animation: scanningGlow 3s ease-in-out infinite;
}

.window-card.confirming-active {
    border-top-color: #14B8A660;
    border-right-color: #14B8A660;
    border-bottom-color: #14B8A660;
    box-shadow: 0 0 6px #14B8A640;
}

.window-card.traded-active {
    border-top-color: #00C07660;
    border-right-color: #00C07660;
    border-bottom-color: #00C07660;
    box-shadow: 0 0 6px #00C07640;
}


/* ---- Window card clickable ---- */
.window-card { cursor: pointer; }
/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.empty-state h3 {
    color: var(--text-secondary);
    font-size: var(--text-lg);
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.empty-state p {
    font-size: var(--text-sm);
    max-width: 300px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ================================================================
   WIZARD — Key Setup
   ================================================================ */
.wizard-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.wizard-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.75rem 2rem;
    max-width: 620px;
    width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
}

.wizard-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.wizard-step {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    border-radius: 100px;
    font-family: var(--font-sans);
}

.wizard-step.active {
    color: var(--accent);
    background: var(--accent-dim);
}

.wizard-step.done {
    color: var(--green);
}

.wizard-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.wizard-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    transition: border-color 0.12s;
}

.wizard-card:hover {
    border-color: var(--accent);
}

.wizard-card-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.wizard-card-headline {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.wizard-card-body {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.wizard-card-small {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 0.75rem;
}

.wizard-btn {
    display: inline-block;
    padding: 0.45rem 1rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.12s;
    font-family: var(--font-sans);
}

.wizard-btn-primary {
    background: var(--accent);
    color: #000;
    font-weight: 600;
}

.wizard-btn-primary:hover {
    filter: brightness(1.1);
}

.wizard-btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.wizard-btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border-medium);
}

.wizard-btn-secondary:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.wizard-btn-accent {
    background: transparent;
    color: var(--green);
    border: 1px solid var(--green);
}
.wizard-btn-accent:hover {
    background: rgba(0, 192, 118, 0.12);
}
.wizard-btn-accent:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.wizard-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.wizard-key-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.wizard-key-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    flex-wrap: wrap;
}

.wizard-key-row:last-child { margin-bottom: 0; }

.wizard-key-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    min-width: 70px;
}

.wizard-key-value {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-primary);
    word-break: break-all;
    flex: 1;
}

.wizard-key-hidden {
    color: var(--text-muted);
}

.wizard-copy-btn, .wizard-reveal-btn {
    padding: 0.15rem 0.4rem;
    font-size: var(--text-xs);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
}

.wizard-copy-btn:hover, .wizard-reveal-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.wizard-warning {
    background: var(--red-dim);
    border: 1px solid rgba(255, 77, 106, 0.25);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    font-size: var(--text-sm);
    color: var(--red);
    line-height: 1.5;
}

.wizard-warning-top,
.wizard-warning-bottom {
    font-size: var(--text-sm);
    padding: 0.75rem 1rem;
    text-align: center;
    background: var(--red-dim);
    border: 1px solid rgba(255, 77, 106, 0.3);
}

.wizard-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.wizard-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

.wizard-checkbox input[type="checkbox"] {
    accent-color: var(--accent);
}

.wizard-fund-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.wizard-fund-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.wizard-fund-text {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin: 0.35rem 0;
}

.wizard-balance {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--accent);
    margin: 0.25rem 0;
}

.wizard-skip-link {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-decoration: none;
}

.wizard-skip-link:hover {
    color: var(--text-secondary);
}

.wizard-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.wizard-input-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wizard-input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.12s;
}

.wizard-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.wizard-import-instructions {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.wizard-derived {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.wizard-spinner {
    text-align: center;
    color: var(--accent);
    font-size: var(--text-base);
    padding: 2rem 0;
}

.wizard-error {
    text-align: center;
    color: var(--red);
    font-size: var(--text-base);
    padding: 1rem 0;
}

.wizard-completion {
    text-align: center;
    padding: 1rem 0;
}

.wizard-checkmark {
    font-size: 2.5rem;
    color: var(--green);
    margin-bottom: 0.5rem;
}

.wizard-completion-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.wizard-completion-body {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.wizard-completion-details {
    font-size: var(--text-sm);
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.8;
}

.wizard-security-note {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* ================================================================
   WALLET PANEL — Phase 3
   ================================================================ */
.wallet-panel-dialog {
    max-width: 480px;
}

.wallet-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.wallet-panel-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
}

.wallet-panel-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    transition: color 0.12s;
}

.wallet-panel-close:hover { color: var(--text-primary); }

.wallet-panel-back {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.25rem;
    transition: color 0.12s;
}

.wallet-panel-back:hover { color: var(--accent); }

.wallet-panel-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Address section */
.wallet-panel-address {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
}

.wallet-panel-address-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    display: block;
}

.wallet-panel-address-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wallet-panel-address-value {
    font-family: var(--font-mono);
    font-size: var(--text-base);
    color: var(--text-primary);
    font-weight: 500;
}

.wallet-panel-scan-link {
    font-size: 0.6rem;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}

.wallet-panel-scan-link:hover {
    text-decoration: underline;
}

/* USDC inline logo */
.usdc-logo {
    display: inline-block;
    vertical-align: middle;
    width: 16px;
    height: 16px;
    margin-right: 3px;
    position: relative;
    top: -1px;
}

/* Balance section */
.wallet-panel-balance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.wallet-panel-balance-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.wallet-panel-balance-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
}
.wallet-panel-balance-loading {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 400;
}

/* Action buttons */
.wallet-panel-actions {
    display: flex;
    gap: 0.5rem;
}

.wallet-panel-actions .wizard-btn {
    flex: 1;
    text-align: center;
}

/* Recent activity */
.wallet-panel-activity {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
}

.wallet-panel-activity-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.4rem;
}

.wallet-panel-activity-empty {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.5rem 0;
}

.wallet-panel-activity-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0;
    font-size: 0.7rem;
    border-bottom: 1px solid var(--border);
}

.wallet-panel-activity-row:last-child { border-bottom: none; }

.activity-icon {
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
}

.activity-deposit .activity-icon { color: var(--green); }
.activity-withdrawal .activity-icon { color: var(--red); }

.activity-type {
    color: var(--text-secondary);
    text-transform: capitalize;
    min-width: 65px;
}

.activity-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.activity-hash {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--accent);
    text-decoration: none;
}

.activity-hash:hover { text-decoration: underline; }

/* Footer buttons */
.wallet-panel-footer {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.wallet-panel-footer-btn {
    flex: 1;
    padding: 0.35rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s;
    text-align: center;
}

.wallet-panel-footer-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.wallet-panel-footer-btn-danger:hover {
    border-color: var(--red);
    color: var(--red);
}

.wallet-panel-allowance-warning {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
    text-align: center;
}

/* ================================================================
   DEPOSIT FLOW
   ================================================================ */
.deposit-instructions {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 0.25rem;
}

.deposit-chain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
}

.deposit-chain-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
    text-align: center;
}

.deposit-chain-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.deposit-chain-name {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.deposit-chain-min {
    display: block;
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.deposit-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.deposit-address-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.deposit-address-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.deposit-address-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
}

.deposit-address-value {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-primary);
    word-break: break-all;
    flex: 1;
}

.deposit-qr-container {
    display: flex;
    justify-content: center;
    padding: 0.5rem;
    background: #FFFFFF;
    border-radius: var(--radius-sm);
    max-width: 200px;
    margin: 0 auto;
}

.deposit-qr-container svg {
    width: 100%;
    height: auto;
}

.deposit-min-note {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-align: center;
}

.deposit-warning {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    font-size: 0.7rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.deposit-chains-info {
    margin-top: 0.5rem;
}

.deposit-chains-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.deposit-chains-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.deposit-chain-tag {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.deposit-onramp {
    margin-top: 0.75rem;
    text-align: center;
}

.deposit-onramp-link {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    transition: background 0.12s;
}

.deposit-onramp-link:hover {
    background: rgba(245, 158, 11, 0.1);
}

.deposit-balance-watch {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    font-family: var(--font-mono);
    margin-top: 0.75rem;
}

.deposit-success {
    background: var(--green-dim);
    border: 1px solid var(--green);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--green);
    text-align: center;
}

/* ================================================================
   DEPOSIT TABS (Bridge — EVM / Solana / Bitcoin / Polygon)
   ================================================================ */
.wizard-deposit-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}
.wizard-dep-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.5rem 0.25rem;
    cursor: pointer;
    font-family: var(--font-mono);
    transition: color 0.12s, border-color 0.12s;
}
.wizard-dep-tab:hover {
    color: var(--text-primary);
}
.wizard-dep-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.wizard-deposit-pane {
    min-height: 6rem;
    padding: 0.5rem 0;
}
.wizard-deposit-addr-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}
.wizard-deposit-addr-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.5rem;
}
.wizard-deposit-addr-value {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-primary);
    word-break: break-all;
    flex: 1;
}
.wizard-deposit-network {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}
.wizard-deposit-warning {
    font-size: 0.7rem;
    color: var(--amber);
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.5rem;
}
.wizard-deposit-unavailable {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 1.5rem 0.5rem;
}

/* ================================================================
   WITHDRAW FLOW
   ================================================================ */
.withdraw-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.withdraw-balance-row {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    font-family: var(--font-mono);
}

.withdraw-balance-row strong {
    color: var(--accent);
}

.withdraw-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.withdraw-amount-row {
    display: flex;
    gap: 0.35rem;
}

.withdraw-amount-row .wizard-input {
    flex: 1;
}

.withdraw-max-btn {
    padding: 0.3rem 0.6rem !important;
    font-size: 0.65rem !important;
}

.withdraw-error {
    font-size: 0.7rem;
    color: var(--red);
    text-align: center;
}

.withdraw-confirm-summary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.withdraw-confirm-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.withdraw-confirm-row strong {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.withdraw-confirm-warning {
    margin-top: 0.5rem;
    font-size: 0.65rem;
    color: var(--red);
    text-align: center;
    font-weight: 600;
}

/* Withdraw chain grid */
.withdraw-chain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.4rem;
}
.withdraw-chain-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
    text-align: center;
}
.withdraw-chain-card:hover { border-color: var(--border-medium); background: var(--bg-card-hover); }
.withdraw-chain-card.selected { border-color: var(--accent); background: var(--accent-dim); }
.withdraw-chain-name { display: block; font-size: 0.72rem; font-weight: 600; color: var(--text-primary); }
.withdraw-chain-rec { font-weight: 400; color: var(--accent); font-size: 0.6rem; }
.withdraw-chain-min { display: block; font-size: 0.6rem; color: var(--text-muted); margin-top: 2px; }

/* Withdraw status tracker */
.withdraw-status-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
}
.withdraw-status-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.withdraw-status-text { font-size: 0.8rem; color: var(--text-primary); font-weight: 600; margin-bottom: 0.3rem; }
.withdraw-status-detail { font-size: 0.7rem; color: var(--text-secondary); margin-bottom: 0.75rem; }
.withdraw-status-bar { display: flex; justify-content: center; gap: 0.5rem; }
.withdraw-status-step {
    font-size: 0.6rem; font-family: var(--font-mono);
    color: var(--text-muted); padding: 0.25rem 0.5rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.withdraw-status-step.done {
    color: var(--green); border-color: var(--green);
    background: var(--green-dim);
}

/* ================================================================
   EXPORT KEY
   ================================================================ */
.export-warning {
    background: rgba(255, 77, 106, 0.08);
    border: 1px solid rgba(255, 77, 106, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.export-warning strong {
    color: var(--red);
}

.export-key-display {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.export-key-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.export-key-value {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-primary);
    word-break: break-all;
    padding: 0.4rem;
    background: var(--bg-panel);
    border-radius: 3px;
    margin-bottom: 0.35rem;
    min-height: 2em;
}

.export-key-actions {
    display: flex;
    gap: 0.35rem;
}

.export-key-expired {
    opacity: 0.4;
}

.export-countdown {
    font-size: 0.7rem;
    color: var(--accent);
    text-align: center;
    font-family: var(--font-mono);
}

.export-cleared {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}

/* ================================================================
   ZERO BALANCE NUDGE
   ================================================================ */
.strategy-zero-balance-warning {
    background: var(--accent-dim);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 3px;
    padding: 0.25rem 0.4rem;
    font-size: 0.6rem;
    color: var(--accent);
    margin-top: 0.2rem;
}

.zero-balance-link {
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

.zero-balance-link:hover {
    color: var(--accent-hover);
}

.strategy-wallet-setup-nudge {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 3px;
    padding: 0.25rem 0.4rem;
    font-size: 0.6rem;
    color: var(--amber);
    margin-top: 0.2rem;
}

.wallet-setup-link {
    color: var(--amber);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

.wallet-setup-link:hover {
    color: var(--color-paper);
}

/* Wallet gear icon in topbar — pill button */
.wallet-gear {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: color 0.12s, border-color 0.12s, background 0.12s;
    line-height: 1;
}

.wallet-gear:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

.trading-wallet-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.12s;
    white-space: nowrap;
}

.trading-wallet-pill:hover {
    background: var(--accent-dim);
}

.twp-icon {
    font-size: 0.7rem;
}

@media (max-width: 768px) {
    .wizard-cards {
        grid-template-columns: 1fr;
    }
    .wizard-dialog {
        padding: 1rem;
    }
}

/* ================================================================
   SCROLLBARS
   ================================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-active); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-active); }

/* ================================================================
   RESPONSIVE — Narrow desktop ≤1280px
   ================================================================ */
@media (max-width: 1280px) {
    .panel-left { width: 38%; }
}

/* ================================================================
   RESPONSIVE — Small laptop ≤960px
   ================================================================ */
@media (max-width: 960px) {
    .main-layout { flex-direction: column; }
    .panel-left {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        max-height: 45vh;
    }
    .panel-right { flex: 1; min-height: 200px; }
}

/* ================================================================
   RESPONSIVE — Tablet / small laptop ≤768px
   ================================================================ */
@media (max-width: 768px) {

    /* ── Topbar ── */
    .topbar {
        flex-wrap: wrap;
        min-height: 44px;
        height: auto;
        padding: 0.25rem 0.75rem;
        gap: 0.5rem;
    }
    .logo-powered { display: none; }
    .polymarket-badge span { display: none; }

    /* ── Main nav — horizontal scroll ── */
    .main-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .main-nav::-webkit-scrollbar { display: none; }
    .nav-tab {
        min-height: 44px;
        padding: 0.55rem 0.75rem;
        font-size: 0.68rem;
    }

    /* ── Stats strip ── */
    .stats-strip {
        height: 36px;
        padding: 0 0.75rem;
    }

    /* ── Right panel — stack chart below markets ── */
    .panel-right { flex-direction: column; }
    .panel-right-markets {
        width: 100%;
        max-height: 35vh;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }
    .panel-right-chart { flex: 1; min-height: 200px; }
    .panel-divider { display: none; }

    /* ── Trade log grid — 10→8 cols: hide TF + ENTRY ── */
    .trade-header .th-col:nth-child(4),
    .trade-card .tc-tf { display: none; }
    .trade-header .th-col:nth-child(6),
    .trade-card .tc-price { display: none; }
    .trade-header,
    .trade-card {
        grid-template-columns: 40px 1fr 42px 24px 52px 48px 56px 60px;
    }

    /* ── Optimize page — stack vertical ── */
    .opt-page-layout {
        flex-direction: column;
    }
    .opt-left-panel {
        width: 100%;
        max-width: unset;
        min-width: unset;
        max-height: 45vh;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }
    .opt-right-panel {
        padding: 0.75rem;
    }

    /* ── Wallet dropdown ── */
    .wallet-dropdown {
        width: min(220px, calc(100vw - 1rem));
    }

    /* ── Misc ── */
    .windows-grid { padding: 0.5rem; }
}

/* ================================================================
   RESPONSIVE — Large phone ≤640px
   ================================================================ */
@media (max-width: 640px) {

    /* ── Trade log — horizontal scroll wrapper ── */
    .trade-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .trade-header,
    .trade-card {
        min-width: 420px;
    }

    /* ── Topbar — hide polymarket badge entirely ── */
    .polymarket-badge { display: none; }
    .logo { font-size: 0.95rem; }

    /* ── Strategy cards — touch-friendly ── */
    .strategy-card { padding: 0.6rem 0.65rem; }
    .sc-name { font-size: 0.75rem; }

    /* ── Nav tabs — tighter ── */
    .nav-tab {
        padding: 0.5rem 0.6rem;
        font-size: 0.65rem;
    }
}

/* ================================================================
   RESPONSIVE — Small phone ≤480px
   ================================================================ */
@media (max-width: 480px) {

    /* ── Stats strip — hide entirely ── */
    .stats-strip { display: none; }

    /* ── Topbar ── */
    .topbar {
        padding: 0 0.5rem;
        gap: 0.25rem;
    }
    .utc-clock { display: none; }
    .logo { font-size: 0.9rem; }
    .logo-tag { display: none; }
    .wallet-btn { min-height: 44px; }

    /* ── Trade log — also hide TYPE col, 8→7 cols ── */
    .trade-header .th-col:nth-child(3),
    .trade-card .tc-type,
    .trade-card .t-badge { display: none; }
    .trade-header,
    .trade-card {
        grid-template-columns: 40px 1fr 24px 52px 48px 56px 60px;
    }

    /* ── Strategy cards — larger touch targets ── */
    .three-dot-btn { padding: 0.3rem 0.5rem; }
    .sc-stat-badge { min-height: 28px; display: flex; align-items: center; }

    /* ── Wallet dropdown → bottom sheet ── */
    .wallet-dropdown {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        border-radius: 12px 12px 0 0;
        max-height: 60vh;
        overflow-y: auto;
    }

    /* ── Dialogs / modals — wider ── */
    .confirm-dialog,
    .wizard-dialog,
    .risk-panel-dialog,
    .wallet-panel-dialog {
        width: 95vw;
        max-width: 95vw;
        padding: 0.75rem;
    }

    /* ── Touch targets ── */
    .pill { min-height: 36px; display: flex; align-items: center; }
    .opt-btn-disabled,
    .opt-left-header { min-height: 36px; }

    /* ── Regime strip — tighter ── */
    .regime-strip {
        gap: 0.35rem;
        padding: 3px 0.4rem;
    }
    .regime-pill {
        font-size: 0.48rem;
        padding: 1px 3px;
    }

    /* ── Misc ── */
    .section-body { padding: 0.25rem; }
    .windows-grid { padding: 0.5rem; }
}

/* ================================================================
   WALLET DROPDOWN
   ================================================================ */
.wallet-chevron {
    font-size: 0.55rem;
    margin-left: 0.15rem;
    vertical-align: middle;
}

.wallet-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.5rem 0;
    z-index: 3000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 var(--card-highlight);
}

.wd-address-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.75rem;
}

.wd-address {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-primary);
}

.wd-copy-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.6rem;
    padding: 0.15rem 0.35rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
}

.wd-copy-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.wd-balance {
    padding: 0 0.75rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
}

.wd-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

.wd-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.75rem;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.72rem;
    font-family: var(--font-sans);
    cursor: pointer;
    text-align: left;
    transition: background 0.1s;
}

.wd-item:hover {
    background: var(--bg-card-hover);
}

.wd-icon {
    font-size: 0.75rem;
    width: 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.wd-disconnect {
    color: var(--red);
}

.wd-disconnect .wd-icon {
    color: var(--red);
}

/* ================================================================
   WALLET SETTINGS PANEL
   ================================================================ */
.ws-section {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.ws-section:last-of-type {
    border-bottom: none;
}

.ws-row {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.ws-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.ws-toggle {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.ws-desc {
    font-size: 0.62rem;
    color: var(--text-secondary);
    line-height: 1.3;
    padding-left: 1.4rem;
}

.ws-input-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding-left: 1.4rem;
    margin-top: 0.2rem;
}

.ws-dollar {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.ws-input {
    width: 100px;
    font-size: 0.72rem;
    padding: 0.3rem 0.5rem;
}

.ws-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ws-hours-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding-left: 1.4rem;
    margin-top: 0.2rem;
    font-size: 0.68rem;
    color: var(--text-secondary);
}

.ws-hour-input {
    width: 48px;
    font-size: 0.72rem;
    padding: 0.3rem;
    text-align: center;
}

.ws-hour-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ws-actions {
    padding-top: 0.6rem;
}

.ws-divider {
    height: 1px;
    background: var(--border);
    margin: 0.75rem 0;
}

.ws-footer-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ws-footer-link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.7rem;
    cursor: pointer;
    text-align: left;
    padding: 0.3rem 0;
    transition: color 0.12s;
}

.ws-footer-link:hover {
    color: var(--accent-hover);
}

.ws-kill-btn {
    background: var(--red-dim);
    border: 1px solid var(--red);
    color: var(--red);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.12s;
    text-align: center;
}

.ws-kill-btn:hover {
    background: rgba(255, 77, 106, 0.2);
}

.confirm-danger {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

/* ---- WebSocket disconnect banner ---- */
.ws-disconnect-banner {
    background: rgba(255, 77, 106, 0.12);
    border-bottom: 1px solid rgba(255, 77, 106, 0.3);
    color: var(--red);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-align: center;
    padding: 0.35rem;
    letter-spacing: 0.02em;
}

/* ================================================================
   Strategy Creator — entry point button
   ================================================================ */

.create-strategy-btn {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    color: #000;
    text-decoration: none;
    padding: 0.4rem 1rem;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    margin-left: auto;
    transition: opacity 0.12s;
    white-space: nowrap;
    letter-spacing: 0.04em;
}

.create-strategy-btn:hover {
    opacity: 0.85;
}

/* Redeem button in trade log header */
.redeem-btn {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-up);
    background: transparent;
    border: 1px solid var(--color-up);
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.6rem;
    margin-left: auto;
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: 0.02em;
    transition: background 0.12s, color 0.12s;
}
.redeem-btn:hover {
    background: var(--green-dim);
}
.redeem-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ================================================================
   Phase 4a — Risk Panel
   ================================================================ */

.risk-shield-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--text-lg);
    padding: 0.15rem 0.3rem;
    margin-left: 0.25rem;
    border-radius: var(--radius-sm);
    transition: color 0.12s, background 0.12s;
}
.risk-shield-btn:hover {
    color: var(--accent);
    background: var(--accent-dim);
}

/* Overlay */
.risk-panel-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}
.risk-panel-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    width: 460px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

/* Header */
.risk-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
.risk-panel-title {
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    color: var(--text-primary);
    font-weight: 600;
}
.risk-panel-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 0.3rem;
}
.risk-panel-close:hover { color: var(--text-primary); }

/* Body */
.risk-panel-body {
    padding: 1rem 1.25rem 1.25rem;
}
.risk-panel-desc {
    font-family: var(--font-sans);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    margin: 0 0 1rem;
    line-height: 1.5;
}

/* Toggle rows */
.risk-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.risk-toggle-row:last-child { border-bottom: none; }

/* Alternation ratio rich row */
.alt-ratio-wrap {
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}
.alt-ratio-wrap .risk-toggle-row {
    border-bottom: none;
    padding-bottom: 0.5rem;
}
.alt-scale {
    padding: 0 0 0.25rem;
}
.alt-scale-track {
    position: relative;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right,
        var(--color-up) 0%,
        var(--color-up) 40%,
        var(--accent) 40%,
        var(--accent) 70%,
        var(--color-down) 70%,
        var(--color-down) 100%
    );
    margin-bottom: 14px;
}
.alt-scale-marker {
    position: absolute;
    top: calc(100% + 1px);
    transform: translateX(-50%);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    color: var(--text-primary);
    pointer-events: none;
    line-height: 1;
    transition: left 0.12s ease;
}
.alt-scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.risk-toggle-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
}
.risk-toggle-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.risk-toggle-label {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
}
.risk-toggle-desc {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.4;
}

/* Toggle switch */
.risk-toggle-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
    flex-shrink: 0;
}
.risk-toggle-switch input { opacity: 0; width: 0; height: 0; }
.risk-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 18px;
    transition: background 0.12s, border-color 0.12s;
}
.risk-toggle-slider::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.12s, background 0.12s;
}
.risk-toggle-switch input:checked + .risk-toggle-slider {
    background: var(--accent-dim);
    border-color: var(--accent);
}
.risk-toggle-switch input:checked + .risk-toggle-slider::before {
    transform: translateX(16px);
    background: var(--accent);
}

/* Threshold input */
.risk-threshold-input {
    width: 60px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    padding: 0.3rem 0.4rem;
    text-align: right;
    flex-shrink: 0;
}
.risk-threshold-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Mode selector (per-strategy) */
.risk-mode-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.risk-radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
}
.risk-radio-label input[type="radio"] {
    accent-color: var(--accent);
}

/* Save button */
.risk-panel-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}
.risk-save-btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    padding: 0.45rem 1.2rem;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.12s;
}
.risk-save-btn:hover { opacity: 0.85; }
.risk-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.risk-save-btn.risk-save-success { background: var(--green); color: #fff; opacity: 1; }

/* Kill log section */
.risk-panel-section {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.risk-section-title {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 600;
}
.kill-log {
    max-height: 200px;
    overflow-y: auto;
}
.kill-log-empty, .kill-log-loading {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--text-muted);
    padding: 0.5rem 0;
}
.kill-log-entry {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.4;
}
.kill-log-entry:last-child { border-bottom: none; }
.kill-log-ts {
    color: var(--text-muted);
    flex-shrink: 0;
}
.kill-log-asset {
    color: var(--tier1-teal);
    font-weight: 600;
    flex-shrink: 0;
}
.kill-log-kill {
    color: var(--red);
    font-weight: 600;
}
.kill-log-reason {
    color: var(--text-secondary);
    flex: 1;
}
.kill-log-strat {
    color: var(--text-muted);
    font-style: italic;
}

/* ============================================================
   Strategy Optimizer (Phase 4c-B)
   ============================================================ */

/* Suggestion cards */
.opt-suggestion-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem;
}

.opt-delta-pos { color: var(--color-up); font-weight: 600; }
.opt-delta-neg { color: var(--color-down); font-weight: 600; }

.opt-apply-btn {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: opacity 0.12s;
}
.opt-apply-btn:hover { opacity: 0.85; }
.opt-apply-btn.opt-applied {
    background: var(--color-up);
    color: var(--bg-primary);
    cursor: default;
}

.opt-dismiss-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    cursor: pointer;
    font-family: var(--font-sans);
    transition: color 0.12s, border-color 0.12s;
}
.opt-dismiss-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }

/* No improvements state */
.opt-no-improvements {
    text-align: center;
    padding: 1rem 0.5rem;
}
.opt-revert-btn {
    background: transparent;
    color: var(--color-down);
    border: 1px solid var(--color-down);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    cursor: pointer;
    margin-top: 0.2rem;
    font-family: var(--font-sans);
    font-weight: 600;
    transition: background 0.12s, color 0.12s;
}
.opt-revert-btn:hover { background: var(--color-down); color: #000; }


/* ================================================================
   MAIN NAV — full-width tab bar below topbar
   ================================================================ */
.main-nav {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 0.5rem;
    flex-shrink: 0;
}

.nav-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.55rem 1rem;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--text-primary);
}

.nav-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ================================================================
   OPTIMIZE PAGE — full-height layout
   ================================================================ */
.optimize-page {
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.opt-page-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* ---- Left panel (30%) ---- */
.opt-left-panel {
    width: 30%;
    min-width: 220px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    overflow: hidden;
    min-height: 0;
}

.opt-left-header {
    padding: 0.6rem 1rem;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.opt-left-list {
    flex: 1;
    overflow-y: auto;
}

.opt-empty-list {
    padding: 1.5rem;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    text-align: center;
}

/* Strategy row in left panel */
.opt-strategy-row {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.12s;
}

.opt-strategy-row:hover { background: var(--bg-elevated); }

.opt-strategy-row.selected {
    background: var(--bg-elevated);
    border-left: 2px solid var(--badge-scanning);
}

.opt-row-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.opt-row-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.opt-row-name {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.opt-row-meta {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.opt-row-stats {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

/* Badges */
.opt-badge {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.1rem 0.45rem;
    border-radius: 100px;
    margin-top: 0.15rem;
}

.opt-badge-ready    { background: var(--accent-dim); color: var(--accent); }
.opt-badge-running  { background: rgba(245,158,11,0.12); color: var(--badge-scanning); }
.opt-badge-suggestions { background: var(--green-dim); color: var(--color-up); }
.opt-badge-failed   { background: var(--red-dim); color: var(--color-down); }
.opt-badge-cancelled { background: rgba(107,114,128,0.12); color: var(--text-muted); }

/* Optimize button in row */
.opt-row-btn {
    background: none;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}

.opt-row-btn:hover { background: var(--accent); color: #000; }

.opt-btn-disabled {
    border-color: var(--border-subtle);
    color: var(--text-muted);
    cursor: not-allowed;
}

.opt-btn-disabled:hover { background: none; color: var(--text-muted); }

/* Row progress while running */
.opt-row-progress {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--badge-scanning);
    flex-shrink: 0;
}

/* Small spinner */
.opt-spinner-sm {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--border-subtle);
    border-top-color: var(--badge-scanning);
    border-radius: 50%;
    animation: optSpin 0.8s linear infinite;
}

/* ---- Right panel (70%) ---- */
.opt-right-panel {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
    padding: 1.5rem;
}

.opt-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    text-align: center;
}

/* ---- Shared panel title ---- */
.opt-panel-title {
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 1rem;
}

/* ---- Config panel (state 2) ---- */
.opt-config-wrap { max-width: 560px; }

.opt-config-summary {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.opt-config-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
    gap: 0.5rem;
}

.opt-config-row:last-child { border-bottom: none; }

.opt-config-label {
    font-family: var(--font-sans);
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    flex-shrink: 0;
}

.opt-config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.opt-config-table td {
    padding: 0.15rem 0.3rem;
    color: var(--text-primary);
}

.opt-config-table td:first-child { color: var(--text-muted); text-transform: capitalize; }

.opt-config-indicator {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0.15rem 0;
}

.opt-config-ind-name {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--accent);
}

.opt-config-param {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 0.05rem 0.25rem;
    border-radius: var(--radius-sm);
}

.opt-cta-btn {
    background: var(--accent);
    border: none;
    color: #000;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 0.6rem;
    transition: opacity 0.12s;
}

.opt-cta-btn:hover { opacity: 0.85; }

.opt-cta-explain {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: 1.5;
    max-width: 480px;
}

/* ---- Running panel (state 3) ---- */
.opt-running-wrap { max-width: 480px; }

.opt-steps {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.opt-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
}

.opt-step-pending { color: var(--text-muted); }
.opt-step-active  { color: var(--badge-scanning); border-color: rgba(245,158,11,0.35); }
.opt-step-done    { color: var(--color-up); border-color: var(--border-subtle); opacity: 0.75; }

.opt-step-icon {
    width: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.opt-step-label { flex: 1; }

.opt-cancel-btn {
    background: none;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
}

.opt-cancel-btn:hover { color: var(--text-primary); border-color: var(--border-medium); }

/* ---- Results panel (state 4) ---- */
.opt-results-wrap { max-width: 680px; }

.opt-results-sub {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: -0.5rem 0 1rem;
}

.opt-rerun-btn {
    background: none;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 1rem;
    display: inline-block;
    transition: background 0.12s, color 0.12s;
}

.opt-rerun-btn:hover { background: var(--accent); color: #000; }

.opt-suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

/* opt-suggestion-card already styled above (old CSS) */
.opt-sug-text {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--text-primary);
    margin: 0 0 0.4rem;
    line-height: 1.45;
}

.opt-sug-metrics {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    margin-bottom: 0.4rem;
}

.opt-sug-trades { color: var(--text-muted); }

.opt-sug-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

/* Applied changes log */
.opt-applied-log { margin-top: 1.5rem; }

.opt-applied-log-title {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.opt-applied-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.opt-applied-table th {
    text-align: left;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.25rem 0.4rem;
    border-bottom: 1px solid var(--border-subtle);
}

.opt-applied-table td {
    padding: 0.3rem 0.4rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

.opt-collecting { color: var(--text-muted); font-style: italic; }

/* Equity chart */
.opt-chart-wrap {
    margin: 1rem 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    padding: 0.75rem;
}

.opt-page-chart {
    width: 100%;
    display: block;
}

/* No improvements */
.opt-no-improvements {
    padding: 1rem;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    text-align: center;
}

/* delta colors for results panel */
.opt-delta-pos { color: var(--color-up); font-weight: 600; }
.opt-delta-neg { color: var(--color-down); font-weight: 600; }

/* ---- Failed / Cancelled panels ---- */
.opt-failed-wrap, .opt-cancelled-wrap { max-width: 560px; }
.opt-failed-message, .opt-cancelled-message {
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius);
    background: rgba(239,68,68,0.06);
    padding: 1rem;
    margin-bottom: 1rem;
}
.opt-cancelled-message {
    border-color: var(--border-subtle);
    background: var(--bg-elevated);
}
.opt-failed-title { font-family: var(--font-sans); font-weight: 600; color: var(--color-down); margin: 0 0 0.5rem; font-size: var(--text-lg); }
.opt-failed-reason { font-family: var(--font-sans); color: var(--text-muted); font-size: var(--text-base); margin: 0; }

/* ---- Past Runs section ---- */
.opt-past-runs { margin-top: 1.5rem; }
.opt-past-runs-title {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 0.5rem;
}
.opt-past-row {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.35rem;
    cursor: pointer;
    transition: background 0.12s;
}
.opt-past-row:hover { background: var(--bg-elevated); }
.opt-past-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
}
.opt-past-icon { font-size: var(--text-sm); }
.opt-past-complete .opt-past-icon { color: var(--color-up); }
.opt-past-failed .opt-past-icon { color: var(--color-down); }
.opt-past-cancelled .opt-past-icon { color: var(--text-muted); }
.opt-past-date { color: var(--text-secondary); }
.opt-past-info { color: var(--text-primary); font-weight: 600; }
.opt-past-wr { color: var(--text-muted); margin-left: auto; }
.opt-past-detail {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
}
.opt-past-sug {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    padding: 0.2rem 0;
}
.opt-past-sug .opt-delta-pos { margin-right: 0.4rem; }
.opt-past-error { color: var(--color-down); font-size: var(--text-sm); margin: 0; }

/* ---- Skeleton loader ---- */
.opt-skeleton-row {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.opt-skeleton-line {
    border-radius: 3px;
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-surface) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: optSkeletonPulse 1.4s ease-in-out infinite;
}

.opt-sk-name  { height: 12px; width: 65%; }
.opt-sk-meta  { height: 9px; width: 40%; }
.opt-sk-badge { height: 9px; width: 30%; }

@keyframes optSkeletonPulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Redesigned detail panel ---- */
.opt-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.opt-detail-chip {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding: 0.15rem 0.45rem;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.opt-detail-section {
    margin-bottom: 1rem;
}

.opt-detail-section-label {
    display: block;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}

.opt-params-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.opt-param-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    padding: 0.15rem 0.4rem;
    font-size: var(--text-xs);
}

.opt-param-key { font-family: var(--font-sans); color: var(--text-muted); }
.opt-param-val { font-family: var(--font-mono); color: var(--accent); font-weight: 600; }

.opt-indicators-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.opt-ind-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.55rem;
}

.opt-ind-name {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--accent);
    display: block;
    margin-bottom: 0.2rem;
}

.opt-ind-params {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* Trade count requirement */
.opt-trade-req {
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: var(--radius);
    background: rgba(245,158,11,0.06);
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.opt-trade-req-header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.3rem;
}

.opt-trade-req-icon { font-size: 0.85rem; }

.opt-trade-req-title {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--badge-scanning);
}

.opt-trade-req-text {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0 0 0.5rem;
}

.opt-trade-req-bar {
    height: 4px;
    background: var(--border-subtle);
    border-radius: 2px;
    overflow: hidden;
}

.opt-trade-req-fill {
    height: 100%;
    background: var(--badge-scanning);
    border-radius: 2px;
    transition: width 0.3s;
}

.opt-cta-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.opt-cta-disabled:hover { opacity: 0.4; }

/* ---- Right panel tabs (Optimizer / Monitor) ---- */
.opt-right-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
    margin: -1.5rem -1.5rem 1.25rem;
    padding: 0 1.5rem;
}

.opt-right-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
}

.opt-right-tab:hover { color: var(--text-primary); }
.opt-right-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- Monitor panel ---- */
.opt-monitor-wrap { max-width: 100%; }

.opt-monitor-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.opt-monitor-sub {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: -0.5rem 0 1rem;
}

.opt-monitor-loading {
    font-family: var(--font-sans);
    color: var(--text-muted);
    font-size: var(--text-base);
    padding: 2rem 0;
}

.opt-monitor-empty {
    font-family: var(--font-sans);
    color: var(--text-muted);
    font-size: var(--text-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    background: var(--bg-elevated);
}

.opt-monitor-table-wrap {
    overflow-x: auto;
}

.opt-monitor-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
}

.opt-monitor-table th {
    text-align: left;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.35rem 0.4rem;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.opt-monitor-table td {
    padding: 0.35rem 0.4rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
    white-space: nowrap;
}

.opt-monitor-table tbody tr:hover { background: var(--bg-elevated); }

.mon-time { color: var(--text-secondary); font-size: var(--text-xs); }
.mon-dir-up { color: var(--color-up); font-weight: 700; }
.mon-dir-down { color: var(--color-down); font-weight: 700; }
.mon-res-win { color: var(--color-up); font-weight: 600; }
.mon-res-loss { color: var(--color-down); font-weight: 600; }
.mon-res-pending { color: var(--badge-scanning); font-style: italic; }

.mon-signals {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mon-sig {
    display: inline-block;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    padding: 0 0.25rem;
    margin: 0 0.1rem;
    font-size: var(--text-xs);
    color: var(--accent);
}

.mon-mode-live {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-up);
    background: var(--green-dim);
    padding: 0.05rem 0.35rem;
    border-radius: 100px;
}

.mon-mode-paper {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-paper);
    background: rgba(79, 142, 247, 0.12);
    padding: 0.05rem 0.35rem;
    border-radius: 100px;
}

.mon-refresh-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-up);
    opacity: 0.5;
    transition: opacity 0.3s;
}

.mon-refresh-pulse {
    opacity: 1;
    animation: monPulse 0.6s ease;
}

@keyframes monPulse {
    0%   { transform: scale(1); opacity: 1; }
    50%  { transform: scale(1.5); opacity: 0.7; }
    100% { transform: scale(1); opacity: 0.5; }
}

/* ================================================================
   CREATOR PAGE — embedded in SPA, fills remaining height
   ================================================================ */
#creator-page {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ================================================================
   RESEARCH LOG PAGE
   ================================================================ */
.research-page {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
}

.research-layout {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem;
}

.research-header { margin-bottom: 1.25rem; }

.research-title {
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
}

.research-subtitle {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: 0 0 1rem;
}

.research-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

/* Reuse existing .pill styles; add active state */
.research-filter.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}

.research-feed {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.research-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 3rem 1rem;
    text-align: center;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--bg-elevated);
}
.research-empty svg { opacity: 0.7; margin-bottom: 0.25rem; }
.research-empty-heading {
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}
.research-empty-sub {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.research-entry {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    padding: 1rem;
}

.research-entry-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.research-entry-date {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.research-entry-tag {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.1rem 0.45rem;
    border-radius: 100px;
    background: var(--accent-dim);
    color: var(--accent);
}

.research-entry-finding {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--text-primary);
    line-height: 1.5;
    margin: 0 0 0.6rem;
}

.research-entry-section { margin-top: 0.5rem; }

.research-entry-label {
    display: block;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.research-entry-body {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.research-entry-basis {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ================================================================
   SOCIAL FOOTER
   ================================================================ */
.social-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 0.35rem 1rem;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: color 0.12s;
}
.social-link:hover { color: var(--text-primary); }
.social-link svg { opacity: 0.6; transition: opacity 0.12s; }
.social-link:hover svg { opacity: 1; }

/* ================================================================
   LOOP ANALYSIS PANELS
   ================================================================ */
.loop-analyzing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}
.loop-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--tier2-blue);
    border-radius: 50%;
    animation: optSpinnerSpin 0.8s linear infinite;
    margin-bottom: 1rem;
}
.loop-analyzing-text {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.3rem;
}
.loop-analyzing-sub {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin: 0;
}
.loop-insufficient {
    text-align: center;
    padding: 3rem 1rem;
}
.loop-insuf-title {
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}
.loop-insuf-text {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: 0 0 1rem;
    line-height: 1.5;
}
.loop-insuf-sub {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin: 0.5rem 0 1.5rem;
}
.loop-progress-bar {
    width: 60%;
    max-width: 240px;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    margin: 0 auto;
    overflow: hidden;
}
.loop-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.loop-results {
    max-width: 640px;
    padding: 0.5rem 0;
}
.loop-results-title {
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.4rem;
}
.loop-current {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin: 0 0 0.75rem;
}
.loop-divider {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 0.75rem 0;
}
.loop-section {
    margin-bottom: 1.25rem;
}
.loop-section-title {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.4rem;
}
.loop-section-body {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 0.5rem;
}
.loop-section-muted {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
}
.loop-regime-pills {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}
.loop-pill {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--badge-scanning);
    border: 1px solid var(--badge-scanning);
    background: rgba(245, 158, 11, 0.1);
    border-radius: 100px;
    padding: 0.15rem 0.45rem;
}
.loop-hour-chips {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}
.loop-hour-chip {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--badge-scanning);
    border: 1px solid var(--badge-scanning);
    background: rgba(245, 158, 11, 0.1);
    border-radius: 100px;
    padding: 0.15rem 0.35rem;
}
.loop-section-stats {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin: 0 0 0.2rem;
}
.loop-section-note {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
}
.loop-summary-section {
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.75rem;
}
.loop-summary {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
    line-height: 1.5;
    margin: 0;
}
.loop-disclaimer {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
    margin: 0.75rem 0;
}
.loop-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}
.loop-create-btn {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    border: none;
    background: var(--accent);
    color: #000;
    cursor: pointer;
    transition: opacity 0.12s;
}
.loop-create-btn:hover { opacity: 0.85; }
.loop-back-btn {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s;
}
.loop-back-btn:hover {
    border-color: var(--border-medium);
    color: var(--text-primary);
}

/* Real-trade Loop panel extras */
.loop-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.loop-badge-real {
    background: var(--green-dim);
    color: var(--green);
}
.loop-badge-bt {
    background: rgba(241, 196, 15, 0.15);
    color: var(--amber);
}
.loop-date-range {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 6px;
}
.loop-source-badge {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-left: 6px;
}
.loop-hero-stats {
    display: flex;
    gap: 1.5rem;
    margin: 12px 0;
}
.loop-hero-stat {
    text-align: center;
}
.loop-hero-val {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-mono, monospace);
}
.loop-hero-val.good { color: var(--green); }
.loop-hero-val.ok { color: var(--amber); }
.loop-hero-val.bad { color: var(--red); }
.loop-hero-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.loop-asset-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.loop-pill-good { background: var(--green-dim) !important; color: var(--green) !important; }
.loop-pill-bad { background: var(--red-dim) !important; color: var(--red) !important; }
.loop-regime-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.loop-regime-dim {
    font-size: 0.7rem;
    color: var(--text-secondary);
    min-width: 70px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.loop-hour-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.loop-hour-cell {
    width: 26px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-family: var(--font-mono, monospace);
    border-radius: 3px;
    background: var(--bg-card);
    color: var(--text-secondary);
}
.loop-hour-good { background: rgba(0, 192, 118, 0.2); color: var(--green); }
.loop-hour-bad { background: rgba(255, 77, 106, 0.2); color: var(--red); }
.loop-hour-empty { opacity: 0.3; }
.loop-suggestion-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
}
.loop-suggestion-text {
    margin: 6px 0 4px;
    font-size: 0.82rem;
    color: var(--text-primary);
}
.loop-suggestion-impact {
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.loop-sweep-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.loop-sweep-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}
.loop-sweep-sub {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 4px 0 0;
}

/* ================================================================
   REGIME STRIP
   ================================================================ */
.regime-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    height: 28px;
    padding: 0 1rem;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
}
.regime-asset {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.regime-asset-label {
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-right: 0.15rem;
}
.regime-dim {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.regime-dim-label {
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.03em;
}
.regime-pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.03em;
    line-height: 1.4;
    white-space: nowrap;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    cursor: default;
}

/* Direction pills */
.regime-pill[data-regime="STRONG TREND"] {
    background: rgba(0, 192, 118, 0.12);
    color: var(--green);
}
.regime-pill[data-regime="CHOPPY"] {
    background: rgba(90, 96, 112, 0.15);
    color: var(--text-secondary);
}
.regime-pill[data-regime="MIXED"] {
    background: rgba(245, 158, 11, 0.1);
    color: var(--amber);
}

/* Volatility pills */
.regime-pill[data-regime="HIGH VOLATILITY"] {
    background: rgba(255, 77, 106, 0.1);
    color: var(--red);
}
.regime-pill[data-regime="LOW VOLATILITY"] {
    background: rgba(79, 142, 247, 0.1);
    color: var(--blue);
}
.regime-pill[data-regime="NORMAL"] {
    background: rgba(90, 96, 112, 0.15);
    color: var(--text-secondary);
}

/* Momentum pills */
.regime-pill[data-regime="CONTINUING"] {
    background: rgba(0, 192, 118, 0.12);
    color: var(--green);
}
.regime-pill[data-regime="REVERSING"] {
    background: rgba(255, 77, 106, 0.1);
    color: var(--red);
}
.regime-pill[data-regime="NEUTRAL"] {
    background: rgba(90, 96, 112, 0.15);
    color: var(--text-secondary);
}

@media (max-width: 640px) {
    .regime-strip {
        flex-wrap: wrap;
        height: auto;
        padding: 4px 0.5rem;
        gap: 0.5rem;
    }
    .regime-pill {
        font-size: var(--text-xs);
        padding: 1px 6px;
    }
}

/* ================================================================
   ML Dashboard Status Indicators
   ================================================================ */
.ml-dash-status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: var(--text-xs);
    padding: 0.25rem 0;
    margin-top: 0.15rem;
}
.ml-dash-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ml-dash-dot.trained { background: var(--color-up); }
.ml-dash-dot.ready { background: var(--amber); }
.ml-dash-dot.collecting { background: var(--text-muted); }
.ml-dash-trained { color: var(--color-up); }
.ml-dash-ready { color: var(--amber); }
.ml-dash-collecting { color: var(--text-muted); }

/* ================================================================
   ML Tab
   ================================================================ */
.ml-page { padding: 1rem 0 3rem; flex: 1; min-height: 0; overflow-y: auto; }
.ml-layout { max-width: 820px; margin: 0 auto; padding: 0 1rem; }

/* ML sub-nav — matches main nav style, smaller */
.ml-sub-nav {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 0.5rem;
}
.ml-sub-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.4rem 0.85rem;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
    white-space: nowrap;
}
.ml-sub-tab:hover { color: var(--text-primary); }
.ml-sub-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* Strategy cards */
.ml-cards { display: flex; flex-direction: column; gap: 1rem; }

.ml-strategy-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 1.25rem;
}

.ml-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.ml-card-name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
}
.ml-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ml-tf-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 600;
    background: rgba(79, 142, 247, 0.1);
    color: var(--tier2-blue);
    border: 1px solid rgba(79, 142, 247, 0.15);
}
.ml-status-toggle { cursor: pointer; }
.ml-status-toggle:hover { filter: brightness(1.2); }

.ml-card-config {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.ml-config-item {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

/* Progress bars */
.ml-progress-section { margin-bottom: 1rem; }
.ml-progress-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}
.ml-progress-label {
    width: 32px;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
}
.ml-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}
.ml-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--text-muted);
    transition: width 0.3s;
}
.ml-progress-fill.ready { background: var(--color-up); }
.ml-progress-count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    min-width: 64px;
    text-align: right;
}

/* Model stats */
.ml-model-stats {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 1rem;
}
.ml-model-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ml-model-trained {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}
.ml-model-acc {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-up);
}

/* Explanation text */
.ml-explain {
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-surface);
    border-radius: 6px;
    border-left: 2px solid var(--border-medium);
}

/* Train section */
.ml-train-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.ml-no-model {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
}
.ml-retrain-note {
    font-size: 11px;
    color: var(--text-muted);
}
.ml-train-status {
    font-size: var(--text-xs);
    font-weight: 500;
}
.ml-train-status.success { color: var(--color-up); }
.ml-train-status.error { color: var(--color-down); }

/* Buttons */
.ml-btn {
    padding: 0.4rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s;
}
.ml-btn:hover { border-color: var(--border-medium); }
.ml-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ml-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}
.ml-btn-primary:hover { filter: brightness(1.1); }
.ml-btn-amber {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--amber);
}
.ml-btn-amber:hover { background: rgba(245, 158, 11, 0.25); }

.ml-add-link {
    display: block;
    margin-top: 1rem;
    background: none;
    border: none;
    color: var(--accent);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    cursor: pointer;
    padding: 0;
}
.ml-add-link:hover { text-decoration: underline; }

/* Empty state */
.ml-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}
.ml-empty-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}
.ml-empty-state h3 {
    color: var(--text-primary);
    font-size: var(--text-base);
    margin: 0 0 0.5rem;
}
.ml-empty-state p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    max-width: 420px;
    margin: 0 auto 1.25rem;
    line-height: 1.5;
}

/* Modal */
.ml-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.ml-modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    width: 420px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
}
.ml-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}
.ml-modal-header h3 {
    margin: 0;
    font-size: var(--text-base);
    color: var(--text-primary);
}
.ml-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.ml-modal-close:hover { color: var(--text-primary); }
.ml-modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ml-modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
}

/* ── Wallet Picker (EIP-6963) ── */
.wallet-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.wallet-picker {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    width: 340px;
    max-width: 90vw;
}
.wallet-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}
.wallet-picker-header h3 {
    margin: 0;
    font-size: var(--text-base);
    color: var(--text-primary);
}
.wallet-picker-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.wallet-picker-close:hover { color: var(--text-primary); }
.wallet-picker-list {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.wallet-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    transition: background 0.15s;
}
.wallet-picker-item:hover {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
}
.wallet-picker-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

/* Form elements */
.ml-form-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}
.ml-form-input {
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    outline: none;
    width: 100%;
    box-sizing: border-box;
}
.ml-form-input:focus { border-color: var(--accent); }
.ml-form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: -0.25rem;
}
.ml-form-slider {
    width: 100%;
    accent-color: var(--accent);
}

/* Timeframe pill select */
.ml-pill-select {
    display: flex;
    gap: 0.35rem;
}
.ml-pill-option {
    padding: 0.3rem 0.75rem;
    border-radius: 100px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s;
}
.ml-pill-option:hover { border-color: var(--border-medium); }
.ml-pill-option.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* Asset chips */
.ml-asset-chips {
    display: flex;
    gap: 0.5rem;
}
.ml-chip {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
}
.ml-chip input[type="checkbox"] { accent-color: var(--accent); }

/* Bet size row */
.ml-bet-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: var(--text-sm);
}
.ml-bet-input { width: 90px !important; }

/* Training Data table */
.ml-data-section { }
.ml-data-header { margin-bottom: 1.25rem; }
.ml-data-header h3 {
    margin: 0 0 0.35rem;
    font-size: var(--text-base);
    color: var(--text-primary);
}
.ml-data-header p {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}
.ml-data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    overflow: hidden;
}
.ml-data-table th,
.ml-data-table td {
    padding: 0.6rem 1rem;
    text-align: center;
    font-size: var(--text-sm);
}
.ml-data-table th {
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-subtle);
}
.ml-data-table td {
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
}
.ml-data-table tr:last-child td { border-bottom: none; }
.ml-data-tf {
    font-weight: 600;
    color: var(--text-secondary) !important;
    text-align: left !important;
}
.ml-data-ready { color: var(--color-up) !important; font-weight: 600; }
.ml-data-pending { color: var(--text-muted); font-size: var(--text-xs); }
.ml-data-note {
    margin-top: 0.75rem;
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.ml-data-hint {
    margin-top: 0.25rem;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ML responsive */
@media (max-width: 640px) {
    .ml-layout { padding: 0 0.5rem; }
    .ml-sub-tab { padding: 0.35rem 0.6rem; font-size: 10px; }
    .ml-strategy-card { padding: 1rem; }
    .ml-card-config { gap: 0.5rem; }
    .ml-modal { width: 95vw; }
}
@media (max-width: 480px) {
    .ml-card-top { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
    .ml-card-config { flex-direction: column; gap: 0.25rem; }
}

/* ================================================================
   ML — Per-asset model grid
   ================================================================ */
.ml-models-grid {
    margin-bottom: 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-surface);
}
.ml-model-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}
.ml-model-row:last-child { border-bottom: none; }
.ml-model-row-empty { opacity: 0.5; }

.ml-model-asset-badge {
    display: inline-block;
    min-width: 36px;
    text-align: center;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: var(--text-xs);
    font-weight: 700;
    background: rgba(79, 142, 247, 0.1);
    color: var(--tier2-blue);
}
.ml-model-headline {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    min-width: 72px;
}
.ml-model-acc-val {
    font-size: var(--text-base);
    font-weight: 600;
    min-width: 32px;
}
.ml-acc-good { color: var(--green); }
.ml-acc-warn { color: var(--amber); }
.ml-acc-bad { color: var(--red); }
.ml-acc-neutral { color: var(--text-muted); }
.ml-model-thresh-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
}
.ml-model-secondary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
}
.ml-model-samples {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}
.ml-model-window-acc {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.ml-model-date {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-left: auto;
}
.ml-model-stale {
    font-size: var(--text-xs);
    color: var(--amber);
    font-weight: 500;
}
.ml-model-no-model {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
}
.ml-model-detail-btn {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    line-height: 1;
    transition: all 0.15s;
}
.ml-model-detail-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-medium);
}

/* ================================================================
   ML — Training results panel (inline)
   ================================================================ */
.ml-train-results {
    margin-top: 1rem;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.04);
    padding: 0.75rem;
    animation: mlFadeIn 0.3s ease;
}
@keyframes mlFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ml-train-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--amber);
}
.ml-train-results-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.ml-train-results-dismiss:hover { color: var(--text-primary); }

.ml-train-result-asset {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}
.ml-train-result-asset:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.ml-train-result-asset-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}
.ml-train-result-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}
.ml-train-result-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.ml-train-result-col-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}

/* ================================================================
   ML — Confidence threshold grid (mini cards)
   ================================================================ */
.ml-conf-grid {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.ml-conf-cell {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    text-align: center;
    min-width: 52px;
}
.ml-conf-thresh {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
}
.ml-conf-acc {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}
.ml-conf-count {
    font-size: 10px;
    color: var(--text-muted);
}

/* ================================================================
   ML — Feature importance bars
   ================================================================ */
.ml-feat-list { display: flex; flex-direction: column; gap: 0.3rem; }

.ml-feat-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.ml-feat-name {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 70px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ml-feat-bar-wrap {
    flex: 1;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}
.ml-feat-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--amber);
    transition: width 0.3s;
}
.ml-feat-pct {
    font-size: 10px;
    color: var(--text-muted);
    min-width: 32px;
    text-align: right;
}
.ml-feat-list-full .ml-feat-name { min-width: 100px; }

/* ================================================================
   ML — Inline edit widgets
   ================================================================ */
.ml-config-editable {
    cursor: pointer;
    position: relative;
    transition: color 0.15s;
}
.ml-edit-icon {
    opacity: 0;
    font-size: 10px;
    margin-left: 0.2rem;
    transition: opacity 0.15s;
}
.ml-config-editable:hover { color: var(--text-primary); }
.ml-config-editable:hover .ml-edit-icon { opacity: 0.6; }

.ml-inline-editor {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.ml-inline-slider {
    width: 100px;
    accent-color: var(--accent);
}
.ml-inline-slider-val {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--amber);
    min-width: 28px;
}
.ml-inline-input {
    width: 60px;
    padding: 0.2rem 0.4rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: var(--text-xs);
    font-family: var(--font-sans);
}
.ml-inline-input:focus { border-color: var(--accent); outline: none; }
.ml-inline-dollar {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.ml-inline-save,
.ml-inline-cancel {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    padding: 0.15rem 0.35rem;
    line-height: 1;
    transition: all 0.15s;
}
.ml-inline-save {
    color: var(--color-up);
    border-color: rgba(34, 197, 94, 0.3);
}
.ml-inline-save:hover { background: rgba(34, 197, 94, 0.1); }
.ml-inline-cancel {
    color: var(--text-muted);
}
.ml-inline-cancel:hover { color: var(--text-primary); }

.ml-inline-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.15s;
}
.ml-inline-chip.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}
.ml-inline-chip input[type="checkbox"] {
    accent-color: var(--accent);
    width: 12px;
    height: 12px;
}

/* ================================================================
   ML — Model detail modal
   ================================================================ */
.ml-modal-detail { width: 480px; }

.ml-detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.ml-detail-stat {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 0.5rem 0.6rem;
    text-align: center;
}
.ml-detail-stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
}
.ml-detail-stat-val {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}
.ml-detail-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0.75rem 0 0.4rem;
}

/* Confidence table */
.ml-conf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.ml-conf-table th {
    text-align: left;
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--text-muted);
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}
.ml-conf-table td {
    padding: 0.35rem 0.5rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
}
.ml-conf-table tr:last-child td { border-bottom: none; }
.ml-conf-active {
    background: rgba(245, 158, 11, 0.1);
}
.ml-conf-active td { color: var(--amber); font-weight: 600; }

/* ── Per-asset toggle switch ── */
.ml-asset-toggle {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}
.ml-asset-toggle input { opacity: 0; width: 0; height: 0; }
.ml-asset-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-medium);
    border-radius: 8px;
    transition: background 0.2s;
}
.ml-asset-toggle-slider::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 12px;
    height: 12px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.ml-asset-toggle input:checked + .ml-asset-toggle-slider {
    background: rgba(245, 158, 11, 0.3);
}
.ml-asset-toggle input:checked + .ml-asset-toggle-slider::before {
    transform: translateX(12px);
    background: var(--amber);
}

/* ── Disabled (toggled-off) asset rows ── */
.ml-model-row-disabled {
    opacity: 0.4;
}

/* ── Best threshold highlight ── */
.ml-conf-best {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 4px;
}
.ml-conf-table tr.ml-conf-best td {
    color: var(--amber);
    font-weight: 600;
}

/* ── Clickable threshold rows/cells ── */
.ml-conf-selectable { cursor: pointer; }
.ml-conf-table tr.ml-conf-selectable:hover td {
    background: rgba(245, 158, 11, 0.08);
}
.ml-conf-table tr.ml-conf-selectable td:last-child {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
}
.ml-conf-table tr.ml-conf-active td:last-child {
    color: var(--amber);
}
.ml-conf-cell.ml-conf-selectable:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--amber);
}

/* ── Best threshold hint on model rows ── */
.ml-model-conf-warn { color: var(--color-warning); }

/* ── Combined accuracy summary (inline beside timeframe) ── */
.ml-combined-summary {
    font-size: var(--text-xs);
    font-weight: 600;
    color: #22c55e;
    margin-left: 0.5rem;
    opacity: 0.9;
}

/* ================================================================
   ML — Enhanced responsive
   ================================================================ */
@media (max-width: 640px) {
    .ml-train-result-body { grid-template-columns: 1fr; }
    .ml-detail-stats { grid-template-columns: repeat(2, 1fr); }
    .ml-modal-detail { width: 95vw; }
    .ml-conf-grid { gap: 0.25rem; }
    .ml-conf-cell { min-width: 45px; padding: 0.25rem 0.35rem; }
    .ml-model-row { gap: 0.4rem; padding: 0.4rem 0.6rem; }
    .ml-feat-name { min-width: 55px; }
    .ml-inline-slider { width: 80px; }
}
