/* TradingView palettes, dark (default) and light (Settings / ☾ ☀). Tokens only below. */
:root {
  --bg: #131722; --panel: #1e222d; --panel-2: #2a2e39; --line: #2a2e39;
  --text: #d1d4dc; --muted: #8b8f9a; --accent: #2962ff;   /* muted: 5:1 on --bg (was #787b86, 4.2:1) */
  --up: #26a69a; --down: #ef5350; --warn: #f0b90b; --level: #f0b90b;
  --ok-bg: #0f3d2e; --warn-bg: #3d3208; --bad-bg: #4a1818; --demo-bg: #2a2208; --demo-line: #4a3c0c;
  --shadow: #0009;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ffffff; --panel: #f0f3fa; --panel-2: #e0e3eb; --line: #e0e3eb;
  --text: #131722; --muted: #6a6d78; --accent: #2962ff;
  --up: #089981; --down: #f23645; --warn: #b07d00; --level: #d48806;
  --ok-bg: #e3f5ef; --warn-bg: #fff4d6; --bad-bg: #fde8ea; --demo-bg: #fff4d6; --demo-line: #f0dca0;
  --shadow: #0003;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif; }
body { display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

#demo-banner { background: var(--demo-bg); color: var(--warn); padding: 5px 12px; font-size: 12px;
  border-bottom: 1px solid var(--demo-line); flex: none; }

.bar { display: flex; align-items: center; gap: 4px; padding: 5px 8px; border-bottom: 1px solid var(--line);
  flex: none; min-height: 42px; overflow-x: auto; }
.sym { font-weight: 600; padding: 6px 10px; border-radius: 4px; background: var(--panel); white-space: nowrap; }
.sym:hover, .tool:hover, .tfs button:hover { background: var(--panel-2); }
.tfs { display: flex; }
.tfs button, .tool { padding: 6px 8px; border-radius: 4px; color: var(--muted); white-space: nowrap; }
.tfs button.on, .tool.on { color: var(--text); background: var(--panel-2); }
.tool.on#level-btn { color: var(--level); }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.grow { flex: 1; }
.pill { padding: 3px 9px; border-radius: 10px; font-size: 12px; white-space: nowrap;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; flex: none; }   /* never widens the top bar */
.pill.green { background: var(--ok-bg); color: var(--up); }
.pill.amber { background: var(--warn-bg); color: var(--warn); }
.pill.red { background: var(--bad-bg); color: var(--down); }
.pill.grey { background: var(--panel); color: var(--muted); }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 6px; white-space: nowrap; }
.tool.icon { font-size: 15px; padding: 5px 8px; }
/* Line icons (sprite in index.html): follow the text colour and the theme */
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round;
  stroke-linejoin: round; flex: none; vertical-align: -4px; }
.tool, .lv button, .selbar button, .st-row button, .mv, .menu-row button, .sd header .x { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.st-row .ic, .selbar .ic, .lv button .ic, .mv .ic, .caret .ic, .st-toggle .ic { width: 14px; height: 14px; vertical-align: -2px; }
.main.side-hidden .side { display: none; }        /* desktop: more room for the charts */
/* Right icon rail (TradingView-style): one panel at a time; the open one is highlighted */
.rail { width: 44px; flex: none; border-left: 1px solid var(--line); display: flex; flex-direction: column;
  gap: 4px; padding: 6px 4px; align-items: center; }
.rail button { width: 36px; height: 36px; border-radius: 6px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.rail button:hover { background: var(--panel-2); color: var(--text); }
.rail button.on { background: var(--panel-2); color: var(--accent); }
.rail button span, .rail .phone-only { display: none; }
.panel-head { padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--line); flex: none; }
.menu.settings { width: 300px; max-height: calc(100vh - 70px); overflow-y: auto; gap: 0; padding: 0; }
.menu.settings section { padding: 8px 12px 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.menu-title { padding: 10px 12px; font-weight: 600; }
.menu.settings label { align-items: flex-start; line-height: 1.35; }
.menu.settings label input { margin-top: 2px; }
.menu.settings label small { display: block; color: var(--muted); font-size: 11px; }
.menu-sub { font-size: 12px; color: var(--muted); }
.ind-list { display: flex; flex-direction: column; }
.ind-list button { text-align: left; padding: 7px 8px; border-radius: 4px; display: flex; justify-content: space-between; gap: 12px; }
.ind-list button:hover { background: var(--panel-2); }
.ind-list small { color: var(--muted); }
/* Indicator settings window (web/study-dialog.js): Inputs · Style · Visibility */
.dialog.sd { width: min(600px, calc(100vw - 16px)); padding: 0; display: flex; flex-direction: column;
  max-height: calc(100vh - 12vh - 24px); }
.sd header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; font-size: 15px; }
.sd header .x { color: var(--muted); padding: 4px 8px; border-radius: 4px; }
.sd header .x:hover { background: var(--panel-2); color: var(--text); }
.sd-tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.sd-tabs button { padding: 8px 10px; color: var(--muted); }
.sd-tabs button.on { color: var(--text); box-shadow: inset 0 -2px var(--accent); }
.sd-body { padding: 10px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; min-height: 200px; }
.sd .row { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.sd .row > span:first-child { flex: 1; }
.sd .row.chk { justify-content: flex-start; }
.sd .row.chk > span { flex: 0 1 auto; }
.sd label.chk { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.sd .row.sty label.chk { flex: 1 1 auto; min-width: 90px; }
.sd .row.sty label.chk span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd .row.vis { gap: 14px; flex-wrap: wrap; }
.sd .row.vis > span:first-child { flex: 0 0 70px; color: var(--muted); }
.sd input { width: auto; padding: 0; font-size: inherit; flex: none; }   /* undo the login box's full-width inputs */
.sd input[type=checkbox] { margin: 0; width: 15px; height: 15px; accent-color: var(--accent); }
.sd input[type=number], .sd select { padding: 5px 8px; border-radius: 4px; border: 1px solid var(--panel-2);
  background: var(--bg); color: var(--text); font: inherit; }
.sd input[type=number] { width: 90px; }
.sd input.num { width: 70px; }
.sd .clr { display: inline-flex; align-items: center; gap: 4px; }
.sd input[type=color] { width: 28px; height: 24px; border: 1px solid var(--panel-2); border-radius: 4px; padding: 0; background: none; }
.sd input[type=range] { width: 60px; accent-color: var(--accent); }
.sd-head { margin-top: 10px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sd-note { margin: 0 0 6px; color: var(--muted); }
.sd footer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.sd footer button { padding: 7px 14px; border-radius: 4px; }
.sd footer .ghost { border: 1px solid var(--panel-2); }
.sd footer .ghost:hover { background: var(--panel-2); }
.sd footer .ok { background: var(--accent); color: #fff; font-weight: 600; }
@media (max-width: 700px) {
  #study-dialog { padding-top: 0; align-items: flex-end; }
  .dialog.sd { width: 100vw; max-height: 85vh; border-radius: 10px 10px 0 0; }
  .sd .row.sty { flex-wrap: wrap; row-gap: 4px; padding: 4px 0; border-bottom: 1px solid var(--panel-2); }
  .sd .row.sty label.chk { flex-basis: 100%; }
}
.pane .studies { display: flex; flex-direction: column; gap: 1px; font-size: 12px; align-items: flex-start; }
.st-row { display: flex; align-items: center; gap: 6px; pointer-events: auto; padding: 1px 4px 1px 0; border-radius: 3px; }
.st-row .st-val { font-variant-numeric: tabular-nums; }
.st-row.off .st-name, .st-row.off .st-val { opacity: .45; }
.st-row button { display: none; padding: 1px 5px; border-radius: 3px; color: var(--muted); background: var(--panel); font-size: 11px; }
.st-row:hover button { display: inline-block; }
.st-row button:hover { color: var(--text); background: var(--panel-2); }
.st-row.fixed { pointer-events: none; color: var(--muted); }
@media (hover: none) { .st-row.open button { display: inline-block; } }   /* touch: tap the name first */
.st-toggle { pointer-events: auto; color: var(--muted); font-size: 11px; padding: 2px 6px; margin-left: -6px;
  border-radius: 3px; display: inline-flex; align-items: center; gap: 2px; min-height: 20px; }
.st-toggle:hover { color: var(--text); background: var(--panel-2); }
.studies.folded .st-row { display: none; }
.menu-head { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 4px 2px 0; }
.menu-note { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.4; max-width: 260px; }
.dsep { height: 1px; background: var(--line); margin: 4px 2px; }
.drawbar .magnet { position: relative; }
.drawbar .magnet.on { background: var(--panel-2); color: var(--accent); }
.drawbar .magnet small { position: absolute; right: 2px; bottom: 1px; font-size: 9px; font-weight: 700; color: var(--accent); }
.brk { display: none; }

.main { flex: 1; display: flex; min-height: 0; }
.charts { flex: 1; display: grid; gap: 1px; background: var(--line); min-width: 0; }
.charts.g-1 { grid-template-columns: 1fr; }
.charts.g-2h { grid-template-columns: 1fr 1fr; }
.charts.g-2v { grid-template-rows: 1fr 1fr; }
.charts.g-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.charts.phone-one { grid-template-columns: 1fr !important; grid-template-rows: 1fr !important; }
.charts.phone-one .pane:not(.shown) { display: none; }
.menu-wrap { position: relative; }
.menu { position: fixed; z-index: 45; background: var(--panel); border: 1px solid var(--panel-2);
  border-radius: 6px; padding: 8px; box-shadow: 0 8px 24px var(--shadow); min-width: 240px; display: flex; flex-direction: column; gap: 6px; }
.menu-row { display: flex; gap: 4px; }
.menu-row button { flex: 1; padding: 6px 4px; border-radius: 4px; color: var(--muted); background: var(--bg); white-space: nowrap; }
.menu-row button.on { color: var(--text); background: var(--panel-2); }
.menu label { display: flex; gap: 8px; align-items: center; color: var(--text); padding: 2px 2px; cursor: pointer; }
.pane-tabs { display: flex; gap: 2px; }
.pane-tabs button { width: 28px; padding: 6px 0; border-radius: 4px; color: var(--muted); }
.pane-tabs button.on { background: var(--panel-2); color: var(--text); }
.tf-typing { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 50; background: var(--panel);
  border: 1px solid var(--accent); border-radius: 6px; padding: 10px 18px; font-size: 22px; font-weight: 600; }
.pane.placing .chart { touch-action: none; }      /* iPad/iPhone: drawing, not scrolling, under the finger */
.pane { position: relative; background: var(--bg); min-height: 0; min-width: 0; outline: 1px solid transparent; }
.charts:not(.g-1):not(.phone-one) .pane.active { outline-color: var(--accent); outline-offset: -1px; }
.pane .chart { position: absolute; inset: 0; }
.pane .tl { position: absolute; left: 10px; top: 8px; right: 70px; z-index: 3; pointer-events: none;
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }   /* prices, then indicators */
.pane .legend { font-size: 12px; }
.pane .legend b { font-size: 13px; margin-right: 8px; }
.pane .legend .o { color: var(--muted); margin-right: 6px; }
.pane .legend .up { color: var(--up); } .pane .legend .down { color: var(--down); }
.pane.placing .chart { cursor: crosshair; }
.drawbar { display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; border-right: 1px solid var(--line); flex: none; }
.drawbar button { width: 32px; height: 32px; border-radius: 4px; color: var(--muted); font-size: 16px; }
.drawbar button:hover { background: var(--panel-2); color: var(--text); }
.drawbar button.on { background: var(--panel-2); color: var(--accent); }
.selbar { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); z-index: 4; display: flex; gap: 4px;
  align-items: center; background: var(--panel); border: 1px solid var(--panel-2); border-radius: 6px; padding: 4px 6px;
  font-size: 12px; box-shadow: 0 4px 12px var(--shadow); }
.selbar span { color: var(--muted); padding: 0 6px; }
.selbar button { padding: 4px 8px; border-radius: 4px; color: var(--text); background: var(--panel-2); }
.selbar button.on { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.selbar button.armed { color: var(--warn); background: var(--warn-bg); }
.lv .kind { color: var(--accent); font-size: 12px; }
.lv .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

.side { width: var(--side-w, 280px); flex: none; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
/* Drag the panel's left edge to resize it (desktop/iPad); the width is remembered on this device. */
.side-resize { width: 6px; margin-right: -6px; flex: none; cursor: col-resize; z-index: 4; position: relative; touch-action: none; }
.side-resize::after { content: ""; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px; background: transparent; transition: background .15s; }
.side-resize:hover::after, .side-resize:focus-visible::after, .side-resize.drag::after { background: var(--accent); }
.side-resize:focus { outline: none; }
.main.side-hidden .side-resize { display: none; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; }
body.resizing .charts { pointer-events: none; }
.tab { overflow-y: auto; flex: 1; }
.group { padding: 10px 12px 4px; font-size: 11px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.row { display: grid; grid-template-columns: 1fr auto 62px; gap: 8px; padding: 6px 12px; align-items: center;
  cursor: pointer; font-variant-numeric: tabular-nums; }
.row:hover { background: var(--panel); }
.row.current { background: var(--panel-2); }
.row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .ltp { text-align: right; }
.row .chg { text-align: right; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); }
.row.stale .name::after { content: " · stale"; color: var(--warn); font-size: 11px; }

.lv { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px; padding: 7px 12px; align-items: center;
  border-bottom: 1px solid var(--panel); font-variant-numeric: tabular-nums; }
.lv .price { color: var(--level); }
.lv button { padding: 4px 8px; border-radius: 4px; background: var(--panel); color: var(--muted); }
.lv button.armed { color: var(--warn); background: var(--warn-bg); }
.lv button:hover { background: var(--panel-2); }
.hint { color: var(--muted); padding: 12px; line-height: 1.5; }
.lv .lbl { min-width: 0; background: transparent; border: 1px solid transparent; color: var(--text);
  border-radius: 4px; padding: 3px 6px; font: inherit; }
.lv .lbl:hover, .lv .lbl:focus { border-color: var(--panel-2); background: var(--bg); outline: none; }
.lv .lbl::placeholder { color: var(--muted); opacity: .6; }

.watch-bar { display: flex; gap: 6px; justify-content: flex-end; padding: 6px 8px; border-bottom: 1px solid var(--panel); }
.sec-head { display: flex; align-items: center; gap: 6px; width: 100%; padding: 9px 12px 5px; text-align: left;
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sec-head:hover { color: var(--text); }
.sec-head .caret { width: 10px; }
.sec-head .count { margin-left: auto; font-size: 11px; opacity: .7; }
.row.global .name { color: var(--muted); }
.sec.editing { border-bottom: 1px solid var(--panel); padding-bottom: 4px; }
.sec-edit { display: flex; gap: 4px; padding: 8px 8px 4px 12px; }
.sec-edit .sec-title { flex: 1; min-width: 0; padding: 5px 8px; border-radius: 4px; border: 1px solid var(--panel-2);
  background: var(--bg); color: var(--text); font: inherit; font-weight: 600; }
.row.edit { grid-template-columns: 1fr auto; cursor: default; }
.mv { padding: 3px 7px; border-radius: 4px; color: var(--muted); background: var(--panel); margin-left: 2px; }
.mv:hover:not(:disabled) { color: var(--text); background: var(--panel-2); }
.mv:disabled { opacity: .3; cursor: default; }
.add { display: block; width: calc(100% - 24px); margin: 4px 12px; padding: 6px; border-radius: 4px;
  border: 1px dashed var(--panel-2); color: var(--muted); }
.add:hover { color: var(--text); border-color: var(--muted); }
.new-sec { margin: 10px 12px 14px; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: var(--panel-2); color: var(--muted); margin-left: 6px; }

.toasts { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel-2); border-left: 3px solid var(--warn); padding: 10px 12px; border-radius: 4px;
  max-width: 340px; box-shadow: 0 4px 16px var(--shadow); }

.overlay { position: fixed; inset: 0; background: var(--shadow); display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh; z-index: 40; }
.dialog { background: var(--panel); border-radius: 6px; width: min(420px, calc(100vw - 32px)); padding: 12px;
  box-shadow: 0 12px 40px var(--shadow); }
.dialog input { width: 100%; padding: 10px; border-radius: 4px; border: 1px solid var(--panel-2);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
#search-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
#search-list li { padding: 8px 10px; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; }
#search-list li.sel, #search-list li:hover { background: var(--panel-2); }
#search-list li.group { cursor: default; color: var(--muted); font-size: 11px; padding: 10px 10px 4px; background: none; }
.sec-note { color: var(--muted); font-size: 11px; padding: 2px 10px 6px; }
.login { display: flex; flex-direction: column; gap: 10px; padding: 20px; }
.login h1 { margin: 0 0 4px; font-size: 18px; }
.login button { padding: 10px; border-radius: 4px; background: var(--accent); color: #fff; font-weight: 600; }
.err { color: var(--down); margin: 0; min-height: 1em; }

/* Phone: one chart, side panel slides over it, bigger touch targets. */
/* Medium widths (iPad portrait, small windows): the desktop top bar must fit without scrolling */
@media (max-width: 1000px) {
  .clock, .wide { display: none; }
  .tfs button { padding: 6px 6px; }
}
/* iPad portrait (701-900 px): desktop layout, but side-by-side charts stack (design 6A) */
@media (min-width: 701px) and (max-width: 900px) and (orientation: portrait) {
  .charts.g-2h { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}
/* Phone (≤ 700 px): one chart at a time, the rail becomes a bottom tab bar, each panel a full screen */
@media (max-width: 700px) {
  .main { flex-direction: column; }
  .drawbar { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; padding: 4px 8px; }
  .drawbar button { width: 40px; height: 36px; }
  .desk-only, #theme-btn { display: none; }        /* phone: theme lives in ⚙ Settings */
  .menu-wrap:has(#settings-btn) { order: 3; }
  .bar { column-gap: 2px; }                        /* row 1 holds symbol · health · 1-4 · settings */
  .bar .tool.icon { padding: 8px 6px; }
  .pane-tabs button { width: 26px; }
  .wide { display: none; }
  .menu-wrap:has(#ind-btn) { order: 6; }          /* ƒx right after the timeframes: in view without scrolling */
  .dsep { width: 1px; height: auto; margin: 4px 2px; }
  /* Two rows: [symbol · health · 1-4 · settings] then [timeframes · layout · ƒx]. Nothing off-screen. */
  .bar { flex-wrap: wrap; overflow: visible; row-gap: 4px; }
  .sym { order: 1; }
  #health { order: 2; margin-left: auto; }
  .brk { display: block; order: 4; flex-basis: 100%; height: 0; }
  .tfs { order: 5; }
  #level-btn { order: 6; }
  #layout-btn { order: 7; }
  .menu-wrap { order: 7; }
  .pane-tabs { order: 3; }
  .sep, .bar .grow, .clock { display: none; }     /* the top bar's spacer only: dialog footers keep theirs */
  /* Row 2: timeframes, layout, templates, ƒx, alert, replay, snapshot in ONE row that scrolls sideways
     (menus are position: fixed, so the scroller never clips them). */
  .bar-tools { display: flex; order: 5; flex-basis: 100%; min-width: 0; align-items: center; gap: 2px;
    overflow-x: auto; scrollbar-width: none; }
  .bar-tools::-webkit-scrollbar { display: none; }
  .bar-tools > * { flex: 0 0 auto; }
  #alert-btn, #replay-btn, #snap-btn { order: 9; }
  .side, .main.side-hidden .side, .side-resize { display: none; }
  .main.phone-panel .side { display: flex; flex: 1; width: auto; border-left: 0; min-height: 0; }
  .main.phone-panel .charts, .main.phone-panel .drawbar { display: none; }
  .rail { width: auto; flex-direction: row; border-left: 0; border-top: 1px solid var(--line); gap: 0;
    padding: 2px 0 calc(2px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .rail button { width: auto; flex: 1; height: 48px; flex-direction: column; gap: 2px; border-radius: 0; }
  .rail button.on { background: none; }
  .rail button span { display: block; font-size: 10px; }
  .rail .phone-only { display: flex; }
  .tfs button, .tool { padding: 8px 6px; }
  .row, .lv { padding-top: 10px; padding-bottom: 10px; }
  .mv { padding: 7px 10px; }
  .sec-head { padding-top: 12px; padding-bottom: 8px; }
}

/* ⚙ › Status (web/status.js) */
.menu-title { display: flex; align-items: center; justify-content: space-between; }
.menu-title .tool { font-weight: 400; padding: 4px 8px; }
.dialog.sd.status { width: min(640px, calc(100vw - 16px)); }
.st-summary { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.st-feed { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0 0; }
.sd-body p { margin: 2px 0 6px; line-height: 1.5; }
.st-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.st-list li small { display: block; color: var(--muted); font-size: 11px; }
.st-list li.error { color: var(--down); }
.st-list li.warning { color: var(--warn); }
.st-table { border-collapse: collapse; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.st-table th, .st-table td { text-align: left; padding: 3px 12px 3px 0; }
.st-table th { color: var(--muted); font-weight: 400; font-size: 12px; }
.warn { color: var(--warn); }

/* ── M6c: templates menu, Today's levels box, toast actions ─────────────────── */
.tpl-menu { width: 340px; max-width: calc(100vw - 16px); max-height: calc(100vh - 70px); overflow-y: auto; }
.tpl { display: grid; grid-template-columns: 1fr auto auto 24px 24px; gap: 4px; align-items: center; padding: 4px 2px; border-radius: 4px; }
.tpl:hover { background: var(--bg); }
.tpl-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-name small { display: block; color: var(--muted); font-size: 11px; }
.tpl button { padding: 5px 7px; border-radius: 4px; font-size: 12px; color: var(--muted); background: var(--bg); white-space: nowrap; }
.tpl button:hover { color: var(--text); background: var(--panel-2); }
.tpl button.x { background: transparent; padding: 4px; }
.tpl button .ic { width: 14px; height: 14px; }
.tpl-edit { display: flex; flex-direction: column; gap: 6px; padding: 8px; margin-bottom: 6px; border-radius: 6px; background: var(--panel-2); font-size: 12px; }
.tpl-edit-row { display: flex; gap: 6px; }
.tpl-edit-row button { padding: 5px 9px; border-radius: 4px; font-size: 12px; }
.tpl-edit-row button:not(.ok) { background: var(--bg); color: var(--text); }
.tpl-form { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.tpl-save-row { display: flex; gap: 6px; }
.tpl-save-row input { flex: 1; min-width: 0; padding: 6px 8px; border-radius: 4px; border: 1px solid var(--panel-2); background: var(--bg); color: var(--text); font: inherit; }
button.ok { background: var(--accent); color: #fff; padding: 6px 12px; border-radius: 4px; }
button.ok:disabled { opacity: .4; cursor: default; }
button.ghost { color: var(--muted); padding: 6px 10px; border-radius: 4px; border: 1px solid var(--panel-2); display: inline-flex; gap: 4px; align-items: center; }
button.ghost:hover { color: var(--text); }
button.ghost .ic { width: 14px; height: 14px; }
.today { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--line); }
.today-head { font-size: 12px; color: var(--muted); }
.today textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 64px; padding: 6px 8px; border-radius: 4px;
  border: 1px solid var(--panel-2); background: var(--bg); color: var(--text); font: 13px/1.5 ui-monospace, "SF Mono", Menlo, monospace; }
.today-row { display: flex; gap: 6px; flex-wrap: wrap; }
.today-msg { font-size: 12px; line-height: 1.5; }
.today-msg .ic { width: 12px; height: 12px; vertical-align: -1px; }
.today-msg button { margin-top: 4px; }
.today-note { margin: 0; font-size: 11px; color: var(--muted); }
/* "day-level", not "today": .today is the Today's-levels box (a column flexbox) and won the cascade,
   stacking each row's pin/price/label/bell/× vertically (30 Sep, live). */
.lv.day-level { grid-template-columns: auto auto 1fr auto auto; }
.lv button.pin { padding: 4px; color: var(--muted); opacity: .6; }
.lv button.pin.on { color: var(--level); opacity: 1; }
.toast-act { margin-left: 12px; color: var(--accent); font-weight: 600; padding: 2px 4px; }
@media (max-width: 700px) { .today textarea, .tpl-save-row input { font-size: 16px; } }

/* ── M6d: Alerts panel, Create-alert window, counter ─────────────────────────── */
.al-head { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 12px 6px; }
.al-head .ic { width: 14px; height: 14px; }
.sub-tabs { display: flex; gap: 2px; padding: 0 12px 6px; border-bottom: 1px solid var(--line); }
.sub-tabs button { padding: 6px 10px; border-radius: 4px; color: var(--muted); }
.sub-tabs button.on { background: var(--panel-2); color: var(--text); }
.al { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.al-title { min-width: 0; font-size: 13px; line-height: 1.35; }
.al .why { display: block; color: var(--muted); font-size: 11px; }
.al.st-error { background: var(--bad-bg); }
.al.st-error .why { color: var(--down); }
.al button { padding: 4px 8px; border-radius: 4px; color: var(--muted); background: var(--panel); }
.al button:hover { background: var(--panel-2); color: var(--text); }
.al button.x { padding: 4px; }
.al button .ic { width: 14px; height: 14px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 8px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.st-armed .tag, .k-telegram_ok .tag { background: var(--ok-bg); color: var(--up); }
.st-fired .tag, .k-fired .tag { background: var(--warn-bg); color: var(--warn); }
.st-error .tag, .k-error .tag, .k-telegram_failed .tag, .k-late .tag { background: var(--bad-bg); color: var(--down); }
.log-day { display: flex; gap: 8px; align-items: center; padding: 8px 12px; font-size: 12px; color: var(--muted); }
.log-day input { background: var(--bg); color: var(--text); border: 1px solid var(--panel-2); border-radius: 4px; padding: 4px 6px; font: inherit; }
.lg { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: baseline; padding: 6px 12px; border-bottom: 1px solid var(--line); font-size: 12px; }
.lg-t { color: var(--muted); font-variant-numeric: tabular-nums; }
.lg-x { min-width: 0; white-space: pre-wrap; }
.rail button.dot { position: relative; }
.rail button.dot::after { content: ''; position: absolute; top: 6px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--down); }
#alert-count { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; border: 0; font: inherit; }
#alert-count .ic { width: 12px; height: 12px; }
.ad .row { display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: center; padding: 4px 0; }
.ad select, .ad input { width: 100%; box-sizing: border-box; padding: 7px 8px; border-radius: 4px; border: 1px solid var(--panel-2);
  background: var(--bg); color: var(--text); font: inherit; }
.ad header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ad footer { display: flex; gap: 8px; margin-top: 10px; }
.ad .err { color: var(--down); margin: 4px 0 0; font-size: 12px; min-height: 1em; }
.ad .sd-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
@media (max-width: 700px) { .ad select, .ad input { font-size: 16px; } .ad .row { grid-template-columns: 1fr; } }
#snap-btn.busy { opacity: .5; cursor: progress; }

/* ── M6e: bar replay ────────────────────────────────────────────────────────── */
@media (min-width: 701px) { .bar-tools { display: contents; } }   /* desktop / iPad: part of the one-row top bar */
.replay-bar { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 30;
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 24px);
  background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; padding: 6px 10px; box-shadow: 0 8px 24px var(--shadow); }
.replay-bar button, .replay-bar select { padding: 6px 10px; border-radius: 4px; background: var(--bg); color: var(--text);
  border: 1px solid var(--panel-2); font: inherit; min-height: 32px; }
.replay-bar button:disabled { opacity: .4; }
.replay-bar .ic { width: 14px; height: 14px; }
.rp-msg { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rp-date { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); }
.rp-date input { background: var(--bg); color: var(--text); border: 1px solid var(--panel-2); border-radius: 4px; padding: 4px 6px; font: inherit; }
#replay-btn.on { color: var(--accent); background: var(--panel-2); }
@media (max-width: 700px) {                         /* phone: a status line + one row of controls */
  .replay-bar { bottom: calc(60px + env(safe-area-inset-bottom, 0px)); gap: 4px; padding: 4px 6px;
    left: 12px; right: 12px; transform: none; max-width: none; }
  .replay-bar .rp-msg { flex-basis: 100%; order: -1; text-align: center; }
  .replay-bar:not(.picking) .rp-date, .replay-bar .rp-word { display: none; }
  .replay-bar button, .replay-bar select { padding: 4px 8px; }
  .rp-date input { font-size: 16px; }
}

/* ── M6f: Market panel, watchlist day line ─────────────────────────────────── */
.mk-head { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px 2px; gap: 8px; }
.mk-head .muted, .mk-row small { color: var(--muted); font-size: 11px; }
.mk-count { padding: 2px 12px; font-size: 18px; font-variant-numeric: tabular-nums; }
.mk-bar { display: flex; height: 6px; margin: 6px 12px 8px; border-radius: 3px; overflow: hidden; background: var(--panel-2); }
.mk-bar i { display: block; height: 100%; }
.mk-bar .a { background: var(--up); } .mk-bar .d { background: var(--down); } .mk-bar .u { background: var(--muted); }
.mk-idx { padding: 0 12px 8px; font-size: 13px; }
.mk-idx .muted { color: var(--muted); font-size: 12px; }
.mk-tabs { padding-top: 4px; }
.mk-row { display: grid; grid-template-columns: 1fr auto 64px; gap: 8px; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums; cursor: pointer; }
.mk-row:hover { background: var(--panel); }
.mk-row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-row small { margin-left: 6px; }
.mk-row b { text-align: right; }
.mk-note { font-size: 11px; color: var(--muted); padding: 8px 12px; margin: 0; }
.mk-note.warn { color: var(--warn); }
.row .xrow { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; margin-top: -2px; }
.row .rng { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .rng .rbar { position: relative; width: 56px; height: 3px; border-radius: 2px; background: var(--panel-2); }
.row .rng .rbar i { position: absolute; top: -2px; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: var(--text); }
