/* ═══════════════════════════════════════════════ */
/*  GTS Signal Builder — Design System            */
/* ═══════════════════════════════════════════════ */

/*  Visitor gating: when a page-content has .visitor-gated, hide all its
    direct children except the .page-header (kept so the page title still
    reads correctly) and the .visitor-gate-panel (the Sign-in card we
    show in its place). Using a CSS rule rather than setting style.display
    in JS avoids fighting any inline display:grid / display:flex that the
    page markup uses — those layouts come back intact when the user signs
    in and the .visitor-gated class is removed. */
.page-content.visitor-gated > *:not(.page-header):not(.visitor-gate-panel) {
    display: none !important;
}

/* Override Chrome/WebKit autofill yellow on dark theme */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary) !important;
    transition: background-color 9999s ease-in-out 0s !important;
}

:root {
    /* Colors */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-card-hover: #1f2537;
    --bg-input: #0d1117;
    --bg-elevated: #252b3b;

    --border: #2d3548;
    --border-focus: #6366f1;
    --border-hover: #4a5068;

    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;

    --accent-blue: #6366f1;
    --accent-blue-hover: #818cf8;
    --accent-blue-glow: rgba(99, 102, 241, 0.25);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.2);
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #a855f7;
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;

    --left-color: #3b82f6;
    --left-glow: rgba(59, 130, 246, 0.15);
    --right-color: #10b981;
    --right-glow: rgba(16, 185, 129, 0.15);
    --op-color: #f59e0b;
    --op-glow: rgba(245, 158, 11, 0.15);

    /* Spacing */
    --gap-xs: 4px;
    --gap-sm: 8px;
    --gap-md: 16px;
    --gap-lg: 24px;
    --gap-xl: 32px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-blue: 0 0 20px var(--accent-blue-glow);
    --shadow-glow-green: 0 0 20px var(--accent-green-glow);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --desktop-ui-scale: 1;
}

/* ═══ Reset & Base ═══ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    /* `clip` (not `hidden`) prevents horizontal overflow WITHOUT turning the
       root into a scroll container — `overflow-x: hidden` here silently breaks
       `position: sticky` on .top-nav, making the nav "detach"/scroll away. */
    overflow-x: clip;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    /* Page-level compaction: scale the whole app uniformly so nav, sidebars,
       content and the glued sub-nav all share one coordinate space and stay
       aligned. 0.92 = ~15% larger than the previous builder-only 0.8 zoom,
       i.e. compact but readable. */
    zoom: 0.92;
    /* `clip` not `hidden`: prevents any descendant from forcing horizontal
       scroll (the whole top-nav + main content shifting right with the leftmost
       ~30-50px clipped) WITHOUT establishing a scroll container — `hidden` here
       breaks `position: sticky` on .top-nav so the nav detaches on scroll.
       Individual overflow-x:auto regions inside the page still scroll on their own. */
    overflow-x: clip;
}

@media (min-width: 1280px) {
    /* Desktop UI scale DISABLED (kept here for easy re-enable).
       `zoom` on <html> is a known Chrome breaker of `position: sticky`: with
       zoom != 1 the sticky .top-nav mis-positions and detaches/scrolls away
       the moment the page scrolls (e.g. on Mass Strategies). Set back to 1.1
       ONLY if the sticky nav is reworked to survive a zoomed root. */
    :root {
        --desktop-ui-scale: 1;
    }

    html:not(.desktop-embedded-builder) {
        zoom: var(--desktop-ui-scale);
    }
}

/* Per-page bump: scale ONLY the My Strategies page ~10% larger than the rest of
   the app (the site-wide body zoom stays 0.92). Scoped to #page-strategies so no
   other page is affected. */
#page-strategies {
    zoom: 1.1;
}

#login-overlay #auth-hint,
#login-overlay div:has(> a[href="#terms"][onclick*="openPublicLegalPage"]) {
    display: none !important;
}

#login-overlay.auth-compact-mode {
    padding: 8px !important;
}

#login-overlay.auth-compact-mode #auth-modal-card {
    width: min(360px, calc(100vw - 18px)) !important;
    max-height: calc(100vh - 16px) !important;
    padding: 9px 14px !important;
    transform: none !important;
}

#login-overlay.auth-register-mode #auth-modal-card > div:first-of-type {
    gap: 8px !important;
    margin-bottom: 6px !important;
}

#login-overlay.auth-register-mode #auth-modal-card > div:first-of-type > div:first-child {
    width: 32px !important;
    height: 32px !important;
    border-radius: 10px !important;
}

#login-overlay.auth-register-mode #auth-modal-card > div:first-of-type > div:last-child > div:nth-child(2) {
    font-size: 18px !important;
}

#login-overlay.auth-register-mode #auth-modal-card > div:first-of-type > div:last-child > div:nth-child(3) {
    display: none !important;
}

#login-overlay.auth-register-mode #auth-tab-login,
#login-overlay.auth-register-mode #auth-tab-register {
    padding: 7px 10px !important;
}

#login-overlay.auth-register-mode #google-signin-row {
    margin-bottom: 6px !important;
}

#login-overlay.auth-register-mode #google-signin-button {
    min-height: 32px !important;
}

#login-overlay.auth-register-mode #register-form label {
    margin-bottom: 3px !important;
    font-size: 11px !important;
}

#login-overlay.auth-register-mode #register-form input[type="text"],
#login-overlay.auth-register-mode #register-form input[type="email"],
#login-overlay.auth-register-mode #register-form input[type="password"] {
    min-height: 34px !important;
    margin-bottom: 6px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
}

#login-overlay.auth-register-mode #reg-before-signup {
    max-height: 118px !important;
    overflow-y: auto !important;
    padding: 7px 10px !important;
    margin-bottom: 7px !important;
}

#login-overlay.auth-register-mode #reg-before-signup ul {
    line-height: 1.25 !important;
}

#login-overlay.auth-register-mode #reg-before-signup li {
    margin-bottom: 2px !important;
}

.gts-balloon {
    position: relative;
}

.gts-balloon::before,
.gts-balloon::after {
    position: absolute;
    left: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
    z-index: 200;
}

.gts-balloon::before {
    content: attr(data-balloon);
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(6px);
    min-width: 180px;
    max-width: 240px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(5, 7, 13, 0.96);
    border: 1px solid #1f2937;
    color: #e2e8f0;
    font-size: 11px;
    line-height: 1.45;
    text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
    white-space: normal;
}

.gts-balloon::after {
    content: '';
    bottom: calc(100% + 4px);
    transform: translateX(-50%) translateY(6px);
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: rgba(5, 7, 13, 0.96) transparent transparent transparent;
}

.gts-balloon:hover::before,
.gts-balloon:hover::after,
.gts-balloon:focus-visible::before,
.gts-balloon:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ═══ Scrollbar ═══ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ═══ Top Navigation ═══ */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    min-height: 62px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.top-nav-inner {
    width: 100%;
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.nav-primary {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.community-shortcut {
    text-decoration: none;
}

.community-shortcut i {
    color: #86efac;
}

.community-shortcut:hover {
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.08) inset;
}

.community-shortcut:hover i {
    color: #bbf7d0;
}

html.desktop-embedded-builder .app-layout {
    min-height: 100vh;
}

html.desktop-embedded-builder .top-nav {
    display: none !important;
}

.embedded-elements-nav {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 20px 6px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.72), rgba(10, 14, 23, 0.38));
    position: sticky;
    top: 0;
    z-index: 25;
    backdrop-filter: blur(10px);
}

html.desktop-embedded-builder .embedded-elements-nav {
    display: flex;
}

.embedded-elements-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 7px 14px;
    border-radius: 11px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(15, 23, 42, 0.72);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
}

.embedded-elements-tab:hover {
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.24);
    background: rgba(99, 102, 241, 0.08);
}

.embedded-elements-tab.active {
    color: #e8edff;
    border-color: rgba(99, 102, 241, 0.32);
    background: rgba(99, 102, 241, 0.16);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.08);
}

.embedded-elements-tab i {
    color: var(--accent-blue);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 36px;
}

.brand-name-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    line-height: 1;
}

.brand-kicker {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(103, 232, 249, 0.78);
}

.brand-icon {
    font-size: 22px;
    color: var(--accent-blue);
    filter: drop-shadow(0 0 8px var(--accent-blue-glow));
}

.brand-name {
    font-size: 16.5px;
    font-weight: 800;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-pink));
    color: white;
    letter-spacing: 0.5px;
}

@media (max-width: 1500px) {
    .brand-badge {
        display: none;
    }
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 11px;
    /* Center the tabs in the available space (between brand and right-side
       controls) — grouped with a consistent gap, sitting toward the middle. */
    justify-content: center;
    min-width: 0;
    flex: 1 1 auto;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    /* Hide the horizontal scrollbar visually (scroll still works via wheel
       / trackpad / drag) so the nav row doesn't show an ugly grey strip
       below the links when content overflows. */
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* IE / legacy Edge */
}
.nav-links::-webkit-scrollbar { display: none; height: 0; width: 0; }

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 11px;
    border-radius: 11px;
    border: 1px solid transparent;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.2px;
    font-weight: 600;
    line-height: 1.1;
    transition: all 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.nav-link i {
    font-size: 13.2px;
    opacity: 0.92;
    flex: 0 0 14px;
    text-align: center;
}

@media (max-width: 1800px) {
    .top-nav {
        padding-left: 12px;
        padding-right: 12px;
    }

    .top-nav-inner,
    .nav-primary {
        gap: 8px;
    }

    .nav-links {
        gap: 4px;
    }

    .nav-link {
        gap: 4px;
        min-height: 37px;
        padding: 0 8px;
        border-radius: 9px;
        font-size: 12.5px;
    }

    .nav-link i {
        flex-basis: 13px;
        font-size: 12.5px;
    }

    .nav-user {
        gap: 7px;
    }

    .quota-badge {
        padding-left: 9px;
        padding-right: 9px;
        font-size: 12px;
    }
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(148, 163, 184, 0.12);
}

.nav-link.active {
    color: var(--accent-blue);
    background: rgba(99, 102, 241, 0.14);
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.08);
}

#page-settings {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 88px);
}
#page-settings > *:last-child {
    flex: 1;
}

#page-expressions select,
#page-strategies select,
#page-signals select,
#page-charts select,
#page-expressions input[type="text"],
#page-strategies input[type="text"],
#page-signals input[type="text"] {
    min-height: 38px;
    background: #0d1117 !important;
    background-color: #0d1117 !important;
    color: var(--text-primary) !important;
    border: 1px solid #2d3548 !important;
    color-scheme: dark;
    box-shadow: none;
}

#page-expressions select,
#page-strategies select,
#page-signals select,
#page-charts select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 34px !important;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
        linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%) !important;
    background-position:
        calc(100% - 16px) calc(50% - 2px),
        calc(100% - 10px) calc(50% - 2px) !important;
    background-size: 6px 6px, 6px 6px !important;
    background-repeat: no-repeat !important;
}

#page-expressions select option,
#page-strategies select option,
#page-signals select option,
#page-charts select option {
    background: #0d1117;
    color: var(--text-primary);
}

#seq-getter,
#seq-reset-expr,
#seq-add-expr {
    min-height: 40px !important;
    height: 40px !important;
    background: var(--bg-input) !important;
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    color-scheme: dark;
    padding: 0 34px 0 12px !important;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
        linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%) !important;
    background-position:
        calc(100% - 16px) calc(50% - 2px),
        calc(100% - 10px) calc(50% - 2px) !important;
    background-size: 6px 6px, 6px 6px !important;
    background-repeat: no-repeat !important;
}

#seq-getter option,
#seq-reset-expr option,
#seq-add-expr option {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
}

body:not([data-theme="light"]) #seq-getter,
body:not([data-theme="light"]) #seq-reset-expr,
body:not([data-theme="light"]) #seq-add-expr,
html[data-theme="dark"] #seq-getter,
html[data-theme="dark"] #seq-reset-expr,
html[data-theme="dark"] #seq-add-expr,
[data-theme="dark"] #seq-getter,
[data-theme="dark"] #seq-reset-expr,
[data-theme="dark"] #seq-add-expr {
    background: #0d1117 !important;
    background-color: #0d1117 !important;
    color: #e5edf7 !important;
    border-color: #2d3548 !important;
    -webkit-text-fill-color: #e5edf7 !important;
    color-scheme: dark !important;
}

body:not([data-theme="light"]) #seq-getter option,
body:not([data-theme="light"]) #seq-reset-expr option,
body:not([data-theme="light"]) #seq-add-expr option,
html[data-theme="dark"] #seq-getter option,
html[data-theme="dark"] #seq-reset-expr option,
html[data-theme="dark"] #seq-add-expr option,
[data-theme="dark"] #seq-getter option,
[data-theme="dark"] #seq-reset-expr option,
[data-theme="dark"] #seq-add-expr option {
    background: #0d1117 !important;
    color: #e5edf7 !important;
}

.nav-user {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    flex: 0 0 auto;
    min-height: 40px;
}

.history-monitor-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.history-monitor-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    background: rgba(99, 102, 241, 0.12);
    color: #c7d2fe;
    font-size: 12px;
    font-weight: 700;
}

.history-monitor-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.history-monitor-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.history-monitor-card-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 14px;
}

.history-monitor-kv {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    font-size: 12px;
}

.history-monitor-kv:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.history-monitor-kv span {
    color: var(--text-muted);
}

.history-monitor-kv strong {
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
}

.history-monitor-artifacts {
    display: grid;
    gap: 10px;
}

.history-monitor-artifact {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(15, 23, 42, 0.45);
}

.history-monitor-artifact-path {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    word-break: break-word;
}

.history-monitor-artifact-meta {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 11px;
}

.history-monitor-json {
    margin: 0;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.history-monitor-empty {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: 1px dashed rgba(99, 102, 241, 0.24);
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.28);
    color: var(--text-secondary);
    text-align: center;
    padding: 32px 20px;
}

.history-monitor-empty i {
    font-size: 24px;
    color: var(--accent-blue);
}

@media (max-width: 1100px) {
    .history-monitor-grid {
        grid-template-columns: 1fr;
    }
}

.nav-product-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(34, 211, 238, 0.24);
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.14), rgba(99, 102, 241, 0.16));
    color: #9be7ff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.nav-product-chip i {
    font-size: 10px;
}

body.chart-only-mode .nav-links .nav-link:not([data-page="charts"]),
body.chart-only-mode .quota-badge,
body.chart-only-mode .brand-badge,
body.chart-only-mode #library-sidebar,
body.chart-only-mode #library-expand-btn {
    display: none !important;
}

body.chart-only-mode .top-nav {
    display: none !important;
}

body.chart-only-mode .app-layout {
    width: 100vw;
    min-height: 100vh;
}

body.chart-only-mode .library-sidebar+.library-expand-btn+.app-container,
body.chart-only-mode .app-container {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    min-width: 100vw;
    padding: 0;
}

body.chart-only-mode #app-layout,
body.chart-only-mode #page-charts,
body.chart-only-mode #charts-tab-content {
    width: 100%;
    max-width: none;
}

body.chart-only-mode #page-charts .page-header,
body.chart-only-mode #charts-tabs,
body.chart-only-mode #charts-running-bar {
    display: none !important;
}
/* Landing Charts embed keeps the tabs so visitors can browse all analysis. */
body.chart-embed-mode #charts-tabs { display: flex !important; }
/* Embedded-in-landing frames: hide the bottom legal/footer bar. */
body.gts-embed-mode .gts-legalbar { display: none !important; }
/* University: more breathing room between sections (less crowded). */
#page-university .channels-section { margin-top: 30px !important; }

/* Standalone University (?university_only=1) — single-source explainer with a
   landing-style nav, linked from the landing page and (later) both apps. */
#uni-only-bar { display: none; }
body.university-only-mode .top-nav,
body.university-only-mode #library-sidebar,
body.university-only-mode #library-expand-btn,
body.university-only-mode .quota-badge,
body.university-only-mode .brand-badge,
body.edgar-only-mode .top-nav,
body.edgar-only-mode #library-sidebar,
body.edgar-only-mode #library-expand-btn,
body.edgar-only-mode .quota-badge,
body.edgar-only-mode .brand-badge {
    display: none !important;
}
body.university-only-mode #uni-only-bar,
body.edgar-only-mode #uni-only-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px clamp(16px,4vw,40px); border-bottom: 1px solid rgba(148,163,184,.16);
    background: #0b1220; position: sticky; top: 0; z-index: 50;
}
body.university-only-mode .app-layout,
body.edgar-only-mode .app-layout { width: 100vw; min-height: 100vh; }
body.university-only-mode .app-container,
body.edgar-only-mode .app-container { flex: 1 1 auto; width: 100%; max-width: none; padding: 24px clamp(16px,4vw,40px); }
@media (max-width: 860px) { body.university-only-mode .uni-only-links a:not(:last-child), body.edgar-only-mode .uni-only-links a:not(:last-child) { display: none; } }

body.chart-only-mode #charts-tab-content {
    min-height: 100vh;
    padding: 0;
}

.quota-badge {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 4px 9px 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.quota-badge.quota-warn {
    border-color: rgba(245, 158, 11, .4);
    background: rgba(245, 158, 11, .08);
    color: #fcd34d;
}

.quota-badge.quota-exhausted {
    border-color: rgba(239, 68, 68, .4);
    background: rgba(239, 68, 68, .08);
    color: #fca5a5;
}

#user-avatar-btn {
    min-height: 40px !important;
    padding: 5px 9px 5px 5px !important;
    gap: 5px !important;
    font-size: 13.2px !important;
}

#user-avatar {
    width: 29px !important;
    height: 29px !important;
    font-size: 12px !important;
}

#user-avatar-btn .fa-chevron-down {
    font-size: 10px !important;
}

.plan-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    letter-spacing: 0.5px;
}

/* ═══ App Container ═══ */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--gap-lg);
}

/* ═══ Page Header ═══ */
.page-header {
    margin-bottom: var(--gap-lg);
}

#page-builder {
    padding-top: 6px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
}

.page-header h1 i {
    color: var(--accent-blue);
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ═══ Expression Name ═══ */
.expression-name-section {
    margin-bottom: var(--gap-lg);
}

.expression-name-section label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.expression-name-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: var(--gap-xs);
}

.expression-counter-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 22px;
    padding: 0 8px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.55);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
}

.name-input-row {
    display: flex;
    gap: var(--gap-sm);
}

.name-input-row input {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.name-input-row input:focus {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-glow-blue);
}

.btn-auto-name {
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--accent-purple);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-auto-name:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-purple);
}

/* ═══ Builder Canvas ═══ */
.builder-canvas {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--gap-md);
    margin-bottom: var(--gap-lg);
}

/* ═══ Side Panels ═══ */
.side-panel {
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    min-height: 400px;
    transition: all 0.3s;
}

.left-panel:hover {
    border-color: var(--left-color);
    box-shadow: 0 0 30px var(--left-glow);
}

.right-panel:hover {
    border-color: var(--right-color);
    box-shadow: 0 0 30px var(--right-glow);
}

.side-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap-md);
    padding-bottom: var(--gap-sm);
    border-bottom: 1px solid var(--border);
}

.side-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.left-label {
    color: var(--left-color);
}

.right-label {
    color: var(--right-color);
}

.btn-clear-side {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.2s;
}

.btn-clear-side:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

/* ═══ Element Type Grid ═══ */
.element-type-section label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--gap-sm);
}

.element-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
    gap: 10px;
    margin-bottom: var(--gap-md);
}

.elem-type-btn {
    min-height: 66px;
    padding: 10px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background:
        linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(15, 23, 42, 0.40) 65%, rgba(34, 211, 238, 0.06) 100%),
        var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-align: center;
    line-height: 1.15;
    white-space: normal;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 12px rgba(99, 102, 241, 0.10);
}

.elem-type-btn:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
    background: var(--bg-elevated);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.element-type-grid.is-locked .elem-type-btn,
.elem-type-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: var(--border);
    color: var(--text-dim);
    background: var(--bg-input);
}

.elem-type-btn.selected {
    border-color: var(--accent-blue);
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-blue-hover);
    font-weight: 600;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2), 0 10px 24px rgba(99, 102, 241, 0.12);
}

.elem-type-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 14px;
}

.elem-type-label {
    display: block;
    max-width: 100%;
}

.elem-type-btn.cat-technical {
    border-color: rgba(99, 102, 241, 0.45);
}

.elem-type-btn.cat-price {
    border-color: rgba(16, 185, 129, 0.45);
}

.elem-type-btn.cat-pattern {
    border-color: rgba(168, 85, 247, 0.45);
}

.elem-type-btn.cat-utility {
    border-color: rgba(245, 158, 11, 0.45);
}

.elem-type-btn.cat-fundamental {
    border-color: rgba(6, 182, 212, 0.45);
}

.elem-type-btn.cat-trading {
    border-color: rgba(236, 72, 153, 0.45);
}

.elem-type-btn.cat-technical .elem-type-icon {
    color: var(--accent-blue-hover);
}

.elem-type-btn.cat-price .elem-type-icon {
    color: #34d399;
}

.elem-type-btn.cat-pattern .elem-type-icon {
    color: #c084fc;
}

.elem-type-btn.cat-utility .elem-type-icon {
    color: #fbbf24;
}

.elem-type-btn.cat-fundamental .elem-type-icon {
    color: #22d3ee;
}

.elem-type-btn.cat-trading .elem-type-icon {
    color: #f472b6;
}

@media (max-width: 1440px) {
    .element-type-grid {
        grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    }
}

@media (max-width: 760px) {
    .element-type-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ═══ Element Config ═══ */
.element-config {
    min-height: 200px;
    flex: 1 1 auto;
    overflow-y: auto;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: var(--gap-md);
    border: 1px solid var(--border);
}

.config-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 180px;
    color: var(--text-dim);
    gap: var(--gap-sm);
    font-size: 13px;
}

.config-placeholder i {
    font-size: 24px;
}

.extended-indicator-help {
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(34, 211, 238, 0.22);
    border-radius: var(--radius-sm);
    background: rgba(8, 17, 34, 0.72);
    display: grid;
    gap: 7px;
}

.ext-help-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.ext-help-title {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.25;
}

.ext-help-family {
    margin-top: 2px;
    color: var(--accent-cyan);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.ext-doc-link {
    flex-shrink: 0;
    color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.08);
    border: 1px solid rgba(34, 211, 238, 0.22);
    border-radius: 4px;
    padding: 4px 7px;
    text-decoration: none;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.ext-doc-link:hover {
    background: rgba(34, 211, 238, 0.14);
    border-color: rgba(34, 211, 238, 0.38);
}

.ext-help-line,
.ext-help-outputs {
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.45;
}

.ext-doc-section {
    display: grid;
    gap: 3px;
}

.ext-doc-label {
    color: var(--accent-cyan);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.ext-help-line code {
    color: #dbeafe;
    white-space: normal;
    word-break: break-word;
}

.ext-help-line strong,
.ext-help-outputs strong {
    color: var(--text-primary);
}

.ext-output-chip {
    display: inline-flex;
    align-items: center;
    margin: 2px 4px 2px 0;
    padding: 2px 6px;
    border: 1px solid rgba(99, 102, 241, 0.28);
    border-radius: 4px;
    color: #c4b5fd;
    background: rgba(99, 102, 241, 0.1);
    font-size: 10px;
    font-family: var(--font-mono);
}

.ext-output-selector {
    margin: 8px 0 10px;
    padding: 8px;
    border: 1px solid rgba(34, 211, 238, 0.18);
    border-radius: var(--radius-sm);
    background: rgba(8, 17, 34, 0.5);
}

.ext-help-muted {
    color: var(--text-dim);
    font-size: 10px;
}

.ext-doc-fields {
    display: grid;
    gap: 5px;
    margin-top: 6px;
}

.ext-doc-field {
    display: grid;
    grid-template-columns: minmax(70px, 0.42fr) minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 5px 6px;
    border: 1px solid rgba(99, 102, 241, 0.14);
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.45);
}

.ext-doc-field code {
    color: #c4b5fd;
    font-size: 10px;
    line-height: 1.25;
    white-space: normal;
    word-break: break-word;
}

.ext-doc-field span {
    color: var(--text-secondary);
    font-size: 10px;
    line-height: 1.35;
}

.ext-doc-field b {
    color: var(--accent-cyan);
    font-weight: 800;
}

.ext-doc-details {
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    padding-top: 7px;
}

.ext-doc-details summary {
    cursor: pointer;
    color: var(--text-primary);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.ext-param-help {
    margin-top: 4px;
    color: var(--text-dim);
    font-size: 10px;
    line-height: 1.35;
}

.ext-param-help span {
    color: var(--accent-cyan);
    font-weight: 700;
}

/* Config form elements */
.config-field {
    margin-bottom: var(--gap-md);
}

.config-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--gap-xs);
}

.config-field select,
.config-field input[type="number"],
.config-field input[type="text"],
.config-field input[type="date"],
.config-field input[type="time"] {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}

.config-field select:focus,
.config-field input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--accent-blue-glow);
}

.config-field input[type="number"] {
    padding-right: 14px;
}

.config-field input[type="date"],
.config-field input[type="time"] {
    color-scheme: dark;
}

input[type="number"] {
    color-scheme: dark;
}

.config-field select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.config-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-sm);
}

/* Searchable indicator list */
.indicator-search {
    position: relative;
    margin-bottom: var(--gap-sm);
}

.indicator-search input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.indicator-search i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 12px;
}

.indicator-list {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.indicator-item {
    padding: 6px 12px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    border-bottom: 1px solid rgba(45, 53, 72, 0.5);
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
}

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

.indicator-item.selected {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.26), rgba(34, 211, 238, 0.12));
    color: #f8fafc;
    font-weight: 700;
    box-shadow: inset 4px 0 0 var(--accent-cyan), 0 0 0 1px rgba(99, 102, 241, 0.26), 0 0 16px rgba(99, 102, 241, 0.08);
}

.indicator-item.selected .ind-category {
    color: #c4b5fd;
}

.indicator-item .ind-category {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-left: 8px;
    letter-spacing: 0.3px;
}

.indicator-item-compact {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}

.indicator-item-compact .indicator-title {
    display: block;
    width: 100%;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.indicator-item-compact .ind-category {
    margin-left: 0;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

/* ═══ Timeframe Chips ═══ */
.timeframe-section {
    margin-top: var(--gap-md);
}

.timeframe-section label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--gap-sm);
}

.timeframe-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tf-chip {
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.tf-chip:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.tf-chip.selected {
    border-color: var(--accent-cyan);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.22), rgba(59, 130, 246, 0.12));
    color: #cffafe;
    box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.18), 0 0 12px rgba(6, 182, 212, 0.08);
}

.field-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.field-tabs.compact {
    gap: 6px;
}

.field-tab {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.field-tab.compact {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 10px;
}

.field-tab:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
    background: rgba(6, 182, 212, 0.06);
}

.field-tab.selected {
    border-color: var(--accent-cyan);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.22), rgba(59, 130, 246, 0.12));
    color: #cffafe;
    box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.16), 0 0 10px rgba(6, 182, 212, 0.08);
}

.field-item {
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: all 0.15s;
    position: relative;
}

.field-item:hover {
    border-color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.05);
}

.field-item.selected {
    border-color: var(--accent-cyan);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), rgba(59, 130, 246, 0.1));
    color: #cffafe;
    box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.14), 0 0 8px rgba(6, 182, 212, 0.08);
}

.field-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.field-item-name {
    font-weight: 600;
    color: var(--text-primary);
}

.field-item-check {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(148, 163, 184, 0.24);
    color: transparent;
    background: rgba(255, 255, 255, 0.02);
    flex: 0 0 auto;
}

.field-item.selected .field-item-check {
    color: #0a0e17;
    border-color: rgba(34, 211, 238, 0.7);
    background: linear-gradient(135deg, #67e8f9, #22d3ee);
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.25);
}

/* ═══ Side Submit ═══ */
.side-submit {
    margin-top: var(--gap-md);
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(26, 31, 46, 0) 0%, rgba(26, 31, 46, 0.96) 28%);
    padding-top: 10px;
    z-index: 2;
}

.btn-submit-side {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--accent-green);
    border-radius: var(--radius-md);
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-submit-side:hover {
    background: rgba(16, 185, 129, 0.2);
    box-shadow: 0 0 15px var(--accent-green-glow);
}

/* ═══ Operation Panel ═══ */
.operation-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    align-self: center;
}

.operation-panel:hover {
    border-color: var(--op-color);
    box-shadow: 0 0 30px var(--op-glow);
}

.operation-header {
    margin-bottom: var(--gap-md);
    text-align: center;
}

.operation-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--op-color);
}

.operation-grid {
    display: flex;
    flex-direction: column;
    gap: var(--gap-md);
}

.op-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}

.op-group-label {
    width: 100%;
    text-align: center;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.operation-header {
    width: 100%;
    margin-bottom: var(--gap-md);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.btn-reset-operation {
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset-operation:hover {
    border-color: var(--accent-red);
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.op-btn {
    width: 40px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.op-btn:hover {
    border-color: var(--op-color);
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.op-btn.selected {
    border-color: var(--op-color);
    background: rgba(245, 158, 11, 0.2);
    color: var(--op-color);
    box-shadow: 0 0 10px var(--op-glow);
}

.op-btn.logic {
    width: auto;
    padding: 0 12px;
    font-size: 11px;
}

/* ═══ Symbol Section ═══ */
.symbol-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    margin-bottom: var(--gap-lg);
}

.symbol-section>label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--gap-sm);
}

.symbol-input-row input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    margin-bottom: var(--gap-sm);
}

.symbol-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.symbol-chip {
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.symbol-chip:hover {
    border-color: var(--accent-orange);
    color: var(--text-primary);
}

.symbol-chip.selected {
    border-color: var(--accent-orange);
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

/* ═══ Preview Section ═══ */
.preview-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    margin-bottom: var(--gap-lg);
}

.builder-json-import-card {
    border-color: rgba(16, 185, 129, 0.35);
    box-shadow: inset 3px 0 0 #14b8a6;
    background:
        linear-gradient(180deg, rgba(20, 184, 166, 0.035), rgba(26, 31, 46, 0) 72%),
        var(--bg-card);
}

.builder-json-import-card .preview-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.builder-json-import-card .preview-header h3 i {
    color: #14b8a6;
}

.builder-json-import-subtitle {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.builder-json-import-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 7px;
    background: rgba(16, 185, 129, 0.16);
    border: 1px solid rgba(16, 185, 129, 0.22);
    color: #34d399;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.builder-json-import-collapse-label {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.builder-json-import-tool-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 2px 0 12px;
}

.builder-json-import-mini {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 7px;
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.builder-json-import-mini-schema {
    display: none !important;
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.08);
}

.builder-json-import-mini-urls {
    display: none !important;
    color: #22d3ee;
    border-color: rgba(34, 211, 238, 0.35);
    background: rgba(34, 211, 238, 0.08);
}

.builder-json-import-mini-prompt {
    color: #c084fc;
    border-color: rgba(192, 132, 252, 0.35);
    background: rgba(168, 85, 247, 0.08);
}

.builder-json-import-mini:hover {
    filter: brightness(1.08);
}

.btn-copy-json.builder-json-import-save {
    color: var(--accent-green);
    border-color: var(--accent-green);
    background: var(--accent-green-glow);
}

.btn-copy-json.builder-json-import-save:hover {
    box-shadow: var(--shadow-glow-green);
    filter: brightness(1.08);
}

.builder-json-import-textarea {
    width: 100%;
    min-height: 144px;
    resize: vertical;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(8, 12, 20, 0.72);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
}

.builder-json-import-textarea::placeholder {
    color: #7c879d;
}

.builder-json-import-textarea:focus {
    outline: none;
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.16);
}

.builder-json-import-action-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap-md);
}

.preview-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-copy-json {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.preview-human {
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: var(--gap-sm);
    font-size: 14px;
    line-height: 1.6;
    min-height: 48px;
    display: flex;
    align-items: center;
}

.preview-placeholder {
    color: var(--text-dim);
    font-style: italic;
    font-size: 13px;
}

.preview-human .left-part {
    color: var(--left-color);
    font-weight: 600;
}

.preview-human .op-part {
    color: var(--op-color);
    font-weight: 700;
    margin: 0 8px;
}

.preview-human .right-part {
    color: var(--right-color);
    font-weight: 600;
}

.preview-json {
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    overflow-x: auto;
    max-height: 200px;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* ═══ Action Buttons ═══ */
.action-buttons {
    display: flex;
    gap: var(--gap-md);
    justify-content: center;
    padding: var(--gap-lg) 0 96px;
    flex-wrap: wrap;
}

.btn-save,
.btn-template,
.btn-reset {
    padding: 12px 28px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
}

.btn-save {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-save:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-blue-glow);
}

.btn-save:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.save-status-banner {
    margin: 12px auto 0;
    min-height: 20px;
    max-width: 840px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
}

.save-status-banner.is-info {
    color: #bfdbfe;
    background: rgba(37, 99, 235, 0.14);
    border-color: rgba(96, 165, 250, 0.28);
}

.save-status-banner.is-success {
    color: #bbf7d0;
    background: rgba(22, 163, 74, 0.14);
    border-color: rgba(74, 222, 128, 0.26);
}

.save-status-banner.is-error {
    color: #fecaca;
    background: rgba(220, 38, 38, 0.14);
    border-color: rgba(248, 113, 113, 0.26);
}

/* ═══ Pricing / Plans ═══ */
.pricing-area {
    max-width: 1220px;
    margin: 0 auto 34px;
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.42);
}

.pricing-area-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.pricing-area-kicker,
.pricing-area-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    border: 1px solid rgba(99, 102, 241, 0.24);
    border-radius: 999px;
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.1);
    font-size: 11px;
    font-weight: 800;
}

.pricing-area-header h2 {
    margin-top: 10px;
    font-size: 24px;
    line-height: 1.2;
    color: var(--text-primary);
}

.pricing-area-header p {
    max-width: 760px;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

.pricing-area-pill {
    flex-shrink: 0;
    border-color: rgba(16, 185, 129, 0.22);
    color: #86efac;
    background: rgba(16, 185, 129, 0.1);
}

.pricing-area-pill-muted {
    border-color: rgba(245, 158, 11, 0.24);
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.1);
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    align-items: stretch;
    margin-bottom: 28px;
}

.pricing-grid-alerts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pricing-grid-advanced {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 0;
}

.pricing-price-note {
    min-height: 68px;
}

.pricing-price-note span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 12px;
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.54);
    font-size: 16px;
    font-weight: 800;
}

.pricing-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 24px;
    border-radius: 22px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background:
        radial-gradient(circle at top, rgba(99, 102, 241, 0.08), transparent 45%),
        linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(10, 14, 23, 0.98));
    box-shadow: 0 18px 60px rgba(3, 7, 18, 0.22);
    overflow: hidden;
}

.pricing-card-featured {
    border-color: rgba(99, 102, 241, 0.36);
    box-shadow: 0 20px 70px rgba(79, 70, 229, 0.2);
    transform: translateY(-4px);
}

.pricing-card-current {
    border-color: rgba(52, 211, 153, 0.4);
    box-shadow: 0 18px 60px rgba(16, 185, 129, 0.18);
}

.pricing-popular-badge {
    position: absolute;
    top: 18px;
    right: 18px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(249, 115, 22, 0.95));
    color: #fff7ed;
    box-shadow: 0 10px 24px rgba(249, 115, 22, 0.22);
}

.pricing-card-header {
    margin-bottom: 18px;
}

.pricing-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 14px;
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.pricing-plan-name {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 6px;
}

.pricing-plan-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.pricing-price-row {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    margin-bottom: 18px;
}

.pricing-currency {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-secondary);
    padding-bottom: 8px;
}

.pricing-amount {
    font-size: 54px;
    line-height: 0.95;
    font-weight: 900;
    color: #f8fafc;
}

.pricing-period {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    padding-bottom: 10px;
}

.pricing-cta {
    width: 100%;
    min-height: 46px;
    margin-bottom: 20px;
    border: none;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.pricing-cta:hover {
    transform: translateY(-1px);
}

.pricing-cta-secondary {
    background: rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.18);
}

.pricing-cta-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #eef2ff;
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.24);
}

.pricing-cta-enterprise {
    background: linear-gradient(135deg, #10b981, #06b6d4);
    color: #ecfeff;
    box-shadow: 0 12px 28px rgba(16, 185, 129, 0.2);
}

.pricing-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.pricing-feature {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.pricing-feature i {
    margin-top: 2px;
    width: 14px;
    text-align: center;
}

.pricing-feature.included i {
    color: #34d399;
}

.pricing-feature.excluded {
    color: var(--text-dim);
}

.pricing-feature.excluded i {
    color: #f87171;
}

.pricing-feature.highlight {
    color: #f8fafc;
}

.pricing-feature-note {
    display: inline-block;
    margin-top: 2px;
    font-size: 10px;
    color: var(--text-muted);
}

.pricing-comparison-section,
.pricing-faq-section {
    margin-top: 30px;
}

.pricing-section-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 22px;
}

.pricing-section-title i {
    color: var(--accent-blue);
    margin-right: 8px;
}

.pricing-faq-section .pricing-section-title i {
    color: var(--accent-cyan);
}

.pricing-comparison-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(10, 14, 23, 0.98));
}

.pricing-comparison-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.pricing-comparison-table th,
.pricing-comparison-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    font-size: 12px;
    color: var(--text-secondary);
}

.pricing-comparison-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
}

.pricing-table-feature-col {
    text-align: left;
    width: 42%;
}

.pricing-table-plan-col {
    text-align: center;
    width: 19%;
}

.pricing-table-pro-col {
    color: #c4b5fd !important;
}

.pricing-table-category td {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.08);
}

.pricing-check {
    color: #34d399;
}

.pricing-x {
    color: #f87171;
}

.pricing-unlimited {
    color: #34d399;
    font-weight: 800;
}

.pricing-faq-grid {
    display: grid;
    gap: 14px;
}

.pricing-faq-item {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(10, 14, 23, 0.96));
    overflow: hidden;
}

.pricing-faq-q {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.pricing-faq-q i {
    color: var(--text-muted);
    transition: transform 0.18s ease;
}

.pricing-faq-a {
    display: none;
    padding: 0 18px 16px;
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.pricing-faq-item.open .pricing-faq-a {
    display: block;
}

.pricing-faq-item.open .pricing-faq-q i {
    transform: rotate(180deg);
}

@media (max-width: 1180px) {
    .pricing-grid {
        grid-template-columns: 1fr;
    }

    .pricing-grid-alerts,
    .pricing-grid-advanced {
        grid-template-columns: 1fr;
    }

    .pricing-card-featured {
        transform: none;
    }
}

.btn-template {
    background: var(--bg-card);
    color: var(--accent-orange);
    border: 1px solid var(--border);
}

.btn-template:hover {
    border-color: var(--accent-orange);
    background: rgba(245, 158, 11, 0.1);
}

.btn-reset {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-reset:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

/* Common Button Classes */
.btn-primary {
    background: var(--accent-blue);
    color: #fff;
    border: 1px solid var(--accent-blue);
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--accent-blue-hover);
    box-shadow: 0 0 15px var(--accent-blue-glow);
    transform: translateY(-1px);
}

.btn-outline {
    background: rgba(99, 102, 241, 0.05);
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 10px var(--accent-blue-glow);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* ═══ Templates Modal ═══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content,
.modal-card {
    width: 95%;
    max-width: 600px;
    background: var(--bg-card);
    background-color: #0f172a !important;
    /* Ensure solid dark background */
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--gap-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    animation: slideUp 0.3s ease;
    overflow: hidden;
    position: relative;
    color: #fff;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: -16px -16px 16px -16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h4,
.modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.feedback-modal {
    width: min(520px, calc(100vw - 32px));
    max-width: 520px;
    padding: 0;
    border-radius: 16px;
    background: #111827 !important;
    overflow: visible;
}

/* Compact glassy variant for showNotice() info dialogs */
.modal-content.app-alert-modal {
    width: min(420px, calc(100vw - 32px));
    max-width: 420px;
    padding: 18px;
    border-radius: 18px;
    background-color: transparent !important;
    background-image: linear-gradient(135deg, rgba(67, 56, 202, 0.22) 0%, rgba(15, 23, 42, 0.14) 50%, rgba(34, 211, 238, 0.22) 100%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid rgba(165, 180, 252, 0.32);
    box-shadow:
        0 18px 56px rgba(99, 102, 241, 0.26),
        0 4px 16px rgba(0, 0, 0, 0.32),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.modal-content.app-alert-modal.app-alert-modal-wide {
    width: min(900px, calc(100vw - 56px));
    max-width: 900px;
}

.modal-content.app-alert-modal.app-alert-modal-wide .modal-body {
    max-height: min(70vh, 720px);
    overflow: auto;
}
.modal-content.app-alert-modal .modal-header {
    margin: -18px -18px 12px -18px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(165, 180, 252, 0.18);
}
.modal-content.app-alert-modal .modal-header h4 {
    font-size: 15px;
    font-weight: 600;
}
.modal-content.app-alert-modal .modal-body {
    font-size: 14px;
    line-height: 1.5;
}
.modal-content.app-alert-modal .modal-footer {
    margin-top: 12px;
}

.feedback-modal.feedback-choice-active {
    padding-bottom: 130px;
}

.feedback-modal .modal-header {
    margin: 0;
    padding: 18px 28px 6px;
    background: transparent;
    border-bottom: 0;
}

.feedback-modal .modal-header h4 {
    font-size: 21px;
    line-height: 1.2;
}

.feedback-modal .modal-close {
    top: 18px;
    right: 18px;
}

.feedback-modal-body {
    padding: 0 28px 22px;
}

.feedback-helper {
    margin: 4px 0 18px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.feedback-field {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-bottom: 13px;
}

.feedback-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}

.feedback-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.feedback-input,
.feedback-textarea,
.feedback-select,
.feedback-choice {
    width: 100%;
    border: 1px solid #2c3548;
    border-radius: 12px;
    background: #0b1220;
    color: var(--text-primary);
    font: inherit;
    font-size: 16px;
    outline: none;
}

.feedback-input,
.feedback-select,
.feedback-choice {
    height: 40px;
    padding: 0 13px;
}

.feedback-choice {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.feedback-choice i {
    font-size: 11px;
    color: var(--text-secondary);
}

.feedback-choice-menu {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 9100;
    overflow: hidden;
    max-height: 210px;
    overflow-y: auto;
    border: 1px solid #2c3548;
    border-radius: 10px;
    background: #0b1220;
    box-shadow: 0 18px 42px rgba(0, 0, 0, .45);
}

.feedback-choice.open .feedback-choice-menu {
    display: block;
}

.feedback-choice-menu button {
    width: 100%;
    display: block;
    padding: 10px 13px;
    border: 0;
    border-radius: 0;
    background: #0b1220;
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.feedback-choice-menu button:hover,
.feedback-choice-menu button:focus {
    background: rgba(99, 102, 241, .2);
    outline: none;
}

.feedback-textarea {
    min-height: 104px;
    max-height: 260px;
    resize: vertical;
    padding: 12px 13px;
}

.feedback-input:focus,
.feedback-textarea:focus,
.feedback-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}

.feedback-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 10px;
}

.feedback-actions .btn-primary,
.feedback-actions .btn-secondary {
    height: 40px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 800;
    padding: 0 14px;
}

.feedback-status {
    min-height: 18px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.gts-legalbar {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 1200 !important;
}

@media (max-width: 680px) {
    .gts-legalbar > div {
        grid-template-columns: 1fr !important;
        gap: 5px !important;
        padding: 6px var(--gap-md) !important;
    }

    .gts-legalbar > div > div {
        justify-content: center !important;
        grid-column: auto !important;
    }

    .app-layout .app-container {
        padding-bottom: 112px;
    }

    .feedback-modal .modal-header,
    .feedback-modal-body {
        padding-left: 22px;
        padding-right: 22px;
    }

    .feedback-modal.feedback-choice-active {
        padding-bottom: 110px;
    }

    .feedback-grid,
    .feedback-actions {
        grid-template-columns: 1fr;
    }
}

/* Symbol Selection Modal */
.modal-card.symbol-dialog-modal {
    background-color: rgba(15, 23, 42, 0.72) !important;
    background-image:
        linear-gradient(135deg, rgba(79, 70, 229, 0.18), rgba(8, 13, 24, 0.78) 44%, rgba(6, 182, 212, 0.11)),
        radial-gradient(circle at 14% 0%, rgba(99, 102, 241, 0.18), transparent 32%),
        radial-gradient(circle at 86% 10%, rgba(34, 211, 238, 0.12), transparent 30%) !important;
    -webkit-backdrop-filter: blur(26px) saturate(155%);
    backdrop-filter: blur(26px) saturate(155%);
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow:
        0 28px 80px rgba(0, 0, 0, 0.52),
        0 0 0 1px rgba(99, 102, 241, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.symbol-dialog-header {
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.72), rgba(30, 41, 59, 0.38));
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.symbol-provider-kicker {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

.symbol-provider-pill {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border-radius: 999px;
    color: #dff8ff;
    background: rgba(6, 182, 212, 0.16);
    border: 1px solid rgba(34, 211, 238, 0.28);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.symbol-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 22px;
    padding: 2px 0 2px;
    overflow: visible;
    min-height: 44px;
    align-items: flex-start;
}

.symbol-category-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.symbol-category-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.symbol-category-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.symbol-tab {
    padding: 7px 11px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
    line-height: 1;
    min-height: 32px;
    max-width: 100%;
}

.symbol-tab:hover {
    color: var(--text-main);
    border-color: rgba(148, 163, 184, 0.28);
    background: rgba(255, 255, 255, 0.06);
}

.symbol-tab.active {
    background: rgba(99, 102, 241, 0.18);
    color: #fff;
    border-color: rgba(99, 102, 241, 0.36);
}

.symbol-tab.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.symbol-tab-label {
    color: inherit;
    font-weight: 700;
    letter-spacing: 0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.symbol-tab-count {
    color: inherit;
    opacity: 0.8;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.24);
}

.symbol-list {
    display: flex;
    flex-direction: column;
    max-height: 450px;
    overflow-y: auto;
    margin: 0 -16px;
}

.symbol-row-header {
    display: flex;
    gap: 12px;
    padding: 8px 16px;
    margin-top: 6px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.symbol-row {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.symbol-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.symbol-row.selected {
    background: rgba(99, 102, 241, 0.08);
}

.symbol-row .col-sym {
    width: 100px;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 13px;
}

.symbol-row .col-desc {
    flex: 1;
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.symbol-row .col-src {
    width: 60px;
    display: flex;
    justify-content: flex-end;
}

.src-badge {
    padding: 1px 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    font-size: 8px;
    font-weight: 700;
    color: var(--text-dim);
    border: 1px solid var(--border-subtle);
}

.symbol-row.selected .col-sym {
    color: var(--accent-cyan);
}

.symbol-list::-webkit-scrollbar {
    width: 4px;
}

.symbol-list::-webkit-scrollbar_thumb {
    background: var(--border);
    border-radius: 4px;
}

.modal-search {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    padding: 10px 14px;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    margin-bottom: 16px;
    outline: none;
}

.modal-search:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px -16px -16px -16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid var(--border-subtle);
}

/* Date/Time picker compact overrides — prevent clipping in iframe */
#date-time-picker-overlay .modal-card {
    padding: 0;
    overflow: visible;
}

#date-time-picker-overlay .modal-header {
    margin: 0;
    padding: 6px 10px;
}

#date-time-picker-overlay .modal-footer {
    margin: 0;
    padding: 4px 8px;
}

.support-mail-copy {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 190px;
    min-width: 0;
    padding: 3px 8px;
    border: 1px solid rgba(34, 211, 238, 0.18);
    border-radius: 6px;
    background: rgba(34, 211, 238, 0.06);
    color: #cbd5e1;
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

.support-mail-copy:hover {
    border-color: rgba(34, 211, 238, 0.42);
    background: rgba(34, 211, 238, 0.1);
    color: #e0f2fe;
}

.support-mail-copy span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.support-mail-copy.copied {
    border-color: rgba(74, 222, 128, 0.42);
    background: rgba(74, 222, 128, 0.1);
    color: #bbf7d0;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--gap-md);
}

.template-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--gap-md);
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.template-card .tmpl-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.template-card .tmpl-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: var(--gap-sm);
}

.template-card .tmpl-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tmpl-tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-elevated);
    color: var(--text-muted);
}

/* ═══ Responsive ═══ */
@media (max-width: 1200px) {
    .builder-canvas {
        grid-template-columns: 1fr;
    }

    .operation-panel {
        flex-direction: row;
        min-width: auto;
    }

    .operation-panel .operation-grid {
        flex-direction: row;
    }
}

@media (max-width: 768px) {
    .top-nav {
        padding: 0 var(--gap-md);
    }

    .nav-links {
        display: none;
    }

    .app-container {
        padding: var(--gap-md);
    }
}

/* ═══ NLP Section ═══ */
.nlp-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    margin-bottom: var(--gap-lg);
    border-left: 3px solid var(--accent-purple);
}

.nlp-header {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    margin-bottom: var(--gap-sm);
    font-size: 13px;
    color: var(--text-secondary);
}

.nlp-header i {
    color: var(--accent-purple);
}

.nlp-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    color: white;
    letter-spacing: 0.5px;
}

.nlp-input-row {
    display: flex;
    gap: var(--gap-sm);
    margin-bottom: var(--gap-sm);
}

.nlp-input-row input {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}

.nlp-input-row input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.2);
}

.btn-nlp-parse {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-nlp-parse:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.nlp-examples {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.nlp-example {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-mono);
}

.nlp-example:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

/* ═══ Unary Section ═══ */
.unary-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    margin-bottom: var(--gap-lg);
}

.unary-header,
.repeat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap-md);
}

.unary-header label,
.repeat-header label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.optional-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-elevated);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-lg);
}

.unary-left,
.unary-right {
    padding: var(--gap-sm);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
}

.unary-side-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--gap-sm);
    padding-bottom: var(--gap-xs);
    border-bottom: 1px solid var(--border);
}

.unary-left .unary-side-label {
    color: var(--left-color);
}

.unary-right .unary-side-label {
    color: var(--right-color);
}

.unary-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: var(--gap-sm);
}

.unary-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.unary-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.unary-btn.active {
    border-color: var(--accent-cyan);
    background: linear-gradient(180deg, rgba(6, 182, 212, 0.22), rgba(59, 130, 246, 0.16));
    color: #cffafe;
    box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.03), 0 0 18px rgba(6, 182, 212, 0.12);
}

.unary-param-row {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    margin-top: var(--gap-xs);
}

.unary-param-row label {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.unary-param-row input {
    width: 60px;
    padding: 4px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font-mono);
}

/* ═══ Repeat Section ═══ */
.repeat-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    margin-bottom: var(--gap-lg);
}

.repeat-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--gap-md);
}

/* ═══ App Layout (Sidebar + Main) ═══ */
.app-layout {
    display: flex;
    min-height: calc(100vh - 56px);
}

.app-layout .app-container {
    flex: 1;
    min-width: 0;
    padding-bottom: 72px;
}

/* ═══ Library Sidebar ═══ */
.library-sidebar {
    /* Pinned to the viewport so the sidebar's bottom is always flush
       against the viewport bottom regardless of how far the user
       scrolls in the main content. position: fixed avoids the sticky-
       bottom-clipped-by-parent issue where a long Builder page makes
       the sidebar bottom rise up out of view. */
    position: fixed;
    left: 0;
    top: 48px;
    bottom: 28px;
    width: clamp(222px, 17.5vw, 19.9vw);   /* +10% wider expression rail */
    min-width: 222px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    z-index: 50;
    padding-bottom: 0;
}
/* When the sidebar is fixed, the main content area needs a left margin
   equal to the sidebar's width so it doesn't slide under it. */
.app-layout > .app-container,
.app-layout > main {
    margin-left: clamp(222px, 17.5vw, 19.9vw);   /* match +10% sidebar width */
}
.library-sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}
.library-sidebar.collapsed ~ .app-container,
.library-sidebar.collapsed ~ main {
    margin-left: 0;
    max-width: 1540px;
}

body.monitor-page-active .app-layout > .app-container,
body.monitor-page-active .app-layout > main {
    width: calc(100vw - clamp(222px, 17.5vw, 19.9vw) - 10px);
    max-width: none;
    margin-right: 10px;
    padding: 0;
}

body.monitor-page-active .library-sidebar.collapsed ~ .app-container,
body.monitor-page-active .library-sidebar.collapsed ~ main {
    width: calc(100vw - 10px);
}

.app-layout > .app-container:has(> #page-monitor:not([style*="display:none"]):not([style*="display: none"])),
.app-layout > main:has(> #page-monitor:not([style*="display:none"]):not([style*="display: none"])) {
    width: calc(100vw - clamp(222px, 17.5vw, 19.9vw) - 10px);
    max-width: none;
    margin-right: 10px;
    padding: 0;
}

/* Builder iframe tabs hide the SaaS library because the embedded tool has its
   own sidebar, but the outer builder rail must keep the same x-position as the
   Expression Builder tab. Otherwise the 3-button sub-nav rebases on click. */
body.builder-iframe-subtab-active .app-layout > .app-container,
body.builder-iframe-subtab-active .app-layout > main {
    margin-left: clamp(222px, 17.5vw, 19.9vw);
    max-width: 1400px;
}

.library-sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    overflow: hidden;
}

.library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.library-header h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.library-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(30, 41, 59, 0.78);
    color: var(--text-secondary);
    cursor: pointer;
}

.library-expand-btn {
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
}

.library-expand-btn span {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.library-header h3 i {
    color: var(--accent-purple);
}

.library-toggle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.library-search {
    position: relative;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.library-search input {
    width: 100%;
    padding: 7px 10px 7px 28px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
}

.library-search input:focus {
    border-color: var(--accent-purple);
}

.library-search>i {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 10px;
}

.library-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.library-tabs.strategy-library-tabs {
    flex-wrap: nowrap;
}

.library-tabs.strategy-library-tabs .lib-tab {
    min-width: 0;
    padding-left: 2px;
    padding-right: 2px;
    font-size: 9px;
    letter-spacing: 0.1px;
}

.library-mode-filters {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.lib-tab {
    flex: 1;
    padding: 8px 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}
.lib-tab-count {
    margin-left: 4px;
    color: var(--accent-cyan);
    font-weight: 700;
    text-transform: none;
}

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

.lib-tab.active {
    color: var(--accent-purple);
    border-bottom-color: var(--accent-purple);
    background: rgba(168, 85, 247, 0.05);
}

.lib-mode-filter {
    flex: 1;
    padding: 5px 8px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.35px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.18s;
}

.lib-mode-filter:hover {
    color: var(--text-primary);
    border-color: rgba(34, 211, 238, 0.3);
}

.lib-mode-filter.active {
    color: var(--accent-cyan);
    border-color: rgba(34, 211, 238, 0.35);
    background: rgba(34, 211, 238, 0.08);
}

.library-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 6px;
    padding-bottom: 16px;
    scroll-padding-top: 0;
}

.library-footer {
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    font-size: 10px;
    color: var(--text-dim);
    text-align: center;
    flex-shrink: 0;
    /* Belt-and-suspenders: force the footer to the bottom of the sidebar
       even if .library-list ever fails to expand (bug #16/#17). */
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.library-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-elevated, rgba(99,102,241,0.08));
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, color .12s, border-color .12s;
}
.library-sort-btn:hover {
    color: var(--accent-blue, #818cf8);
    border-color: var(--accent-blue, #818cf8);
    background: rgba(99,102,241,0.14);
}

/* Library items */
.lib-item {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(45, 53, 72, 0.3);
    cursor: pointer;
    transition: background-color 0.15s, box-shadow 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    overflow: visible;
    min-height: 0;
    scroll-snap-align: start;
    scroll-margin-top: 0;
}

.lib-item:hover {
    background: var(--bg-elevated);
}

.lib-item.selected {
    background: linear-gradient(90deg, rgba(96, 165, 250, 0.14), rgba(34, 211, 238, 0.08));
    box-shadow: inset 3px 0 0 var(--accent-cyan);
}

.lib-item.selected .lib-item-name {
    color: #dbeafe;
}

.lib-item.selected .lib-item-desc {
    color: var(--text-secondary);
}

.lib-item.dragging {
    opacity: 0.5;
    background: rgba(168, 85, 247, 0.1);
}

.lib-item-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    /* Allow long names like PERFECT_TRIANGLE_BREAKOUT_DETECTED to wrap inside
       the sidebar instead of being cut by overflow:hidden. Matches desktop. */
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.45;
}

.lib-item-title-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
}

.lib-item-title-row .lib-item-name {
    flex: 1;
}

.lib-item-title-row .lib-item-name > i,
.lib-item-name > i {
    user-select: none;
    -webkit-user-select: none;
}

.lib-copy-name,
.lib-community-link {
    width: 22px;
    height: 22px;
    margin-top: -2px;
    flex: 0 0 auto;
    border: 1px solid rgba(99, 102, 241, 0.24);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.58);
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.lib-community-link {
    opacity: 1;
}

.lib-community-link:hover {
    color: var(--accent-cyan);
    border-color: rgba(6, 182, 212, 0.42);
    background: rgba(6, 182, 212, 0.12);
}

.lib-title-tree-count {
    user-select: none;
    -webkit-user-select: none;
}

.lib-title-tree-count {
    height: 18px;
    min-width: 18px;
    padding: 0 5px;
    flex: 0 0 auto;
    border: 1px solid rgba(6, 182, 212, 0.32);
    border-radius: 999px;
    background: rgba(6, 182, 212, 0.13);
    color: #67e8f9;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.lib-item:hover .lib-copy-name,
.lib-copy-name:focus,
.lib-copy-name.copied {
    opacity: 1;
}

.lib-copy-name:hover,
.lib-copy-name.copied {
    color: var(--accent-cyan);
    border-color: rgba(6, 182, 212, 0.42);
    background: rgba(6, 182, 212, 0.12);
}

.lib-tree-count {
    background: rgba(6, 182, 212, 0.12) !important;
    border-color: rgba(6, 182, 212, 0.30) !important;
    color: #67e8f9 !important;
}

.library-load-sentinel {
    width: 100%;
    height: 1px;
    margin: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.mini-glass-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 100000;
    transform: translate(-50%, 8px);
    opacity: 0;
    max-width: min(420px, calc(100vw - 32px));
    padding: 11px 18px;
    border: 1px solid rgba(165, 180, 252, 0.28);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(67, 56, 202, 0.18) 0%, rgba(15, 23, 42, 0.26) 60%, rgba(34, 211, 238, 0.14) 100%);
    color: #f1f5ff;
    box-shadow:
        0 8px 24px rgba(99, 102, 241, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.mini-glass-toast.compact {
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 12px;
    max-width: min(280px, calc(100vw - 32px));
}

.mini-glass-toast.deploy-toast {
    top: 88px;
    right: 24px;
    bottom: auto;
    left: auto;
    transform: translate(8px, 0);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    max-width: min(320px, calc(100vw - 32px));
    white-space: normal;
}

.mini-glass-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.mini-glass-toast.deploy-toast.show {
    transform: translate(0, 0);
}

.lib-item-desc {
    font-size: 10px;
    color: var(--text-muted);
    min-width: 0;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.35;
}

.lib-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    flex-wrap: wrap;
    min-width: 0;
}

.lib-item-subs {
    font-size: 9px;
    color: var(--accent-cyan);
}

.lib-item-cat {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-input);
    color: var(--text-dim);
}

.lib-item-cat.momentum {
    color: var(--accent-orange);
    background: rgba(245, 158, 11, 0.1);
}

.lib-item-cat.trend {
    color: var(--accent-blue);
    background: rgba(99, 102, 241, 0.1);
}

.lib-item-cat.volatility {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
}

.lib-item-cat.candle {
    color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
}

.lib-item-cat.composite {
    color: var(--accent-purple);
    background: rgba(168, 85, 247, 0.1);
}

.lib-item-cat.user {
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.1);
}

.lib-item-cat.mode-helper {
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.12);
}

.lib-item-cat.mode-alert {
    color: #34d399;
    background: rgba(52, 211, 153, 0.12);
}

.lib-item-cat.mode-state-machine {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.12);
}

.lib-item-drag {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

.lib-item:hover .lib-item-drag {
    opacity: 1;
}

.lib-item-selected-badge {
    margin-left: auto;
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(34, 211, 238, 0.12);
    color: var(--accent-cyan);
    border: 1px solid rgba(34, 211, 238, 0.22);
}

/* Strategy Library: shared color grammar across My Strategies, Runs, Monitor. */
.strategy-lib-item {
    border-left: 3px solid transparent;
    min-height: 92px;
    max-height: 148px;
    overflow: hidden;
    padding-top: 10px;
    padding-bottom: 9px;
}

.strategy-lib-item .strategy-lib-icon {
    color: #a78bfa;
    font-size: 9px;
}

.strategy-lib-item .lib-item-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}

.strategy-lib-item .lib-item-desc {
    -webkit-line-clamp: 1;
    line-height: 1.3;
}

.strategy-lib-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.strategy-lib-stat {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 102px;
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px solid rgba(100, 116, 139, 0.30);
    background: rgba(15, 23, 42, 0.50);
    color: #9fb3d9;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.strategy-lib-stat i {
    font-size: 8px;
    opacity: 0.85;
}

.strategy-lib-stat-units {
    color: #c4b5fd;
    border-color: rgba(139, 92, 246, 0.32);
    background: rgba(139, 92, 246, 0.12);
}

.strategy-lib-stat-nodes {
    color: #67e8f9;
    border-color: rgba(6, 182, 212, 0.30);
    background: rgba(6, 182, 212, 0.10);
}

.strategy-lib-stat-symbol {
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.30);
    background: rgba(59, 130, 246, 0.11);
}

.strategy-lib-stat-handlers {
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.30);
    background: rgba(34, 197, 94, 0.10);
}

.strategy-lib-stat-element {
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.28);
    background: rgba(245, 158, 11, 0.10);
}

.strategy-lib-item .lib-item-meta {
    gap: 5px;
    align-items: flex-start;
}

.strategy-lib-item .lib-item-meta > span:first-child {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 38px;
    overflow: hidden;
    min-width: 0;
    flex: 1 1 auto;
}

.strategy-lib-item.strategy-lib-running.strategy-lib-rt {
    background: linear-gradient(90deg, rgba(20, 184, 166, 0.18), rgba(15, 23, 42, 0.03));
    border-left-color: #14b8a6;
}

.strategy-lib-item.strategy-lib-running.strategy-lib-hist {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.18), rgba(15, 23, 42, 0.03));
    border-left-color: #f59e0b;
}

.strategy-lib-item.strategy-lib-deployed:not(.strategy-lib-running) {
    background: transparent;
    border-left-color: rgba(148, 163, 184, 0.28);
}

.strategy-lib-item.strategy-lib-community {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.10), rgba(15, 23, 42, 0.02));
    border-left-color: #10b981;
}

.strategy-lib-item.strategy-lib-permutation {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.10), rgba(15, 23, 42, 0.02));
    border-left-color: #f59e0b;
}

.strategy-lib-item.selected {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.20), rgba(168, 85, 247, 0.08));
    box-shadow: inset 3px 0 0 #818cf8;
}

.strategy-lib-item.strategy-lib-rt .strategy-lib-icon { color: #2dd4bf; }
.strategy-lib-item.strategy-lib-hist .strategy-lib-icon { color: #fbbf24; }
.strategy-lib-item.strategy-lib-community .strategy-lib-icon { color: #34d399; }
.strategy-lib-item.strategy-lib-permutation .strategy-lib-icon { color: #fbbf24; }

.strategy-lib-cat {
    border: 1px solid transparent;
    max-width: 86px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.strategy-lib-cat-source {
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.13);
    border-color: rgba(139, 92, 246, 0.28);
}

.strategy-lib-cat-runtime {
    color: #f8fafc;
    background: rgba(71, 85, 105, 0.55);
    border-color: rgba(148, 163, 184, 0.22);
}

.strategy-lib-rt .strategy-lib-cat-runtime {
    color: #5eead4;
    background: rgba(20, 184, 166, 0.14);
    border-color: rgba(20, 184, 166, 0.36);
}

.strategy-lib-hist .strategy-lib-cat-runtime {
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.36);
}

.strategy-lib-cat-running {
    color: #86efac;
    background: rgba(34, 197, 94, 0.13);
    border-color: rgba(34, 197, 94, 0.34);
}

.strategy-lib-cat-deployed {
    color: #bbf7d0;
    background: rgba(22, 163, 74, 0.14);
    border-color: rgba(22, 163, 74, 0.34);
}

.strategy-lib-cat-symbol {
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.30);
}

.strategy-lib-cat-count {
    color: #fde68a;
    background: rgba(180, 83, 9, 0.12);
    border-color: rgba(245, 158, 11, 0.26);
}

.strategy-lib-status {
    color: #93c5fd;
    font-weight: 700;
    flex: 0 0 auto;
    max-width: 58px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.strategy-lib-running .strategy-lib-status {
    color: #86efac;
}

.strategy-lib-hist.strategy-lib-running .strategy-lib-status {
    color: #fcd34d;
}

.strategy-lib-add-btn {
    margin-top: 7px;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.10);
    color: #34d399;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    align-self: flex-start;
}

.strategy-lib-add-btn:hover {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.52);
}

.lib-section-header {
    padding: 7px 12px;
    min-height: 26px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    position: static;
    display: flex;
    align-items: center;
    gap: 6px;
    scroll-snap-align: start;
}

.lib-section-header.user-section {
    color: var(--accent-green);
    background: rgba(16, 185, 129, 0.08);
}

.lib-section-header.community-section {
    color: var(--accent-purple);
    background: rgba(168, 85, 247, 0.08);
}

/* Expand button when sidebar collapsed */
.library-expand-btn {
    position: fixed;
    left: 8px;
    top: 78px;
    width: 42px;
    height: 42px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--accent-purple);
    box-shadow: 2px 2px 8px rgba(0,0,0,0.4);
    z-index: 60;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 51;
    transition: all 0.2s;
    overflow: hidden;
}

.library-expand-btn:hover {
    background: var(--bg-elevated);
    width: 42px;
}

.library-expand-btn span {
    display: none;
}

/* Drop zone highlights */
.side-panel.drop-highlight {
    border-color: var(--accent-purple) !important;
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.3) !important;
    background: rgba(168, 85, 247, 0.05);
}

/* ═══ Notification Channels Section ═══ */
.channels-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    margin-bottom: var(--gap-lg);
}

.channels-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap-md);
}

.channels-header label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.settings-exchanges-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.provider-featured-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(15, 23, 42, 0.96));
    border-color: rgba(99, 102, 241, 0.28);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
}

.provider-featured-card:hover {
    border-color: rgba(129, 140, 248, 0.48);
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.16);
}

.channel-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 9px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
}

.channel-card:hover {
    border-color: var(--accent-blue);
    background: var(--bg-elevated);
}

.channel-card.active {
    border-color: var(--accent-green);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(34, 197, 94, 0.08));
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.16), 0 0 20px rgba(16, 185, 129, 0.08);
}

.gts-strategy-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.gts-strategy-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

/* CONFIG / STATS tabbed card — shared by Config, Permutations, Community on
   the My Strategies page so all three tabs render the same strategy card. */
.gts-card-tabs {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.gts-card-tabbar {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.gts-card-tab {
    flex: 0 0 auto;
    padding: 5px 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .4px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all .15s;
}

.gts-card-tab.active {
    color: var(--accent-blue-hover);
    border-bottom-color: var(--accent-blue);
    background: rgba(99, 102, 241, .08);
}

.gts-card-tabpanel {
    padding: 8px;
}

.gts-card-stats-empty {
    font-size: 11px;
    color: var(--text-muted);
    padding: 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.gts-card-stats-empty i {
    font-size: 18px;
    opacity: .5;
}

/* Inline expandable expression chips inside the flow card */
.gts-expr-chip {
    transition: background .15s;
}

.gts-expr-chip:hover {
    background: rgba(167, 139, 250, 0.2) !important;
}

.gts-expr-detail {
    background: rgba(167, 139, 250, 0.06);
    border: 1px solid rgba(167, 139, 250, 0.22);
    border-left: 3px solid var(--accent-purple);
    border-radius: 5px;
    padding: 7px 10px;
    font-size: 10px;
    color: var(--text-secondary);
}

.gts-expr-detail-head {
    font-size: 10px;
    font-weight: 700;
    color: #c4b5fd;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 3px;
}

.gts-expr-detail-summary {
    font-family: var(--font-mono), monospace;
    color: var(--text-primary);
    word-break: break-word;
}

.gts-expr-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    font-size: 9px;
    color: var(--text-muted);
}

.gts-expr-detail-empty {
    color: var(--text-muted);
    font-style: italic;
}

.gts-expr-kind {
    margin-left: auto;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .4px;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.gts-expr-kind.alert {
    color: var(--accent-orange);
    background: rgba(245, 158, 11, .14);
}

.gts-expr-kind.helper {
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, .12);
}

.gts-expr-rows {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
    margin-top: 6px;
}

.gts-expr-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 10px;
    padding: 3px 7px;
    background: rgba(148, 163, 184, .06);
    border-radius: 4px;
}

.gts-expr-row span {
    color: var(--text-muted);
}

.gts-expr-row strong {
    color: var(--text-primary);
    font-family: var(--font-mono), monospace;
    text-align: right;
    word-break: break-word;
}

/* Recursive value row spans full width so the nested detail can open below it. */
.gts-expr-row-ref {
    grid-column: 1 / -1;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

.gts-expr-count {
    margin-left: auto;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .3px;
    padding: 1px 6px;
    border-radius: 3px;
    color: var(--accent-purple);
    background: rgba(167, 139, 250, .14);
}

/* When both the count and kind badges are present, keep them grouped right. */
.gts-expr-detail-head .gts-expr-count + .gts-expr-kind {
    margin-left: 6px;
}

.gts-strategy-row-main {
    min-width: 0;
    flex: 1;
}

.gts-strategy-row-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin-bottom: 4px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
}

.gts-strategy-row-title-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gts-strategy-row-desc {
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.45;
    margin-bottom: 6px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gts-strategy-row-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.gts-strategy-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.18);
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1;
}

.gts-strategy-badge.community {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.22);
    color: #34d399;
}

.gts-strategy-badge.permutation {
    background: rgba(245, 158, 11, 0.09);
    border-color: rgba(245, 158, 11, 0.24);
    color: #fbbf24;
}

.gts-strategy-badge.symbol {
    background: rgba(56, 189, 248, 0.08);
    border-color: rgba(56, 189, 248, 0.22);
    color: #7dd3fc;
}

.gts-strategy-row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.gts-strategy-row-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.my-expression-card {
    background: var(--bg-card);
    border: 1px solid rgba(99, 102, 241, 0.26);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    min-width: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.my-expression-card:hover {
    border-color: rgba(129, 140, 248, 0.44);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.18);
}

.my-expression-card.is-deployed-alert {
    background: linear-gradient(180deg, rgba(48, 55, 85, 0.78), rgba(30, 36, 58, 0.92));
    border-color: rgba(129, 140, 248, 0.78);
}

.my-expression-main {
    flex: 1;
    min-width: 0;
}

.my-expression-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.my-expression-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.my-expression-summary {
    color: #e2e8f0;
    font-size: 12px;
    line-height: 1.35;
    margin-bottom: 7px;
}

.my-expression-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin-bottom: 7px;
}

.my-expression-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(30, 41, 59, 0.7);
    color: #cbd5e1;
}

.my-expression-pill.path {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.22);
    color: #c7d2fe;
}

.my-expression-stats {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 5px 14px;
}

.my-expression-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 11px;
}

.my-expression-stat i {
    width: 12px;
    text-align: center;
}

.my-expression-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-shrink: 0;
    align-items: center;
    max-width: 48%;
}

.my-expression-action-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 11px;
    border-radius: 7px;
    cursor: pointer;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(30, 41, 59, 0.86);
    color: var(--text-secondary);
}

.my-expression-action-btn.primary {
    background: rgba(99, 102, 241, 0.22);
    border-color: rgba(99, 102, 241, 0.32);
    color: #c7d2fe;
}

.my-expression-action-btn.success {
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.28);
    color: #86efac;
}

.my-expression-action-btn.danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.28);
    color: #fecaca;
}

@media (max-width: 960px) {
    .my-expression-card {
        flex-direction: column;
        align-items: stretch;
    }

    .my-expression-actions {
        justify-content: flex-start;
    }

    .my-expression-title {
        white-space: normal;
    }
}

.gts-strategy-row-btn:hover {
    border-color: rgba(148, 163, 184, 0.28);
    color: var(--text-primary);
}

.gts-strategy-row-btn.primary {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.06);
    color: #22c55e;
}

.gts-strategy-row-btn.primary:hover {
    border-color: rgba(34, 197, 94, 0.62);
    background: rgba(34, 197, 94, 0.1);
}

.channel-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.channel-icon.email {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-blue);
}

.channel-icon.telegram {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
}

.channel-icon.whatsapp {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.channel-icon.sms {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

.channel-icon.webhook {
    background: rgba(168, 85, 247, 0.15);
    color: var(--accent-purple);
}

.channel-icon.discord {
    background: rgba(88, 101, 242, 0.16);
    color: #9ba7ff;
}

.channel-icon.phone {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.channel-icon.screen {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}

.channel-info {
    flex: 1;
    min-width: 0;
}

.channel-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-detail {
    font-size: 9px;
    color: var(--text-muted);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.channel-toggle {
    width: 32px;
    height: 18px;
    border-radius: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.channel-toggle.on {
    background: var(--accent-green);
    border-color: var(--accent-green);
}

.channel-toggle::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.channel-toggle.on::after {
    transform: translateX(14px);
}

/* Responsive: hide sidebar on small screens */
@media (max-width: 1024px) {
    .library-sidebar {
        position: fixed;
        left: 0;
        top: 56px;
        z-index: 100;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
}

/* ═══ Light Theme ═══ */
[data-theme="light"] {
    --bg-primary: #e8edf4;
    --bg-secondary: #f1f5f9;
    --bg-card: #f8fafd;
    --bg-card-hover: #edf1f7;
    --bg-input: #ffffff;
    --bg-elevated: #dde4ee;

    --border: #bfc9d9;
    --border-focus: #6366f1;
    --border-hover: #8494a7;

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #475569;
    --text-dim: #64748b;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* Light theme — Signal Monitor stat cards with colored tints */
[data-theme="light"] #signal-stats>div {
    border-color: #bfc9d9;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] #signal-stats>div:nth-child(1) {
    background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
    border-left: 3px solid #10b981;
}

[data-theme="light"] #signal-stats>div:nth-child(2) {
    background: linear-gradient(135deg, #ecfeff, #f0f9ff);
    border-left: 3px solid #06b6d4;
}

[data-theme="light"] #signal-stats>div:nth-child(3) {
    background: linear-gradient(135deg, #eff6ff, #eef2ff);
    border-left: 3px solid #6366f1;
}

[data-theme="light"] #signal-stats>div:nth-child(4) {
    background: linear-gradient(135deg, #fef2f2, #fff1f2);
    border-left: 3px solid #ef4444;
}

[data-theme="light"] #signal-stats>div:nth-child(5) {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border-left: 3px solid #f59e0b;
}

/* Light theme — Signal Monitor table */
[data-theme="light"] #signal-table thead tr {
    background: #e2e8f0 !important;
}

[data-theme="light"] #signal-table th {
    color: #334155 !important;
    border-bottom: 2px solid #bfc9d9 !important;
}

[data-theme="light"] #signal-table td {
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] #signal-table tbody tr:hover {
    background: #f1f5f9;
}

/* Light theme — page backgrounds and cards */
[data-theme="light"] .page-content {
    color: #1e293b;
}

[data-theme="light"] .page-header h1 {
    color: #0f172a;
}

[data-theme="light"] .page-subtitle {
    color: #475569;
}

/* Light theme — Signal pagination */
[data-theme="light"] #signal-pagination button {
    background: #f1f5f9 !important;
    color: #334155 !important;
    border: 1px solid #bfc9d9 !important;
}

[data-theme="light"] #signal-pagination button:hover {
    background: #e2e8f0 !important;
}

/* Light theme — dropdowns/filters better visibility */
[data-theme="light"] #signal-channel-filter,
[data-theme="light"] #signal-status-filter {
    background: #f1f5f9 !important;
    border-color: #94a3b8 !important;
    color: #1e293b !important;
    font-weight: 500;
}

/* Light theme — search box */
[data-theme="light"] .indicator-search {
    background: #ffffff !important;
    border: 1px solid #94a3b8 !important;
}

[data-theme="light"] .indicator-search input {
    color: #0f172a !important;
}

/* Light theme — expression cards better contrast */
[data-theme="light"] .page-content .channels-grid>div {
    border-color: #bfc9d9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .top-nav {
    background: rgba(255, 255, 255, 0.9);
    border-bottom-color: var(--border);
}

[data-theme="light"] .nav-link {
    color: #475569;
}

[data-theme="light"] .nav-link:hover {
    color: #334155;
    background: linear-gradient(135deg, rgba(191, 219, 254, 0.34), rgba(216, 180, 254, 0.28));
}

[data-theme="light"] .nav-link.active {
    color: #5b5bd6;
    background: linear-gradient(135deg, rgba(186, 230, 253, 0.42), rgba(221, 214, 254, 0.52));
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.22);
}

[data-theme="light"] .embedded-elements-nav {
    background: #ffffff;
    border-bottom: 1px solid #d0d9e6;
    box-shadow: 0 10px 24px rgba(148, 163, 184, 0.12);
}

[data-theme="light"] .embedded-elements-tab {
    background: #f8fafd;
    color: #64748b;
    border-color: #d0d9e6;
}

[data-theme="light"] .embedded-elements-tab:hover {
    color: #334155;
    background: linear-gradient(135deg, rgba(191, 219, 254, 0.34), rgba(216, 180, 254, 0.22));
    border-color: rgba(129, 140, 248, 0.24);
}

[data-theme="light"] .embedded-elements-tab.active {
    color: #0f172a;
    background: linear-gradient(135deg, rgba(186, 230, 253, 0.42), rgba(221, 214, 254, 0.52));
    border-color: rgba(129, 140, 248, 0.28);
    box-shadow: inset 0 -2px 0 rgba(6, 182, 212, 0.9);
}

[data-theme="light"] .embedded-elements-tab i {
    color: #0ea5e9;
}

[data-theme="light"] .quota-badge {
    background: #f8fafc;
    color: #475569;
    border-color: #cbd5e1;
}

[data-theme="light"] .library-sidebar,
[data-theme="light"] .library-header,
[data-theme="light"] .library-search,
[data-theme="light"] .library-tabs,
[data-theme="light"] .library-footer {
    background: #f8fafd;
}

[data-theme="light"] .library-mode-filters {
    border-bottom: 1px solid #d0d9e6;
    background: #f8fafd;
}

[data-theme="light"] .lib-tab {
    color: #64748b;
}

[data-theme="light"] .lib-tab:hover {
    color: #0f172a;
    background: #f8fafc;
}

[data-theme="light"] .lib-tab.active {
    color: #7c3aed;
    background: rgba(168, 85, 247, 0.08);
}

[data-theme="light"] .lib-mode-filter {
    background: #f8fafd;
    color: #64748b;
    border-color: #d0d9e6;
}

[data-theme="light"] .lib-mode-filter:hover {
    color: #0f172a;
    border-color: rgba(34, 211, 238, 0.35);
    background: #f8fafc;
}

[data-theme="light"] .lib-item {
    border-bottom: 1px solid rgba(208, 217, 230, 0.7);
}

[data-theme="light"] .lib-item:hover {
    background: #f8fafc;
}

[data-theme="light"] .lib-item.selected {
    background: linear-gradient(90deg, rgba(96, 165, 250, 0.12), rgba(34, 211, 238, 0.06));
}

[data-theme="light"] .lib-item.selected .lib-item-name {
    color: #0f172a;
}

[data-theme="light"] .lib-item.selected .lib-item-desc {
    color: #475569;
}

[data-theme="light"] #page-expressions select,
[data-theme="light"] #page-strategies select,
[data-theme="light"] #page-signals select,
[data-theme="light"] #page-charts select,
[data-theme="light"] #page-expressions input[type="text"],
[data-theme="light"] #page-strategies input[type="text"],
[data-theme="light"] #page-signals input[type="text"] {
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
    color-scheme: light;
}

[data-theme="light"] #page-expressions select,
[data-theme="light"] #page-strategies select,
[data-theme="light"] #page-signals select,
[data-theme="light"] #page-charts select {
    background-image:
        linear-gradient(45deg, transparent 50%, #64748b 50%),
        linear-gradient(135deg, #64748b 50%, transparent 50%) !important;
}

[data-theme="light"] #page-expressions select option,
[data-theme="light"] #page-strategies select option,
[data-theme="light"] #page-signals select option,
[data-theme="light"] #page-charts select option {
    background: #ffffff;
    color: #0f172a;
}

[data-theme="light"] .preview-json {
    background: #1e293b;
    color: #e2e8f0;
}

[data-theme="light"] .channel-toggle {
    background: #cbd5e1;
}

/* ─── Light theme v2 — Builder panels, brand indigo/violet axis ─── */

/* LEFT/RIGHT labels: deeper, quieter — less neon on light bg */
[data-theme="light"] .left-label  { color: #312e81; }
[data-theme="light"] .right-label { color: #5b21b6; }

/* Side panels: tuned-down off-white (less bright), brand-tinted elevation */
[data-theme="light"] .side-panel {
    background: #f3f4fa;
    border-color: #cbcfdf;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 14px rgba(99, 102, 241, 0.06);
}
[data-theme="light"] .left-panel:hover {
    border-color: #6366f1;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.22), 0 6px 18px rgba(99, 102, 241, 0.12);
}
[data-theme="light"] .right-panel:hover {
    border-color: #a855f7;
    box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.22), 0 6px 18px rgba(168, 85, 247, 0.12);
}
[data-theme="light"] .side-header { border-bottom-color: #e4e6f1; }

/* "ELEMENT TYPE" eyebrow: heavier, more visible */
[data-theme="light"] .element-type-section label {
    color: #3f4664;
    font-weight: 700;
}

/* Element-type cards: white-on-tinted-panel for visible separation, dark+heavy text */
[data-theme="light"] .elem-type-btn {
    background: #ffffff;
    border-color: #c7cad9;
    color: #0b1220;
    font-weight: 650;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), inset 0 -1px 0 rgba(15, 23, 42, 0.04);
}
[data-theme="light"] .elem-type-btn:hover {
    background: #f3f1ff;
    border-color: #6366f1;
    color: #0b1220;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.22), 0 4px 12px rgba(99, 102, 241, 0.12);
}
[data-theme="light"] .elem-type-btn.selected {
    background: #ebe9ff;
    border-color: #6366f1;
    color: #312e81;
    box-shadow: inset 0 0 0 1.5px #6366f1, 0 4px 12px rgba(99, 102, 241, 0.16);
}
[data-theme="light"] .elem-type-btn:disabled,
[data-theme="light"] .element-type-grid.is-locked .elem-type-btn {
    background: #f1f1f7;
    color: #9ca0b8;
    border-color: #e2e3ee;
}
[data-theme="light"] .elem-type-icon { background: rgba(67, 56, 202, 0.06); }

/* Category-tinted card borders, brand-aligned pastels */
[data-theme="light"] .elem-type-btn.cat-technical   { border-color: #c7d2fe; }
[data-theme="light"] .elem-type-btn.cat-price       { border-color: #bbf7d0; }
[data-theme="light"] .elem-type-btn.cat-pattern     { border-color: #ddd6fe; }
[data-theme="light"] .elem-type-btn.cat-utility     { border-color: #fde68a; }
[data-theme="light"] .elem-type-btn.cat-fundamental { border-color: #a5f3fc; }
[data-theme="light"] .elem-type-btn.cat-trading     { border-color: #f9a8d4; }

/* Category icon hues: darker, legible on the off-white card */
[data-theme="light"] .elem-type-btn.cat-technical   .elem-type-icon { color: #4338ca; }
[data-theme="light"] .elem-type-btn.cat-price       .elem-type-icon { color: #047857; }
[data-theme="light"] .elem-type-btn.cat-pattern     .elem-type-icon { color: #7c3aed; }
[data-theme="light"] .elem-type-btn.cat-utility     .elem-type-icon { color: #b45309; }
[data-theme="light"] .elem-type-btn.cat-fundamental .elem-type-icon { color: #0e7490; }
[data-theme="light"] .elem-type-btn.cat-trading     .elem-type-icon { color: #be185d; }

/* Element config (body below type cards): match tuned-down panel */
[data-theme="light"] .element-config {
    background: #f3f4fa;
    border-color: #cbcfdf;
}

/* EXPRESSION NAME action buttons (copy + magic-wand auto-gen): distinct + on-brand */
[data-theme="light"] .btn-auto-name {
    background: #ffffff;
    border: 1px solid #c7cad9;
    color: #4338ca;
}
[data-theme="light"] .btn-auto-name:hover {
    background: #f3f1ff;
    border-color: #6366f1;
    color: #312e81;
}
[data-theme="light"] .btn-auto-name--ghost { color: #3f4664; opacity: 0.85; }
[data-theme="light"] .btn-auto-name--ghost:hover {
    background: #f3f1ff;
    border-color: #6366f1;
    color: #4338ca;
    opacity: 1;
}

/* ─── Light theme — beat inline dark-theme colors (visitor banner, user pill, counters) ─── */

/* Visitor banner: was lavender #c7d2fe on faint tint → invisible on white */
[data-theme="light"] #builder-visitor-banner {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.10), rgba(168, 85, 247, 0.06)) !important;
    border: 1px solid rgba(99, 102, 241, 0.35) !important;
    color: #1f2540 !important;
}
[data-theme="light"] #builder-visitor-banner strong { color: #0b1220 !important; }
[data-theme="light"] #builder-visitor-banner i { color: #4338ca !important; }

/* Sign-In button inside visitor banner */
[data-theme="light"] #builder-visitor-banner button {
    background: #6366f1 !important;
    border-color: #4f46e5 !important;
    color: #ffffff !important;
}
[data-theme="light"] #builder-visitor-banner button:hover {
    background: #4f46e5 !important;
}

@media (max-width: 1100px) {
    #builder-visitor-banner {
        width: 100% !important;
        max-width: none !important;
        margin-left: 0 !important;
    }
}

/* User-avatar pill in top nav (lavender on white = invisible) */
[data-theme="light"] #user-avatar-btn {
    background: rgba(99, 102, 241, 0.10) !important;
    border-color: rgba(99, 102, 241, 0.45) !important;
    color: #312e81 !important;
}
[data-theme="light"] #user-avatar-btn:hover {
    background: rgba(99, 102, 241, 0.18) !important;
}

/* "0 chars" counter pill: was dark slab + muted gray text */
[data-theme="light"] .expression-counter-pill {
    background: #eef0f7 !important;
    border-color: #c7cad9 !important;
    color: #1f2540 !important;
}

/* NLP example pills (RSI(14) < 30, SMA(50) > SMA(200), etc.) */
[data-theme="light"] .nlp-example {
    background: #ffffff;
    border-color: #c7cad9;
    color: #1f2540;
}
[data-theme="light"] .nlp-example:hover {
    border-color: #7c3aed;
    color: #5b21b6;
    background: #faf7ff;
}

/* Input placeholder text — darker so prompts read */
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder {
    color: #6b7188 !important;
    opacity: 1;
}

/* Save & Update Runtime button: black label on light theme */
[data-theme="light"] .btn-save { color: #0b1220; }
[data-theme="light"] .btn-save i { color: #0b1220; }

/* Library sidebar text bump: weak gray → stronger #1f2540, brand-tinted bg */
[data-theme="light"] .library-sidebar,
[data-theme="light"] .library-header,
[data-theme="light"] .library-search,
[data-theme="light"] .library-tabs,
[data-theme="light"] .library-mode-filters,
[data-theme="light"] .library-footer {
    background: #f3f4fa;
}
[data-theme="light"] .lib-tab { color: #1f2540; font-weight: 600; }
[data-theme="light"] .lib-tab:hover { color: #0b1220; }
[data-theme="light"] .lib-tab.active { font-weight: 700; }
[data-theme="light"] .lib-mode-filter {
    background: #ffffff;
    color: #1f2540;
    border-color: #c7cad9;
    font-weight: 600;
}
[data-theme="light"] .lib-item-desc { color: #3f4664; }
[data-theme="light"] .lib-item-name { color: #0b1220; }

/* Small badges + section headers — accent colors too pale on white */
[data-theme="light"] .lib-tab-count { color: #0e7490; }
[data-theme="light"] .lib-item-subs { color: #0e7490; font-weight: 600; }
[data-theme="light"] .lib-item-cat {
    background: #eef0f7;
    color: #1f2540;
    font-size: 9px;
}
[data-theme="light"] .lib-item-cat.momentum { color: #92400e; background: rgba(245,158,11,0.18); }
[data-theme="light"] .lib-item-cat.trend { color: #3730a3; background: rgba(99,102,241,0.16); }
[data-theme="light"] .lib-item-cat.volatility { color: #991b1b; background: rgba(239,68,68,0.16); }
[data-theme="light"] .lib-item-cat.candle { color: #065f46; background: rgba(16,185,129,0.16); }
[data-theme="light"] .lib-item-cat.composite { color: #6b21a8; background: rgba(168,85,247,0.16); }
[data-theme="light"] .lib-item-cat.user { color: #0e7490; background: rgba(6,182,212,0.16); }
[data-theme="light"] .lib-item-cat.mode-helper { color: #6b21a8; background: rgba(167,139,250,0.18); }
[data-theme="light"] .lib-item-cat.mode-alert { color: #047857; background: rgba(52,211,153,0.20); }
[data-theme="light"] .lib-item-cat.mode-state-machine { color: #1d4ed8; background: rgba(96,165,250,0.18); }
[data-theme="light"] .library-header h3 { color: #0b1220; }
[data-theme="light"] .library-header h3 i { color: #7c3aed; }
[data-theme="light"] .library-search input { color: #0b1220; }
[data-theme="light"] .lib-section-header.user-section {
    color: #047857;
    background: rgba(16,185,129,0.14);
    border-bottom-color: rgba(16,185,129,0.28);
}
[data-theme="light"] .lib-section-header.community-section {
    color: #6b21a8;
    background: rgba(168,85,247,0.14);
    border-bottom-color: rgba(168,85,247,0.28);
}

/* lib-item-cat with INLINE dark-theme hex colors — beat with attr selector */
[data-theme="light"] .lib-item-cat[style*="#fbbf24"] {
    color: #92400e !important;
    background: rgba(245,158,11,0.20) !important;
    border-color: rgba(245,158,11,0.40) !important;
}
[data-theme="light"] .lib-item-cat[style*="#cbd5e1"] {
    color: #1f2540 !important;
    background: #eef0f7 !important;
    border-color: #c7cad9 !important;
}
[data-theme="light"] .lib-item-cat[style*="#86efac"] {
    color: #047857 !important;
    background: rgba(16,185,129,0.20) !important;
    border-color: rgba(16,185,129,0.40) !important;
}
[data-theme="light"] .lib-item-cat[style*="#c4b5fd"] {
    color: #6b21a8 !important;
    background: rgba(168,85,247,0.20) !important;
    border-color: rgba(168,85,247,0.40) !important;
}
[data-theme="light"] .lib-item-cat[style*="#7dd3fc"] {
    color: #0e7490 !important;
    background: rgba(14,165,233,0.20) !important;
    border-color: rgba(14,165,233,0.40) !important;
}
[data-theme="light"] .lib-item-cat.lib-tree-count {
    color: #1f2540 !important;
    background: #eef0f7 !important;
    border-color: #c7cad9 !important;
}

/* Broad catch-all for any remaining inline-styled lib-item-cat with rgba(14,165,233,...) */
[data-theme="light"] .lib-item-cat[style*="rgba(14,165,233"],
[data-theme="light"] .lib-item-cat[style*="rgba(14, 165, 233"] {
    color: #0e7490 !important;
    background: rgba(14, 165, 233, 0.20) !important;
    border-color: rgba(14, 165, 233, 0.40) !important;
}

/* Plans & Pricing tiles: hardcoded dark gradient by default, invisible in light */
[data-theme="light"] .pricing-card {
    background:
        radial-gradient(circle at top, rgba(99, 102, 241, 0.10), transparent 45%),
        linear-gradient(180deg, #ffffff, #f6f7fc) !important;
    border: 1px solid #c7cad9;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
    color: #0b1220;
}
[data-theme="light"] .pricing-card-featured {
    border-color: #6366f1;
    box-shadow: 0 14px 40px rgba(99, 102, 241, 0.16);
}
[data-theme="light"] .pricing-card-current {
    border-color: #10b981;
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.14);
}
[data-theme="light"] .pricing-icon {
    border-color: rgba(99, 102, 241, 0.22);
    background: rgba(99, 102, 241, 0.08);
    color: #4338ca;
}
[data-theme="light"] .pricing-plan-name { color: #0b1220; }
[data-theme="light"] .pricing-plan-desc { color: #3f4664; }
[data-theme="light"] .pricing-currency,
[data-theme="light"] .pricing-amount { color: #0b1220; }

/* GTS University page: +10% width when active (if present) */
.app-container:has(> #page-university[style*="display: block"]),
.app-container:has(> #page-university[style*="display:block"]),
.app-container:has(> #page-university[style*="display: flex"]),
.app-container:has(> #page-university[style*="display:flex"]) {
    max-width: 1540px;
}

/* Plans page usage stat tiles — gray (dark slab) to white */
[data-theme="light"] #plans-usage-panel > div {
    background: #ffffff !important;
    border-color: #c7cad9 !important;
}
[data-theme="light"] #plans-usage-panel > div[style*="rgba(239,68,68"] {
    background: rgba(239, 68, 68, 0.10) !important;
    border-color: rgba(239, 68, 68, 0.45) !important;
}
[data-theme="light"] #plans-usage-panel > div > div:first-child { color: #3f4664 !important; }
[data-theme="light"] #plans-usage-panel > div > div:nth-child(2) { color: #0b1220 !important; }
[data-theme="light"] button[onclick="cancelUserPlan()"] {
    background: rgba(239, 68, 68, 0.10) !important;
    color: #991b1b !important;
    border-color: rgba(239, 68, 68, 0.45) !important;
}

/* Plans page area-frames + comparison table — match white "Logged in as" card */
[data-theme="light"] .pricing-area {
    background: #ffffff;
    border: 1px solid #c7cad9;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 14px rgba(99, 102, 241, 0.06);
}
[data-theme="light"] .pricing-area-kicker {
    background: rgba(99, 102, 241, 0.10);
    border-color: rgba(99, 102, 241, 0.40);
    color: #312e81;
}
[data-theme="light"] .pricing-area-pill {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.40);
    color: #047857;
}
[data-theme="light"] .pricing-area-pill-muted {
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.42);
    color: #92400e;
}
[data-theme="light"] .pricing-area-header h2 { color: #0b1220; }
[data-theme="light"] .pricing-area-header p { color: #3f4664; }
[data-theme="light"] .pricing-comparison-table-wrap {
    background: linear-gradient(180deg, #ffffff, #f6f7fc) !important;
    border: 1px solid #c7cad9;
}
[data-theme="light"] .pricing-comparison-table th,
[data-theme="light"] .pricing-comparison-table td {
    color: #1f2540;
    border-bottom-color: #e4e6f1;
}
[data-theme="light"] .pricing-comparison-table th {
    color: #3f4664;
    background: rgba(99, 102, 241, 0.06);
}
[data-theme="light"] .pricing-table-pro-col { color: #6b21a8 !important; }
[data-theme="light"] .pricing-table-category td {
    color: #4338ca;
    background: rgba(99, 102, 241, 0.10);
}
[data-theme="light"] .pricing-check { color: #047857; }
[data-theme="light"] .pricing-x { color: #b91c1c; }

/* Expression Tree visualization — gray slabs + dark navy tab strip */
[data-theme="light"] #tree-viz-canvas {
    background: #ffffff !important;
    border-color: #c7cad9 !important;
}
[data-theme="light"] #tree-viz-side {
    background: #ffffff !important;
    border-color: #c7cad9 !important;
}
[data-theme="light"] #tree-viz-side .tree-side-tabs {
    background: #ffffff !important;
    border-bottom-color: #e4e6f1 !important;
}
[data-theme="light"] .tree-side-tab {
    background: #ffffff !important;
    color: #3f4664 !important;
    border-color: #c7cad9 !important;
}
[data-theme="light"] .tree-side-tab.active,
[data-theme="light"] .tree-side-tab[style*="rgba(99,102,241,0.18)"] {
    background: rgba(99, 102, 241, 0.12) !important;
    color: #312e81 !important;
    border-color: #6366f1 !important;
}
[data-theme="light"] .tree-canvas-counter {
    background: #ffffff !important;
    border-color: #c7cad9 !important;
    color: #0e7490 !important;
}
[data-theme="light"] .tree-counter-pill {
    background: rgba(6, 182, 212, 0.12);
    border-color: rgba(6, 182, 212, 0.40);
    color: #0e7490;
}

/* Channel-detail subtext ("Paid plans only. Free includes ...") */
[data-theme="light"] .channel-detail {
    color: #1f2540;
    font-weight: 600;
    font-size: 10px;
}

/* Expression viewer modal (Details / Outline / Deploy): dark-theme-only by default */
[data-theme="light"] .expression-viewer-modal {
    background: #fbfbfe !important;
    color: #0b1220;
    border: 1px solid #c7cad9;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.18);
}
[data-theme="light"] .expression-viewer-head {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(168, 85, 247, 0.04));
    border-bottom: 1px solid #e4e6f1;
}
[data-theme="light"] .expression-viewer-title-wrap h4 { color: #0b1220; }
[data-theme="light"] .expression-viewer-title-wrap h4 i { color: #4338ca; }
[data-theme="light"] .expression-viewer-meta { color: #3f4664; }
[data-theme="light"] .expression-viewer-meta > span {
    background: #ffffff;
    border: 1px solid #c7cad9;
    color: #1f2540;
}
[data-theme="light"] .expression-viewer-close {
    background: #ffffff;
    border: 1px solid #c7cad9;
    color: #1f2540;
}
[data-theme="light"] .expression-viewer-summary {
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.22);
    color: #0b1220;
}
[data-theme="light"] .expression-viewer-stage {
    background: #ffffff;
    border: 1px solid #d4d6e6;
}
[data-theme="light"] .expression-viewer-outline-shell {
    background: #ffffff;
    border: 1px solid #d4d6e6;
}
[data-theme="light"] .expression-viewer-details-shell {
    background: #ffffff;
    border: 1px solid #c7d2fe;
}
[data-theme="light"] .expression-viewer-outline-title { color: #1f2540; }
[data-theme="light"] .expression-viewer-outline-title-accent { color: #7c3aed; }
[data-theme="light"] .expression-viewer-detail-row {
    border-bottom-color: #e4e6f1;
}
[data-theme="light"] .expression-viewer-detail-key {
    color: #3f4664;
    font-weight: 600;
}
[data-theme="light"] .expression-viewer-detail-value { color: #0b1220; }

/* Glassy app-alert-modal: opaque enough on light bg to read body text */
[data-theme="light"] .modal-content.app-alert-modal {
    background-color: #ffffff !important;
    background-image: linear-gradient(135deg, rgba(99, 102, 241, 0.06) 0%, rgba(255, 255, 255, 0.95) 50%, rgba(168, 85, 247, 0.06) 100%) !important;
    border: 1px solid #c7cad9 !important;
    box-shadow:
        0 18px 56px rgba(99, 102, 241, 0.18),
        0 4px 16px rgba(15, 23, 42, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
    color: #0b1220;
}
[data-theme="light"] .modal-content.app-alert-modal .modal-header {
    background: rgba(99, 102, 241, 0.06);
    border-bottom: 1px solid #e4e6f1;
}
[data-theme="light"] .modal-content.app-alert-modal .modal-header h4 { color: #0b1220; }
[data-theme="light"] .modal-content.app-alert-modal .modal-body { color: #1f2540; }

/* ═══ Trader Theme ═══ */
[data-theme="trader"] {
    --bg-primary: #121a2a;
    --bg-secondary: #182338;
    --bg-card: #21304a;
    --bg-card-hover: #293b59;
    --bg-input: #172235;
    --bg-elevated: #314562;

    --border: #44597e;
    --border-focus: #9eacff;
    --border-hover: #587099;

    --text-primary: #f5f8ff;
    --text-secondary: #c7d3ee;
    --text-muted: #a1b2d5;
    --text-dim: #7c8eb2;

    --accent-blue: #9eacff;
    --accent-blue-hover: #bac5ff;
    --accent-blue-glow: rgba(158, 172, 255, 0.16);
    --accent-green: #84d6c7;
    --accent-green-glow: rgba(132, 214, 199, 0.12);
    --accent-orange: #f5c37c;
    --accent-red: #f08da0;
    --accent-purple: #b8a4ff;
    --accent-cyan: #97ddff;
    --accent-pink: #e2b3ff;

    --left-color: #97ddff;
    --left-glow: rgba(151, 221, 255, 0.1);
    --right-color: #84d6c7;
    --right-glow: rgba(132, 214, 199, 0.1);
    --op-color: #f5c37c;
    --op-glow: rgba(245, 195, 124, 0.1);
}

[data-theme="trader"] .top-nav {
    background: rgba(18, 26, 42, 0.95);
    border-bottom-color: rgba(68, 89, 126, 0.88);
}

[data-theme="trader"] .nav-link.active {
    color: #f7f9ff;
    background: linear-gradient(135deg, rgba(158, 172, 255, 0.2), rgba(151, 221, 255, 0.1));
    box-shadow: inset 0 0 0 1px rgba(184, 164, 255, 0.16);
}

[data-theme="trader"] .library-sidebar,
[data-theme="trader"] .library-header,
[data-theme="trader"] .library-search,
[data-theme="trader"] .library-tabs,
[data-theme="trader"] .library-footer {
    background: var(--bg-card);
}

[data-theme="trader"] .library-sidebar {
    border-right-color: rgba(88, 112, 153, 0.55);
}

[data-theme="trader"] .library-search input,
[data-theme="trader"] .lib-tab,
[data-theme="trader"] .lib-mode-filter {
    background: rgba(23, 34, 53, 0.9);
    border-color: rgba(88, 112, 153, 0.5);
    color: var(--text-secondary);
}

[data-theme="trader"] .library-search input:focus,
[data-theme="trader"] .lib-tab:hover,
[data-theme="trader"] .lib-mode-filter:hover {
    border-color: var(--accent-blue);
}

[data-theme="trader"] .library-list {
    background: linear-gradient(180deg, rgba(18, 27, 43, 0.78), rgba(22, 32, 50, 0.92));
}

[data-theme="trader"] .lib-item {
    background: transparent;
}

[data-theme="trader"] .lib-item:hover {
    background: rgba(158, 172, 255, 0.08);
}

[data-theme="trader"] .lib-item.selected {
    background: linear-gradient(90deg, rgba(158, 172, 255, 0.18), rgba(151, 221, 255, 0.1));
}

/* ═══ Theme Toggle Button ═══ */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15.4px;
    transition: all 0.3s;
}

.theme-toggle:hover {
    border-color: var(--accent-blue);
    color: var(--accent-orange);
    transform: rotate(30deg);
}

.feedback-shortcut:hover {
    color: #a5b4fc;
    transform: translateY(-1px);
}

.theme-select {
    height: 36px;
    min-width: 92px;
    padding: 0 30px 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
        linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
    background-position:
        calc(100% - 16px) calc(50% - 2px),
        calc(100% - 11px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    transition: all 0.2s ease;
}

.theme-select:hover,
.theme-select:focus {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

/* ═══ Channel Config Modal ═══ */
.channel-config-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s;
}

.channel-config-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 520px;
    max-width: 95vw;
    max-height: 90vh;
    /* Flex column so only the body scrolls — header + footer (Save/Cancel) stay
       pinned and visible instead of the whole card scrolling/clipping. */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.channel-config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.channel-config-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.channel-config-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.ch-field {
    margin-bottom: 14px;
}

.ch-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ch-field input,
.ch-field textarea {
    width: 100%;
    padding: 8px 12px;
    font-size: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    transition: border-color 0.2s;
}

#account-current-password,
#account-new-password,
#account-confirm-password {
    color: var(--text-primary);
    background: #05070d;
    border-color: rgba(99, 102, 241, 0.35);
    padding: 4px 12px;
    line-height: 1.3;
}

.ch-field input:focus,
.ch-field textarea:focus {
    border-color: var(--accent-blue);
    outline: none;
}

.ch-field .ch-hint {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 3px;
}

.ch-field textarea {
    min-height: 60px;
    resize: vertical;
}

.channel-config-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.channel-config-footer button {
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.btn-ch-cancel {
    background: var(--bg-input);
    color: var(--text-secondary);
}

.btn-ch-save {
    background: var(--accent-green);
    color: white;
    border-color: var(--accent-green) !important;
}

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

.channel-card .channel-config-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.channel-card .channel-config-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: var(--bg-elevated);
}

/* Drop highlight for drag-drop */
.side-panel.drop-highlight {
    outline: 2px dashed var(--accent-cyan) !important;
    outline-offset: -2px;
    background: rgba(6, 182, 212, 0.05) !important;
}

/* ═══ Sequence Builder ═══ */
.sequence-builder-section {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    overflow: hidden;
}

.seq-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(59, 130, 246, 0.08));
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.seq-header:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(59, 130, 246, 0.15));
}

.seq-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.seq-header h3 i {
    color: var(--accent-purple);
    margin-right: 6px;
}

.seq-toggle {
    color: var(--text-muted);
    transition: transform 0.3s;
}

.seq-toggle.open {
    transform: rotate(180deg);
}

.seq-body {
    padding: 16px;
}

.seq-policy-btn {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.seq-policy-btn:hover {
    border-color: var(--accent-purple);
    color: var(--text-primary);
}

.seq-policy-btn.selected {
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    font-weight: 700;
}

.seq-policy-btn i {
    margin-right: 4px;
}

.choice-card {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.choice-card:hover {
    border-color: var(--accent-purple);
    color: var(--text-primary);
    background: rgba(139, 92, 246, 0.05);
}

.choice-card.selected {
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    font-weight: 700;
}

.seq-step-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    position: relative;
    transition: all 0.2s;
}

.seq-step-card:hover {
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.05);
}

.seq-step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    color: white;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.seq-step-name {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.seq-step-desc {
    font-size: 10px;
    color: var(--text-muted);
}

.seq-step-actions button {
    padding: 4px 8px;
    font-size: 10px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s;
}

.seq-step-actions button:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* Connector line between steps */
.seq-step-card:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 23px;
    width: 2px;
    height: 7px;
    background: var(--accent-purple);
    opacity: 0.4;
}

.lib-item.marked-entry,
.indicator-item.marked-entry {
    position: relative;
    border-color: rgba(56, 189, 248, 0.8) !important;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(99, 102, 241, 0.14)) !important;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.28), 0 10px 26px rgba(15, 23, 42, 0.34);
}

.lib-item.marked-entry::before,
.indicator-item.marked-entry::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 999px;
    background: linear-gradient(180deg, #22d3ee, #818cf8);
}

.lib-item.marked-entry .lib-item-name,
.indicator-item.marked-entry {
    color: #eaf6ff;
}

/* ═══ Interactive Expression Tree ═══ */
.tree-counter-pill {
    display: inline-flex;
    align-items: center;
    height: 22px;
    margin-left: 8px;
    padding: 0 8px;
    border: 1px solid rgba(34, 211, 238, 0.22);
    border-radius: 999px;
    background: rgba(6, 182, 212, 0.08);
    color: var(--accent-cyan);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
    white-space: nowrap;
    text-transform: none;
    letter-spacing: 0;
}

.tree-canvas-counter {
    position: sticky;
    left: 10px;
    top: 10px;
    z-index: 3;
    align-self: flex-start;
    margin: 0 0 -30px 10px;
    padding: 6px 9px;
    border: 1px solid rgba(34, 211, 238, 0.26);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.78);
    color: var(--accent-cyan);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.26);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
}

#tree-viz-html {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
}
#tree-viz-html ul {
    list-style: none;
    margin: 0 0 0 18px;
    padding: 0;
    border-left: 1px dashed rgba(100, 116, 139, 0.35);
}
#tree-viz-html li {
    position: relative;
    padding: 2px 0;
}
#tree-viz-html li::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 14px;
    width: 14px;
    height: 0;
    border-top: 1px dashed rgba(100, 116, 139, 0.35);
}
#tree-viz-html details {
    margin: 0;
}
#tree-viz-html details > summary {
    cursor: pointer;
    list-style: none;
    padding: 3px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
#tree-viz-html details > summary::-webkit-details-marker { display: none; }
#tree-viz-html details > summary::before {
    content: '▸';
    font-size: 10px;
    color: var(--text-dim);
    transition: transform 0.15s;
    flex-shrink: 0;
    width: 10px;
}
#tree-viz-html details[open] > summary::before {
    transform: rotate(90deg);
}
/* Node badges */
.vtree-node {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    border-left: 3px solid;
    background: rgba(255,255,255,0.03);
}
.vtree-node.root {
    border-left-color: #38bdf8;
    color: #7dd3fc;
    background: rgba(56, 189, 248, 0.08);
}
.vtree-node.operation {
    border-left-color: #10b981;
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.08);
}
.vtree-node.left {
    border-left-color: #22c55e;
    color: #86efac;
    background: rgba(34, 197, 94, 0.06);
}
.vtree-node.right {
    border-left-color: #a855f7;
    color: #d8b4fe;
    background: rgba(168, 85, 247, 0.06);
}
.vtree-node.step {
    border-left-color: #f59e0b;
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.06);
}
.vtree-node.meta {
    border-left-color: #64748b;
    color: #94a3b8;
    background: rgba(100, 116, 139, 0.06);
}
.vtree-pill {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 1px 7px;
    border-radius: 999px;
    vertical-align: middle;
}
.vtree-pill.type   { background: rgba(56,189,248,0.15); color: #7dd3fc; }
.vtree-pill.frame  { background: rgba(245,158,11,0.15); color: #fcd34d; }
.vtree-pill.value  { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.vtree-pill.op     { background: rgba(168,85,247,0.18); color: #d8b4fe; }
.vtree-pill.unary  { background: rgba(236,72,153,0.15); color: #f9a8d4; }
.vtree-pill.symbol { background: rgba(6,182,212,0.12);  color: #67e8f9; }
.vtree-detail {
    font-size: 10px;
    color: var(--text-dim);
    margin-left: 4px;
}
/* Highlight on navigate */
.vtree-highlight {
    outline: 2px solid rgba(56, 189, 248, 0.5);
    outline-offset: 2px;
    border-radius: 6px;
    transition: outline-color 0.4s;
}

.expression-viewer-modal {
    width: min(1100px, 96vw);
    max-height: 92vh;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(23, 31, 53, 0.98), rgba(15, 23, 42, 0.985)) !important;
    color: #e2e8f0;
    border: 1px solid rgba(59, 130, 246, 0.2);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58);
    display: flex;
    flex-direction: column;
    border-radius: 28px;
}

.expression-viewer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.expression-viewer-title-wrap h4 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.expression-viewer-title-wrap h4 i {
    color: #dbeafe;
}

.expression-viewer-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-muted);
}

.expression-viewer-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.expression-viewer-close {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(255, 255, 255, 0.02);
}

.expression-viewer-body {
    padding: 18px 22px 16px;
    overflow: auto;
}

.expression-viewer-summary {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(99, 102, 241, 0.22);
    background: rgba(99, 102, 241, 0.08);
    font-size: 14px;
    color: #cbd5e1;
    font-family: var(--font-mono);
    white-space: pre-wrap;
}

.expression-viewer-workbench {
    display: grid;
    grid-template-columns: minmax(0, 0.98fr) minmax(0, 1fr) auto;
    gap: 14px;
    align-items: stretch;
}

.expression-viewer-actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 10px;
}

.expression-viewer-stage {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(56, 189, 248, 0.08);
    background: linear-gradient(180deg, rgba(10, 16, 31, 0.62), rgba(14, 24, 44, 0.74));
    min-height: 380px;
}

.expression-viewer-outline-shell {
    padding: 14px 14px 6px;
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, 0.08);
    background: rgba(9, 14, 26, 0.52);
}

.expression-viewer-details-shell {
    border-color: rgba(99, 102, 241, 0.18);
    background: linear-gradient(180deg, rgba(15, 20, 34, 0.95), rgba(11, 17, 29, 0.96));
}

.expression-viewer-tree-shell {
    min-height: 380px;
    display: flex;
    flex-direction: column;
}

.expression-viewer-outline-title {
    margin-bottom: 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}

.expression-viewer-outline-title-accent {
    color: #d06bff;
}

.expression-viewer-details {
    display: grid;
    gap: 8px;
}

.expression-viewer-detail-row {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 6px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}

.expression-viewer-detail-row:last-child {
    border-bottom: none;
}

.expression-viewer-detail-key {
    color: #7f8da8;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.expression-viewer-detail-key::before {
    content: "";
    width: 4px;
    height: 4px;
    border-radius: 999px;
    background: #f59e0b;
    flex-shrink: 0;
}

.expression-viewer-detail-value {
    color: #dbe4f3;
    font-size: 12px;
    font-family: var(--font-mono);
    word-break: break-word;
    overflow-wrap: anywhere;
}

.expression-viewer-tree {
    overflow: auto;
    max-height: 346px;
    padding: 0 4px 10px;
}

.expression-viewer-icon-btn {
    width: 42px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(255, 255, 255, 0.03);
    color: #cbd5e1;
    cursor: pointer;
}

.expression-viewer-icon-btn:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.3);
    color: #eef2ff;
}

.expression-viewer-danger-btn {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.22);
    color: #fecaca;
}

.expression-viewer-danger-btn:hover {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(239, 68, 68, 0.32);
    color: #fff1f2;
}

.expression-viewer-json-shell {
    margin-top: 14px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 16px;
    background: rgba(5, 10, 20, 0.44);
    overflow: hidden;
}

.expression-viewer-json-shell summary {
    cursor: pointer;
    padding: 12px 14px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
    user-select: none;
}

.expression-viewer-json {
    max-height: 220px;
    overflow: auto;
    border-top: 1px solid rgba(148, 163, 184, 0.08);
    padding: 12px 14px 14px;
    font-family: var(--font-mono);
    font-size: 10px;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-secondary);
}

.expression-viewer-footer {
    padding: 16px 22px 20px;
    display: flex;
    justify-content: flex-end;
}

.expression-viewer-close-btn {
    min-width: 86px;
    border-radius: 14px;
}

#tree-viz-section {
    overflow: visible;
}

#tree-viz-split {
    min-height: min(912px, calc(100vh - 90px)) !important;
    align-items: stretch !important;
}

#tree-viz-canvas,
#tree-viz-side {
    min-height: calc(100vh - 90px) !important;
}

#tree-viz-side {
    height: calc(100vh - 90px) !important;
    max-height: calc(100vh - 90px) !important;
}

.tree-side-panel {
    min-height: 0;
    padding-bottom: 12px;
}

#tree-viz-side {
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.7) rgba(30, 41, 59, 0.85);
}

#tree-viz-side::-webkit-scrollbar {
    width: 16px;
}

#tree-viz-side::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.85);
    border-radius: 8px;
    margin: 4px 0;
}

#tree-viz-side::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.7);
    border-radius: 8px;
    border: 3px solid rgba(30, 41, 59, 0.85);
    min-height: 60px;
}

#tree-viz-side::-webkit-scrollbar-thumb:hover {
    background: rgba(192, 132, 252, 0.95);
}

#tree-viz-side::-webkit-scrollbar-button:single-button {
    background-color: rgba(168, 85, 247, 0.7);
    display: block;
    height: 16px;
    width: 16px;
    border-radius: 4px;
}

#tree-viz-side::-webkit-scrollbar-button:single-button:vertical:decrement {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 8 L6 4 L10 8 Z' fill='white'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
}

#tree-viz-side::-webkit-scrollbar-button:single-button:vertical:increment {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4 L6 8 L10 4 Z' fill='white'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
}

#tree-viz-side::-webkit-scrollbar-button:single-button:hover {
    background-color: rgba(192, 132, 252, 0.95);
}

@media (max-width: 720px) {
    .expression-viewer-modal {
        width: min(96vw, 96vw);
        border-radius: 22px;
    }

    .expression-viewer-head {
        padding: 16px 16px 14px;
    }

    .expression-viewer-body {
        padding: 14px 16px 14px;
    }

    .expression-viewer-stage {
        min-height: 300px;
        padding: 12px;
    }

    .expression-viewer-workbench {
        grid-template-columns: 1fr;
    }

    .expression-viewer-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .expression-viewer-tree {
        max-height: 240px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   History Requests page (#page-history-requests)
   Visual mirrors GTS Strategy & Handler signal-box layout.
   ═══════════════════════════════════════════════════════════════════ */
#page-history-requests .hr-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}

#page-history-requests .hr-quota-banner {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(99, 102, 241, .25);
    background: rgba(99, 102, 241, .06);
    color: var(--text-primary);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

#page-history-requests .hr-quota-banner.warn {
    border-color: rgba(245, 158, 11, .35);
    background: rgba(245, 158, 11, .08);
    color: #fcd34d;
}

#page-history-requests .hr-quota-banner.exhausted {
    border-color: rgba(239, 68, 68, .35);
    background: rgba(239, 68, 68, .08);
    color: #fca5a5;
}

#page-history-requests .hr-quota-banner strong {
    color: var(--text-primary);
}

#page-history-requests .hr-quota-meter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

#page-history-requests .hr-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

#page-history-requests .hr-form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

#page-history-requests .hr-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#page-history-requests .hr-field label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
}

#page-history-requests .hr-field input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 10px;
    font-size: 12px;
    width: 100%;
    box-sizing: border-box;
}

#page-history-requests .hr-symbol-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

#page-history-requests .hr-symbol-row input {
    flex: 1;
    min-width: 0;
}

#page-history-requests .hr-symbol-browse {
    padding: 6px 12px;
    font-size: 11px;
    white-space: nowrap;
}

#page-history-requests .hr-form-grid-trade {
    grid-template-columns: 1fr 1fr 1fr 2fr;
    margin-top: 4px;
}

#page-history-requests .hr-field-spacer {
    visibility: hidden;
}

#page-history-requests .hr-picker {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 14px;
    background: rgba(99, 102, 241, .04);
}

#page-history-requests .hr-picker-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
}

#page-history-requests .hr-picker-hint {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-muted);
}

#page-history-requests .hr-picker-search {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 12px;
    margin-bottom: 8px;
}

#page-history-requests .hr-picker-list {
    max-height: 140px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px;
}

#page-history-requests .hr-picker-empty {
    font-size: 11px;
    color: var(--text-muted);
    padding: 8px;
}

#page-history-requests .hr-picker-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, .12);
    border: 1px solid rgba(99, 102, 241, .24);
    color: var(--accent-blue-hover);
    font-size: 11px;
    font-family: var(--font-mono), monospace;
    cursor: grab;
    user-select: none;
    transition: all .15s;
}

#page-history-requests .hr-picker-chip:hover {
    background: rgba(99, 102, 241, .22);
}

/* History strategy picker — permutation-style. Available list lives in the
   left sidebar (.hr-strategy-sidebar); the Selected-to-run list lives in the
   main form (#page-history-requests). Row classes (.hr-rt-*) are intentionally
   un-scoped so an identical, ALIGNED row renders in both places. */
.hr-strategy-sidebar .hr-policy-btn {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}

.hr-strategy-sidebar .hr-policy-btn.active {
    border-color: var(--accent-blue);
    background: rgba(99, 102, 241, .16);
    color: var(--accent-blue-hover);
}

.hr-rt-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.hr-rt-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: rgba(148, 163, 184, .05);
    cursor: pointer;
    transition: all .15s;
}

.hr-rt-row:hover {
    background: rgba(99, 102, 241, .12);
}

.hr-rt-row.selected {
    border-color: rgba(34, 197, 94, .3);
    background: rgba(34, 197, 94, .07);
}

.hr-rt-row-copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.hr-rt-row-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hr-rt-row-sub {
    font-size: 9px;
    color: var(--text-muted);
    font-family: var(--font-mono), monospace;
}

/* Fixed-width action pills so VIEW / ADD / REMOVE line up in a column
   across every row and every tab — the "aligned view on all" ask. */
.hr-rt-act {
    flex-shrink: 0;
    box-sizing: border-box;
    min-width: 58px;
    text-align: center;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .4px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.hr-rt-act.view {
    color: var(--text-secondary);
    background: rgba(148, 163, 184, .12);
}

.hr-rt-act.add {
    color: var(--accent-blue-hover);
    background: rgba(99, 102, 241, .16);
}

.hr-rt-act.added {
    color: var(--accent-green);
    background: rgba(34, 197, 94, .14);
}

.hr-rt-act.remove {
    color: var(--accent-red);
    background: rgba(239, 68, 68, .12);
}

.hr-rt-empty {
    font-size: 11px;
    color: var(--text-muted);
    padding: 10px;
    text-align: center;
}

/* Inline VIEW detail panel (right / Selected side) close button */
#page-history-requests .hr-strat-detail-close {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(148, 163, 184, .12);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

#page-history-requests .hr-strat-detail-close:hover {
    background: rgba(148, 163, 184, .2);
    color: var(--text-primary);
}

/* VIEW detail modal */
.hr-strat-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 11, 19, .66);
    backdrop-filter: blur(2px);
    padding: 24px;
}

.hr-strat-modal-card {
    width: min(620px, 100%);
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
    overflow: hidden;
}

.hr-strat-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.hr-strat-modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 15px;
    padding: 4px 8px;
    border-radius: 6px;
}

.hr-strat-modal-close:hover {
    background: rgba(148, 163, 184, .12);
    color: var(--text-primary);
}

.hr-strat-modal-body {
    padding: 14px 16px;
    overflow-y: auto;
}

.hr-rt-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin-bottom: 14px;
}

.hr-rt-facts > div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    padding: 5px 8px;
    background: var(--bg-input);
    border-radius: 6px;
}

.hr-rt-facts span {
    color: var(--text-muted);
}

.hr-rt-view-actions {
    margin-bottom: 12px;
}

.hr-rt-json {
    margin: 0;
    font-size: 11px;
    font-family: var(--font-mono), monospace;
    color: var(--text-secondary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    max-height: 38vh;
    overflow: auto;
    white-space: pre;
}

#page-history-requests .hr-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
}

#page-history-requests .hr-slot-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

#page-history-requests .hr-slot {
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    min-height: 180px;
    padding: 12px;
    cursor: pointer;
    transition: all .2s;
}

#page-history-requests .hr-slot.selected {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, .2);
}

#page-history-requests .hr-slot.drop-over {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px rgba(6, 182, 212, .2);
}

#page-history-requests .hr-slot-open-bid { border-left: 3px solid var(--accent-green); }
#page-history-requests .hr-slot-open-ask { border-left: 3px solid var(--accent-cyan); }
#page-history-requests .hr-slot-close-bid { border-left: 3px solid var(--accent-orange); }
#page-history-requests .hr-slot-close-ask { border-left: 3px solid var(--accent-red); }

#page-history-requests .hr-slot-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

#page-history-requests .hr-slot-title {
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

#page-history-requests .hr-slot-policy {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

#page-history-requests .hr-policy-btn {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}

#page-history-requests .hr-policy-btn.active {
    border-color: var(--accent-blue);
    background: rgba(99, 102, 241, .16);
    color: var(--accent-blue-hover);
}

#page-history-requests .hr-slot-dropzone {
    min-height: 104px;
    border: 1px dashed rgba(148, 163, 184, .2);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-content: flex-start;
}

#page-history-requests .hr-slot-dropzone:empty::before {
    content: 'Drag from the Expression Library on the left, or click this box and then click an expression.';
    color: var(--text-dim);
    font-size: 11px;
    text-align: center;
    margin: auto;
    padding: 10px;
    line-height: 1.5;
}

#page-history-requests .hr-expr-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, .12);
    border: 1px solid rgba(99, 102, 241, .24);
    color: var(--accent-blue-hover);
    font-size: 11px;
    font-family: var(--font-mono), monospace;
}

#page-history-requests .hr-expr-tag button {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: .65;
    font-size: 12px;
    padding: 0 0 0 2px;
}

#page-history-requests .hr-expr-tag button:hover { opacity: 1; }

#page-history-requests .hr-validation {
    margin: 12px 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: #fca5a5;
    background: rgba(239, 68, 68, .08);
    border: 1px solid rgba(239, 68, 68, .25);
    display: none;
}

#page-history-requests .hr-validation.show { display: block; }
#page-history-requests .hr-validation ul { margin: 4px 0 0 16px; padding: 0; }

#page-history-requests .hr-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

#page-history-requests .hr-btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .15s;
}

#page-history-requests .hr-btn-primary {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

#page-history-requests .hr-btn-primary:hover { filter: brightness(1.1); }

#page-history-requests .hr-btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
}

#page-history-requests .hr-btn-secondary:hover { background: rgba(148, 163, 184, .1); }

#page-history-requests .hr-list-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

#page-history-requests .hr-table-wrap {
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
}

#page-history-requests .hr-table {
    width: 100%;
    /* Fixed layout so the table can NEVER exceed 100% of its box — columns
       distribute and long content wraps, instead of pushing the Actions column
       off the right edge (clip). */
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 11px;
}

/* Long cell content (target id, mapping pills, buttons) wraps within its column
   instead of forcing the table wider than its container. */
#page-history-requests .hr-table th,
#page-history-requests .hr-table td {
    overflow-wrap: anywhere;
    word-break: break-word;
}
/* The mostly-empty OHLC columns don't need much room; give the action columns more. */
#page-history-requests .hr-table th:nth-child(4),
#page-history-requests .hr-table th:nth-child(5),
#page-history-requests .hr-table th:nth-child(6),
#page-history-requests .hr-table th:nth-child(7) {
    width: 4%;
}
#page-history-requests .hr-table th:nth-child(11),
#page-history-requests .hr-table th:nth-child(12) {
    width: 12%;
}

#page-history-requests .hr-table th {
    text-align: left;
    padding: 8px 10px;
    background: rgba(99, 102, 241, .08);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: .4px;
}

#page-history-requests .hr-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(148, 163, 184, .08);
    color: var(--text-primary);
    vertical-align: top;
}

#page-history-requests .hr-list-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 24px !important;
    font-style: italic;
}

#page-history-requests .hr-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}

#page-history-requests .hr-status-queued { background: rgba(148, 163, 184, .15); color: #cbd5e1; }
#page-history-requests .hr-status-running { background: rgba(99, 102, 241, .18); color: #a5b4fc; }
#page-history-requests .hr-status-done { background: rgba(34, 197, 94, .15); color: #86efac; }
#page-history-requests .hr-status-failed { background: rgba(239, 68, 68, .15); color: #fca5a5; }

#page-history-requests .hr-mini-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(99, 102, 241, .1);
    color: var(--accent-blue-hover);
    font-family: var(--font-mono), monospace;
    font-size: 10px;
}

#page-history-requests .hr-target-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

#page-history-requests .hr-target-detail {
    color: var(--text-dim);
    font-size: 11px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#page-history-requests .hr-mini-empty {
    color: var(--text-dim);
    font-style: italic;
}

#page-history-requests .hr-cancel-btn {
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid rgba(239, 68, 68, .35);
    background: rgba(239, 68, 68, .08);
    color: #fca5a5;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all .15s;
}

#page-history-requests .hr-cancel-btn:hover {
    background: rgba(239, 68, 68, .18);
}

/* ═════════════════════════════════════════════════════════════════════ */
/*  Sub-step 1a: Builder sub-nav — port of GTS_Creator_Hub .sub-tab-bar  */
/*  Source: gts/GTS_Creator_Hub.html:244-284                            */
/* ═════════════════════════════════════════════════════════════════════ */
#page-builder .sub-tab-bar {
    /* Plain in-flow bar, ported 1:1 from GTS desktop (.sub-tab-bar). Pinned
       under the sticky .top-nav (min-height 56px, z-index 100) so the 4 builder
       tabs stay reachable while the page scrolls — but NEVER position:fixed and
       NEVER per-tab repositioned, so the tabs are flush-left and IDENTICAL on
       every sub-tab (Expression Builder, Strategy & Handler, Mass Strategies).
       The old JS "glue" hack that floated this bar over the iframe sidebar is
       gone; it caused the horizontal jump + intermittent vanish. */
    position: sticky;
    top: 56px;
    z-index: 90;
    height: 44px;
    min-height: 44px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* Flush-left, same x on every tab (GTS desktop uses padding: 0 16px). */
    padding: 0 16px;
    gap: 2px;
    margin: 0 -16px 16px;
}
#page-builder .sub-tab-bar .sub-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 14px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    transition: all .15s;
    white-space: nowrap;
}
#page-builder .sub-tab-bar .sub-tab:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, .02);
    border-color: rgba(148, 163, 184, 0.14);
}
#page-builder .sub-tab-bar .sub-tab.active {
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.18);
    background: rgba(99, 102, 241, 0.08);
    box-shadow: inset 0 -2px 0 0 var(--sub-color, var(--accent-blue));
}
#page-builder .sub-tab-bar .sub-tab i {
    font-size: 12px;
}

/* .sub-tab-bar--iframe-glued — RETIRED. The sub-nav is now a plain in-flow bar
   (see above) that is identical on every tab. The class is no longer added by
   JS; this empty selector is kept only so any stale reference is a harmless
   no-op rather than re-introducing the position:fixed jump/vanish. */
#page-builder .sub-tab-bar.sub-tab-bar--iframe-glued {
    /* intentionally empty */
}

/* Visitor banner now renders below the sub-nav, so it just needs a little
   breathing room under the stripe (which already has a 16px bottom margin). */
#page-builder #builder-visitor-banner {
    margin: 0 0 8px !important;
}

#page-builder .sub-placeholder {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}
#page-builder .sub-placeholder i {
    font-size: 48px;
    color: var(--accent-blue);
    margin-bottom: 16px;
    display: block;
}
#page-builder .sub-placeholder h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}
#page-builder .sub-placeholder p {
    font-size: 13px;
}

/* Iframe sub-panels full-bleed; JS glues iframe tabs to the main nav so the
   embedded sidebar starts at the same top edge as the builder workspace. */
#subpanel-strat,
#subpanel-mass {
    position: fixed;
    top: 152px;
    left: 0;
    right: 0;
    bottom: 52px;   /* clear the fixed .gts-legalbar footer (~36px) + 16px gap, matching sizeBuilderIframes() */
    z-index: 1;
    margin: 0;
    padding: 0;
}
#iframe-strategy-handler,
#iframe-mass-strategies {
    width: 100% !important;
    height: 100% !important;
    border: none;
    display: block;
}
#iframe-strategy-handler,
#iframe-mass-strategies {
    width: 100% !important;
    height: 100% !important;
    border: none;
    display: block;
}

/* Compact status pill — used by the Deployment Ops admin page (deployAdminStatusPill).
 * Kept minimal; the user-facing deploy bar that originally owned these is gone. */
.deploy-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.deploy-pill i { font-size: 10px; }
.deploy-pill-idle      { background: rgba(148,163,184,0.18); color: #cbd5e1; border: 1px solid rgba(148,163,184,0.30); }
.deploy-pill-queued    { background: rgba(245,158,11,0.18);  color: #fbbf24; border: 1px solid rgba(245,158,11,0.40); }
.deploy-pill-deploying { background: rgba(59,130,246,0.18);  color: #93c5fd; border: 1px solid rgba(59,130,246,0.40); }
.deploy-pill-live      { background: rgba(16,185,129,0.18);  color: #34d399; border: 1px solid rgba(16,185,129,0.40); }
.deploy-pill-failed    { background: rgba(239,68,68,0.18);   color: #f87171; border: 1px solid rgba(239,68,68,0.40); }

.alert-deploy-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.alert-deploy-tag i { font-size: 9px; }
.alert-deploy-tag-deployed { background: rgba(16,185,129,0.18); color: #34d399; border: 1px solid rgba(16,185,129,0.40); }
.alert-deploy-tag-off      { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }

.alert-deploy-btn {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.alert-deploy-btn i { margin-right: 4px; }
.alert-deploy-btn-add    { background: rgba(16,185,129,0.18); color: #34d399; border: 1px solid rgba(16,185,129,0.40); }
.alert-deploy-btn-remove { background: rgba(239,68,68,0.14);  color: #f87171; border: 1px solid rgba(239,68,68,0.30); }
.alert-deploy-btn-pending,
.alert-deploy-btn:disabled {
    background: rgba(148,163,184,0.10);
    color: #cbd5e1;
    border: 1px solid rgba(148,163,184,0.24);
    cursor: wait;
    opacity: 0.9;
}

.deploy-admin-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.deploy-admin-toolbar input:not([type=checkbox]):not([type=radio]),
.deploy-admin-toolbar select {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.deploy-admin-toolbar input:not([type=checkbox]):not([type=radio]) { min-width: 220px; }
.deploy-admin-toolbar input[type=checkbox] {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--accent, #a78bfa);
    cursor: pointer;
}
.deploy-admin-toolbar button {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
/* Wider variant for buttons that carry a text label, not just an icon. */
.deploy-admin-toolbar button.wide {
    width: auto;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    gap: 6px;
}
.deploy-admin-toolbar button.wide:hover {
    background: var(--bg-elevated);
}
.deploy-admin-toolbar button.wide.danger {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.42);
    color: #fca5a5;
}
.deploy-admin-toolbar button.wide.danger:hover {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(239, 68, 68, 0.6);
    color: #fecaca;
}
.deploy-admin-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 12px;
}
.deploy-admin-summary strong { color: var(--text-primary); }
.deploy-admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}
.deploy-admin-section {
    min-width: 0;
}
.deploy-admin-section h2 {
    margin: 0 0 8px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
}
.deploy-admin-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}
.deploy-admin-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
    font-size: 11px;
}
.deploy-admin-table th,
.deploy-admin-table td {
    padding: 9px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
}
.deploy-admin-table th {
    color: var(--text-muted);
    font-weight: 700;
    background: rgba(148,163,184,0.06);
}
.deploy-admin-table tr:last-child td { border-bottom: 0; }
.deploy-admin-table code {
    color: var(--text-secondary);
    background: rgba(148,163,184,0.08);
    border: 1px solid rgba(148,163,184,0.14);
    border-radius: 4px;
    padding: 2px 5px;
}
.admin-feedback-message {
    max-width: 520px;
    min-width: 280px;
    white-space: pre-wrap;
    line-height: 1.45;
    color: var(--text-secondary);
}
.deploy-admin-empty {
    padding: 14px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 12px;
}
.deploy-admin-error {
    color: #f87171;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.deploy-admin-muted {
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.deploy-admin-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 12px;
    user-select: none;
}
.deploy-admin-checkbox input {
    margin: 0;
    width: 14px;
    height: 14px;
    accent-color: var(--accent, #a78bfa);
    cursor: pointer;
}
.admin-container-input {
    width: 180px;
    padding: 4px 8px;
    font-size: 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: border-color 0.15s, background 0.15s;
}
.admin-container-input:focus { outline: none; border-color: rgba(59,130,246,0.6); }
.admin-container-saving { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.5); }
.admin-container-saved  { border-color: rgba(16,185,129,0.6); background: rgba(16,185,129,0.08); }
.admin-container-error  { border-color: rgba(239,68,68,0.7);  background: rgba(239,68,68,0.10); }
.admin-log-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 6px;
    border: 1px solid rgba(99,102,241,0.35);
    background: rgba(99,102,241,0.16);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.admin-log-btn:hover {
    border-color: rgba(99,102,241,0.60);
    background: rgba(99,102,241,0.24);
}

.deploy-admin-pending-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(245,158,11,0.18);
    color: #fbbf24;
    border: 1px solid rgba(245,158,11,0.40);
}

/* Admin console tab strip */
.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin: 14px 0 18px;
    padding-bottom: 0;
}
.admin-tab {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    color: var(--text-muted);
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.admin-tab i { font-size: 12px; }
.admin-tab:hover { color: var(--text-primary); background: var(--bg-card); }
.admin-tab-active {
    color: var(--text-primary);
    background: var(--bg-card);
    border-color: var(--border);
    border-bottom: 1px solid var(--bg-card);
    margin-bottom: -1px;
}
.admin-health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}
.admin-health-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}
.admin-health-card h3 {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 8px;
}
.admin-health-card dl {
    margin: 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 12px;
    font-size: 13px;
}
.admin-health-card dt { color: var(--text-muted); }
.admin-health-card dd { margin: 0; color: var(--text-primary); word-break: break-all; }
