/* BackTestKing — compact, data-focused UI. Tokens drive both themes. */
/* .theme-light: the light tokens on one element in any theme (the Explain tab draws its copied pictures with it — Word pages are white). */
:root, .theme-light {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --border: #e3e7ee;
    --grid: #eef1f5;
    --text: #151a23;
    --text-2: #5b6576;
    --text-3: #8a93a3;
    --accent: #2458d6;
    --accent-soft: #e8eefc;
    --pos: #0e8a4f;
    --pos-soft: #e3f4ea;
    --neg: #c8322b;
    --neg-soft: #fbe9e8;
    --warn: #a86400;
    --warn-soft: #fff3dc;
    --side: #0d1320;
    --side-2: #151d2e;
    --side-text: #aab4c6;
    --side-active: #ffffff;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
}

:root[data-theme="dark"] {
    --bg: #0a0e16;
    --surface: #111724;
    --surface-2: #151c2b;
    --border: #232c3d;
    --grid: #1a2232;
    --text: #e6e9ef;
    --text-2: #9aa4b6;
    --text-3: #6c7688;
    --accent: #5b8cff;
    --accent-soft: #1a2747;
    --pos: #34c77b;
    --pos-soft: #10291d;
    --neg: #ff6b61;
    --neg-soft: #34161a;
    --warn: #f2b447;
    --warn-soft: #2e2410;
    --side: #070a11;
    --side-2: #0f1522;
    --shadow: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 13.5px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, td.num, th.num, .tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.pos { color: var(--pos) !important; }
.neg { color: var(--neg) !important; }

/* ---------- shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 228px; flex: 0 0 228px; background: var(--side); color: var(--side-text);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; text-decoration: none !important; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; font-weight: 700; font-size: 12px;
    background: linear-gradient(135deg, #2f6bff, #19b37d); color: #fff; letter-spacing: .5px;
}
.brand-name { font-size: 15px; letter-spacing: .2px; color: #dfe5f0; }
.brand-name b { color: #fff; }
.nav-groups { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px; color: #5f6b80; padding: 14px 10px 6px; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--side-text);
    text-decoration: none !important; font-size: 13px;
}
.nav-item svg { width: 16px; height: 16px; opacity: .8; flex: 0 0 16px; }
.nav-item:hover { background: var(--side-2); color: #e7ecf5; }
.nav-item.active { background: #1c2740; color: var(--side-active); }
.nav-item.active svg { opacity: 1; color: #6f9bff; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid #1b2334; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: #25324d; color: #cfe0ff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: 0 0 26px; }
.user-name { display: flex; flex-direction: column; font-size: 12px; color: #d0d7e4; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name small { color: #6d788c; font-size: 10.5px; }
.btn-link-plain { background: none; border: 0; color: #8793a8; font-size: 12px; padding: 0; cursor: pointer; }
.btn-link-plain:hover { color: #fff; }
a.btn-link-plain { text-decoration: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 24px; border-bottom: 1px solid var(--border);
    background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.page-title { flex: 1; min-width: 0; }
.page-title h1 { font-size: 17px; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb { font-size: 11px; color: var(--text-3); display: block; line-height: 1; margin-bottom: 2px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 32px; height: 32px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 6px; display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.content { padding: 20px 24px 48px; max-width: 1640px; width: 100%; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: -240px; transition: left .2s; height: 100vh; }
    .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
    .content { padding: 16px; }
    .topbar { padding: 0 16px; }
}

/* ---------- surfaces */
.card-x { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-x + .card-x { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 13.5px; font-weight: 600; margin: 0; }
.card-head .sub { font-size: 12px; color: var(--text-2); }
.card-body-x { padding: 16px; }
.section-gap { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--surface); padding: 12px 14px; min-width: 0; }
.stat .k { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font-size: 18px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .s { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.stats.lg .stat .v { font-size: 21px; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
    text-align: left; font-weight: 600; color: var(--text-2); font-size: 11px; text-transform: uppercase; letter-spacing: .35px;
    padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
table.data td { padding: 7px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data tr:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; }
table.data tr.clickable { cursor: pointer; }
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th[data-dir="asc"]::after { content: " ▲"; font-size: 9px; }
.sortable-th[data-dir="desc"]::after { content: " ▼"; font-size: 9px; }
.empty { padding: 36px 16px; text-align: center; color: var(--text-2); }
.empty h3 { font-size: 15px; color: var(--text); margin-bottom: 6px; }

/* ---------- badges */
.badge-x { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge-x.ok, .badge-x.Completed, .badge-x.OK, .badge-x.Traded { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.badge-x.bad, .badge-x.Failed, .badge-x.Invalid, .badge-x.Rejected { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.badge-x.warn, .badge-x.Gaps, .badge-x.Cancelled, .badge-x.NotTriggered { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-x.run, .badge-x.Running, .badge-x.Queued { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dir-long { color: var(--pos); font-weight: 600; }
.dir-short { color: var(--neg); font-weight: 600; }

/* ---------- forms */
.form-x label, .lbl { font-size: 11.5px; font-weight: 600; color: var(--text-2); margin-bottom: 3px; display: block; }
.form-control, .form-select { font-size: 13px; border-color: var(--border); background-color: var(--surface); color: var(--text); padding: 5px 9px; border-radius: 6px; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background-color: var(--surface); color: var(--text); }
.form-control-sm, .form-select-sm { font-size: 12.5px; padding: 3px 7px; }
.help { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 16px; }
.fieldset-x { border-top: 1px solid var(--border); padding: 16px; }
.fieldset-x:first-child { border-top: 0; }
.fieldset-x > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-2); margin: 0 0 12px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; margin-top: 22px; }
.check input { width: 15px; height: 15px; }

.btn { font-size: 13px; border-radius: 6px; padding: 5px 12px; font-weight: 500; }
.btn-sm { font-size: 12px; padding: 3px 9px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-outline-secondary { color: var(--text); border-color: var(--border); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }

.alert { font-size: 13px; border-radius: var(--radius); padding: 10px 14px; }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.alert-danger { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.alert-success { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.alert-info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.flash { margin-bottom: 16px; }

/* ---------- progress */
.progress-x { height: 6px; background: var(--grid); border-radius: 99px; overflow: hidden; }
.progress-x > span { display: block; height: 100%; background: var(--accent); transition: width .4s; }

/* ---------- auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.auth-card .brand { padding: 0 0 18px; color: var(--text); }
.auth-card .brand-name, .auth-card .brand-name b { color: var(--text); }

/* ---------- rule builder */
.rule-group { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 10px; background: var(--surface-2); }
.rule-group .rule-group { background: var(--surface); margin-top: 8px; border-left-color: #8b5cf6; }
.rule-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.rule-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; margin-top: 6px; }
.rule-group .rule-group .rule-row { background: var(--surface-2); }
.operand { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; padding: 3px 5px; border-radius: 5px; background: var(--accent-soft); }
.operand select, .operand input, .rule-row > select, .rule-row > input, .rule-row .tol select, .rule-row .tol input { width: auto; min-width: 0; font-size: 12px; padding: 2px 5px; height: 26px; }
.operand input[type=number] { width: 64px; }
.rule-row .tol { display: inline-flex; gap: 4px; align-items: center; font-size: 11px; color: var(--text-2); }
.rule-row .tol input { width: 64px; }
.rule-del { margin-left: auto; border: 0; background: none; color: var(--text-3); font-size: 16px; line-height: 1; padding: 2px 6px; cursor: pointer; }
.rule-del:hover { color: var(--neg); }
.rule-text { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--border); border-radius: 6px; padding: 8px 10px; margin-top: 10px; white-space: normal; }
.logic-pill { font-size: 11px; font-weight: 700; }

/* ---------- charts */
.chart-box { height: 320px; width: 100%; }
.chart-box.sm { height: 180px; }
.chart-box.lg { height: 460px; }

/* ---------- heatmap */
table.heat td.cell { text-align: right; font-weight: 500; }
.heat-pos-1 { background: rgba(14, 138, 79, .12); } .heat-pos-2 { background: rgba(14, 138, 79, .25); } .heat-pos-3 { background: rgba(14, 138, 79, .42); }
.heat-neg-1 { background: rgba(200, 50, 43, .12); } .heat-neg-2 { background: rgba(200, 50, 43, .25); } .heat-neg-3 { background: rgba(200, 50, 43, .42); }

/* ---------- tabs */
.tabs-x { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs-x a, .tabs-x button { padding: 8px 14px; font-size: 13px; color: var(--text-2); border: 0; background: none; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none !important; cursor: pointer; }
.tabs-x .active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.kv { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 6px 16px; font-size: 12.5px; }
.kv dt { color: var(--text-2); font-weight: 500; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.pass { color: var(--pos); font-weight: 700; } .fail { color: var(--neg); font-weight: 700; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.modal-content { background: var(--surface); color: var(--text); border-color: var(--border); }

/* rule-builder compact controls */
.rule-group-head .form-select, .rule-row .form-select, .operand .form-select {
    width: auto; display: inline-block; padding: 2px 24px 2px 7px; background-position: right 6px center; background-size: 10px 8px; height: 26px; font-size: 12px;
}
.rule-row .form-control, .operand .form-control { display: inline-block; height: 26px; font-size: 12px; padding: 2px 6px; }
.operand input[type=number] { width: 60px; }

@media (max-width: 767.98px) {
    .topbar { height: auto; min-height: 58px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; row-gap: 6px; }
    .page-title { flex: 1 1 calc(100% - 50px); }
    .topbar-actions { flex-wrap: wrap; width: 100%; }
    .topbar-actions form { display: inline; }
}

/* ================= Chartink-style condition builder (token sentence + popover menus) ================= */
:root { --op: #7c3aed; --op-soft: #f1ebfe; --pop-shadow: 0 12px 32px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .08); }
:root[data-theme="dark"] { --op: #b48cff; --op-soft: #2a2140; --pop-shadow: 0 12px 32px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .04); }

.cb-group { font-size: 13px; }
.cb-group.nested { margin: 4px 0 4px 14px; padding: 6px 0 6px 12px; border-left: 2px solid var(--op-soft); }
.cb-head { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; color: var(--text-2); padding: 2px 4px 6px; }
.cb-head .cb-actions { opacity: 1; }
.cb-rows { display: flex; flex-direction: column; gap: 2px; }
.cb-row { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 8px; min-height: 36px; }
.cb-row:hover, .cb-row:focus-within { background: var(--surface-2); }
.cb-row.disabled .cb-sentence { opacity: .42; }
.cb-sentence { display: flex; align-items: center; flex-wrap: wrap; gap: 1px 2px; min-width: 0; flex: 1; }
.cb-word { color: var(--text-3); padding: 0 4px; }
.cb-empty-row { color: var(--text-3); font-size: 12.5px; padding: 6px 8px; }
.cb-foot { padding: 6px 4px 2px; }

.cb-tok {
    border: 0; background: transparent; font: inherit; color: var(--text); padding: 3px 6px; min-height: 28px;
    border-radius: 6px; cursor: pointer; line-height: 1.2; white-space: nowrap; transition: background-color .12s ease;
}
.cb-tok:hover { background: var(--accent-soft); }
.cb-tok:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cb-tok.open { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.cb-off { color: var(--text-3); font-family: var(--mono); font-size: 12px; padding: 3px 3px; }
.cb-tf { color: var(--text-2); }
.cb-tf-default { color: var(--text-3); }
.cb-measure { font-weight: 600; }
.cb-params { color: var(--text-2); padding-left: 1px; }
.cb-op, .cb-arith { color: var(--op); font-weight: 600; }
.cb-op:hover, .cb-arith:hover { background: var(--op-soft); }
.cb-logic { color: var(--accent); font-weight: 700; }
.cb-chip { font-size: 11.5px; color: var(--text-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; min-height: 22px; margin-left: 4px; }
.cb-caret { color: var(--text-3); padding: 3px 4px; font-size: 11px; }
.cb-icon { color: var(--text-3); padding: 3px 4px; display: inline-grid; place-items: center; }
.cb-icon svg { width: 16px; height: 16px; }
.cb-num {
    width: 76px; height: 28px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text);
    padding: 2px 6px; font: inherit; font-variant-numeric: tabular-nums; margin: 0 2px;
}
.cb-num:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cb-add { width: 28px; height: 28px; padding: 0; display: inline-grid; place-items: center; border-radius: 8px; background: var(--op); color: #fff; }
.cb-add:hover { background: var(--op); filter: brightness(1.08); }
.cb-add svg { width: 16px; height: 16px; }

.cb-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; opacity: 0; transition: opacity .12s ease; }
.cb-row:hover .cb-actions, .cb-row:focus-within .cb-actions { opacity: 1; }
@media (hover: none) { .cb-actions { opacity: 1; } }
.cb-act { width: 28px; height: 28px; border: 0; background: transparent; color: var(--text-3); border-radius: 6px; display: grid; place-items: center; cursor: pointer; }
.cb-act svg { width: 15px; height: 15px; }
.cb-act:hover { background: var(--surface); color: var(--text); }
.cb-act.danger:hover { color: var(--neg); }
.cb-switch { width: 32px; height: 20px; border-radius: 999px; border: 0; background: var(--border); position: relative; cursor: pointer; padding: 0; margin: 0 4px; transition: background-color .15s ease; }
.cb-switch span { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s ease; }
.cb-switch.on { background: var(--pos); }
.cb-switch.on span { transform: translateX(12px); }

/* popover */
.cb-pop {
    position: absolute; z-index: 1050; min-width: 240px; max-width: 340px; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--pop-shadow); padding: 6px;
    animation: cb-pop-in .12s ease-out;
}
@keyframes cb-pop-in { from { opacity: 0; transform: translateY(-3px) scale(.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cb-pop { animation: none; } .cb-switch, .cb-switch span, .cb-tok { transition: none; } }
.cb-search { width: 100%; height: 30px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); color: var(--text); padding: 4px 9px; font: inherit; margin-bottom: 6px; }
.cb-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cb-list { max-height: 320px; overflow-y: auto; overscroll-behavior: contain; }
.cb-sec { font-size: 11px; font-weight: 600; letter-spacing: .3px; color: var(--text-3); padding: 8px 8px 3px; }
.cb-sec:not(:first-child) { border-top: 1px solid var(--grid); margin-top: 4px; }
.cb-item {
    display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: transparent; color: var(--text); font: inherit;
    text-align: left; padding: 5px 8px; min-height: 30px; border-radius: 6px; cursor: pointer;
}
.cb-item:hover, .cb-item:focus { background: var(--accent); color: #fff; outline: none; }
.cb-item:hover .cb-hint, .cb-item:focus .cb-hint, .cb-item:hover .cb-check, .cb-item:focus .cb-check { color: rgba(255,255,255,.85); }
.cb-item.danger { color: var(--neg); }
.cb-item.danger:hover, .cb-item.danger:focus { background: var(--neg); color: #fff; }
.cb-check { width: 14px; flex: 0 0 14px; color: var(--accent); font-weight: 700; font-size: 12px; }
.cb-label { white-space: nowrap; }
.cb-hint { margin-left: auto; padding-left: 12px; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.cb-empty { color: var(--text-3); padding: 12px 8px; font-size: 12.5px; }
.cb-form { padding: 6px; min-width: 250px; }
.cb-form-title { font-weight: 600; margin-bottom: 8px; }
.cb-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cb-form-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.cb-seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.cb-seg button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.cb-seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 600; }
#slExpr { padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }

/* ---------- Help page ---------- */
.help-page { max-width: 880px; margin: 0 auto; }
.help-hero { padding: 18px 18px 14px; }
.help-hero h1 { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
.help-hero p { font-size: 14px; line-height: 1.55; color: var(--text-2); margin: 0 0 12px; }
.help-tools { display: flex; gap: 8px; align-items: center; }
.help-tools .form-control { flex: 1; min-width: 0; height: 38px; font-size: 14px; }
.help-tools .btn { height: 38px; white-space: nowrap; display: inline-flex; align-items: center; }
#helpCount:empty { display: none; }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.help-toc a { font-size: 12.5px; padding: 5px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.help-toc a:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.help-sec { scroll-margin-top: 104px; overflow: hidden; }
.help-sec > summary { list-style: none; cursor: pointer; padding: 14px 44px 14px 18px; position: relative; }
.help-sec > summary::-webkit-details-marker { display: none; }
.help-sec > summary::after { content: "+"; position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font-size: 20px; color: var(--text-3); }
.help-sec[open] > summary::after { content: "−"; }
.help-sec > summary:hover { background: var(--surface-2); }
.help-sec > summary h2 { font-size: 15.5px; font-weight: 650; margin: 0; }
.help-body { padding: 4px 18px 16px; border-top: 1px solid var(--border); }
.help-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); margin: 18px 0 6px; font-weight: 650; scroll-margin-top: 104px; }
.help-item { font-size: 14px; line-height: 1.6; padding: 10px 0; border-bottom: 1px dashed var(--border); scroll-margin-top: 104px; transition: opacity .15s; }
.help-item:last-child { border-bottom: 0; }
.help-item p { margin: 0 0 6px; }
.help-item p:last-child { margin-bottom: 0; }
.help-item ul, .help-item ol { margin: 4px 0 6px; padding-left: 20px; }
.help-item li { margin: 3px 0; }
.help-dim { opacity: .35; }
.help-example { background: var(--pos-soft); border-left: 3px solid var(--pos); border-radius: 6px; padding: 8px 12px; margin: 8px 0 4px; font-size: 13.5px; }
.help-code, .help-code-inline { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; }
.help-code { display: block; padding: 8px 10px; margin: 6px 0; overflow-x: auto; white-space: nowrap; }
.help-code-inline { padding: 1px 5px; white-space: normal; word-break: break-word; }
.help-grid { list-style: none; padding-left: 0 !important; display: grid; grid-template-columns: 1fr; gap: 6px; }
.help-grid li { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; margin: 0 !important; }
.help-dl { display: grid; grid-template-columns: 1fr; gap: 2px 14px; margin: 0; }
.help-dl dt { font-weight: 650; margin-top: 8px; scroll-margin-top: 104px; }
.help-dl dd { margin: 0 0 4px; color: var(--text-2); }
.help-candle { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.help-candle svg { width: 250px; max-width: 100%; flex: none; color: var(--text-2); }
.help-candle > div { flex: 1 1 260px; min-width: 0; }
.help-candle-body { fill: var(--pos); }
@media (min-width: 768px) {
    .help-grid { grid-template-columns: 1fr 1fr; }
    .help-dl { grid-template-columns: minmax(150px, 220px) 1fr; }
    .help-dl dt { margin-top: 0; }
}
@media (max-width: 575.98px) {
    .help-hero { padding: 14px; }
    .help-sec > summary { padding: 13px 40px 13px 14px; }
    .help-body { padding: 2px 14px 12px; }
    .help-tools { flex-wrap: wrap; }
    .help-tools .form-control { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { .help-item { transition: none; } }
/* Gujarati help: a script-capable font on every platform, a little more line spacing for the matras. */
.help-page:lang(gu) { font-family: "Noto Sans Gujarati", "Nirmala UI", "Gujarati Sangam MN", "Shruti", system-ui, sans-serif; }
.help-page:lang(gu) .help-item, .help-page:lang(gu) .help-hero p { line-height: 1.75; }

/* ---------- Suggestions tab ---------- */
.sg { display: flex; flex-direction: column; gap: 14px; }
.sg .card-x + .card-x { margin-top: 0; }
.sg-h { font-size: 15px; font-weight: 650; margin: 6px 0 0; }
.sg-lead { font-size: 12.5px; margin: 0 0 10px; }
.sg-card { border-left: 3px solid var(--pos); }
.sg-combo { border-left-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow); }
.sg-title { font-weight: 600; font-size: 14px; line-height: 1.45; word-break: break-word; }
.sg-badge { background: var(--accent-soft); color: var(--accent); border-color: transparent; margin-right: 6px; vertical-align: 1px; }
.sg-evidence { font-size: 13px; color: var(--text-2); margin: 6px 0 10px; line-height: 1.5; }
.sg-table td:first-child { white-space: normal; }
.sg-warn { font-size: 12.5px; color: var(--neg); margin-top: 8px; }
.sg-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.sg-actions form { margin: 0; }
.sg-others > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; font-size: 13.5px; }
.sg-others[open] > summary { border-bottom: 1px solid var(--border); }
.sg-row { padding: 9px 0; border-bottom: 1px dashed var(--border); }
.sg-row:last-child { border-bottom: 0; }
.sg-note { font-size: 12px; }
.sg-goal { border-top: 3px solid var(--accent); }
.sg-goal-ok { border-top-color: var(--pos); }
.sg-goal .card-head { flex-wrap: wrap; }
.sg-goal-form { display: flex; align-items: center; gap: 6px; margin: 0; }
.sg-goal-form .lbl { margin: 0; white-space: nowrap; }
.sg-goal-form input { width: 80px; }
.sg-goal-status { font-size: 14px; margin: 0 0 8px; }
.sg-steps { margin: 0 0 8px; padding-left: 20px; font-size: 13px; line-height: 1.6; }

/* ---------- Strategy Lab (AI Brain) ---------- */
.lab { display: flex; flex-direction: column; gap: 14px; }
.lab .card-x + .card-x { margin-top: 0; }
.lab .card-head { flex-wrap: wrap; }
.lab-actions { display: flex; gap: 8px; }
.lab-actions form, .lab-links form { margin: 0; }
.lab-status.Running { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.lab-status.Blocked, .lab-status.Paused { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.lab-status.Converged { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.lab-kv dd { word-break: break-word; }
.lab-counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 12px; }
.lab-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.lab-node { border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; background: var(--surface); min-height: 86px; transition: border-color .3s, box-shadow .3s; }
.lab-node-head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.lab-node-no { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; background: var(--surface-2); color: var(--text-2); flex: none; }
.lab-node-score { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--text-2); }
.lab-node-finding { font-size: 12px; color: var(--text-2); margin-top: 5px; line-height: 1.4; word-break: break-word; }
.lab-node.done { border-color: var(--pos); }
.lab-node.done .lab-node-no { background: var(--pos-soft); color: var(--pos); }
.lab-node.warning { border-color: var(--neg); }
.lab-node.warning .lab-node-no { background: var(--neg-soft); color: var(--neg); }
.lab-node.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: labPulse 1.6s ease-in-out infinite; }
.lab-node.active .lab-node-no { background: var(--accent); color: #fff; }
@keyframes labPulse { 50% { box-shadow: 0 0 0 6px var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) { .lab-node.active { animation: none; } }
.lab-best-title { font-size: 14px; margin: 0 0 8px; }
.lab-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.lab-patterns { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.lab-pattern { border: 1px solid var(--border); border-left: 3px solid var(--neg); border-radius: 6px; padding: 9px 11px; }
.lab-tfs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.lab-tf { border: 1px solid var(--border); border-radius: 6px; padding: 9px 11px; }
.lab-tf-head { font-size: 13px; margin-bottom: 4px; }
.lab-tf-text { font-size: 12.5px; margin: 6px 0 0; line-height: 1.5; }
.lab-exp td.lab-wrap, td.lab-wrap { white-space: normal; min-width: 180px; max-width: 420px; }
.lab-log { list-style: none; margin: 0; padding: 0; font-size: 12.5px; max-height: 420px; overflow-y: auto; }
.lab-log li { padding: 4px 0; border-bottom: 1px dashed var(--border); line-height: 1.45; }
.lab-log li:last-child { border-bottom: 0; }
.lab-log-finding b, .lab-log-upgrade b { color: var(--pos); }
.lab-log-warning b, .lab-log-error b { color: var(--neg); }
.lab-pre { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.lab-pre.lab-changed { border-color: var(--accent); }
.lab-disc-status { font-size: 13px; margin: 0 0 8px; line-height: 1.6; }
.lab-disc-status .badge-x { margin-right: 6px; }
.lab-disc-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin: 6px 0 14px; }
.lab-disc-side { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.lab-disc-side h3, .lab-disc-h { font-size: 13px; font-weight: 700; margin: 0 0 6px; }
.lab-disc-h { margin-top: 4px; }
.lab-disc-conds { margin: 0 0 10px; padding-left: 20px; font-size: 13px; line-height: 1.5; }
.lab-disc-gens summary { font-size: 12px; color: var(--text-2); cursor: pointer; }
.lab-disc-gens ul { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--text-2); line-height: 1.5; }
.lab-disc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.lab-disc-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.lab-disc-item.finalist { border-left: 3px solid var(--accent); }
.lab-disc-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-bottom: 4px; }
.lab-disc-cond { font-size: 13.5px; font-weight: 600; line-height: 1.45; word-break: break-word; }
.lab-disc-stats { font-size: 12.5px; margin-top: 4px; line-height: 1.5; }
.lab-disc-rules, .lab-disc-why { font-size: 12px; margin-top: 4px; line-height: 1.45; word-break: break-word; }
.lab-disc-link { display: inline-block; font-size: 12.5px; margin-top: 6px; }
@media (max-width: 575.98px) { .lab-disc-list, .lab-disc-sides { grid-template-columns: 1fr; } }

/* ---------- Explain tab ---------- */
.ex { display: flex; flex-direction: column; gap: 14px; }
.ex .card-x + .card-x { margin-top: 0; }
.ex-sec { scroll-margin-top: 104px; }
.ex-point { margin: 0 0 6px; font-size: 14px; line-height: 1.6; word-break: break-word; }
.ex-point:last-of-type { margin-bottom: 0; }
.ex .help-example { margin-top: 10px; }

/* ---------- Condition formulas page ---------- */
.fx-hero h2 { font-size: 16px; margin: 0 0 6px; }
.fx-hero p { font-size: 13.5px; line-height: 1.55; margin: 0 0 8px; }
.fx-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.fx-tools input[type=search] { flex: 1 1 260px; }
.fx-tools select { flex: 0 1 200px; width: auto; }
.fx-check { font-size: 13px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.fx-selbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.fx-selbar .faint { margin-right: auto; font-size: 12.5px; }
.fx-table td { vertical-align: top; }
.fx-table .fx-sel { width: 28px; }
.fx-row-formula { display: flex; gap: 8px; align-items: flex-start; }
.fx-row-formula code { font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 6px; padding: 4px 7px; flex: 1 1 auto; min-width: 0; }
.fx-row-formula .fx-copy { flex: none; }
.fx-copy.fx-copied { background: var(--pos-soft); color: var(--pos); border-color: var(--pos); }
.fx-desc { font-size: 13px; line-height: 1.45; min-width: 220px; }
.fx-disc > summary { cursor: pointer; list-style: none; }
.fx-disc > summary h2 { display: inline; font-size: 15px; }
.fx-disc-list { display: grid; gap: 10px; margin-top: 8px; }
.fx-disc-item { border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; }
.fx-disc-top { font-size: 13px; margin-bottom: 6px; }
.fx-card summary { font-size: 12.5px; color: var(--text-2); cursor: pointer; margin-top: 6px; }
.fx-card-lines { font-size: 13px; line-height: 1.5; margin: 6px 0 0; padding-left: 20px; }
@media (max-width: 575.98px) { .fx-table th:nth-child(5), .fx-table td:nth-child(5) { display: none; } .fx-row-formula { flex-direction: column; } }

/* ---------- Strategy Builder: paste a formula ---------- */
.cb-paste { margin-top: 10px; border: 1px dashed var(--border); border-radius: 8px; padding: 6px 10px; }
.cb-paste > summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.cb-paste-hint { font-size: 12.5px; color: var(--text-2); margin: 6px 0; }
.cb-paste-text { font-family: var(--mono); font-size: 12.5px; }
.cb-paste-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.cb-paste-msg { font-size: 12.5px; line-height: 1.45; flex: 1 1 240px; }
.cb-paste-msg.ok { color: var(--pos); }
.cb-paste-msg.bad { color: var(--neg); }

/* ---------- Explain tab pictures (inline SVG; colours follow the theme) ---------- */
.ex-figs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 14px; margin-bottom: 10px; }
.ex-fig { margin: 0; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); min-width: 0; }
.ex-fig-wide { grid-column: 1 / -1; }
.ex-fig-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.ex-fig-cap { font-size: 13px; line-height: 1.5; margin: 8px 0 0; color: var(--text-2); }
.exs { width: 100%; max-width: 560px; height: auto; display: block; overflow: visible; }
.ex-fig-wide .exs { max-width: 760px; }
.ex-fig-chart .exs { max-width: 980px; }
.exs text { font-size: 12px; fill: var(--text); font-family: inherit; }
.exs text.small { font-size: 10.5px; fill: var(--text-2); }
.exs text.strong { font-size: 12px; font-weight: 700; }
.exs text.label { font-size: 11.5px; fill: var(--text); }
.exs text.emoji { font-size: 20px; }
.exs text.op { font-size: 26px; font-weight: 700; fill: var(--text-2); }
.exs text.pos { fill: var(--pos); font-weight: 700; }
.exs text.neg { fill: var(--neg); font-weight: 700; }
.exs .box { fill: var(--surface-2); stroke: var(--border); }
.exs .box.off { opacity: .45; }
.exs .up { fill: var(--pos); stroke: var(--pos); }
.exs .down { fill: var(--neg); stroke: var(--neg); }
.exs .ghost { fill: var(--text-2); stroke: var(--text-2); opacity: .45; }
.exs .wick { stroke: var(--text-2); stroke-width: 1.4; }
.exs .hl { fill: #f5c542; opacity: .28; }
.exs .zone { fill: var(--pos); opacity: .35; }
.exs .bar { fill: var(--surface-2); stroke: var(--border); }
.exs .riskbox { fill: var(--neg); opacity: .22; }
.exs .rewardbox { fill: var(--pos); opacity: .25; }
.exs .entryline { stroke: var(--accent); stroke-width: 2; }
.exs .stopline { stroke: var(--neg); stroke-width: 2; stroke-dasharray: 6 4; fill: none; }
.exs .target { stroke: var(--pos); stroke-width: 2; stroke-dasharray: 6 4; fill: none; }
.exs .priceline { stroke: var(--accent); stroke-width: 2.2; fill: none; }
.exs .arrowline { stroke: var(--text-2); stroke-width: 2; }
.exs .arrowhead { fill: var(--text-2); }
.exs .entrydot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.exs .entrymark { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.exs .exitmark { stroke: var(--text); stroke-width: 2.4; fill: none; }

/* Explain tab: copy for Word / WhatsApp */
.ex-copyall { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.ex-copyhint { font-size: 12px; flex: 1 1 260px; }
.ex-head { flex-wrap: wrap; }
.ex-headtext { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.ex-copybar { display: flex; gap: 6px; flex-wrap: wrap; }
.ex-copybar .btn, .ex-copy-pic { font-size: 11.5px; padding: 2px 8px; }
.ex-copy-pic { margin-top: 8px; }
.ex-copy.ex-copied, .ex-copy-pic.ex-copied { background: var(--pos-soft); color: var(--pos); border-color: var(--pos); }
.ex-copy.ex-copyfail, .ex-copy-pic.ex-copyfail { background: var(--neg-soft); color: var(--neg); border-color: var(--neg); }
.ex-copy-host { position: fixed; left: -10000px; top: 0; width: 1000px; pointer-events: none; }

/* Strategy Lab: discovery analyses */
.lab-an { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 10px; }
.lab-an > summary { cursor: pointer; padding: 8px 12px; font-size: 13px; }
.lab-an[open] > summary { border-bottom: 1px solid var(--border); }
.lab-an-body { padding: 10px 12px; min-width: 0; }
.lab-an-cand { margin: 8px 0 0; }
.lab-an-cand > summary { padding: 6px 10px; font-size: 12.5px; color: var(--accent); }
.lab-disc-item:has(> .lab-an-cand[open]) { grid-column: 1 / -1; }
.lab-an-table { margin: 0 0 14px; min-width: 0; }
.lab-an-table h4 { font-size: 12.5px; font-weight: 700; margin: 0 0 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.lab-an-table h4 .faint { font-weight: 400; }
.lab-an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 0 14px; }
.lab-an-note { font-size: 11.5px; margin: -6px 0 12px; }
.lab-an-kv { margin: 0; }
table.data.compact th, table.data.compact td { padding: 4px 8px; font-size: 12px; }
.lab-heat td { min-width: 52px; }
.lab-heat td.diag { outline: 2px solid var(--text-3); outline-offset: -2px; font-weight: 700; }
.lab-heat .lab-heat-label { text-align: left; font-weight: 500; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.lab-rulecard { font-family: var(--mono); font-size: 12px; line-height: 1.55; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
    padding: 8px 10px; margin: 0; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.lab-copy { font-size: 11px; padding: 1px 8px; }
.lab-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.lab-metrics > div { border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; display: flex; flex-direction: column; min-width: 0; }
.lab-metrics span { font-size: 11px; color: var(--text-2); }
.lab-metrics b { font-size: 15px; }
.lab-metrics small { font-size: 11px; color: var(--text-3); }
.labc { width: 100%; max-width: 720px; height: auto; display: block; }
.labc .eq { fill: none; stroke: var(--accent); stroke-width: 2; }
.labc .dd { fill: var(--neg); opacity: .35; stroke: var(--neg); stroke-width: 1; }
.labc .zero { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 4 3; }
.labc text { font-size: 11px; fill: var(--text-2); font-family: inherit; }
.labc text.end { font-size: 12px; font-weight: 700; }
.labc text.end.pos { fill: var(--pos); }
.labc text.end.neg { fill: var(--neg); }
.lab-heat tbody th.lab-heat-label { text-transform: none; letter-spacing: normal; font-size: 12px; color: var(--text); }
table.data.lab-heat th { position: static; }   /* table.data headers are sticky; here the row labels are headers too, so they would all stick to the top */
table.data td.wrap { white-space: normal; min-width: 180px; }   /* long condition names wrap instead of widening the table */

/* Help page: plain-words line, tip / warning boxes, "full list" folds and Rex */
.help-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.help-tldr { font-size: 14.5px; line-height: 1.55; margin: 12px 0 4px; }
.help-tldr span { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin-bottom: 2px; }
.help-tip, .help-warn { border-left: 3px solid; border-radius: 6px; padding: 8px 12px; margin: 10px 0 4px; font-size: 13.5px; line-height: 1.55; }
.help-tip { background: var(--accent-soft); border-color: var(--accent); }
.help-warn { background: var(--warn-soft); border-color: var(--warn); }
.help-more { margin: 10px 0 4px; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; }
.help-more > summary { cursor: pointer; padding: 9px 0; font-size: 13.5px; font-weight: 600; color: var(--accent); }
.help-more[open] > summary { border-bottom: 1px dashed var(--border); }
.help-rex { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 16px; align-items: center; margin: 12px 0 10px; padding: 12px; border-radius: 14px; background: #fff6e5; border: 1px solid #f0dcb4; }
.help-rex .rx, .help-rex img { width: 100%; height: auto; display: block; border-radius: 10px; }
.help-rex figcaption { font-size: 14.5px; line-height: 1.55; color: #4a3a1c; font-weight: 500; }
:root[data-theme="dark"] .help-rex { background: #2a2418; border-color: #4a3d22; }
:root[data-theme="dark"] .help-rex figcaption { color: #eadbb8; }
@media (max-width: 640px) { .help-rex { grid-template-columns: 1fr; } }
.help-teaser { margin: 4px 0 0; font-size: 13px; line-height: 1.45; color: var(--text-2); font-style: italic; }
.help-sec[open] > summary .help-teaser { display: none; }
/* Condition formulas: "Good for" tag and how the condition did alone */
.fx-good { min-width: 150px; }
.fx-lean { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .3px; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.fx-lean.buy { background: var(--pos-soft); color: var(--pos); }
.fx-lean.sell { background: var(--neg-soft); color: var(--neg); }
.fx-lean.either { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.fx-alone { display: flex; flex-direction: column; gap: 1px; margin-top: 4px; font-size: 11.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Admin → Users and Page access */
.users-inline { display: inline-flex; gap: 6px; align-items: center; }
.users-inline .form-select, .users-inline .form-control { width: auto; min-width: 110px; }
.users-reset { display: inline-block; margin-right: 4px; vertical-align: top; }
.users-reset > summary { list-style: none; }
.users-reset > summary::-webkit-details-marker { display: none; }
.users-reset[open] > summary { margin-bottom: 6px; }
.users-table td { vertical-align: top; }
.access-table td { vertical-align: top; }
.access-table .access-group th { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-2); position: static; }
.access-yes { color: var(--pos); font-weight: 700; }
.access-box { width: 18px; height: 18px; cursor: pointer; }
.access-choice { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.access-choice label { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.access-choice label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.access-choice label.allow:has(input:checked) { background: var(--pos-soft); border-color: var(--pos); color: var(--pos); }
.access-choice label.deny:has(input:checked) { background: var(--neg-soft); border-color: var(--neg); color: var(--neg); }
.access-choice input { margin: 0; }
.users-work { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: 12px; }
.owner-pick { display: inline-flex; gap: 6px; align-items: center; }
.owner-pick .form-select { width: auto; min-width: 180px; }
.owner-banner { border-left: 3px solid var(--warn); background: var(--warn-soft); border-radius: 6px; padding: 8px 12px; margin-bottom: 12px; font-size: 13.5px; }
