:root {
  --bg: #0f1218; --panel: #161b24; --line: #262d3a; --text: #e6e9ef; --muted: #8a93a6;
  --accent: #2f81f7; --good: #2ea043; --warn: #d29922; --bad: #f85149; --code: #0b0e13;
  --chip: #1d2533; --hover: #1a2130; --selected: #1f3a5f;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f6f8; --panel: #ffffff; --line: #d9dde3; --text: #131722; --muted: #5d6573;
  --accent: #2962ff; --good: #089981; --warn: #b26b00; --bad: #e0393e; --code: #fafbfc;
  --chip: #eef1f6; --hover: #eef3fb; --selected: #dbe7ff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; }
button, .btn, select, input, textarea { font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
button, .btn { cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover:not(:disabled), .btn:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.muted { color: var(--muted); }

.top { padding: 12px 16px 8px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; }
.badge { font-weight: 500; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--good); border-color: var(--good); }
.badge.bad { color: var(--warn); border-color: var(--warn); }
.ask { display: flex; gap: 8px; }
.ask input { flex: 1; min-width: 0; padding: 10px 12px; font-size: 15px; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.examples button { font-size: 12px; padding: 3px 9px; border-radius: 999px; color: var(--muted); white-space: normal; text-align: left; max-width: 100%; }

.controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.controls label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 13px; }
.chip button { border: 0; background: none; padding: 0 6px; color: var(--muted); }
.chip button:hover { color: var(--bad); }
.add { display: flex; gap: 4px; }
.add input { width: 64px; }
.auto { font-size: 12px; }
.notes { padding: 6px 16px; color: var(--warn); font-size: 13px; border-bottom: 1px solid var(--line); }

.split { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 30%); min-height: 0; }
/* Focus mode: hide the Ask box and controls row so the chart gets the height */
body.focus #tab-chart > .askbar, body.focus #tab-chart > .controls, body.focus #notes { display: none; }
.chart-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
.chart-top .today-bar { flex: 1 1 340px; min-width: 0; border-bottom: 0; }
.chart-btns { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 8px; margin-left: auto; }
.chart-btns button { padding: 3px 9px; font-size: 12.5px; }
.tf-seg { display: flex; }
.tf-seg button { border-radius: 0; margin-left: -1px; min-width: 32px; font-weight: 600; }
.tf-seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.tf-seg button:last-child { border-radius: 0 6px 6px 0; }
.tf-seg button.active { background: var(--accent); border-color: var(--accent); color: #fff; position: relative; }
body.focus #focusBtn { background: var(--accent); border-color: var(--accent); color: #fff; }
.split.no-pine { grid-template-columns: minmax(0, 1fr); }
.split.no-pine .pine { display: none; }
.chart-wrap:fullscreen { background: var(--bg); height: 100vh; }

/* ---------- right panel: Scans / Pine tabs ---------- */
.side-tabs { display: flex; border-bottom: 1px solid var(--line); }
.side-tabs button { flex: 1; border: 0; border-radius: 0; background: none; padding: 9px; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; }
.side-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.side-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.side-pane[hidden] { display: none; }
#panelScan { flex: 1; min-width: 0; }
.panel-sub { display: flex; gap: 6px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 12px; }
.panel-sub input { width: 90px; padding: 3px 6px; }
.panel-sub button { padding: 2px 8px; }
.panel-list { flex: 1; overflow: auto; background: var(--code); }
.prow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline;
  padding: 7px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-variant-numeric: tabular-nums; }
.prow:hover { background: var(--hover); }
.prow.sel { background: var(--selected); }
.prow .sym { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .nm { display: block; font-weight: 400; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.prow .px { text-align: right; }
.prow .ch { text-align: right; min-width: 58px; font-size: 12px; }
.panel-empty { padding: 16px; color: var(--muted); }

/* ---------- watchlist ---------- */
.wrow { padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-variant-numeric: tabular-nums; }
.wrow:hover { background: var(--hover); }
.wrow.sel { background: var(--selected); }
.wrow .w1 { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline; }
.wrow .sym { font-weight: 600; }
.wrow .ch { min-width: 58px; text-align: right; font-size: 12px; }
.wrow .w2 { font-size: 12px; margin-top: 2px; }
.wrow .w3 { display: flex; gap: 8px; align-items: center; margin-top: 4px; font-size: 12px; }
.wrow .note { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrow .w3 button { border: 0; background: none; padding: 0 4px; color: var(--muted); }
.wrow .w3 button:hover { color: var(--text); }
.wrow .w3 .del:hover { color: var(--bad); }
.st { padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.st.pos { border-color: var(--good); }
.st.neg { border-color: var(--bad); color: var(--bad); }
.st.warn { border-color: var(--warn); color: var(--warn); }
.st.acc, .acc { color: var(--accent); }
.st.acc { border-color: var(--accent); }
.warn { color: var(--warn); }

/* ---------- plan ---------- */
.plan { flex: 1; overflow: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.plan-title { font-size: 16px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--selected); color: var(--accent); }
.plan-facts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; font-variant-numeric: tabular-nums; }
.plan-facts b { color: var(--text); font-weight: 600; }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plan-grid label, .plan-note { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.plan-grid input { width: 100%; font-variant-numeric: tabular-nums; }
.plan-chips { display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-end; }
.plan-chips button { font-size: 11.5px; padding: 3px 8px; border-radius: 999px; color: var(--muted); }
.plan-chips button b { color: var(--text); font-weight: 600; }
.plan-out { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--code); }
.plan-out p { margin: 6px 0 0; font-size: 12.5px; }
.plan-out .big { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--muted); }
.plan-out .big b { font-size: 26px; color: var(--text); font-variant-numeric: tabular-nums; }
.plan-table { width: 100%; font-size: 13px; margin-top: 6px; }
.plan-table td { padding: 3px 0; border: 0; white-space: normal; font-variant-numeric: tabular-nums; }
.plan-table td:first-child { color: var(--muted); width: 42%; }
.plan-note textarea { resize: vertical; }
.plan-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.plan-foot { font-size: 11.5px; margin: 0; }
.side-tabs button { padding: 9px 4px; font-size: 13px; }
.chart-wrap { min-height: 420px; display: flex; flex-direction: column; }
.chart-note { padding: 4px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
#chart { flex: 1; min-height: 0; }
#chart, #chart > div { width: 100%; }
#chart > div { height: 100%; }
.blocked { height: 100%; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center;
  text-align: center; padding: 24px; color: var(--muted); }
.pine { display: flex; flex-direction: column; border-left: 1px solid var(--line); min-height: 0; background: var(--panel); }
.pine-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.spacer { flex: 1; }
.code { flex: 1; margin: 0; padding: 12px; overflow: auto; background: var(--code); white-space: pre;
  font: 12.5px/1.5 ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace; min-height: 200px; }
.problems { padding: 6px 10px; font-size: 12px; color: var(--warn); border-bottom: 1px solid var(--line); }
.problems.okay { color: var(--good); }
details { padding: 6px 10px; border-top: 1px solid var(--line); font-size: 13px; }
#explain { white-space: pre-wrap; color: var(--muted); margin-top: 4px; }
.fix { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.fix textarea { flex: 1; resize: vertical; min-width: 0; }

@media (max-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .pine, .chart-wrap { min-width: 0; }
  .controls > * { max-width: 100%; }
  .add select { min-width: 0; max-width: 150px; }
  .chart-wrap { height: 60vh; }
  .pine { border-left: 0; border-top: 1px solid var(--line); }
  .code { max-height: 60vh; }
}

/* ---------- tabs + index strip ---------- */
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs button { padding: 5px 14px; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.indices { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.index { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 118px; padding: 5px 10px; text-align: left; }
.ix-name { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.ix-px { font-weight: 600; font-variant-numeric: tabular-nums; }
.ix-ch { font-size: 12px; font-variant-numeric: tabular-nums; }
.index.up .ix-ch, .pos { color: var(--good); }
.index.down .ix-ch, .neg { color: var(--bad); }
.tab { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tab[hidden] { display: none; }
.askbar { padding: 10px 16px 8px; border-bottom: 1px solid var(--line); }

/* ---------- scanner ---------- */
.scanner { flex: 1; display: grid; grid-template-columns: minmax(380px, 40%) minmax(0, 1fr); min-height: 0; }
.builder { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; background: var(--panel); }
.builder-head, .builder-foot, .results-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; }
.builder-head { border-bottom: 1px solid var(--line); }
.builder-foot { border-top: 1px solid var(--line); }
.builder label, .results-head label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.conds { flex: 1; overflow: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.cond { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.cond select { max-width: 170px; }
.cond .tf, .cond .mode { max-width: 100px; }
.cond .num { width: 90px; }
.cond .multi { max-width: 220px; }
.cond .del { margin-left: auto; color: var(--muted); }
.cond .del:hover { color: var(--bad); }
.results { display: flex; flex-direction: column; min-height: 0; }
.results-head { border-bottom: 1px solid var(--line); }
.table-wrap { flex: 1; overflow: auto; }
/* Scoped to the results table: bare table/td rules break Lightweight Charts' internal table layout. */
#resultTable { border-collapse: collapse; width: 100%; font-size: 13px; }
#resultTable th, #resultTable td { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
#resultTable th { position: sticky; top: 0; background: var(--panel); cursor: pointer; user-select: none; font-weight: 600; color: var(--muted); }
#resultTable td.n { text-align: right; font-variant-numeric: tabular-nums; }
#resultTable tbody tr { cursor: pointer; }
#resultTable tbody tr:hover { background: var(--hover); }
#resultTable td:nth-child(2) { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.plan-table { border-collapse: collapse; }

/* Live chart (Lightweight Charts) */
#chart { position: relative; }
.oc-legend { position: absolute; top: 6px; left: 10px; z-index: 3; font-size: 12px; pointer-events: none;
  background: color-mix(in srgb, var(--bg) 80%, transparent); padding: 2px 6px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.oc-legend b { font-weight: 600; }
#chart > .oc-legend { height: auto; width: auto; }
.view-seg button { min-width: 0; padding: 3px 9px; font-weight: 600; }

/* ---------- symbol search ---------- */
.sym-btn b { font-weight: 700; }
.sym-modal { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .45); display: flex;
  align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.sym-modal[hidden] { display: none; }
.sym-box { width: min(620px, 100%); max-height: 72vh; display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgb(0 0 0 / .35); overflow: hidden; }
.sym-head { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.sym-head input { flex: 1; min-width: 0; font-size: 16px; padding: 9px 12px; }
.sym-head button { border: 0; background: none; color: var(--muted); font-size: 16px; }
.sym-list { flex: 1; overflow: auto; }
.sym-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.sym-row:hover, .sym-row.sel { background: var(--selected); }
.sym-row .tk { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sym-row .nm { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sym-row .kd { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.sym-row .kd.Index { color: var(--accent); border-color: var(--accent); }
.sym-row mark { background: none; color: var(--accent); }
.sym-empty { padding: 18px 14px; color: var(--muted); }
.sym-foot { padding: 7px 12px; font-size: 11.5px; border-top: 1px solid var(--line); }
@media (max-width: 600px) { .sym-row { grid-template-columns: 96px minmax(0, 1fr); } .sym-row .kd { display: none; } }
.foot { margin: 0; padding: 6px 16px; font-size: 12px; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  html, body { height: auto; }
  .tab { flex: none; }
  .scanner { grid-template-columns: minmax(0, 1fr); }
  .builder, .results { min-width: 0; }
  .builder { border-right: 0; border-bottom: 1px solid var(--line); }
  .conds { flex: none; overflow: visible; }
  .cond select, .cond .multi { flex: 1 1 130px; max-width: 100%; min-width: 0; }
  .table-wrap { max-height: 70vh; }
  .brand { flex-wrap: wrap; }
  .ask input { font-size: 16px; }
}

.today-bar { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline; padding: 5px 12px;
  border-bottom: 1px solid var(--line); background: var(--panel); font-variant-numeric: tabular-nums; font-size: 13px; }

/* ---------- phone layout (≤ 760px): bottom tabs, one full-screen section at a time ---------- */
.mnav { display: none; }
@media (max-width: 760px) {
  html, body { height: 100%; }
  body { height: 100dvh; overflow: hidden; }
  .tab { flex: 1; min-height: 0; }
  #tab-scanner { overflow-y: auto; display: block; }
  #tab-scanner[hidden] { display: none; }
  .top { padding: 8px 10px 6px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand { margin-bottom: 6px; font-size: 15px; flex-wrap: nowrap; }
  #tabbtn-chart, #tabbtn-scanner { display: none; }
  #themeBtn { padding: 3px 9px; font-size: 12.5px; }
  .indices { gap: 6px; }
  .index { min-width: 88px; padding: 3px 8px; }
  .ix-px { font-size: 13px; }

  /* Chart section: search + D/W/M live on the chart line; the Ask box and indicator controls open from
     "ƒx Indicators" (body.show-tools) */
  #tab-chart > .askbar, #tab-chart > .controls, #notes { display: none !important; }
  body.show-tools #tab-chart > .askbar { display: block !important; }
  body.show-tools #tab-chart > .controls { display: flex !important; max-height: 42vh; overflow-y: auto; }
  body.show-tools #notes:not([hidden]) { display: block !important; }
  body.show-tools .controls { gap: 8px 10px; padding: 6px 10px; }
  body.show-tools .controls .add { width: 100%; display: flex; gap: 6px; }
  body.show-tools .controls .add select { flex: 1; min-width: 0; }
  body.show-tools .controls .add input { width: 64px; }
  .phone-only { display: inline-flex !important; }
  #toolsBtn.active { border-color: var(--accent); color: var(--accent); }
  .split { grid-template-columns: minmax(0, 1fr) !important; flex: 1; min-height: 0; }
  .chart-wrap { height: auto; min-height: 0; }
  body[data-mview="chart"] .pine { display: none !important; }
  body:not([data-mview="chart"]) .chart-wrap { display: none; }
  body:not([data-mview="chart"]) .split .pine { display: flex !important; }
  .pine { border: 0; min-height: 0; }
  .side-tabs, #focusBtn, #pineToggle { display: none; }
  .chart-top .today-bar { flex-basis: 100%; font-size: 12px; padding: 4px 10px; }
  .chart-btns { padding: 2px 8px 6px; margin-left: 0; gap: 5px; }
  .chart-btns button { padding: 4px 8px; }

  .mnav { display: flex; flex: none; border-top: 1px solid var(--line); background: var(--panel);
    padding-bottom: env(safe-area-inset-bottom); }
  .mnav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; border: 0; border-radius: 0;
    background: none; padding: 7px 2px 6px; font-size: 11px; color: var(--muted); }
  .mnav button span { font-size: 17px; line-height: 1.1; }
  .mnav button.active { color: var(--accent); font-weight: 600; }
  .sym-modal { padding-top: 6vh; }
  /* Scanner presets: one swipeable row instead of a wall of buttons */
  #presets { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  #presets button { flex: none; white-space: nowrap; }
  .askbar { padding: 8px 10px 6px; }
  .sym-row { padding: 11px 12px; }
}

/* ---- accounts: login page, user menu, dialogs, admin ---- */
.login-page { display: grid; place-items: center; min-height: 100%; padding: 16px; box-sizing: border-box; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; box-sizing: border-box; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card > p { margin: 0 0 16px; }
.login-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.login-tabs button { flex: 1; }
.login-tabs button.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.auth-form label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.auth-form input:not([type=checkbox]) { width: 100%; box-sizing: border-box; }
.auth-form h3 { margin: 0 0 4px; }
.auth-msg { color: var(--bad); min-height: 1em; margin: 0; font-size: 13px; }
.auth-row { display: flex; justify-content: flex-end; gap: 8px; }
.small { font-size: 12px; margin: -4px 0 0; }
.auth-dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(440px, calc(100vw - 32px)); box-sizing: border-box; }
.auth-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.user-menu { position: relative; }
.user-btn { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 200px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.user-pop[hidden] { display: none; }
.user-pop button { text-align: left; border: 0; }
.user-who { padding: 4px 8px 6px; font-size: 12px; border-bottom: 1px solid var(--line); word-break: break-all; }
.admin-page { overflow: auto; }
.admin { padding: 16px; display: flex; flex-direction: column; gap: 28px; max-width: 1300px; }
.admin h2 { margin: 0; font-size: 17px; }
.admin-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; margin-bottom: 10px; }
.admin-head input { margin-left: auto; min-width: 220px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.admin-table th, .admin-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.admin-table th { color: var(--muted); font-weight: 500; background: var(--panel); position: sticky; top: 0; }
.admin-table tr.off td { opacity: .55; }
.admin-table tr.warn td { color: var(--warn); }
.admin-table .actions { display: flex; gap: 6px; }
.admin-table .actions button { font-size: 12px; padding: 3px 8px; }
.share-list { display: flex; flex-direction: column; gap: 8px; }
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.share-row button { margin-left: auto; }
.share-who { color: var(--muted); }
.share-who.on { color: var(--good); }
.share-users { max-height: 300px; overflow: auto; display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.share-users .off { opacity: .6; }
@media (max-width: 760px) {
  .admin-head input { margin-left: 0; width: 100%; }
  .user-btn { max-width: 110px; }
}
.linkish { border: 0; background: none; color: var(--accent); padding: 2px 0; align-self: center; font-size: 13px; }
.linkish:hover { text-decoration: underline; }
.auth-ok { color: var(--good); font-size: 13px; margin: 12px 0 0; }
.qr { background: #fff; border-radius: 8px; padding: 8px; width: 196px; height: 196px; align-self: center; }
.qr svg { width: 100%; height: 100%; display: block; }
code.key, #totpKey { user-select: all; letter-spacing: .5px; }
/* display:flex above would otherwise override the hidden attribute */
.auth-form[hidden], .login-page [hidden], .auth-dialog [hidden], .admin [hidden] { display: none !important; }
.signup-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.auth-form select { width: 100%; }
.phone-only { display: none; }
/* admin: server health */
.health-pill { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); }
.health-pill.ok { color: var(--good); border-color: var(--good); }
.health-pill.bad { color: var(--bad); border-color: var(--bad); }
.health-checks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.hcheck { font-size: 12px; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); }
.hcheck.ok { color: var(--good); }
.hcheck.bad { color: var(--bad); border-color: var(--bad); }
.health-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.hcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.hcard-title { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.hcard-big { font-size: 18px; font-weight: 600; }
.small-line { font-size: 12px; }
.hbar { height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; margin: 4px 0 2px; }
.hbar span { display: block; height: 100%; background: var(--good); }
.hbar span.warn { background: var(--warn); }
.hbar span.bad { background: var(--bad); }
/* ---- trade journal ---- */
#sidePane-journal { overflow-y: auto; }
.j-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.j-stat { display: flex; flex-direction: column; gap: 1px; background: var(--chip); border-radius: 6px; padding: 5px 8px; font-size: 12px; }
.j-stat b { font-size: 14px; }
.j-curve { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.j-spark { width: 100%; height: 60px; }
.j-spark polyline { fill: none; stroke-width: 2; }
.j-spark .j-up { stroke: var(--good); }
.j-spark .j-down { stroke: var(--bad); }
.j-spark .j-zero { stroke: var(--line); stroke-dasharray: 3 3; }
.j-form { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.j-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.j-form input, .j-form select, .j-form textarea { width: 100%; box-sizing: border-box; }
.j-form[hidden] { display: none; }
.j-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.j-tagchips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-btn { font-size: 11px; padding: 2px 8px; border-radius: 999px; color: var(--muted); }
.j-list { display: flex; flex-direction: column; }
.j-row { padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.j-row:hover { background: var(--hover); }
.j-row.open { border-left: 3px solid var(--accent); }
.j-row-head, .j-row-sub { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.j-row-sub { font-size: 12px; justify-content: space-between; }
.j-row-head .spacer { flex: 1; }
.j-row-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.j-setup, .j-tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--chip); }
.j-setup { color: var(--accent); }
.j-empty { padding: 12px 10px; }
.j-breakdown { padding: 4px 10px 14px; }
.j-breakdown h4 { margin: 12px 0 4px; font-size: 13px; }
.j-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.j-table th, .j-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.j-table th:first-child, .j-table td:first-child { text-align: left; }
.j-table th { color: var(--muted); font-weight: 500; }
@media (max-width: 760px) { .mnav button { font-size: 10px; padding: 7px 1px 6px; } .mnav button span { font-size: 16px; } }
/* ---- backtest dialog ---- */
.bt-dialog { width: min(1200px, calc(100vw - 24px)); height: min(860px, calc(100vh - 24px)); padding: 0; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg); color: var(--text); }
.bt-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.bt-dialog[open] { display: flex; flex-direction: column; }
.bt-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.bt-head .spacer { flex: 1; }
.bt-head select { max-width: 380px; }
.bt-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr); }
.bt-form { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; border-right: 1px solid var(--line); }
.bt-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.bt-form input, .bt-form select { width: 100%; box-sizing: border-box; }
.bt-form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 10px; }
.bt-form legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.bt-result { overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.bt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.bt-chart { height: 240px; border: 1px solid var(--line); border-radius: 8px; }
.bt-key.strat { color: #2962ff; } .bt-key.bench { color: #f0b429; }
.bt-split { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 14px; align-items: start; }
.bt-split h4 { margin: 0 0 4px; font-size: 13px; }
.bt-trades { max-height: 360px; overflow-y: auto; }
.bt-trade { cursor: pointer; }
.bt-trade:hover td { background: var(--hover); }
.bt-progress { margin: 2px 0 0; }
.bt-progress span { transition: width .4s; }
@media (max-width: 760px) {
  .bt-dialog { width: 100vw; height: 100dvh; max-width: none; max-height: none; border-radius: 0; margin: 0; }
  .bt-body { grid-template-columns: 1fr; overflow-y: auto; display: block; }
  .bt-form { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .bt-result { overflow: visible; }
  .bt-split { grid-template-columns: 1fr; }
  .bt-head select { max-width: 45vw; }
}
