:root {
    --bg: #f3f6f9;
    --panel: #ffffff;
    --ink: #111827;
    --muted: #687386;
    --line: #dfe5ec;
    --navy: #111827;
    --navy-soft: #1f2937;
    --accent: #f59e0b;
    --accent-dark: #d97706;
    --success: #138a58;
    --danger: #c43d3d;
    --shadow: 0 18px 50px rgba(20, 30, 45, 0.08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }

.site-flashes { width: min(1180px, calc(100% - 32px)); margin: 16px auto 0; }
.site-flashes .notice { margin: 0; border: 1px solid; border-radius: 12px; padding: 13px 15px; font-weight: 750; }
.nav-username { align-self: center; padding: 9px 10px; color: #dbe7f5; font-size: .78rem; font-weight: 850; white-space: nowrap; }
.nav-logout { margin: 0; display: flex; }
.nav-logout input { display: none; }
.nav-logout button { min-height: 36px; border: 1px solid rgba(255,98,109,.32); border-radius: 9px; padding: 0 11px; color: #ffadb3; background: rgba(255,98,109,.08); font-size: .76rem; font-weight: 850; cursor: pointer; }
.nav-logout button:hover { background: rgba(255,98,109,.15); }
.watchlist-inline-button { width: fit-content; min-height: 38px; margin-top: 10px; border: 1px solid rgba(72,143,255,.38); border-radius: 9px; padding: 0 12px; color: #a9c9ff; background: rgba(47,125,255,.08); font-weight: 850; cursor: pointer; }
.watchlist-inline-button.in-watchlist { color: #72e1b7; border-color: rgba(41,211,145,.3); background: rgba(41,211,145,.08); }
.watchlist-auth-modal { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 20px; background: rgba(2,8,18,.78); backdrop-filter: blur(7px); }
.watchlist-auth-card { width: min(440px, 100%); border: 1px solid var(--line); border-radius: 18px; padding: 26px; color: var(--ink); background: var(--panel); box-shadow: 0 26px 80px rgba(0,0,0,.5); }
.watchlist-auth-card h2 { margin-bottom: 10px; }
.watchlist-auth-card p { color: var(--muted); line-height: 1.55; }
.watchlist-auth-actions { display: flex; gap: 10px; margin-top: 20px; }
.watchlist-auth-actions a, .watchlist-auth-actions button { flex: 1; min-height: 44px; border: 1px solid #2f7dff; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: #216ce8; text-decoration: none; font-weight: 850; cursor: pointer; }
.watchlist-auth-actions button { color: var(--muted); border-color: var(--line); background: transparent; }

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px max(20px, calc((100vw - 1180px) / 2));
    background: var(--navy);
    color: white;
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
    width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
    background: var(--accent); color: var(--navy); font-weight: 900; letter-spacing: -1px;
}
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 1rem; }
.brand-copy small { margin-top: 5px; color: #aeb8c6; }

.status-badge, .strategy-tag, .memory-badge {
    border-radius: 999px; padding: 7px 12px; font-size: .78rem; font-weight: 800;
}
.status-offline { background: #2b3442; color: #cbd5e1; }
.status-online { background: rgba(19, 138, 88, .18); color: #8ce0b7; }

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.hero {
    display: grid; grid-template-columns: 1.5fr .65fr; gap: 32px; align-items: end;
    padding: 64px 0 42px;
}
.eyebrow, .step-label { margin: 0 0 8px; font-size: .72rem; letter-spacing: .18em; font-weight: 900; color: var(--accent-dark); }
.hero h1 { margin: 0; font-size: clamp(2.6rem, 7vw, 5.8rem); letter-spacing: -.07em; line-height: .92; max-width: 800px; }
.hero-text { max-width: 690px; color: var(--muted); font-size: 1.05rem; line-height: 1.7; }
.hero-card { background: var(--navy); color: white; border-radius: 22px; padding: 26px; box-shadow: var(--shadow); }
.hero-card p { color: #bbc4d0; line-height: 1.6; margin-bottom: 0; }
.privacy-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--navy); font-weight: 900; margin-bottom: 18px; }

.layout-grid { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.panel-heading, .results-heading, .table-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
h2, h3 { margin-top: 0; }
.panel-heading h2 { margin-bottom: 14px; }
.connection-panel { position: sticky; top: 98px; }
.connection-panel > div > p { color: var(--muted); line-height: 1.55; }
.broker-logo { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: #5f2eea; color: white; font-weight: 900; font-size: 1.25rem; }

.button { border: 0; border-radius: 12px; min-height: 48px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 800; cursor: pointer; transition: .2s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button-full { width: 100%; }
.button-primary { background: var(--navy); color: white; }
.button-secondary { background: #eef2f6; color: var(--ink); }
.button-danger { border: 1px solid rgba(196, 61, 61, .32); color: #a92121; background: #fff1f1; }
.button-accent { background: var(--accent); color: var(--navy); font-size: 1rem; margin-top: 18px; }
.button-accent:hover { background: #ffb52e; }
.backtest-job-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.backtest-job-controls .button { min-height: 44px; }

.connected-user { display: flex; align-items: center; gap: 12px; border: 1px solid #cfeadd; border-radius: 14px; padding: 14px; margin-bottom: 12px; background: #f2fbf7; }
.connected-user div { display: grid; gap: 3px; }
.connected-user small { color: var(--muted); }
.connected-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(19,138,88,.12); }

.info-list { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; display: grid; gap: 13px; }
.info-list div { display: flex; align-items: center; gap: 10px; }
.info-list span { width: 26px; height: 26px; border-radius: 8px; background: #eef2f6; display: grid; place-items: center; font-size: .75rem; font-weight: 900; }
.info-list p { margin: 0; color: var(--muted); font-size: .9rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { display: grid; gap: 8px; }
.field-wide { margin-bottom: 20px; }
label { font-size: .86rem; font-weight: 800; }
input, select { width: 100%; min-height: 48px; border: 1px solid #ccd5df; border-radius: 11px; padding: 0 13px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgba(245,158,11,.13); }
.field small { color: var(--muted); }
.instrument-field { position: relative; }
.autocomplete { position: absolute; top: 78px; left: 0; right: 0; z-index: 10; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 40px rgba(15,23,42,.14); max-height: 330px; overflow: auto; }
.instrument-option { padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #edf1f5; }
.instrument-option:last-child { border-bottom: 0; }
.instrument-option:hover { background: #f8fafc; }
.instrument-option strong, .instrument-option small { display: block; }
.instrument-option small { margin-top: 3px; color: var(--muted); }
.scanner-backtest-import { margin-bottom: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(47,125,255,.05); }
.scanner-backtest-import h3 { margin: 0 0 5px; }
.scanner-backtest-import p { margin: 0; color: var(--muted); line-height: 1.5; }
.scanner-backtest-result-list { display: grid; gap: 8px; max-height: 280px; overflow: auto; margin-top: 14px; }
.scanner-backtest-result { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); text-align: left; cursor: pointer; }
.scanner-backtest-result small { color: var(--muted); text-align: right; }
.scanner-backtest-result:hover, .scanner-backtest-result.selected { border-color: #2f7dff; background: rgba(47,125,255,.09); }
.strategy-tag { background: #fff5dc; color: #9a5d00; }
.strategy-note { margin-top: 20px; border-left: 4px solid var(--accent); background: #fffaf0; padding: 14px; border-radius: 0 10px 10px 0; color: #5b6574; line-height: 1.55; }

.strategy-workspace, .risk-settings { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); }
.strategy-workspace-heading, .risk-settings-heading { margin-bottom: 16px; }
.strategy-workspace-heading h3, .risk-settings-heading h3 { margin: 0 0 6px; font-size: 1.08rem; }
.strategy-workspace-heading p:not(.step-label), .risk-settings-heading p:not(.step-label) { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.risk-settings-toggle { min-height: 52px; border: 1px solid #315c95; border-radius: 13px; padding: 0 16px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; color: #9cc3ff; background: #102139; cursor: pointer; transition: border-color .2s ease, background .2s ease, transform .2s ease; }
.risk-settings-toggle::-webkit-details-marker { display: none; }
.risk-settings-toggle::marker { content: ""; }
.risk-settings-toggle:hover { border-color: #4b82c8; background: #142946; transform: translateY(-1px); }
.risk-settings-toggle:focus-visible { outline: 3px solid rgba(72,143,255,.28); outline-offset: 3px; }
.risk-settings-toggle > span:first-child { font-size: .9rem; font-weight: 850; }
.risk-settings-toggle small { color: var(--muted); font-size: .76rem; text-align: right; }
.risk-settings-chevron { font-size: 1rem; transition: transform .2s ease; }
.risk-settings[open] .risk-settings-chevron { transform: rotate(180deg); }
.risk-settings-content { padding-top: 16px; }
.risk-settings-help { margin: 0 0 14px; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.strategy-mode-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: #f4f7fa; }
.strategy-mode-tab { min-width: 0; border: 1px solid transparent; border-radius: 11px; padding: 13px 16px; display: grid; gap: 3px; text-align: left; color: var(--muted); background: transparent; cursor: pointer; transition: border-color .2s ease, background .2s ease, color .2s ease, transform .2s ease; }
.strategy-mode-tab:hover { color: var(--ink); transform: translateY(-1px); }
.strategy-mode-tab.active { border-color: #c9d9ef; color: #1558b0; background: #fff; box-shadow: 0 7px 20px rgba(38,86,143,.08); }
.strategy-mode-tab span { font-size: .92rem; font-weight: 850; }
.strategy-mode-tab small { color: inherit; opacity: .72; }
.strategy-mode-panel { margin-top: 18px; }
.built-in-strategy-selector { display: grid; gap: 10px; }
.built-in-strategy-toggle { width: 100%; min-height: 48px; border: 1px solid #315c95; border-radius: 13px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #9cc3ff; background: #102139; font: inherit; font-size: .86rem; font-weight: 850; cursor: pointer; transition: border-color .2s ease, background .2s ease, transform .2s ease; }
.built-in-strategy-toggle:hover { border-color: #4b82c8; background: #142946; transform: translateY(-1px); }
.built-in-strategy-toggle:disabled { cursor: wait; opacity: .62; transform: none; }
.built-in-strategy-chevron { font-size: 1rem; transition: transform .2s ease; }
.built-in-strategy-toggle[aria-expanded="true"] .built-in-strategy-chevron { transform: rotate(180deg); }
.built-in-strategy-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
.built-in-strategy-choice { min-width: 0; min-height: 86px; border: 1px solid var(--line); border-radius: 13px; padding: 12px; display: grid; align-content: center; gap: 5px; text-align: left; color: var(--ink); background: var(--panel); cursor: pointer; transition: border-color .2s ease, transform .2s ease, background .2s ease; }
.built-in-strategy-choice:hover { transform: translateY(-2px); border-color: #a8c6ed; }
.built-in-strategy-choice.active { border-color: #4f8fe5; background: #eef6ff; box-shadow: inset 0 0 0 1px rgba(37,105,196,.12); }
.built-in-strategy-choice span { color: var(--accent-dark); font-size: .68rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.built-in-strategy-choice strong { font-size: .8rem; line-height: 1.3; overflow-wrap: anywhere; }
.built-in-strategy-choice > button:first-child { min-width: 0; border: 0; padding: 0; display: grid; gap: 6px; text-align: left; color: inherit; background: transparent; cursor: pointer; }
.built-in-strategy-choice > button:first-child small { min-height: 48px; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.strategy-info-button { width: max-content; border: 0; padding: 2px 0; color: var(--accent-dark); background: transparent; font-size: .72rem; font-weight: 850; cursor: pointer; }
.strategy-info-button:hover { text-decoration: underline; }
.modal-open { overflow: hidden; }
.strategy-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
.strategy-modal-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(2, 8, 18, .78); backdrop-filter: blur(7px); cursor: default; }
.strategy-modal-card { position: relative; width: min(1180px, 100%); max-height: min(880px, calc(100vh - 48px)); border: 1px solid var(--line); border-radius: 22px; padding: 24px; overflow: auto; color: var(--ink); background: var(--panel); box-shadow: 0 28px 90px rgba(0, 0, 0, .42); }
.strategy-modal-header, .strategy-info-heading, .trade-results-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.strategy-modal-header { margin-bottom: 20px; }
.strategy-modal-header h2, .strategy-info-heading h3, .trade-results-heading h3 { margin: 0 0 7px; }
.strategy-modal-header p:not(.step-label), .trade-results-heading p { margin: 0; color: var(--muted); line-height: 1.5; }
.strategy-modal-close { width: 42px; height: 42px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: transparent; font-size: 1.5rem; cursor: pointer; }
.strategy-category-tabs { position: sticky; top: -24px; z-index: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 18px; padding: 10px 0; background: var(--panel); }
.strategy-category-tabs button { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); background: transparent; cursor: pointer; transition: .2s ease; }
.strategy-category-tabs button:hover { border-color: #9dbce3; color: var(--ink); }
.strategy-category-tabs button.active { border-color: #4f8fe5; color: #1558b0; background: #eef6ff; box-shadow: inset 0 0 0 1px rgba(37,105,196,.1); }
.strategy-category-tabs span { font-weight: 850; }
.strategy-category-tabs small { flex: 0 0 auto; border-radius: 999px; padding: 4px 7px; color: inherit; background: rgba(47,125,255,.09); font-size: .66rem; font-weight: 800; }
.strategy-modal .built-in-strategy-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.strategy-modal .built-in-strategy-choice { align-content: start; min-height: 176px; padding: 16px; }
.strategy-info-panel { border: 1px solid var(--line); border-radius: 16px; padding: 20px; background: rgba(47, 125, 255, .05); }
.strategy-info-heading button { border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; color: var(--ink); background: transparent; font-weight: 800; cursor: pointer; }
.strategy-info-panel dl { margin: 18px 0 0; display: grid; grid-template-columns: 180px minmax(0, 1fr); }
.strategy-info-panel dt, .strategy-info-panel dd { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line); }
.strategy-info-panel dt { padding-right: 20px; color: var(--muted); font-weight: 800; }
.strategy-info-panel dd { line-height: 1.55; }
.built-in-configuration { margin-top: 14px; border: 1px solid var(--line); border-radius: 16px; padding: 18px; background: #fbfcfe; }
.built-in-configuration-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.built-in-configuration-heading h3 { margin: 0 0 5px; font-size: 1.05rem; }
.built-in-configuration-heading p:not(.step-label) { margin: 0; max-width: 620px; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.preset-badge { flex: 0 0 auto; border-radius: 999px; padding: 7px 10px; color: #087148; background: #eaf8f1; font-size: .68rem; font-weight: 850; }
.built-in-parameters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.built-in-parameter { display: grid; gap: 7px; }
.built-in-parameter span { color: #536176; font-size: .75rem; }
.built-in-rule-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.built-in-rule-summary div { min-width: 0; border-radius: 11px; padding: 12px; background: #edf3f9; }
.built-in-rule-summary span { display: block; margin-bottom: 5px; color: #1764c5; font-size: .65rem; font-weight: 900; letter-spacing: .09em; }
.built-in-rule-summary p { margin: 0; color: #475569; font-size: .8rem; line-height: 1.45; overflow-wrap: anywhere; }
.risk-settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.risk-setting-card { min-width: 0; border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 8px; background: #fbfcfe; }
.risk-setting-card > span { font-size: .78rem; }
.risk-setting-card > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.risk-setting-card > div b { min-width: 22px; color: var(--muted); font-size: .8rem; }
.risk-setting-card input, .risk-setting-card select { min-height: 42px; }
.risk-setting-card small { min-height: 32px; color: var(--muted); font-weight: 500; line-height: 1.4; }

.condition-builder { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); }
.condition-builder-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.condition-builder-heading h3 { margin: 0 0 6px; font-size: 1.08rem; }
.condition-builder-heading p:not(.step-label) { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.add-condition { min-height: 42px; flex: 0 0 auto; color: #334155; }
.condition-list { display: grid; gap: 14px; }
.empty-conditions { border: 1px dashed #bdc8d5; border-radius: 14px; padding: 24px; text-align: center; color: var(--muted); background: #fafbfd; }
.condition-card { border: 1px solid #cfd8e3; border-radius: 16px; background: #fff; overflow: hidden; transition: opacity .2s ease, border-color .2s ease; }
.condition-card.condition-disabled { opacity: .68; border-style: dashed; background: #f8fafc; }
.condition-card-header { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 14px; border-bottom: 1px solid #e6ebf1; background: #f8fafc; }
.condition-toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.condition-toggle input { width: 18px; min-height: 18px; height: 18px; accent-color: var(--success); }
.condition-actions { display: flex; align-items: center; gap: 9px; }
.join-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
.join-control select { width: auto; min-height: 34px; padding: 0 28px 0 9px; border-radius: 8px; font-size: .76rem; font-weight: 900; }
.remove-condition { border: 0; border-radius: 8px; min-height: 34px; padding: 0 10px; background: #feecec; color: #a72f2f; font-size: .76rem; font-weight: 800; cursor: pointer; }
.remove-condition:hover { background: #fbd9d9; }
.condition-grid { display: grid; grid-template-columns: minmax(0, 1fr) 130px minmax(0, 1fr); gap: 14px; align-items: start; padding: 14px; }
.condition-block { min-width: 0; }
.condition-block-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.condition-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.condition-fields label, .operator-block label { display: grid; gap: 5px; min-width: 0; }
.condition-fields label > span, .operator-block label > span { color: #596579; font-size: .7rem; font-weight: 800; }
.condition-fields input, .condition-fields select, .operator-block select { min-height: 39px; padding: 0 9px; border-radius: 8px; font-size: .78rem; }
.operator-block { padding-top: 25px; }
.condition-preview { margin: 0 14px 14px; border-radius: 9px; padding: 9px 11px; background: #f1f5f9; color: #465468; font-size: .78rem; font-weight: 750; line-height: 1.4; overflow-wrap: anywhere; }
.condition-preview span { color: var(--success); margin-right: 5px; }
.condition-disabled .condition-preview span { color: #8290a3; }

.notice { margin-bottom: 20px; border-radius: 12px; padding: 14px 16px; font-weight: 700; }
.notice-success { background: #eaf8f1; color: #086b42; border: 1px solid #bde7d1; }
.notice-error { background: #fff0f0; color: #a12626; border: 1px solid #f2c6c6; }

.results-section { margin: 34px 0 70px; }
.results-heading { margin-bottom: 18px; align-items: center; }
.results-heading h2 { margin-bottom: 5px; }
.results-heading p { margin: 0; color: var(--muted); }
.memory-badge { background: #eaf8f1; color: #087148; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.metric small { color: var(--muted); font-weight: 700; }
.metric strong { display: block; font-size: 1.6rem; margin-top: 7px; letter-spacing: -.03em; }
.metric-positive strong { color: var(--success); }
.metric-negative strong { color: var(--danger); }
.results-grid { display: grid; grid-template-columns: 1.6fr .7fr; gap: 18px; margin-bottom: 18px; }
.chart-panel canvas { width: 100%; background: #fbfcfd; border-radius: 12px; }
.summary-list { display: grid; gap: 0; }
.summary-row { display: flex; justify-content: space-between; gap: 15px; padding: 12px 0; border-bottom: 1px solid #edf1f5; }
.summary-row span { color: var(--muted); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { text-align: left; padding: 13px 11px; border-bottom: 1px solid #edf1f5; white-space: nowrap; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
td { font-size: .88rem; }
.pnl-positive { color: var(--success); font-weight: 800; }
.pnl-negative { color: var(--danger); font-weight: 800; }
.trade-results-panel { margin-top: 18px; }
.trade-results-heading { margin-bottom: 16px; }
.trade-results-scroll { max-width: 100%; overflow-x: auto; }
.trade-results-table { min-width: 1080px; }
.trade-results-table td { font-variant-numeric: tabular-nums; }
.trade-direction { border-radius: 999px; padding: 5px 8px; font-size: .72rem; font-weight: 850; }
.trade-direction-long { color: var(--success); background: rgba(41, 211, 145, .1); }
.trade-direction-short { color: var(--danger); background: rgba(255, 98, 109, .1); }
.trade-profit { color: var(--success); font-weight: 800; }
.trade-loss { color: var(--danger); font-weight: 800; }
.trade-results-empty { padding: 28px 12px; text-align: center; color: var(--muted); }

footer { background: var(--navy); color: white; text-align: center; padding: 30px 18px; }
footer p { color: #aeb8c6; margin-bottom: 0; }
.hidden { display: none !important; }

@media (max-width: 900px) {
    .topbar { flex-wrap: wrap; }
    .site-nav { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
    .legal-shell { grid-template-columns: 1fr; }
    .legal-sidebar { position: static; order: -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .legal-sidebar h2, .legal-help-card { grid-column: 1 / -1; }
    .hero { grid-template-columns: 1fr; padding-top: 44px; }
    .hero-card { max-width: 460px; }
    .layout-grid { grid-template-columns: 1fr; }
    .connection-panel { position: static; }
    .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .results-grid { grid-template-columns: 1fr; }
    .condition-grid { grid-template-columns: 1fr; }
    .operator-block { padding-top: 0; }
    .built-in-strategy-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .strategy-modal .built-in-strategy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    .topbar { min-height: 68px; padding: 10px 16px; }
    .brand-mark { width: 42px; height: 42px; }
    .brand-copy small { display: none; }
    .status-badge { max-width: 120px; text-align: center; }
    .site-nav a { padding: 8px 9px; font-size: .78rem; }
    .legal-shell { width: min(100% - 22px, 1120px); margin-top: 24px; }
    .legal-document { border-radius: 16px; padding: 22px 18px; }
    .legal-sidebar { grid-template-columns: 1fr; }
    .legal-sidebar h2, .legal-help-card { grid-column: auto; }
    .page-shell { width: min(100% - 22px, 1180px); }
    .hero { padding: 38px 2px 30px; }
    .hero h1 { font-size: 3.15rem; }
    .panel { border-radius: 16px; padding: 18px; }
    .risk-settings-toggle { grid-template-columns: 1fr auto; }
    .risk-settings-toggle small { display: none; }
    .form-grid { grid-template-columns: 1fr; gap: 15px; }
    .metrics-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .metric { padding: 14px; }
    .metric strong { font-size: 1.25rem; }
    .results-heading { align-items: flex-start; flex-direction: column; }
    .condition-builder-heading { flex-direction: column; }
    .add-condition { width: 100%; }
    .condition-card-header { align-items: flex-start; flex-direction: column; }
    .condition-actions { width: 100%; justify-content: space-between; }
    .condition-fields { grid-template-columns: 1fr; }
    .strategy-mode-tabs, .built-in-rule-summary, .risk-settings-grid { grid-template-columns: 1fr; }
    .built-in-strategy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .built-in-parameters { grid-template-columns: 1fr; }
    .built-in-configuration-heading { flex-direction: column; }
    .preset-badge { align-self: flex-start; }
    .strategy-modal { padding: 10px; }
    .strategy-modal-card { max-height: calc(100vh - 20px); border-radius: 16px; padding: 18px; }
    .strategy-modal .built-in-strategy-grid { grid-template-columns: 1fr; }
    .strategy-category-tabs { position: static; grid-template-columns: 1fr; }
    .strategy-modal .built-in-strategy-choice { min-height: 0; }
    .strategy-info-panel dl { grid-template-columns: 1fr; }
    .strategy-info-panel dt { border-bottom: 0; padding-bottom: 2px; }
    .strategy-info-panel dd { padding-top: 3px; }
    .strategy-info-heading, .trade-results-heading { flex-direction: column; }
}

.public-mode-card { display: flex; align-items: center; gap: 14px; border: 1px solid #bce8d8; border-radius: 14px; padding: 16px; background: #eefbf6; margin-bottom: 16px; }
.public-mode-card > div { display: grid; gap: 4px; }
.public-mode-card small { color: var(--muted); }
.data-copy { color: var(--muted); line-height: 1.6; }
.public-data-panel .broker-logo { width: 54px; font-size: .78rem; letter-spacing: .04em; background: #10223d; }


.site-nav { display: flex; align-items: center; justify-content: center; gap: 6px; }
.site-nav a { color: #d8e0ea; text-decoration: none; font-size: .82rem; font-weight: 800; padding: 9px 10px; border-radius: 9px; white-space: nowrap; }
.site-nav a:hover, .site-nav a:focus-visible { color: white; background: rgba(255,255,255,.09); outline: none; }
.terms-note { margin: 12px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.55; text-align: center; }
.terms-note a, .legal-document a, .legal-sidebar a, .footer-links a { color: var(--accent-dark); font-weight: 750; }
.footer-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; margin-top: 18px; }
.footer-links a { color: #dce3ec; text-decoration: none; font-size: .83rem; }
.footer-links a:hover { color: white; text-decoration: underline; }

.legal-shell { width: min(1120px, calc(100% - 32px)); margin: 42px auto 72px; display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 24px; align-items: start; }
.legal-document { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: clamp(24px, 5vw, 54px); box-shadow: var(--shadow); }
.legal-heading { padding-bottom: 28px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.legal-heading h1 { margin: 0; max-width: 820px; font-size: clamp(2.2rem, 6vw, 4.6rem); line-height: .98; letter-spacing: -.055em; }
.legal-updated { margin: 18px 0 0; color: var(--muted); font-size: .88rem; }
.legal-section { padding: 4px 0 26px; }
.legal-section + .legal-section { border-top: 1px solid #edf1f5; padding-top: 26px; }
.legal-section h2 { margin-bottom: 10px; font-size: 1.25rem; letter-spacing: -.02em; }
.legal-section p, .legal-section li { color: #4f5b6c; line-height: 1.75; }
.legal-section p { margin: 0 0 12px; }
.legal-section ul { margin: 8px 0 0; padding-left: 22px; }
.legal-highlight, .legal-warning { border: 1px solid #cfe8dc !important; background: #f2fbf7; border-radius: 16px; padding: 20px !important; margin-bottom: 24px; }
.legal-warning { border-color: #f0d49a !important; background: #fff9ec; }
.legal-highlight + .legal-section, .legal-warning + .legal-section { border-top: 0; }
.legal-sidebar { position: sticky; top: 100px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); display: grid; gap: 6px; }
.legal-sidebar h2 { margin: 2px 8px 10px; font-size: 1rem; }
.legal-sidebar > a { color: var(--ink); text-decoration: none; border-radius: 10px; padding: 11px 12px; font-size: .85rem; }
.legal-sidebar > a:hover { background: #f4f7fa; }
.legal-sidebar > a.active { background: var(--navy); color: white; }
.legal-help-card { margin-top: 12px; padding: 14px; border-radius: 12px; background: #fff8e8; }
.legal-help-card p { margin: 7px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.5; overflow-wrap: anywhere; }
.contact-email { font-size: 1.05rem; overflow-wrap: anywhere; }

@media (max-width: 900px) {
    .topbar { flex-wrap: wrap; }
    .site-nav { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
    .legal-shell { grid-template-columns: 1fr; }
    .legal-sidebar { position: static; order: -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .legal-sidebar h2, .legal-help-card { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
    .site-nav a { padding: 8px 9px; font-size: .78rem; }
    .legal-shell { width: min(100% - 22px, 1120px); margin-top: 24px; }
    .legal-document { border-radius: 16px; padding: 22px 18px; }
    .legal-sidebar { grid-template-columns: 1fr; }
    .legal-sidebar h2, .legal-help-card { grid-column: auto; }
}

/* Consent-gated analytics preferences shared by every page. */
.footer-link-button {
    margin: 0;
    border: 0;
    padding: 0;
    color: #dce3ec;
    background: transparent;
    font-size: .83rem;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}
.footer-link-button:hover,
.footer-link-button:focus-visible { color: white; text-decoration: underline; outline: none; }
.analytics-consent {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 20px max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    pointer-events: none;
}
.analytics-consent-panel {
    width: min(920px, 100%);
    border: 1px solid #2a405d;
    border-radius: 18px;
    padding: 22px;
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 22px;
    align-items: center;
    color: #eef4fd;
    background: linear-gradient(145deg, rgba(13, 27, 45, .99), rgba(7, 16, 28, .99));
    box-shadow: 0 28px 90px rgba(0, 0, 0, .55);
    pointer-events: auto;
}
.analytics-consent-copy { min-width: 0; }
.analytics-consent-kicker { margin: 0 0 6px; color: #55dbaa; font-size: .65rem; font-weight: 900; letter-spacing: .14em; }
.analytics-consent-copy h2 { margin: 0; font-size: clamp(1.15rem, 3vw, 1.45rem); letter-spacing: -.025em; }
.analytics-consent-copy > p:not(.analytics-consent-kicker):not(.analytics-consent-status) { max-width: 640px; margin: 8px 0 0; color: #a4b3c7; font-size: .81rem; line-height: 1.55; }
.analytics-consent-status { margin: 8px 0 0; color: #8fb9f7; font-size: .74rem; font-weight: 750; }
.analytics-consent-actions { display: grid; grid-template-columns: repeat(2, auto); gap: 9px; align-items: center; }
.analytics-consent-actions button {
    min-height: 43px;
    border-radius: 10px;
    padding: 0 15px;
    font-size: .76rem;
    font-weight: 850;
    white-space: nowrap;
    cursor: pointer;
}
.analytics-consent-decline { border: 1px solid #344960; color: #c3cfdd; background: #111f30; }
.analytics-consent-accept { border: 1px solid #347eee; color: white; background: linear-gradient(135deg, #216be8, #358cff); }
.analytics-consent-actions button:hover,
.analytics-consent-actions button:focus-visible { filter: brightness(1.1); outline: 3px solid rgba(66, 139, 255, .2); }
.analytics-consent-actions a { grid-column: 1 / -1; justify-self: center; color: #9ec3fa; font-size: .72rem; font-weight: 750; }
.analytics-consent-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    position: absolute;
    top: 8px;
    right: 8px;
    color: #aebccd;
    background: transparent;
    font-size: 1.35rem;
    cursor: pointer;
}
.analytics-consent-close:hover,
.analytics-consent-close:focus-visible { color: white; background: rgba(255, 255, 255, .07); outline: none; }
body.analytics-consent-visible .feedback-trigger { visibility: hidden; }

[data-theme="light"] .footer-link-button { color: #285b98; }
[data-theme="light"] .footer-link-button:hover,
[data-theme="light"] .footer-link-button:focus-visible { color: #123f75; }
[data-theme="light"] .analytics-consent-panel { border-color: #c8d7e8; color: #132033; background: rgba(255, 255, 255, .99); box-shadow: 0 28px 90px rgba(24, 48, 82, .24); }
[data-theme="light"] .analytics-consent-copy > p:not(.analytics-consent-kicker):not(.analytics-consent-status) { color: #53677f; }
[data-theme="light"] .analytics-consent-status { color: #155ea9; }
[data-theme="light"] .analytics-consent-decline { border-color: #c5d3e2; color: #314860; background: #f0f5fa; }
[data-theme="light"] .analytics-consent-actions a { color: #175fae; }
[data-theme="light"] .analytics-consent-close { color: #53677f; }
[data-theme="light"] .analytics-consent-close:hover,
[data-theme="light"] .analytics-consent-close:focus-visible { color: #18314e; background: #edf3f9; }

@media (max-width: 760px) {
    .nav-username { padding: 12px; }
    .nav-logout button { width: 100%; min-height: 44px; }
    .analytics-consent { padding: 12px 12px max(12px, env(safe-area-inset-bottom)); }
    .analytics-consent-panel { grid-template-columns: 1fr; gap: 16px; padding: 20px 16px 16px; }
    .analytics-consent-copy { padding-right: 24px; }
    .analytics-consent-actions { grid-template-columns: 1fr 1fr; }
    .analytics-consent-actions button { width: 100%; padding: 0 10px; }
}

@media (max-width: 430px) {
    .analytics-consent-actions { grid-template-columns: 1fr; }
    .analytics-consent-actions a { grid-column: auto; }
}

/* Keep the selected light theme last in the cascade. */
[data-theme="light"] {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #132033;
    --muted: #607087;
    --line: #d8e1ec;
    --navy: #eaf0f8;
    --navy-soft: #dde7f3;
    --accent: #176fe5;
    --accent-dark: #125fc5;
    --success: #087c55;
    --danger: #c43d49;
    --shadow: 0 20px 55px rgba(35,58,91,.1);
}
[data-theme="light"] body { background: radial-gradient(circle at 85% 8%, rgba(23,111,229,.08), transparent 28%), var(--bg); }
[data-theme="light"] .app-topbar { border-color: #d6e0ec; color: #132033; background: rgba(250,252,255,.94); }
[data-theme="light"] .brand-copy small { color: #6b7b90; }
[data-theme="light"] .site-nav a { color: #52647b; }
[data-theme="light"] .site-nav a:hover, [data-theme="light"] .site-nav a:focus-visible, [data-theme="light"] .site-nav a.active { color: #0d56ae; background: rgba(23,111,229,.09); }
[data-theme="light"] .header-cta { color: #0d5fc5; border-color: #a9c7ed; background: #edf5ff; }
[data-theme="light"] .theme-toggle, [data-theme="light"] .nav-toggle { color: #35506e; border-color: #cbd8e7; background: #f3f7fc; }
[data-theme="light"] .nav-toggle span { background: #435a74; }
[data-theme="light"] .hero h1 { color: #132033; }
[data-theme="light"] .hero-text { color: #607087; }
[data-theme="light"] .panel, [data-theme="light"] .metric, [data-theme="light"] .legal-document, [data-theme="light"] .legal-sidebar { border-color: var(--line); background: #fff; }
[data-theme="light"] .public-mode-card, [data-theme="light"] .connected-user { border-color: #b8dfcf; background: #f0faf6; }
[data-theme="light"] input, [data-theme="light"] select { border-color: #c5d1df; color: #16243a; background: #fff; }
[data-theme="light"] input[type="date"], [data-theme="light"] input[type="time"] { color-scheme: light; }
[data-theme="light"] .autocomplete { border-color: var(--line); background: #fff; box-shadow: 0 20px 50px rgba(35,58,91,.15); }
[data-theme="light"] .instrument-option { border-color: #e3e9f1; }
[data-theme="light"] .instrument-option:hover { background: #f4f8fd; }
[data-theme="light"] .condition-card { border-color: #cbd7e4; background: #fff; }
[data-theme="light"] .condition-card.condition-disabled { background: #f7f9fc; }
[data-theme="light"] .condition-card-header { border-color: #dbe3ed; background: #f6f9fc; }
[data-theme="light"] .join-control select, [data-theme="light"] .condition-fields input, [data-theme="light"] .condition-fields select, [data-theme="light"] .operator-block select { border-color: #c7d3e1; color: #1a2b42; background: #fff; }
[data-theme="light"] .condition-preview { color: #4b5f77; background: #edf3f9; }
[data-theme="light"] .empty-conditions { border-color: #b9c7d7; color: #64758a; background: #f8fafc; }
[data-theme="light"] .strategy-mode-tabs { border-color: #d5dfeb; background: #f4f7fa; }
[data-theme="light"] .strategy-mode-tab { color: #68788d; }
[data-theme="light"] .strategy-mode-tab:hover { color: #18283e; }
[data-theme="light"] .strategy-mode-tab.active { border-color: #c9d9ef; color: #1558b0; background: #fff; box-shadow: 0 7px 20px rgba(38,86,143,.08); }
[data-theme="light"] .built-in-strategy-toggle { border-color: #b9cce5; color: #1558b0; background: #eef5ff; }
[data-theme="light"] .built-in-strategy-toggle:hover { border-color: #8eb1df; background: #e6f0ff; }
[data-theme="light"] .risk-settings-toggle { border-color: #b9cce5; color: #1558b0; background: #eef5ff; }
[data-theme="light"] .risk-settings-toggle:hover { border-color: #8eb1df; background: #e6f0ff; }
[data-theme="light"] .built-in-strategy-choice { border-color: #d7e0eb; color: #16243a; background: #fff; }
[data-theme="light"] .built-in-strategy-choice:hover { border-color: #a8c6ed; }
[data-theme="light"] .built-in-strategy-choice.active { border-color: #4f8fe5; background: #eef6ff; }
[data-theme="light"] .built-in-configuration, [data-theme="light"] .risk-setting-card { border-color: #d7e0eb; background: #fbfcfe; }
[data-theme="light"] .preset-badge { color: #087148; background: #eaf8f1; }
[data-theme="light"] .built-in-parameter span { color: #536176; }
[data-theme="light"] .built-in-rule-summary div { background: #edf3f9; }
[data-theme="light"] .built-in-rule-summary span { color: #1764c5; }
[data-theme="light"] .built-in-rule-summary p { color: #475569; }
[data-theme="light"] .chart-panel canvas { background: #fbfcfe; }
[data-theme="light"] .summary-row { border-color: #e3e9f0; }
[data-theme="light"] .legal-document p, [data-theme="light"] .legal-document li, [data-theme="light"] .legal-section p, [data-theme="light"] .legal-section li { color: #4f6075; }
[data-theme="light"] .legal-heading, [data-theme="light"] .legal-section + .legal-section { border-color: #e0e7ef; }
[data-theme="light"] .legal-sidebar > a { color: #2e4057; }
[data-theme="light"] .legal-sidebar > a:hover { background: #edf3f9; }
[data-theme="light"] .legal-sidebar > a.active { color: white; background: #176fe5; }
[data-theme="light"] .legal-help-card { background: #edf5ff; }
[data-theme="light"] .legal-highlight { border-color: #b8dfcf !important; background: #f0faf6; }
[data-theme="light"] .legal-warning { border-color: #ead19d !important; background: #fff9ec; }
[data-theme="light"] footer { color: #24364d; border-color: #d7e0eb; background: #eaf0f7; }
[data-theme="light"] footer p { color: #627389; }
[data-theme="light"] .footer-links a { color: #285b98; }
[data-theme="light"] .feedback-dialog { border-color: #cfdbe8; color: #132033; background: #fff; box-shadow: 0 30px 100px rgba(22,43,74,.25); }
[data-theme="light"] .feedback-icon-close, [data-theme="light"] .feedback-close-button { color: #42566e; border-color: #cad6e4; background: #f2f6fb; }
[data-theme="light"] .feedback-field > span { color: #334961; }
[data-theme="light"] .feedback-field input, [data-theme="light"] .feedback-field select, [data-theme="light"] .feedback-field textarea { color: #132033; border-color: #c4d1e0; background: #fff; }
[data-theme="light"] .feedback-status-success { color: #096f4d; background: #ecf9f4; }
[data-theme="light"] .feedback-status-error { color: #a92d38; background: #fff0f1; }

@media (max-width: 760px) {
    .theme-toggle { margin-left: auto; }
    .nav-toggle { margin-left: 0; }
    [data-theme="light"] .app-topbar .site-nav { border-color: #cbd8e7; background: rgba(250,252,255,.99); box-shadow: 0 24px 60px rgba(35,58,91,.2); }
}

/* Shared theme control, feedback dialog and responsive safety */
button, input, select, textarea { font: inherit; }
img, canvas { max-width: 100%; }
.panel, .metric, .results-grid > *, .layout-grid > * { min-width: 0; }
.chart-panel { overflow: hidden; }
.chart-panel canvas { display: block; }

.theme-toggle {
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid #26384f;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #b7c7dc;
    background: #0b1624;
    font-size: .72rem;
    font-weight: 850;
    white-space: nowrap;
    cursor: pointer;
}
.theme-toggle:hover, .theme-toggle:focus-visible { color: white; border-color: #3b6dac; outline: none; }
.theme-icon { width: 18px; font-size: 1rem; line-height: 1; }

.feedback-trigger {
    min-height: 48px;
    padding: 0 18px;
    border: 1px solid rgba(101,161,255,.55);
    border-radius: 999px;
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 45;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: white;
    background: linear-gradient(135deg, #216be8, #358cff);
    box-shadow: 0 16px 42px rgba(18,82,190,.35);
    font-size: .82rem;
    font-weight: 850;
    cursor: pointer;
}
.feedback-trigger:hover { transform: translateY(-2px); }
.feedback-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.feedback-backdrop { position: absolute; inset: 0; background: rgba(1,7,14,.75); backdrop-filter: blur(7px); }
.feedback-dialog {
    width: min(620px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    overflow-y: auto;
    position: relative;
    border: 1px solid #2a3c54;
    border-radius: 20px;
    padding: clamp(20px, 5vw, 32px);
    color: var(--ink);
    background: linear-gradient(145deg, #0d1928, #09131f);
    box-shadow: 0 30px 100px rgba(0,0,0,.5);
}
.feedback-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 24px; }
.feedback-heading p { margin: 0 0 7px; color: var(--success); font-size: .66rem; font-weight: 900; letter-spacing: .14em; }
.feedback-heading h2 { margin: 0; font-size: clamp(1.45rem, 4vw, 2rem); letter-spacing: -.035em; }
.feedback-icon-close {
    width: 38px;
    height: 38px;
    border: 1px solid #2b3d54;
    border-radius: 9px;
    flex: 0 0 auto;
    color: #aab8ca;
    background: #0b1725;
    font-size: 1.5rem;
    cursor: pointer;
}
#feedbackForm { display: grid; gap: 17px; }
.feedback-two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.feedback-field { min-width: 0; display: grid; gap: 7px; }
.feedback-field > span { color: #aebbcf; font-size: .76rem; }
.feedback-field > span small { color: var(--muted); font-weight: 600; }
.feedback-field input, .feedback-field select, .feedback-field textarea {
    width: 100%;
    border: 1px solid #2a3b52;
    border-radius: 10px;
    padding: 11px 12px;
    color: #edf3fc;
    background: #08131f;
    outline: none;
}
.feedback-field input, .feedback-field select { min-height: 47px; }
.feedback-field textarea { min-height: 132px; resize: vertical; line-height: 1.55; }
.feedback-field input:focus, .feedback-field select:focus, .feedback-field textarea:focus { border-color: #3d83f4; box-shadow: 0 0 0 3px rgba(47,125,255,.13); }
.feedback-limit { justify-self: end; color: var(--muted); font-size: .68rem; }
.feedback-honeypot { width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; position: absolute !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; }
.feedback-actions { display: flex; justify-content: flex-end; gap: 10px; }
.feedback-actions button { min-height: 45px; padding: 0 17px; border-radius: 10px; font-weight: 850; cursor: pointer; }
.feedback-close-button { border: 1px solid #2a3b52; color: #b1bfd1; background: #101d2d; }
.feedback-submit-button { border: 0; color: white; background: linear-gradient(135deg, #216be8, #358cff); }
.feedback-submit-button:disabled { opacity: .55; cursor: wait; }
.feedback-status { min-height: 0; border-radius: 10px; font-size: .82rem; font-weight: 750; line-height: 1.5; }
.feedback-status:not(:empty) { padding: 11px 13px; }
.feedback-status-success { color: #72e1b7; border: 1px solid rgba(41,211,145,.3); background: rgba(41,211,145,.08); }
.feedback-status-error { color: #ffadb3; border: 1px solid rgba(255,98,109,.3); background: rgba(255,98,109,.08); }
body.modal-open { overflow: hidden; }

/* Light theme overrides the dark application shell without changing layout. */
[data-theme="light"] {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #132033;
    --muted: #607087;
    --line: #d8e1ec;
    --navy: #eaf0f8;
    --navy-soft: #dde7f3;
    --accent: #176fe5;
    --accent-dark: #125fc5;
    --success: #087c55;
    --danger: #c43d49;
    --shadow: 0 20px 55px rgba(35,58,91,.1);
}
[data-theme="light"] body { background: radial-gradient(circle at 85% 8%, rgba(23,111,229,.08), transparent 28%), var(--bg); }
[data-theme="light"] .app-topbar { border-color: #d6e0ec; color: #132033; background: rgba(250,252,255,.94); }
[data-theme="light"] .brand-copy small { color: #6b7b90; }
[data-theme="light"] .site-nav a { color: #52647b; }
[data-theme="light"] .site-nav a:hover, [data-theme="light"] .site-nav a:focus-visible, [data-theme="light"] .site-nav a.active { color: #0d56ae; background: rgba(23,111,229,.09); }
[data-theme="light"] .header-cta { color: #0d5fc5; border-color: #a9c7ed; background: #edf5ff; }
[data-theme="light"] .theme-toggle, [data-theme="light"] .nav-toggle { color: #35506e; border-color: #cbd8e7; background: #f3f7fc; }
[data-theme="light"] .nav-toggle span { background: #435a74; }
[data-theme="light"] .hero h1 { color: #132033; }
[data-theme="light"] .hero-text { color: #607087; }
[data-theme="light"] .panel, [data-theme="light"] .metric, [data-theme="light"] .legal-document, [data-theme="light"] .legal-sidebar { border-color: var(--line); background: #fff; }
[data-theme="light"] .public-mode-card, [data-theme="light"] .connected-user { border-color: #b8dfcf; background: #f0faf6; }
[data-theme="light"] input, [data-theme="light"] select { border-color: #c5d1df; color: #16243a; background: #fff; }
[data-theme="light"] input[type="date"], [data-theme="light"] input[type="time"] { color-scheme: light; }
[data-theme="light"] .autocomplete { border-color: var(--line); background: #fff; box-shadow: 0 20px 50px rgba(35,58,91,.15); }
[data-theme="light"] .instrument-option { border-color: #e3e9f1; }
[data-theme="light"] .instrument-option:hover { background: #f4f8fd; }
[data-theme="light"] .condition-card { border-color: #cbd7e4; background: #fff; }
[data-theme="light"] .condition-card.condition-disabled { background: #f7f9fc; }
[data-theme="light"] .condition-card-header { border-color: #dbe3ed; background: #f6f9fc; }
[data-theme="light"] .join-control select, [data-theme="light"] .condition-fields input, [data-theme="light"] .condition-fields select, [data-theme="light"] .operator-block select { border-color: #c7d3e1; color: #1a2b42; background: #fff; }
[data-theme="light"] .condition-preview { color: #4b5f77; background: #edf3f9; }
[data-theme="light"] .empty-conditions { border-color: #b9c7d7; color: #64758a; background: #f8fafc; }
[data-theme="light"] .chart-panel canvas { background: #fbfcfe; }
[data-theme="light"] .summary-row { border-color: #e3e9f0; }
[data-theme="light"] .legal-document p, [data-theme="light"] .legal-document li, [data-theme="light"] .legal-section p, [data-theme="light"] .legal-section li { color: #4f6075; }
[data-theme="light"] .legal-heading, [data-theme="light"] .legal-section + .legal-section { border-color: #e0e7ef; }
[data-theme="light"] .legal-sidebar > a { color: #2e4057; }
[data-theme="light"] .legal-sidebar > a:hover { background: #edf3f9; }
[data-theme="light"] .legal-sidebar > a.active { color: white; background: #176fe5; }
[data-theme="light"] .legal-help-card { background: #edf5ff; }
[data-theme="light"] .legal-highlight { border-color: #b8dfcf !important; background: #f0faf6; }
[data-theme="light"] .legal-warning { border-color: #ead19d !important; background: #fff9ec; }
[data-theme="light"] footer { color: #24364d; border-color: #d7e0eb; background: #eaf0f7; }
[data-theme="light"] footer p { color: #627389; }
[data-theme="light"] .footer-links a { color: #285b98; }
[data-theme="light"] .feedback-dialog { border-color: #cfdbe8; color: #132033; background: #fff; box-shadow: 0 30px 100px rgba(22,43,74,.25); }
[data-theme="light"] .feedback-icon-close, [data-theme="light"] .feedback-close-button { color: #42566e; border-color: #cad6e4; background: #f2f6fb; }
[data-theme="light"] .feedback-field > span { color: #334961; }
[data-theme="light"] .feedback-field input, [data-theme="light"] .feedback-field select, [data-theme="light"] .feedback-field textarea { color: #132033; border-color: #c4d1e0; background: #fff; }
[data-theme="light"] .feedback-status-success { color: #096f4d; background: #ecf9f4; }
[data-theme="light"] .feedback-status-error { color: #a92d38; background: #fff0f1; }

@media (max-width: 760px) {
    .theme-toggle { margin-left: auto; }
    .nav-toggle { margin-left: 0; }
    [data-theme="light"] .app-topbar .site-nav { border-color: #cbd8e7; background: rgba(250,252,255,.99); box-shadow: 0 24px 60px rgba(35,58,91,.2); }
}

@media (max-width: 560px) {
    .feedback-modal { padding: 10px; align-items: end; }
    .feedback-dialog { width: 100%; max-height: calc(100vh - 20px); border-radius: 17px; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
    .feedback-two-column { grid-template-columns: 1fr; }
    .feedback-actions { display: grid; grid-template-columns: 1fr 1.35fr; }
    .feedback-actions button { width: 100%; padding: 0 10px; }
}

@media (max-width: 430px) {
    .theme-toggle { width: 40px; padding: 0; }
    .theme-label { width: 1px; height: 1px; position: absolute; overflow: hidden; clip: rect(0 0 0 0); }
    .feedback-trigger { min-height: 44px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); padding: 0 14px; }
}

/* Premium shared shell and dark application theme */
:root {
    --bg: #060d16;
    --panel: #0c1725;
    --ink: #eef4fd;
    --muted: #8d9cb1;
    --line: #203149;
    --navy: #050b14;
    --navy-soft: #0d1929;
    --accent: #2f7dff;
    --accent-dark: #69a2ff;
    --success: #29d391;
    --danger: #ff626d;
    --shadow: 0 22px 65px rgba(0, 0, 0, .24);
}

body { background: radial-gradient(circle at 85% 8%, rgba(47,125,255,.08), transparent 28%), var(--bg); }
.app-topbar { min-height: 78px; border-bottom: 1px solid rgba(139,161,195,.14); background: rgba(5,11,20,.92); backdrop-filter: blur(18px); }
.brand-mark { background: linear-gradient(145deg, #2f7dff, #1e5ec8); color: white; box-shadow: 0 8px 24px rgba(47,125,255,.24); }
.brand-copy small { color: #6f8097; }
.site-nav a { color: #8797ac; }
.site-nav a:hover, .site-nav a:focus-visible, .site-nav a.active { color: white; background: rgba(47,125,255,.11); }
.header-cta { min-height: 40px; padding: 0 14px; border: 1px solid rgba(72,143,255,.38); border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: #a9c9ff; background: rgba(47,125,255,.08); text-decoration: none; font-size: .72rem; font-weight: 850; white-space: nowrap; }
.header-cta:hover { color: white; border-color: rgba(83,151,255,.68); background: rgba(47,125,255,.16); }
.nav-toggle { width: 42px; height: 40px; padding: 9px; border: 1px solid #26364b; border-radius: 9px; display: none; align-content: center; gap: 4px; background: #0b1624; cursor: pointer; }
.nav-toggle span { display: block; height: 2px; border-radius: 99px; background: #a8b5c7; }

.page-shell { width: min(1220px, calc(100% - 36px)); }
.hero { padding-top: 72px; }
.hero h1 { color: #f5f8fd; }
.hero-text { color: #8d9cb1; }
.hero-card { border: 1px solid #20334c; background: linear-gradient(145deg, #0d1b2d, #09131f); }
.hero-card p { color: #8999af; }
.privacy-icon { background: rgba(41,211,145,.13); color: #56e3af; }
.panel, .metric, .legal-document, .legal-sidebar { border-color: var(--line); background: linear-gradient(145deg, #0d1928, #09131f); }
.broker-logo, .public-data-panel .broker-logo { background: linear-gradient(145deg, #236ce4, #184aa2); }
.public-mode-card, .connected-user { border-color: rgba(41,211,145,.24); background: rgba(41,211,145,.055); }
.public-mode-card small, .data-copy, .field small, .info-list p { color: var(--muted); }
.info-list { border-color: var(--line); }
.info-list span { color: #8db8fa; background: rgba(47,125,255,.1); }
.strategy-tag { color: #88b4fa; background: rgba(47,125,255,.1); }
.strategy-note { border-left-color: var(--accent); color: #91a1b7; background: rgba(47,125,255,.06); }
.strategy-workspace, .risk-settings { border-color: var(--line); }
.strategy-mode-tabs { border-color: #26384f; background: #08131f; }
.strategy-mode-tab { color: #7f90a7; }
.strategy-mode-tab:hover { color: #dbe6f4; }
.strategy-mode-tab.active { border-color: #315c95; color: #9cc3ff; background: #102139; box-shadow: 0 8px 24px rgba(0,0,0,.24); }
.built-in-strategy-choice { border-color: #26384f; color: #dce6f3; background: #0a1522; }
.built-in-strategy-choice:hover { border-color: #3c6da9; }
.built-in-strategy-choice.active { border-color: #3f83dc; background: #10233b; box-shadow: inset 0 0 0 1px rgba(85,151,239,.12); }
.built-in-configuration, .risk-setting-card { border-color: #26384f; background: #091522; }
.preset-badge { color: #65deb0; background: rgba(41,211,145,.09); }
.built-in-parameter span { color: #8e9db1; }
.built-in-rule-summary div { background: #101f31; }
.built-in-rule-summary span { color: #76aaff; }
.built-in-rule-summary p { color: #9eadc1; }
input, select { border-color: #2a3b52; background: #08131f; color: #edf3fc; }
input:focus, select:focus { border-color: #3d83f4; box-shadow: 0 0 0 3px rgba(47,125,255,.13); }
input[type="date"], input[type="time"] { color-scheme: dark; }
.autocomplete { border-color: var(--line); background: #0b1725; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.instrument-option { border-color: #1c2b40; }.instrument-option:hover { background: #102036; }
.button-secondary { color: #b5c2d3; background: #132136; }.button-primary { background: #216ce8; }
.button-danger { border-color: rgba(255,98,109,.3); color: #ffadb3; background: rgba(255,98,109,.09); }
.button-accent { color: white; background: linear-gradient(135deg, #226de9, #378dff); box-shadow: 0 13px 32px rgba(47,125,255,.2); }.button-accent:hover { background: linear-gradient(135deg, #307cf4, #4a98ff); }
.condition-builder { border-color: var(--line); }.condition-builder-heading p:not(.step-label) { color: var(--muted); }
.condition-card { border-color: #283a51; background: #091421; }.condition-card.condition-disabled { background: #0a131e; }.condition-card-header { border-color: #213249; background: #0d1a2a; }
.join-control select, .condition-fields input, .condition-fields select, .operator-block select { border-color: #2b3c53; background: #0b1725; color: #e1e8f2; }
.remove-condition { color: #ff9ca3; background: rgba(255,98,109,.09); }.remove-condition:hover { background: rgba(255,98,109,.16); }
.condition-preview { color: #9fadc0; background: #101e30; }.empty-conditions { border-color: #2b3d54; color: #78899f; background: #09131f; }
.notice-success { color: #78e3ba; border-color: rgba(41,211,145,.3); background: rgba(41,211,145,.08); }.notice-error { color: #ffadb3; border-color: rgba(255,98,109,.3); background: rgba(255,98,109,.08); }
.memory-badge { color: #65deb0; background: rgba(41,211,145,.09); }
.metric small, .summary-row span, th { color: var(--muted); }.metric-positive strong { color: var(--success); }.metric-negative strong { color: var(--danger); }
.chart-panel canvas { background: #08131f; }.summary-row, th, td { border-color: #1d2d42; }
footer { border-top: 1px solid rgba(134,157,193,.13); background: #050b14; }
.terms-note { color: #718198; }
.legal-document p, .legal-document li, .legal-section p, .legal-section li { color: #9cabc0; }
.legal-heading, .legal-section + .legal-section { border-color: #1e2e43; }.legal-sidebar > a { color: #bac5d4; }.legal-sidebar > a:hover { background: #111f31; }.legal-sidebar > a.active { background: #216de9; }
.legal-help-card { background: rgba(47,125,255,.08); }.legal-highlight, .legal-warning { border-color: rgba(41,211,145,.22) !important; background: rgba(41,211,145,.055); }.legal-warning { border-color: rgba(234,173,72,.25) !important; background: rgba(234,173,72,.06); }

@media (max-width: 1040px) {
    .app-topbar .header-cta { display: none; }
}

@media (max-width: 760px) {
    .app-topbar { min-height: 68px; flex-wrap: nowrap; padding: 10px 14px; }
    .nav-toggle { margin-left: auto; display: grid; }
    .app-topbar .site-nav { width: min(320px, calc(100vw - 28px)); padding: 10px; border: 1px solid #26384f; border-radius: 13px; position: absolute; top: 66px; right: 14px; display: none; align-items: stretch; background: rgba(7,15,26,.98); box-shadow: 0 24px 60px rgba(0,0,0,.42); }
    .app-topbar .site-nav.nav-open { display: grid; }
    .app-topbar .site-nav a { padding: 12px; }
}

@media (max-width: 900px) {
    .topbar { flex-wrap: wrap; }
    .site-nav { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
    .legal-shell { grid-template-columns: 1fr; }
    .legal-sidebar { position: static; order: -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .legal-sidebar h2, .legal-help-card { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
    .site-nav a { padding: 8px 9px; font-size: .78rem; }
    .legal-shell { width: min(100% - 22px, 1120px); margin-top: 24px; }
    .legal-document { border-radius: 16px; padding: 22px 18px; }
    .legal-sidebar { grid-template-columns: 1fr; }
    .legal-sidebar h2, .legal-help-card { grid-column: auto; }
}
