/* Fonts: static/fonts/fonts.css (shared with the landing and legal pages) */
@import url("/static/fonts/fonts.css");

:root {
  /* Original dark (default). Same values as static/palette.js - tests/js/css_tokens.test.js keeps them in step. */
  --bg: #0f1218; --panel: #161b24; --line: #262d3a; --text: #e6e9ef; --muted: #8a93a6;
  --accent: #2f81f7; --accent-ink: #ffffff; --selected: #1f3a5f;
  --good: #2ea043; --up: #2ea043; --bad: #f85149; --down: #f85149; --warn: #d29922;
  --code: #0b0e13; --chip: #1d2533; --hover: #1a2130;
  --radius: 8px; --radius-lg: 10px;
  accent-color: var(--accent);
  color-scheme: dark;
}
:root[data-theme="light"] {
  /* Original light */
  --bg: #f5f6f8; --panel: #ffffff; --line: #d9dde3; --text: #131722; --muted: #5d6573;
  --accent: #2962ff; --accent-ink: #ffffff; --selected: #dbe7ff;
  --good: #089981; --up: #089981; --bad: #e0393e; --down: #e0393e; --warn: #b26b00;
  --code: #fafbfc; --chip: #eef1f6; --hover: #eef3fb;
  color-scheme: light;
}
:root[data-theme="night"] {
  /* Night desk (new dark) */
  --bg: #17191e; --panel: #1c1f25; --line: #2b2f37; --text: #e9e6df; --muted: #9d9a93;
  --accent: #f0a43a; --accent-ink: #1b1608; --selected: #2c2718;
  --good: #45c98f; --up: #45c98f; --bad: #f26b63; --down: #f26b63; --warn: #e3c55a;
  --code: #121418; --chip: #23272e; --hover: #21252c;
  color-scheme: dark;
}
:root[data-theme="evergreen"] {
  /* Evergreen (new light) */
  --bg: #ffffff; --panel: #f7f9f8; --line: #e6ebe8; --text: #17201c; --muted: #5b6863;
  --accent: #0c5a43; --accent-ink: #ffffff; --selected: #e1efe9;
  --good: #0f8a5f; --up: #0f8a5f; --bad: #c2413b; --down: #c2413b; --warn: #9a6a00;
  --code: #f7f9f8; --chip: #eef2f0; --hover: #f1f5f3;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums; }
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: var(--radius); padding: 6px 10px; }
button, .btn { cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .12s; }
/* :where() = no specificity, so any button that sets its own background (live toggle, link-style, tool buttons)
   keeps it on hover; only on devices that hover, so a tap on a phone doesn't leave it grey */
@media (hover: hover) {
  :where(button:not(:disabled), .btn):hover { background: var(--hover); }
}
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
table th { color: var(--muted); font-weight: 500; }
::selection { background: var(--selected); }
@media (prefers-reduced-motion: reduce) { button, .btn { transition: none; } }
.muted { color: var(--muted); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.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); }
.badge.feed { font-weight: 600; white-space: nowrap; }
.badge.feed.on { color: var(--accent-ink); background: var(--good); border-color: var(--good); animation: feedpulse 2s ease-in-out infinite; }
.badge.feed.down { color: var(--bad); border-color: var(--bad); }
@keyframes feedpulse { 50% { opacity: .75; } }
@media (max-width: 600px) { .badge.feed .src { display: none; } }
@media (prefers-reduced-motion: reduce) { .badge.feed.on { animation: none; } }
.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) 7px var(--panel-w, minmax(320px, 30%)); min-height: 0; }
/* Drag handle between the chart and the panel: just the ↔ cursor on hover (no highlight) */
.splitter { cursor: col-resize; position: relative; background: var(--bg); touch-action: none; z-index: 2; }
.splitter::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; background: var(--line); }
.splitter::before { content: "⋮"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: var(--muted);
  font-size: 14px; line-height: 1; padding: 6px 0; background: var(--bg); border-radius: 3px; z-index: 1; pointer-events: none; }
.splitter:focus-visible { outline: none; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe, body.resizing #chart { pointer-events: none; }   /* the chart must not swallow the drag */
/* Focus mode: hide the Ask box and controls row so the chart gets the height */
.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: var(--accent-ink); position: relative; }
.split.no-pine { grid-template-columns: minmax(0, 1fr); }
.split.no-pine .pine, .split.no-pine .splitter { display: none; }
.chart-wrap:fullscreen { background: var(--bg); height: 100vh; }

/* ---------- right panel: Scans / Pine tabs ---------- */
/* One row, never wider than the panel: tabs that don't fit go into the "⋯" menu (panel.js) */
.side-tabs { display: flex; flex-wrap: nowrap; overflow: hidden; border-bottom: 1px solid var(--line); min-width: 0; }
.side-tabs button { flex: 1 0 auto; border: 0; border-radius: 0; background: none; padding: 9px 9px; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.side-tabs button:hover:not(:disabled) { color: var(--text); background: var(--hover); }
.side-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.side-tabs button[hidden] { display: none; }
.side-tabs .side-more { flex: 0 0 auto; padding: 9px 12px; font-size: 15px; letter-spacing: 1px; }
.side-tabs .side-more[aria-expanded="true"] { color: var(--text); background: var(--hover); }
.pine { position: relative; min-width: 0; }
.side-more-menu { position: absolute; right: 6px; top: 40px; z-index: 30; display: flex; flex-direction: column; min-width: 150px;
  padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.28); }
.side-more-menu[hidden] { display: none; }
.side-more-menu button { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 5px; font-weight: 600; color: var(--text); }
.side-more-menu button:hover { background: var(--hover); }
.side-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.side-pane[hidden] { display: none; }
#panelScan { flex: 1; min-width: 0; }
/* A panel's top row never makes the panel wider: dropdowns / filter boxes shrink first, buttons (↻ …) never do,
   and if it still doesn't fit the row wraps to a second line. */
.panel-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line);
  font-size: 12px; min-width: 0; }
.panel-sub > select { flex: 1 1 70px; min-width: 70px; width: 0; text-overflow: ellipsis; }
.panel-sub input { padding: 3px 6px; }
.panel-sub > input:not([type="checkbox"]) { flex: 1 1 50px; width: 0; min-width: 50px; max-width: 140px; }
.panel-sub button, .panel-sub label, .panel-sub .mk-seg { flex: none; }
.panel-sub button { padding: 2px 8px; }
.panel-sub .spacer { flex: 1 1 0; min-width: 0; }
.side-pane, .pine > * { min-width: 0; }
.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 { 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); }
  .splitter { display: none; }
  .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; }
.theme-sel { padding: 5px 8px; max-width: 150px; }
.tabs button { padding: 5px 14px; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.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(460px, 52%) 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); }
.block-picker { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.block-picker[hidden] { display: none; }
.block-picker label { display: inline-flex; gap: 5px; align-items: center; }
.block-picker input[type=number] { width: 72px; }
.block-picker .bp-help { flex-basis: 100%; color: var(--muted); font-size: 12.5px; }
.block-picker .bp-out { flex-basis: 100%; font-size: 12.5px; }
.block-picker .bp-out.err { color: var(--down); }
.block-picker .bp-actions { display: flex; gap: 8px; }
.block-picker button:disabled { opacity: .5; cursor: not-allowed; }
.builder-foot { border-top: 1px solid var(--line); }
.builder label, .results-head label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
/* Compact, Chartink-style rows: small font + tight padding so many conditions fit on screen at once. */
.conds { flex: 1; overflow: auto; padding: 4px 8px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.cond { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); line-height: 1.2; }
.cond select, .cond input, .cond button { font-size: 12px; padding: 2px 5px; border-radius: 4px; }
.cond select { max-width: 150px; }
.cond .tf, .cond .mode { max-width: 90px; }
.cond .num { width: 70px; }
.cond .dup, .cond .del { padding: 1px 6px; }
.cond .multi { max-width: 220px; }
.cond .dup { margin-left: auto; color: var(--muted); }
.cond .dup:hover { color: var(--accent); }
.cond .dup + .del { margin-left: 0; }
.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; }

/* ---------- 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; }
  .cond select, .cond input { font-size: 16px; padding: 4px 6px; } /* <16px makes iOS zoom on focus */
  .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; }
  #themeSel { padding: 3px 6px; font-size: 12.5px; max-width: 120px; }
  .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) */
  .top-row { flex-wrap: wrap; }
  .head-ask { display: none; }
  body.show-tools .head-ask { display: block; flex-basis: 100%; min-width: 0; }
  .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, #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; overflow-x: auto; 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 */
  .preset-pick { max-width: 100%; }
  .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: live ticks (Groww / Shoonya) */
.feed-pill { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.feed-pill.on { color: var(--accent-ink); background: var(--good); border-color: var(--good); }
.feed-pill.wait { color: var(--good); border-color: var(--good); }
.feed-pill.down { color: var(--bad); border-color: var(--bad); }
.shoonya-box { display: flex; flex-direction: column; gap: 8px; max-width: 720px; }
.shoonya-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.shoonya-row input { flex: 1 1 260px; min-width: 0; }
.ok-text { color: var(--good); }
.err-text { color: var(--bad); font-weight: 600; }
/* 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; }
/* Backtest is its own top tab now: the whole page below the top bar */
.bt-page { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  border-top: 1px solid var(--line); }
.bt-page .bt-body { grid-template-columns: var(--bt-form-w, 340px) minmax(0, 1fr); position: relative; }
.bt-page.form-hidden .bt-body { grid-template-columns: minmax(0, 1fr); }
.bt-page.form-hidden .bt-form, .bt-page.form-hidden .bt-resize { display: none; }
.bt-resize { position: absolute; top: 0; bottom: 0; left: calc(var(--bt-form-w, 340px) - 3px); width: 7px; cursor: col-resize; z-index: 3; }
.bt-resize:hover, .bt-resize:active { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.bt-fold { white-space: nowrap; }
.bt-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.bt-head .spacer { flex: 1; }
.bt-scan { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 14px; border-bottom: 1px solid var(--line);
  font-size: 13px; line-height: 1.4; }
.bt-scan-pick { max-width: 280px; font-weight: 600; }
.bt-uni-pick { max-width: 200px; }
.bt-scan-text { flex: 1 1 300px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  color: var(--muted); }
.bt-scan-text.open { white-space: normal; color: var(--text); }
.bt-scan-text:hover { color: var(--text); }
.bt-head .page-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42ch; }
.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 label[hidden] { display: none; }
.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; }
.st-bystock { margin-top: 12px; }
.ms-hist-ctl { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.ms-hist-ctl input[type=date] { max-width: 9.5em; }
.ms-mtable td.ms-hist { white-space: nowrap; }
.results-head .hist-ctl { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); }
.st-bystock h4 { margin: 0 0 4px; font-size: 13px; }
.st-bystock .table-wrap { max-height: 320px; overflow: auto; }
.st-bystock tr.clickable { cursor: pointer; }
.st-bystock th { cursor: pointer; }
.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-body[hidden] { display: none; }
.bt-tabs button { font-size: 12px; }
.trig-top { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.trig-top .spacer { flex: 1; }
/* The trigger list keeps (nearly) the whole screen height instead of the space left under the chart and the P&L box:
   the result column scrolls, and once scrolled down the table fills the view with its own sticky header. */
.trig-table { flex: none; max-height: calc(100dvh - 190px); min-height: 160px; }
.trig-table th { position: sticky; top: 0; z-index: 1; background: var(--bg); }
.trig-table { overflow-x: auto; }
.trig-table table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px;
  white-space: nowrap; font-variant-numeric: tabular-nums; }
.trig-table th { color: var(--muted); font-weight: 600; text-align: right; padding: 4px 7px; border-bottom: 1px solid var(--line);
  vertical-align: bottom; line-height: 1.25; }
.trig-table td { text-align: right; padding: 3px 7px; border-bottom: 1px solid var(--line); background: var(--bg); }
.trig-table th:nth-child(-n+2), .trig-table td:nth-child(-n+2) { text-align: left; }
/* Time and Stock stay in view while the other columns scroll sideways */
.trig-table th:nth-child(1), .trig-table td:nth-child(1) { position: sticky; left: 0; box-sizing: border-box; width: 100px; min-width: 100px; }
.trig-table th:nth-child(2), .trig-table td:nth-child(2) { position: sticky; left: 100px; box-sizing: border-box; min-width: 96px;
  border-right: 1px solid var(--line); }
.trig-table th:nth-child(-n+2) { z-index: 2; }
.trig-table td:nth-child(-n+2) { z-index: 1; }
.trig-table th.val { white-space: normal; min-width: 64px; max-width: 110px; }
.trig-table tr:hover td { background: var(--hover); }
.trig-table td.tr-sym .linkish { font-weight: 600; padding: 0; }
.trig-table td.tr-now { font-weight: 600; }
.trig-table th.sortable { cursor: pointer; user-select: none; }
.trig-table th.sortable:hover, .trig-table th.sortable.on { color: var(--text); }
.since-bar { font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.since-bar b { font-size: 14px; white-space: nowrap; }
.since-money { margin-top: 3px; }
.since-money .paper-in { width: 74px; padding: 1px 4px; font-size: 12px; }
.since-money .paper-t { width: 92px; padding: 1px 3px; font-size: 12px; }
.since-money .paper-time { white-space: nowrap; }
.since-filters { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.since-filters .paper-f { font-size: 12px; padding: 1px 3px; }
.since-filters .paper-fv { width: 60px; }
.since-filters .small-btn { font-size: 12px; padding: 1px 8px; }
.filter-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 6px; font-size: 12px; white-space: nowrap; }
.since-money .paper-one { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; white-space: nowrap; }
.ms-all-wrap { margin: 6px 8px; }
.ms-all { margin: 4px 0 0; }
.ms-all-head { font-weight: 600; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px;
  width: 100%; box-sizing: border-box; white-space: normal; text-align: left; cursor: pointer; font-size: 12.5px; }
.ms-all-head:hover { background: var(--hover); }
.ms-pick { position: relative; }
.ms-badge { font-size: 12px; padding: 2px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.ms-badge.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.ms-badge.behind { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); font-weight: 600; }
.ms-badge.changed { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); font-weight: 600; }
.ms-mtable tr.ms-old td { opacity: .5; font-style: italic; }
.ms-badge:disabled { opacity: .7; cursor: progress; }
.ms-pick-btn { font-size: 12px; padding: 2px 8px; }
.ms-pick-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; min-width: 220px; max-height: 320px; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; box-shadow: 0 6px 20px rgba(0,0,0,.35);
  display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.ms-pick-all { display: flex; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
#trigCsv { text-align: center; }
.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; }
  #tab-backtest { overflow-y: auto; display: block; }
  #tab-backtest[hidden] { display: none; }
  .bt-page { min-height: 100%; }
  .bt-page .bt-body { grid-template-columns: 1fr; }
  .bt-page.form-hidden .bt-form { display: flex; }
  .bt-resize, .bt-fold { display: none; }
  .bt-head { flex-wrap: wrap; }
  .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; }
  .trig-table { max-height: 80vh; }
  .bt-split { grid-template-columns: 1fr; }
  .bt-head select { max-width: 45vw; }
}
.oc-live { position: absolute; top: 6px; right: 70px; z-index: 3; font-size: 11px; font-weight: 700; color: var(--bad);
  pointer-events: none; letter-spacing: .04em; }
.db-row .kd { white-space: nowrap; }
#dbBtn b { font-weight: 700; }
.sym-row .kd.live { color: var(--bad); border-color: var(--bad); }

/* Indicators listed on the chart (TradingView-style), under the OHLC legend */
.chart-wrap { position: relative; }
.study-legend { position: absolute; left: 10px; z-index: 4; display: flex; flex-direction: column; gap: 2px;
  font-size: 12px; max-width: 60%; }
.study-legend[hidden] { display: none; }
.st-row { display: inline-flex; align-items: center; gap: 2px; width: fit-content; padding: 1px 4px; border-radius: 4px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); border: 1px solid transparent; }
.st-row:hover { border-color: var(--line); }
.st-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin: 0 3px 0 1px; }
.st-name { padding-right: 4px; color: var(--text, inherit); white-space: nowrap; }
.st-row button { border: 0; background: none; color: var(--muted); padding: 0 4px; font-size: 12px; line-height: 1.4;
  opacity: 0; min-width: 0; }
.st-row:hover button, .st-row:focus-within button { opacity: 1; }
.st-row .st-del:hover { color: var(--bad); }
.st-row .st-set:hover { color: var(--accent); }
.st-len { width: 64px; font-size: 12px; padding: 1px 4px; }
@media (hover: none) { .st-row button { opacity: 1; } }

/* Header: index cards, then the Ask box taking the rest of the row */
.top-row { display: flex; gap: 12px; align-items: flex-start; }
.top-row .indices { flex: 0 1 auto; min-width: 0; }
.head-ask { flex: 1 1 360px; min-width: 300px; padding-top: 4px; }
.head-ask .ask { align-items: center; }
.head-ask .ask input { padding: 9px 12px; font-size: 14px; }
.head-ask .auto { display: flex; gap: 4px; align-items: center; color: var(--muted); font-size: 12px; white-space: nowrap; }
.head-ask .notes { padding: 4px 2px 0; border: 0; font-size: 12px; }
.st-row.open { border-color: var(--line); }
.st-row.open button { opacity: 1; }
.st-pop { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; width: fit-content; margin: 2px 0 4px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font-size: 12px;
  box-shadow: 0 4px 14px rgb(0 0 0 / .35); }
.st-pop label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.st-widths { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.st-widths span { margin-right: 2px; }
.st-widths button { width: 30px; height: 24px; padding: 0; display: grid; place-items: center; min-width: 0; }
.st-widths button i { display: block; width: 18px; background: currentColor; border-radius: 1px; }
.st-widths button.active { border-color: var(--accent); color: var(--accent); }
.st-done { font-size: 12px; padding: 3px 10px; }

/* ---------- drawing tools (TradingView layout) ---------- */
.chart-row { flex: 1; display: flex; min-height: 0; }
.chart-row > #chart { flex: 1; min-width: 0; }
.draw-bar { flex: 0 0 52px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  border-right: 1px solid var(--line); background: var(--bg); overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none; }
.draw-bar::-webkit-scrollbar { display: none; }
.draw-bar[hidden] { display: none; }
.db-btn { width: 36px; height: 36px; padding: 0; min-width: 0; border: 0; border-radius: 4px; background: none;
  color: var(--text); display: grid; place-items: center; }
.db-btn:hover { background: var(--selected); }
.db-btn.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.db-group { position: relative; }
.db-group { position: relative; display: flex; justify-content: center; width: 100%; }
.db-more { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 10px; height: 22px; padding: 0;
  min-width: 0; border: 0; border-radius: 3px; background: none; color: var(--muted); font-size: 12px; line-height: 1;
  opacity: .55; }
.db-group:hover .db-more { opacity: 1; }
.db-more:hover { color: var(--text); background: var(--selected); }
.db-sep { width: 26px; height: 1px; margin: 5px 0; background: var(--line); }
.db-flyout { position: absolute; z-index: 20; min-width: 190px; padding: 6px 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgb(0 0 0 / .4); }
.db-flyout button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 2px 12px 2px 6px; border: 0;
  border-radius: 0; background: none; text-align: left; color: var(--text); }
.db-flyout button:hover { background: var(--selected); }
.draw-float { position: absolute; z-index: 6; top: 64px; right: 90px; display: flex;
  align-items: center; gap: 2px; padding: 3px 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .35); }
.draw-float[hidden] { display: none; }
.draw-float button { width: 30px; height: 30px; padding: 0; min-width: 0; border: 0; border-radius: 4px; background: none;
  color: var(--text); display: grid; place-items: center; }
.draw-float button:hover { background: var(--selected); }
.draw-float button.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.df-sep { width: 1px; height: 20px; margin: 0 3px; background: var(--line); }
.df-color i { display: block; width: 16px; height: 16px; border-radius: 3px; border: 1px solid var(--line); }
.df-w i { display: block; width: 16px; background: currentColor; border-radius: 1px; }
.df-s i { display: block; width: 18px; height: 0; border-top: 2px solid currentColor; }
.df-s i.ln-dashed { border-top-style: dashed; }
.df-s i.ln-dotted { border-top-style: dotted; }
.df-palette { position: absolute; top: 38px; display: grid; grid-template-columns: repeat(5, 22px); gap: 6px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgb(0 0 0 / .4); }
.df-palette button { width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--line); }
@media (max-width: 760px) { .draw-bar { flex-basis: 38px; } .db-btn { width: 32px; height: 32px; } }
.draw-edit { position: absolute; z-index: 8; min-width: 80px; padding: 3px 6px; resize: none; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif; line-height: 1.3;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 4px; outline: none; white-space: pre; }

/* Compact header on desktop: one-line index chips and a slimmer Ask box, so the chart gets the height */
@media (min-width: 761px) {
  .top { padding: 6px 16px 6px; }
  .brand { margin-bottom: 5px; }
  .top-row { align-items: center; }
  .index { flex: 0 0 auto; flex-direction: row; align-items: baseline; gap: 5px; min-width: 0; padding: 3px 8px; white-space: nowrap; }
  .top-row .indices { scrollbar-width: none; }
  .top-row .indices::-webkit-scrollbar { display: none; }
  .head-ask { flex: 1 1 280px; min-width: 280px; }
  .ix-px { font-size: 13px; }
  .ix-name { font-size: 11.5px; }
  .ix-ch { font-size: 12px; font-weight: 600; }
  .head-ask { padding-top: 0; }
  .head-ask .ask input { padding: 5px 10px; font-size: 13.5px; }
  .head-ask .ask button { padding: 5px 14px; }
}
.live-badge { flex: 0 0 auto; font-size: 11px; font-weight: 700; color: var(--bad); letter-spacing: .04em; white-space: nowrap;
  padding: 1px 6px; border: 1px solid color-mix(in srgb, var(--bad) 50%, transparent); border-radius: 4px; }
.live-badge[hidden] { display: none; }
.bt-tabs button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* scanner: parse preview (phase 3b) */
.scan-preview { padding: 8px 16px 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.scan-preview .pv-head { color: var(--muted); margin-bottom: 4px; }
.scan-preview .pv-lines { margin: 0 0 6px; padding-left: 22px; }
.scan-preview .pv-lines li { margin: 2px 0; }
.scan-preview .pv-unread { color: var(--down); margin: 4px 0; }
.scan-preview .pv-note { color: var(--warn); font-size: 12.5px; margin: 2px 0; }
.scan-preview .pv-actions { display: flex; gap: 8px; margin-top: 6px; }
.scan-preview .pv-q { margin: 2px 0 6px; }
.scan-preview .pv-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.scan-preview .pv-ai { display: inline-block; font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin-bottom: 4px; }
.scan-preview button:disabled { opacity: .5; cursor: not-allowed; }
.cond .ago-wrap { display: inline-flex; align-items: center; gap: 3px; }
.cond input.ago { width: 3.2em; }

/* trades tab (phase 3c) */
.bt-form label.check { flex-direction: row; align-items: center; gap: 6px; }

/* live scans (phase 3d) */
.live-box { padding: 6px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.live-box summary { cursor: pointer; }
.live-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; }
.live-ctl label.check { display: inline-flex; align-items: center; gap: 4px; }
#liveToggle.on { color: var(--down); }
.live-list { margin: 4px 0 6px; padding-left: 22px; max-height: 260px; overflow: auto; }
.live-list li.early { opacity: .75; }

/* Scanner: ready-made scans dropdown, the scan as one plain sentence */
.preset-pick { max-width: 220px; color: var(--muted); }
.scan-summary { padding: 7px 16px; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.45; background: var(--panel); }
.scan-summary b { color: var(--muted); font-weight: 600; }

/* Signals on the chart (chartsignals.js) */
.sig-sel { max-width: 190px; padding: 2px 6px; font-size: 12.5px; }
.sig-sel.on { border-color: #d500f9; color: #d500f9; }
.sig-note { min-width: 52px; text-align: left; white-space: nowrap; }
.sig-note::before { content: "▲ "; color: #d500f9; }
.sig-note[hidden] { display: none; }
@media (max-width: 720px) { .sig-sel { max-width: 150px; } }

/* Events tab (events.js) */
.ev-status { padding: 3px 10px; font-size: 11px; border-bottom: 1px solid var(--line); }
.ev-status:empty { display: none; }
.ev-day { position: sticky; top: 0; padding: 5px 10px; font-size: 12px; font-weight: 700; background: var(--panel); border-bottom: 1px solid var(--line); }
.ev-row { display: grid; grid-template-columns: minmax(84px, 30%) auto minmax(0, 1fr) auto 20px; gap: 8px; align-items: baseline; padding: 6px 10px;
  border-bottom: 1px solid var(--line); cursor: pointer; font-size: 12.5px; }
.ev-row:hover { background: var(--hover); }
.ev-row .sym { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-title { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-type { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 9px; border: 1px solid currentColor; white-space: nowrap; }
.ev-results { color: #2962ff; } .ev-dividend { color: #089981; } .ev-bonus { color: #f0b429; } .ev-split { color: #d500f9; }
.ev-rights { color: #ff9800; } .ev-buyback { color: #00bcd4; } .ev-other { color: var(--muted); }
#sidePane-events .panel-sub select { max-width: 120px; }

/* Telegram alerts dialog (auth.js) */
.tg-form label { display: block; }
.tg-chat-row { display: flex; gap: 6px; }
.tg-chat-row input { flex: 1; min-width: 0; }
.tg-chats { display: flex; flex-direction: column; gap: 4px; }
.tg-chats button { text-align: left; }
.tg-state { margin: 0; font-size: 13px; color: var(--muted); }
.tg-state.on { color: var(--good); }
.auth-msg.ok { color: var(--muted); }
.tg-form .auth-row .spacer { flex: 1; }
.tg-help { font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.tg-help summary { cursor: pointer; font-weight: 600; }
.tg-help ol { margin: 8px 0 6px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.tg-help code { background: var(--code); padding: 0 4px; border-radius: 4px; }
.auth-dialog:has(.tg-form) { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; }

/* "My scans" tab (myscans.js) */
.ms-row { padding: 9px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.ms-row.live { box-shadow: inset 3px 0 0 var(--good); }
.ms-head { display: flex; gap: 8px; align-items: baseline; }
.ms-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-meta { font-size: 11.5px; white-space: nowrap; }
.ms-ctl { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 12.5px; }
.ms-ctl button { padding: 3px 9px; font-size: 12.5px; }
.ms-live.on { background: var(--good); border-color: var(--good); color: var(--accent-ink); font-weight: 700; }
.ms-chart.on { border-color: #d500f9; color: #d500f9; }
.ms-tg, .ms-early { display: inline-flex; align-items: center; gap: 4px; }
.ms-msg { color: var(--bad); font-size: 12.5px; }
.ms-msg.ok-text { color: var(--good); }
.ms-count { align-self: flex-start; font-size: 12.5px; }
.ms-count:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.ms-matches { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; max-height: 320px; overflow: auto; font-variant-numeric: tabular-nums; }
.ms-countline { display: flex; gap: 10px; align-items: center; }
.ms-csv { font-size: 12px; }
.ms-mtable { border-collapse: collapse; font-size: 11.5px; width: 100%; white-space: nowrap; }
.ms-mtable th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 600; text-align: right; padding: 2px 5px; border-bottom: 1px solid var(--line); }
.ms-mtable td { text-align: right; padding: 1px 5px; border-bottom: 1px solid var(--line); }
.ms-mtable th:nth-child(-n+2), .ms-mtable td:nth-child(-n+2) { text-align: left; }
.ms-mtable th.ms-sort { cursor: pointer; user-select: none; }
.ms-mtable th.ms-sort:hover, .ms-mtable th.ms-sort.on { color: var(--text); }
.ms-mrow { cursor: pointer; }
.ms-mrow:hover { background: var(--hover); }
.ms-sym { font-weight: 600; }
.ms-mtable td.ms-now { font-weight: 600; }
.ms-foot { padding: 6px 12px; font-size: 12px; border-top: 1px solid var(--line); }
.ms-foot.on { color: var(--good); }
@media (max-width: 760px) { .mnav button { flex: 1 0 auto; min-width: 54px; } }

/* Broker-style watchlists (watchlists.js) */
.wl-bar { flex-wrap: wrap; }
.wl-bar select#wlSel { flex: 1; min-width: 0; }
.wl-add-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.wl-add-wrap input { flex: 1; width: auto; min-width: 0; }
.wl-add-bar > select { flex: 0 1 auto; width: auto; min-width: 70px; }     /* the Add box gets the room, not the sort */
.wl-found-box { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / .35); max-height: 260px; overflow: auto; }
.wl-found { display: block; width: 100%; text-align: left; border: 0; border-radius: 0; background: none; padding: 6px 10px; font-size: 13px; }
button.wl-found:hover { background: var(--hover); }
.wl-status { padding: 3px 10px; font-size: 11.5px; border-bottom: 1px solid var(--line); }
.wl-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 64px 18px 22px; gap: 10px; align-items: baseline; padding: 7px 12px;
  border-bottom: 1px solid var(--line); cursor: pointer; font-variant-numeric: tabular-nums; }
.wl-row:hover { background: var(--hover); }
.wl-row.sel { background: var(--selected); }
.wl-row .sym { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-row .ch { text-align: right; font-size: 12px; }
.wl-row .wl-del { border: 0; background: none; padding: 0; color: var(--muted); }
.wl-row .wl-del:hover { color: var(--bad); }
.wl-btn-wrap { position: relative; display: inline-flex; }
.wl-btn { font-size: 15px; line-height: 1; padding: 2px 8px; }
.wl-btn.on { color: var(--warn); border-color: var(--warn); }
.wl-menu { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 210px; max-width: 280px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; box-shadow: 0 8px 24px rgb(0 0 0 / .4);
  display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.wl-menu[hidden] { display: none; }
.wl-menu-title { font-weight: 700; font-size: 12px; color: var(--muted); }
.plan-list-head { border-top: 1px solid var(--line); }
.plan-list { flex: 0 1 auto; max-height: 36%; min-height: 0; }   /* only as tall as its rows; the form keeps the room */

/* market cap in the lists */
.ev-mcap { font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.wl-row .sym .nm { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }

/* ---- fundamentals page ---- */
.fund-btn { font-weight: 700; }
.fd-info { border: 0; background: none; padding: 0; color: var(--muted); font-size: 14px; line-height: 1; cursor: pointer; }
.fd-info:hover { color: var(--accent); }
.fund-dialog { width: min(980px, calc(100vw - 24px)); }
.fd-head { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 16px 16px; }
.fd-foot { padding: 8px 16px; border-top: 1px solid var(--line); font-size: 12px; }
.fd-sec { margin-top: 14px; }
.fd-sec h3 { margin: 0 0 8px; font-size: 14px; }
.fd-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.fd-kv > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); min-width: 0; }
.fd-kv span { font-size: 11.5px; } .fd-kv b { font-size: 13.5px; overflow-wrap: anywhere; }
.fd-scroll { overflow-x: auto; }
.fd-table { border-collapse: collapse; width: 100%; font-size: 12.5px; white-space: nowrap; }
.fd-table th, .fd-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.fd-table th:first-child, .fd-table td:first-child { text-align: left; }
.fd-table th { color: var(--muted); font-weight: 500; }
.fd-note { font-size: 12px; margin: 6px 0 0; }
.fd-list { margin: 0; padding-left: 18px; font-size: 13px; } .fd-list li { margin: 3px 0; }
.fd-news-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.fd-news-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 13px; }
.fd-news-head a { color: var(--accent); font-size: 12px; }
.fd-news-item p { margin: 4px 0 0; font-size: 12.5px; line-height: 1.45; }
@media (max-width: 760px) { .fd-body { padding: 4px 12px 12px; } .fd-kv { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- news tab + pop-ups ---- */
.nw-tg { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.nw-tg input { width: auto; flex: none; margin: 0; }
.nw-row { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.nw-head { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.nw-head a { color: var(--text); }
.nw-sym { border: 0; background: none; padding: 0; font-weight: 700; color: var(--accent); cursor: pointer; white-space: nowrap; }
.nw-subj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-time { white-space: nowrap; font-size: 11.5px; }
.nw-body { margin: 4px 0 0; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nw-link { font-size: 11.5px; color: var(--accent); }
.news-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.news-toast { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 10px;
  background: var(--panel); color: var(--text); box-shadow: 0 6px 24px rgba(0, 0, 0, .35); cursor: pointer; font-size: 12.5px; }
@media (max-width: 760px) { .news-toasts { bottom: 72px; } }

/* Market tab: stock list with today's change and volume */
.mk-bar select { max-width: 150px; }
.mk-bar #mkStatus { flex: 1 1 140px; min-width: 0; }
.mk-bar #mkQ { flex: 1 1 110px; max-width: 200px; }
.mk-seg { display: inline-flex; }
.mk-seg button { border-radius: 0; margin-left: -1px; padding: 2px 6px; }
.mk-seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.mk-seg button:last-child { border-radius: 0 6px 6px 0; }
.mk-seg button.active { background: var(--selected); border-color: var(--accent); font-weight: 600; }
.mk-table { border-collapse: collapse; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mk-table th { position: sticky; top: 0; z-index: 1; background: var(--panel); color: var(--muted); font-weight: 600; text-align: left;
  padding: 4px 6px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.mk-table th.on { color: var(--text); }
.mk-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
.mk-table .num { text-align: right; }
.mk-row { cursor: pointer; }
.mk-row:hover { background: var(--hover); }
.mk-eod { font-size: 10px; }

/* P&L box (backtest triggers, My scans): one-line header, result tiles, aligned settings */
.pnl-box { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 12.5px; padding: 0; overflow: hidden; }
.pnl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; width: 100%; box-sizing: border-box; text-align: left;
  background: none; border: 0; border-radius: 0; padding: 6px 10px; cursor: pointer; font-size: 12.5px; color: var(--text); line-height: 1.4; }
.pnl-head:hover { background: var(--hover); }
.pnl-caret { width: 10px; color: var(--muted); }
.pnl-tag { font-size: 11px; padding: 0 6px; border-radius: 9px; background: var(--chip); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pnl-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 4px; padding: 6px 10px; border-top: 1px solid var(--line); }
.pnl-tile { display: flex; flex-direction: column; gap: 0; padding: 2px 6px; border-radius: 5px; background: var(--bg); min-width: 0; line-height: 1.3; }
.pnl-tl { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pnl-tv { font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pnl-tile.wide { grid-column: span 2; }
.pnl-form { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 10px; align-items: center; padding: 8px 10px 10px;
  border-top: 1px solid var(--line); }
.pnl-l { color: var(--muted); font-size: 12px; text-align: right; }
.pnl-c { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.pnl-c select, .pnl-c input { font-size: 12px; padding: 2px 4px; }
.pnl-in { width: 84px; }
.pnl-small { width: 60px; }
.pnl-time { width: 96px; }
.pnl-cmp-wrap { grid-column: 1 / -1; overflow-x: auto; }
.pnl-cmp { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.pnl-cmp th, .pnl-cmp td { padding: 3px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.pnl-cmp th:first-child, .pnl-cmp td:first-child { text-align: left; }
.pnl-cmp th { color: var(--muted); font-weight: 500; }
.pnl-cmp tbody tr { cursor: pointer; }
.pnl-cmp tbody tr.static { cursor: default; }
.warn-text { color: var(--warn); }
.pnl-loading { opacity: .55; transition: opacity .15s; }
.pnl-cmp tbody tr:hover { background: var(--bg); }
.pnl-cmp tr.best td { font-weight: 700; }
.pnl-cmp tr.best td:first-child::after { content: " ★"; color: var(--accent); }
.pnl-check { display: inline-flex; align-items: center; gap: 4px; }
.ms-since { margin: 4px 0 6px; }
.ms-all-wrap { margin: 6px 8px; }
.bt-result > .pnl-box, #trigSince { flex: none; }
#stResult > * { flex: none; }                       /* the trades results scroll as one page; nothing shrinks */
/* Trades table: no box of its own on wide screens, so its header sticks to the top while the results scroll */
#stResult .bt-trades { max-height: none; overflow: visible; border: 0; }
#stResult .st-table thead th { position: sticky; top: -12px; background: var(--bg); z-index: 2; box-shadow: 0 1px 0 var(--line);
  cursor: pointer; user-select: none; white-space: nowrap; }
#stResult .st-table thead th.on { color: var(--text); }
#stResult .st-table thead th:hover { color: var(--accent); }
.st-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.st-filters .st-q { width: 140px; }
.st-filters select, .st-filters input, .st-filters button { font-size: 12.5px; }
@media (max-width: 760px) {             /* phones: the table scrolls sideways in its own box, header sticks inside it */
  #stResult .bt-trades { max-height: 70vh; overflow: auto; }
  #stResult .st-table thead th { top: 0; }
}

/* Holdings tab */
#hSummary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.h-skipped { padding: 0 10px; font-size: 12px; }
.h-skipped:empty { display: none; }
.h-scroll { overflow-x: auto; }
@media (max-width: 600px) { #hSummary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.h-sectors { grid-column: 1 / -1; font-size: 12px; }
.h-sectors summary { cursor: pointer; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-sectors[open] { display: flex; flex-direction: column; gap: 3px; }
.h-sec-table td.h-sec-name, .h-sec-table th:first-child { text-align: left; max-width: 11em; overflow: hidden; text-overflow: ellipsis; }
.h-sec-table th:first-child, .h-sec-table td:first-child { position: static; background: none; }
.h-sec-w { white-space: nowrap; }
.h-sec-bar { display: inline-block; width: 48px; height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.h-sec-bar > span { display: block; height: 100%; background: var(--accent); }
.h-warn { grid-column: 1 / -1; color: var(--warn); font-size: 12px; }
.h-heavy { color: var(--warn); font-weight: 600; }
/* Holdings: the whole tab scrolls as one (opening Sectors never squeezes the stock list) */
#sidePane-holdings { overflow-y: auto; }
#sidePane-holdings #hList { flex: none; overflow: visible; }
/* Full view: Holdings across the whole width, the chart hidden */
.split.hold-full { grid-template-columns: minmax(0, 1fr) !important; }
.split.hold-full .chart-wrap, .split.hold-full .splitter { display: none !important; }
.split.hold-full #hSummary { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.split.hold-full #sidePane-holdings .h-scroll { overflow: visible; }
.split.hold-full #sidePane-holdings .h-table { font-size: 13px; }
.split.hold-full .h-sec-table { width: auto; min-width: 60%; }
.split.hold-full .h-sec-table td.h-sec-name { max-width: 22em; }
.split.hold-full .h-stock .h-sector { max-width: 24em; }
.h-sec-table th { cursor: pointer; }
.h-full-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
@media (max-width: 760px) { .h-full-btn { display: none; } }
/* Holdings tables: roomy rows, aligned digits, two-line cells (value on top, detail below in small grey) */
.h-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.h-table th, .h-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
.h-table th { user-select: none; font-weight: 600; font-size: 11.5px; color: var(--muted); position: sticky; top: 0; z-index: 1;
  background: var(--code); line-height: 1.25; }
.h-table th:first-child, .h-table td:first-child { position: sticky; left: 0; background: var(--code); z-index: 1; }
.h-table th:first-child { z-index: 2; }
.h-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--chip) 45%, var(--code)); }
.h-table tbody tr:hover td { background: var(--chip); }
.h-table .h-left { text-align: left; }
.h-table .h-center { text-align: center; }
.h-table .h-top { display: block; font-weight: 500; }
.h-table .h-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 1px; }
.h-table td.pos .h-sub, .h-table td.neg .h-sub, .h-table .h-sub.pos, .h-table .h-sub.neg { color: inherit; opacity: 0.85; }
.h-table .h-sub.neg { color: var(--down); }
.h-table .h-sub.pos { color: var(--up); }
.h-table .h-pnl .h-top { font-weight: 700; }
.h-sym { font-weight: 700; font-size: 13px; padding: 0; }
.h-stock .h-sector { max-width: 12em; overflow: hidden; text-overflow: ellipsis; }
.h-sort { cursor: pointer; }
.h-sort:hover, .h-sort.on { color: var(--text); }
.h-pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.h-pill.up { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.h-pill.down { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.h-pill.side { background: var(--chip); color: var(--muted); }
.h-wbar { display: block; margin: 4px 0 0 auto; width: 52px; height: 4px; border-radius: 2px; background: var(--chip); overflow: hidden; }
.h-wbar > span { display: block; height: 100%; background: var(--accent); }
.h-heavy .h-wbar > span { background: var(--warn); }
.h-edit { padding: 0 2px; font-size: 12px; opacity: 0.7; }
.h-edit:hover { opacity: 1; }
.h-date { font-size: 12px; padding: 2px 4px; width: 132px; }
.split.hold-full #sidePane-holdings .h-table { font-size: 13.5px; }
.ms-plan { padding: 0 2px; font-size: 12px; opacity: 0.55; }
.ms-mrow:hover .ms-plan, .ms-plan:focus-visible { opacity: 1; }
.ms-session { margin: 6px 10px; padding: 6px 10px; border-radius: 6px; font-size: 12px; background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
/* Plan tab: compact - two rows of three fields, R chips on one line, the result as four tiles */
.plan-grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 8px; }
.plan-grid3 select { width: 100%; }
.plan-rchips { align-items: center; font-size: 12px; }
.plan-rchips #targetChips { display: inline-flex; gap: 5px; }
.plan-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.plan-tile { display: flex; flex-direction: column; gap: 1px; background: var(--chip); border-radius: 6px; padding: 6px 9px; min-width: 0; }
.plan-tile span { font-size: 11px; color: var(--muted); }
.plan-tile b { font-size: 17px; font-variant-numeric: tabular-nums; }
.plan-tile small { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-out { padding: 8px !important; }
.plan-out p.warn { font-size: 11.5px; margin: 6px 0 0; }
.plan-note textarea { min-height: 30px; }
@media (max-width: 420px) { .plan-grid3 { grid-template-columns: 1fr 1fr; } }
/* Telegram dialog: one tap first, own bot as an advanced option */
.tg-onetap { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.tg-onetap[hidden] { display: none; }
.tg-onetap p { margin: 0; }
.tg-connect { font-size: 15px; padding: 10px 14px; align-self: flex-start; }
.tg-wait { border-top: 1px dashed var(--line); padding-top: 8px; }
.tg-wait-msg::before { content: "⏳ "; }
.tg-own { font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.tg-own > summary { cursor: pointer; color: var(--muted); }
.tg-own[open] { display: flex; flex-direction: column; gap: 8px; }
.auth-legal { font-size: 12px; color: var(--muted); text-align: center; margin: 14px 0 0; line-height: 1.6; }
.auth-legal a { color: var(--muted); }
.auth-legal a:hover { color: var(--text); }
/* First-day welcome */
.ob-dialog { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow-y: auto; overflow-x: hidden; }
.ob-body { display: flex; flex-direction: column; gap: 10px; }
.ob-body h3 { margin: 4px 0 0; font-size: 20px; }
.ob-body h4 { margin: 6px 0 0; font-size: 15px; }
.ob-body p { margin: 0; }
.ob-dots { display: flex; gap: 6px; }
.ob-dots span { width: 26px; height: 4px; border-radius: 2px; background: var(--line); }
.ob-dots span.on { background: var(--accent); }
.ob-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ob-card { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 10px 12px; border-radius: 10px;
  white-space: normal; min-width: 0; overflow-wrap: anywhere; height: auto; line-height: 1.35;
  border: 1px solid var(--line); background: var(--chip); color: var(--text); cursor: pointer; font: inherit; position: relative; }
.ob-card strong { font-size: 14px; }
.ob-tags { font-size: 11.5px; color: var(--muted); }
.ob-tags b { color: var(--accent); font-weight: 700; }
.ob-about { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.ob-card[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--chip)); }
.ob-card[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 8px; right: 10px; color: var(--accent); font-weight: 800; }
.ob-next { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.ob-body .auth-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.ob-body .auth-row .spacer { flex: 1; }
.panel-empty .primary { margin-top: 10px; }
@media (max-width: 560px) { .ob-cards { grid-template-columns: 1fr; } }
/* Backtest tab (right panel) */
#sidePane-backtest .pine-head button { padding: 2px 9px; }
.btp-info { margin: 4px 10px; }
.btp-wrap { overflow: auto; flex: 1; min-height: 0; }
.btp-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.btp-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.btp-table td.num { text-align: right; }
.btp-when { font-size: 11.5px; }
.btp-row { cursor: pointer; }
.btp-row:hover { background: var(--chip); }
.btp-row.on { background: color-mix(in srgb, var(--accent) 16%, transparent); }
#btpBody { display: flex; flex-direction: column; min-height: 0; flex: 1; }
#btpBody[hidden] { display: none; }
#btpQ { width: 100%; }

/* Signals "New / All" toggle next to the chart's Signals box; continuation rows in the Triggers list */
.sig-every { font-size: 12px; padding: 2px 8px; }
.sig-every.on { color: #d500f9; border-color: #d500f9; }
.trig-table tr.tr-cont td { color: var(--muted); }
.trig-table tr.tr-cont td.tr-time { font-style: italic; }

/* ---------- phase 2 shell: one-row top bar, left menu, Ask bar ---------- */
.top { display: flex; align-items: center; gap: 14px; padding: 6px 14px; }
.top .brand { margin: 0; flex: none; gap: 8px; }
.logo { width: 20px; height: 20px; display: block; flex: none; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; }
.top .indices { flex: 1 1 auto; min-width: 0; padding-bottom: 0; scrollbar-width: none; }
.top .indices::-webkit-scrollbar { display: none; }
.top .tabs { margin-left: auto; flex: none; align-items: center; }
.head-ask { display: none; flex: none; padding: 6px 14px; border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0; }
body.show-tools .head-ask { display: block; }
#toolsBtn.active { color: var(--accent); border-color: var(--accent); }
.shell { flex: 1; display: flex; min-height: 0; }
.pages { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.rail { flex: 0 0 64px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0;
  background: var(--panel); border-right: 1px solid var(--line); }
.rail button { width: 52px; padding: 7px 0 6px; border: 0; background: none; border-radius: var(--radius); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; }
.rail button svg { width: 20px; height: 20px; }
.rail button:hover:not(.active) { color: var(--text); background: var(--hover); }
.rail button.active { color: var(--accent); background: var(--selected); }
@media (max-width: 760px) {
  .rail { display: none; }
  .top { flex-wrap: wrap; gap: 6px 10px; padding: 8px 10px 6px; padding-top: max(8px, env(safe-area-inset-top)); }
  .top .indices { order: 3; flex-basis: 100%; }
}
#sigSel { max-width: 128px; }
#pineToggle.on { color: var(--accent); }

/* ---------- phase 2: Signals tab, More menu, My scans on the Scanner page ---------- */
.side-more { font-weight: 600; }
.tab-badge[hidden] { display: none; }
.tab-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; font-size: 10.5px;
  line-height: 16px; text-align: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.sig-seg { display: flex; gap: 2px; margin: 8px 10px 4px; padding: 2px; background: var(--chip); border-radius: var(--radius); }
.sig-seg button { flex: 1; border: 0; background: none; padding: 5px 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.sig-seg button.active { background: var(--bg); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
#sigLive, .sig-results { display: flex; flex-direction: column; min-height: 0; flex: 1; }
#sigLive[hidden], .sig-results[hidden] { display: none; }
#sidePane-signals { display: flex; flex-direction: column; min-height: 0; }
#sidePane-signals[hidden] { display: none; }
#sigScan { max-width: 170px; }
.sig-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%;
  padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; text-align: left; }
.sig-row:hover { background: var(--hover); }
.sig-t { font-size: 12px; }
.sig-main { min-width: 0; } .sig-main b { display: block; }
.sig-main small, .sig-px small { display: block; font-size: 11px; margin-top: 1px; }
.sig-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sig-px { text-align: right; font-variant-numeric: tabular-nums; }
#sigEmpty { padding: 24px 16px; text-align: center; }
#sigEmpty p { margin: 0 0 10px; color: var(--muted); }
.myscans-box { border-top: 1px solid var(--line); margin-top: 8px; max-height: 45%; overflow: auto; flex: none; }
.box-title { margin: 10px 12px 4px; font-size: 14px; }

/* ---------- phase 2: dock the panel right (default) or at the bottom ---------- */
.icon-btn { display: inline-grid; place-items: center; padding: 4px 6px; }
.icon-btn svg { width: 18px; height: 18px; }
#dockBtn .d-bottom { display: none; }
#dockBtn.on .d-bottom { display: inline; } #dockBtn.on .d-right { display: none; }
@media (min-width: 901px) {
.split.dock-bottom { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 7px var(--panel-h, 300px); }
.split.dock-bottom .chart-wrap { min-height: 260px; }
.split.dock-bottom .splitter { cursor: row-resize; }
.split.dock-bottom .splitter::after { top: 3px; bottom: auto; left: 0; right: 0; width: auto; height: 1px; }
.split.dock-bottom .splitter::before { content: "⋯"; }
.split.dock-bottom .pine { border-left: 0; border-top: 1px solid var(--line); min-height: 0; overflow: hidden; }
.split.dock-bottom.no-pine { grid-template-rows: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  #dockBtn { display: none; }
}


/* ---------- phase 2: 6-button phone bar + More sheet ---------- */
.mnav-more { display: none; }
@media (max-width: 760px) {
  .mnav { overflow-x: hidden; }
  .mnav button { flex: 1 1 0; min-width: 0; }
  .mnav button svg { width: 21px; height: 21px; margin-bottom: 1px; }
  .mnav-more { position: fixed; left: 8px; right: 8px; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 40;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px; background: var(--panel);
    border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 8px 24px rgb(0 0 0 / .25); }
  .mnav-more[hidden] { display: none; }
  .mnav-more button { padding: 12px 6px; font-weight: 600; }
}
/* chart toolbar on one row from laptop widths up */
@media (min-width: 761px) {
  .chart-btns { gap: 4px; }
  .tf-seg button { padding: 3px 6px; }
}
@media (min-width: 761px) and (max-width: 1500px) { .db-word { display: none; } }

/* ---------- phase 3: shared page pieces (Scanner, Backtest) ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 12px 16px 10px; border-bottom: 1px solid var(--line); }
.page-head .page-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; margin-right: auto; }
.page-title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.page-sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.sec-title { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.j-stat, .bt-cards > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; }
.j-stat > span:first-child, .bt-cards > div > span:first-child { font-size: 11.5px; color: var(--muted); }
.j-stat b, .bt-cards > div b { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.j-table thead th, .tbl thead th, #resultTable th { color: var(--muted); font-weight: 500; background: var(--panel); }
.j-table tbody tr:hover, .tbl tbody tr:hover, #resultTable tbody tr:hover { background: var(--hover); }
.j-table td, .tbl td { font-variant-numeric: tabular-nums; }
.builder-head .sec-title { margin-right: 6px; }
.cond-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px 6px; }
.cond-empty p { margin: 0 0 2px; font-size: 13px; }
.cond-example { font-size: 12.5px; white-space: normal; text-align: left; }
.myscans-box .box-title { margin: 12px 12px 4px; }
#tab-scanner .page-head { border-bottom: 0; padding-bottom: 4px; }
/* Backtest page */
.bt-head .page-text { margin-right: 8px; }
.bt-desc { font-size: 12.5px; font-weight: 500; margin-left: 6px; }
.bt-tabs { display: flex; gap: 2px; padding: 2px; background: var(--chip); border-radius: var(--radius); }
.bt-tabs button { border: 0; background: none; padding: 5px 12px; font-weight: 600; color: var(--muted); }
.bt-tabs button.active { background: var(--bg); color: var(--text); border: 0; box-shadow: 0 0 0 1px var(--line); }
.bt-group { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.bt-group:last-of-type { border-bottom: 0; }
.bt-form fieldset { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 10px 0 0; margin: 0; }
.bt-form legend { padding: 0 6px 0 0; font-size: 13px; font-weight: 600; color: var(--text); }
/* login page brand */
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand img { width: 28px; height: 28px; flex: none; }

/* ---------- My scans inside the Signals tab (chart panel) ---------- */
.scan-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#sigMine { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }
#sigMine[hidden] { display: none; }
.myscans-panel .ms-row { padding: 10px 12px; }
.myscans-panel .ms-ctl { gap: 6px; }
.sig-seg button { padding: 5px 6px; }

/* Day-by-day P&L chart in the P&L box: running P&L, each day's P&L, drawdown */
.pnl-chart-wrap { padding: 4px 10px 8px; }
.pnl-chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; font-size: 11px; margin-bottom: 2px; }
.pnl-chart-info { flex: 1 1 100%; }
.pnl-chart { height: 240px; width: 100%; }
@media (max-width: 600px) { .pnl-chart { height: 220px; } }
.pnl-zooms { margin-left: auto; display: inline-flex; gap: 4px; }
.pnl-zoom { padding: 0 7px; font-size: 11px; line-height: 18px; min-width: 24px; }
.pnl-chart-off { padding: 2px 10px 8px; }
/* Full view: the P&L chart over the whole screen (Esc / ✕ Close) */
.pnl-chart-wrap.full { position: fixed; inset: 0; z-index: 2000; background: var(--panel); padding: 12px 16px;
  display: flex; flex-direction: column; }
.pnl-chart-wrap.full .pnl-chart { flex: 1 1 auto; height: auto; min-height: 0; }
.pnl-chart-wrap.full .pnl-chart-legend { font-size: 13px; margin-bottom: 8px; }
/* P&L box: month-by-month table, month chips */
.pnl-periods { padding: 4px 10px 6px; border-top: 1px solid var(--line); font-size: 12px; }
.pnl-periods > summary { cursor: pointer; padding: 2px 0; }
.pnl-periods-scroll { max-height: 260px; overflow: auto; margin-top: 4px; }
.pnl-periods-t { border-collapse: collapse; width: 100%; max-width: 640px; font-variant-numeric: tabular-nums; }
.pnl-periods-t th, .pnl-periods-t td { padding: 2px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pnl-periods-t th:first-child, .pnl-periods-t td:first-child { text-align: left; }
.pnl-periods-t th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 500; font-size: 11px; }
.pnl-mon { padding: 0 6px; font-size: 11px; line-height: 18px; min-width: 0; }
.pnl-mon.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pnl-per-sw { display: inline-flex; gap: 3px; margin-left: 10px; vertical-align: middle; }
.pnl-rule { flex: 1 1 320px; min-width: 200px; max-width: 520px; }
.pnl-rule-pick { max-width: 170px; }

.sig-box-btn { font-size: 12px; white-space: nowrap; }
.sig-box-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
