/* Trading terminal. Panels meet on one-pixel seams (the grid gap shows --line), no cards. Tokens only. */
body.is-terminal { background: var(--line); font-size: 14px; }
.term { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; background: var(--line); gap: 1px; }
.num { letter-spacing: 0; font-weight: 500; }
.up { color: var(--profit); }
.down { color: var(--loss); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.45; }
.hint.up { color: var(--profit); }
.hint.down { color: var(--loss); }
.panel-h { font-family: var(--font-body); font-size: 13px; font-weight: 650; letter-spacing: 0.01em; }
.count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); font-family: var(--font-mono); font-size: 11px; }
.hide-sm { display: none; }
@media (min-width: 760px) { .hide-sm { display: revert; } }
.button { min-height: 40px; padding: 8px 16px; font-size: 13px; }
.button-primary:hover { background: color-mix(in srgb, var(--accent-fill) 88%, var(--ink)); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 0.2em; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
input, select { font: inherit; }

/* ── Grid: chart and tables left, markets and the order panel right, margin line under both ── */
body.is-terminal { background: var(--bg); }
.term { display: grid; gap: 1px; background: var(--line); grid-template-columns: minmax(0, 1fr); grid-template-areas: "market" "chart" "right" "tables" "margin" "foot"; }
.term > *, .area-left > * { background: var(--bg); min-width: 0; }
.area-left { display: contents; }
.market-head { grid-area: market; }
.area-chart { grid-area: chart; height: clamp(380px, 60svh, 600px); }
.area-right { grid-area: right; display: flex; flex-direction: column; gap: 1px; background: var(--line); }
.area-right > * { background: var(--bg); }
.area-watch { order: 2; }
.area-side { order: 1; }
.area-tables { grid-area: tables; }
.area-margin { grid-area: margin; }
.term-foot { grid-area: foot; }
@media (min-width: 1024px) {
  .term { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "left right" "margin margin" "foot foot"; }
  .area-left { grid-area: left; display: flex; flex-direction: column; gap: 1px; background: var(--line); min-width: 0; }
  .area-chart { height: clamp(460px, calc(100dvh - 61px - 65px - 270px), 820px); }
  .area-tables { flex: 1; }
  .area-watch { order: 0; }
  .area-side { flex: 1; }
}
@media (min-width: 1360px) { .term { grid-template-columns: minmax(0, 1fr) 368px; } }

/* ── Market head ── */
.market-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px; padding: 10px 16px; min-height: 64px; }
.mh-id { display: grid; gap: 2px; }
.mh-ticker { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: 0.01em; }
.mh-name { font-size: 12px; color: var(--muted); }
.mh-price { display: flex; align-items: baseline; gap: 10px; }
.mh-price strong { font-size: 24px; }
.mh-facts { display: flex; gap: 22px; margin: 0; }
.mh-facts dt { font-size: 11px; color: var(--muted); }
.mh-facts dd { margin: 0; font-size: 13px; }
.mh-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 0 auto; }
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 9px; border-radius: 13px; background: var(--surface); color: var(--muted-strong); font-size: 12px; font-weight: 600; }
.badge-live { background: var(--profit-soft); color: var(--profit); }
.badge-demo { background: var(--gold-soft); color: var(--gold); }
.badge-open::before, .badge-closed::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--profit); }
.badge-closed::before { background: var(--loss); }
.acct-switch select { min-height: 40px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 4px 10px; font-size: 13px; max-width: 300px; }

/* ── Watchlist ── */
.watch { display: flex; flex-direction: column; }
.watch-tabs { display: flex; gap: 2px; padding: 6px 8px 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.watch-tabs::-webkit-scrollbar { display: none; }
.watch-tabs button { flex: none; min-height: 40px; padding: 0 10px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted-strong); font-size: 13px; font-weight: 600; white-space: nowrap; }
.watch-tabs button:hover { color: var(--ink); }
.watch-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent-fill); }
.watch-tools { display: grid; gap: 8px; padding: 8px; }
.watch-search { display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); border: 1px solid transparent; }
.watch-search:focus-within { border-color: var(--accent); }
.watch-search input { flex: 1; min-width: 0; min-height: 38px; border: 0; background: none; color: var(--ink); outline: none; font-size: 13px; }
.watch-tools .seg { display: flex; }
.watch-tools .seg button { flex: 1; font-family: var(--font-body); font-weight: 600; }
.seg button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent-text); }
.watch-list { max-height: 300px; overflow-y: auto; padding: 0 4px 6px; }
@media (min-width: 1024px) { .watch-list { max-height: min(300px, 32vh); } }
.watch-row { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; border-radius: 4px; }
.watch-row:hover, .watch-row.is-current { background: var(--surface); }
.watch-head { grid-template-columns: 30px minmax(0, 1fr) 96px 64px; padding: 4px 8px 4px 0; font-size: 11px; color: var(--muted); position: sticky; top: 0; background: var(--bg); z-index: 1; }
.watch-head span:nth-child(n + 3) { text-align: right; }
.watch-pick { display: grid; grid-template-columns: minmax(0, 1fr) 96px 64px; gap: 6px; align-items: center; min-height: 44px; padding: 4px 8px 4px 0; background: none; border: 0; color: var(--ink); text-align: left; font-size: 13px; }
.watch-pick .num { text-align: right; font-size: 12.5px; }
.w-name { display: grid; min-width: 0; }
.w-name strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-name small { font-size: 11px; color: var(--muted); }
.star { display: grid; place-items: center; width: 30px; height: 44px; padding: 0; background: none; border: 0; color: var(--line-strong); }
.star:hover { color: var(--muted-strong); }
.star.on { color: var(--accent); }
.star.on svg { fill: currentColor; }
.empty-row { padding: 16px 10px; color: var(--muted); font-size: 13px; }

/* ── Side tabs ── */
.side-tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); }
.side-tabs button { flex: 1; min-height: 42px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted-strong); font-size: 13px; font-weight: 600; }
.side-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent-fill); }
[role="tabpanel"][hidden] { display: none; }

/* ── Margin line ── */
.area-margin { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; margin: 0; padding: 14px 16px; }
@media (min-width: 760px) { .area-margin { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.area-margin dt { font-size: 11px; color: var(--muted); }
.area-margin dd { margin: 2px 0 0; font-size: 16px; font-weight: 500; }

/* ── Menus and pickers ── */
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 200px; display: grid; padding: 6px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); }
.menu > button { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 10px 6px 30px; position: relative; background: none; border: 0; color: var(--ink); border-radius: 4px; text-align: left; font-size: 13px; }
.menu > button svg { position: absolute; left: 8px; color: var(--accent); }
.menu > button:hover { background: var(--surface); }
.menu-wide { min-width: 280px; }
.menu-tf { min-width: 236px; gap: 8px; padding: 10px; }
.menu-title { display: block; margin: 0 0 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tf-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.tf-grid button { min-height: 36px; background: none; border: 1px solid var(--line-control); border-radius: 4px; color: var(--ink); font: 500 12px/1 var(--font-mono); }
.tf-grid button:hover { background: var(--surface); border-color: var(--line-control-hover); }
.tf-grid button[aria-checked="true"] { border-color: var(--accent); color: var(--accent); }
.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 4px; cursor: pointer; }
.check-row:hover { background: var(--surface); }
.check-row input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent-fill); }
.check-row span { display: grid; gap: 2px; font-size: 13px; }
.check-row small { color: var(--muted); font-size: 11px; }
.picker { width: min(92vw, 360px); padding: 8px; }
.picker-search { display: flex; align-items: center; gap: 8px; padding: 0 10px; margin-bottom: 6px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); }
.picker-search input { flex: 1; min-height: 40px; background: none; border: 0; color: var(--ink); outline: none; }
.picker-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.picker ul { max-height: 360px; overflow-y: auto; display: grid; }
.picker li button { display: grid; grid-template-columns: minmax(0, 1fr) auto 76px; gap: 12px; align-items: center; width: 100%; min-height: 48px; padding: 6px 10px; background: none; border: 0; color: var(--ink); text-align: left; border-radius: 4px; font-size: 13px; }
.picker li button:hover, .picker li button[aria-current="true"] { background: var(--surface); }
.picker li button span:first-child { display: grid; }
.picker li small { color: var(--muted); font-size: 11px; }
.picker .num { text-align: right; }

/* ── Chart ── */
.chart-shell { height: 100%; display: flex; flex-direction: column; background: var(--surface); }
.chart-shell.is-full { position: fixed; inset: 0; z-index: 100; height: 100vh; height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--surface); }
html.chart-full-open, html.chart-full-open body { overflow: hidden; overscroll-behavior: none; }
.chart-bar { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--line); min-height: 44px; overflow-x: auto; scrollbar-width: none; }
.chart-bar::-webkit-scrollbar { display: none; }
.chart-bar .menu-wrap { flex: none; }
.bar-gap { flex: 1; }
.seg { display: inline-flex; flex: none; padding: 2px; border-radius: var(--radius-sm); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-control); }
.seg button { min-width: 34px; min-height: 32px; padding: 0 8px; background: none; border: 0; color: var(--muted-strong); font-family: var(--font-mono); font-size: 12px; border-radius: 4px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
.tool-btn { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; background: none; border: 0; border-radius: var(--radius-sm); color: var(--muted-strong); }
.tool-btn.wide { display: inline-flex; gap: 6px; width: auto; padding: 0 10px; font-size: 13px; }
.tool-btn.text { width: auto; padding: 0 10px; font-family: var(--font-mono); font-size: 12px; }
.tool-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.tool-btn[aria-pressed="true"], .tool-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-text); }
.chart-body { flex: 1; display: flex; min-height: 0; }
.draw-bar { display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: none; }
.draw-sep { height: 1px; margin: 4px 6px; background: var(--line-strong); }
.chart-canvas { position: relative; flex: 1; min-width: 0; }
.chart-canvas.is-drawing { cursor: crosshair; }
.chart-box { position: absolute; inset: 0; }
.chart-box:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.legend { position: absolute; top: 8px; left: 10px; z-index: 3; pointer-events: none; display: grid; gap: 4px; font-size: 12px; }
.legend-title { display: flex; gap: 10px; align-items: baseline; }
.legend-title strong { font-family: var(--font-display); font-weight: 600; font-size: 13px; }
.legend-title span { color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.legend-ohlc { display: flex; flex-wrap: wrap; gap: 2px 12px; font-family: var(--font-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.legend-ohlc i { font-style: normal; color: var(--muted); margin-right: 4px; }
.legend-ind i { color: inherit; opacity: .8; }
.chart-noscript { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
@media (max-width: 759px) {
  .chart-body { flex-direction: column; }
  .draw-bar { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; padding: 2px 6px; }
  .draw-sep { width: 1px; height: auto; margin: 6px 4px; }
  .legend-ohlc span:nth-child(n + 5) { display: none; }
  .legend-ind { display: none; }
}
@media (pointer: coarse) { .tool-btn { width: 44px; height: 44px; } .seg button { min-height: 40px; min-width: 44px; } }

/* ── Book and tape ── */
.book { display: flex; flex-direction: column; height: 100%; font-size: 12px; }
.tabs-mini { display: flex; gap: 2px; padding: 3px; background: var(--surface); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--line-control); }
.tabs-mini button { flex: 1; min-height: 34px; padding: 0 10px; background: none; border: 0; border-radius: 4px; color: var(--muted-strong); font-size: 13px; font-weight: 600; white-space: nowrap; }
.tabs-mini button:hover { color: var(--ink); }
.tabs-mini button[aria-checked="true"], .tabs-mini button[aria-selected="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tabs-flat { box-shadow: none; background: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0 8px; gap: 4px; }
.tabs-flat button { flex: none; border-radius: 0; min-height: 40px; }
.tabs-flat button[aria-selected="true"] { background: none; box-shadow: inset 0 -2px 0 var(--accent); }
.book-head, .book-side button, .tape li { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 6px; padding: 0 12px; }
.book-head { padding-block: 8px 4px; color: var(--muted); font-size: 11px; }
.book-head span:not(:first-child), .book-side span:not(:first-child), .tape span:not(:first-child) { text-align: right; }
.book-side button { position: relative; width: 100%; min-height: 21px; align-items: center; background: none; border: 0; color: var(--ink); font-family: var(--font-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.book-side button:hover { background: var(--surface); }
.book-side span { position: relative; z-index: 1; }
.depth { position: absolute; right: 0; top: 1px; bottom: 1px; }
.depth.ask { background: var(--loss-soft); }
.depth.bid { background: var(--profit-soft); }
.book-mid { display: flex; align-items: baseline; justify-content: space-between; padding: 8px 12px; border-block: 1px solid var(--line); }
.book-mid strong { font-size: 16px; }
.book-mid span { color: var(--muted); font-size: 11px; }
.tape { font-family: var(--font-mono); font-size: 11.5px; }
.tape li { min-height: 21px; align-items: center; }
.tape li span:last-child { color: var(--muted); }

/* ── Order panel ── */
.order-panel { padding: 14px 16px 18px; }
.order-panel form { display: grid; gap: 14px; }
.side-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.side-switch button { display: grid; gap: 2px; min-height: 52px; border: 1px solid var(--line-control); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-weight: 650; font-size: 15px; }
.side-switch small { font-size: 11px; font-weight: 500; color: var(--muted); }
.side-switch .buy[aria-checked="true"] { background: var(--profit); border-color: var(--profit); color: var(--on-profit); }
.side-switch .sell[aria-checked="true"] { background: var(--loss); border-color: var(--loss); color: var(--on-loss); }
.side-switch button[aria-checked="true"] small { color: inherit; opacity: 0.85; }
.o-field { display: grid; gap: 6px; }
.o-field > label, .label-row label { font-size: 12px; font-weight: 600; color: var(--muted-strong); }
.label-row { display: flex; justify-content: space-between; align-items: center; }
.unit-toggle { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface); border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line-control); }
.unit-toggle button { min-height: 28px; padding: 0 8px; background: none; border: 0; border-radius: 3px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.unit-toggle button[aria-checked="true"] { background: var(--surface-2); color: var(--ink); }
.input-unit { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.input-unit:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.input-unit input, .bracket-grid input, .bracket-form input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; background: none; border: 0; color: var(--ink); font-family: var(--font-mono); font-size: 14px; outline: none; }
.bracket-grid input, .bracket-form input { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.bracket-grid input:focus-visible, .bracket-form input:focus-visible { border-color: var(--accent); }
.unit { padding: 0 12px; color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.unit-btn { margin-right: 4px; min-height: 34px; padding: 0 10px; background: var(--surface-2); border: 0; border-radius: 4px; color: var(--muted-strong); font-size: 12px; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.presets button { min-height: 32px; background: var(--surface); border: 1px solid var(--line-control); border-radius: 4px; color: var(--muted-strong); font-family: var(--font-mono); font-size: 12px; }
.presets button:hover { border-color: var(--line-control-hover); color: var(--ink); }
.check-line { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 13px; color: var(--muted-strong); cursor: pointer; }
.check-line input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent-fill); }
.bracket-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.order-sum { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; }
.order-sum > div { display: flex; justify-content: space-between; gap: 12px; }
.order-sum dt { color: var(--muted); }
.order-sum dd { text-align: right; }
.order-sum .warn dd { color: var(--loss); }
.form-warn { font-size: 12px; color: var(--ink); background: var(--loss-soft); border-left: 3px solid var(--loss); padding: 8px 10px; border-radius: 4px; }
.submit { display: grid; gap: 2px; min-height: 54px; border: 0; border-radius: var(--radius-sm); font-weight: 700; font-size: 15px; }
.submit small { font-size: 11px; font-weight: 500; opacity: 0.85; }
.submit.buy, .submit.sell { background: var(--accent-fill); color: var(--accent-on-fill); }
.submit:hover:not(:disabled) { filter: brightness(1.06); }
.form-error { min-height: 1em; font-size: 12px; color: var(--loss); }
.order-locked { display: grid; gap: 10px; margin-top: 12px; }
.order-locked .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Amount slider, leverage and bracket switches */
.slider { display: block; padding: 6px 2px 0; }
.slider input { width: 100%; height: 6px; margin: 0; appearance: none; -webkit-appearance: none; border-radius: 3px; background: linear-gradient(to right, var(--accent-fill) var(--fill, 0%), var(--surface-2) var(--fill, 0%)); cursor: pointer; }
.slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); border: 4px solid var(--accent-fill); }
.slider input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 4px solid var(--accent-fill); }
.slider input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.o-field select { min-height: 44px; padding: 0 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 14px; }
.toggles { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; align-items: center; }
.toggles > input { min-height: 40px; padding: 0 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); color: var(--ink); font-family: var(--font-mono); font-size: 13px; min-width: 0; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 13px; color: var(--muted-strong); cursor: pointer; grid-column: 1; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 36px; height: 20px; margin: 0; border-radius: 10px; background: var(--surface-2); position: relative; cursor: pointer; transition: background 160ms; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted-strong); transition: transform 160ms; }
.switch input:checked { background: var(--accent-fill); }
.switch input:checked::after { transform: translateX(16px); background: var(--accent-on-fill); }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .switch input, .switch input::after { transition: none; } }

/* ── Rules panel ── */
.rules { padding: 14px 16px 18px; display: grid; gap: 14px; align-content: start; }
.rules-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.chip { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 4px; background: var(--surface-2); color: var(--muted-strong); }
.chip-active { color: var(--accent-text); background: var(--accent-soft); }
.chip-passed { color: var(--profit); background: var(--profit-soft); }
.chip-failed { color: var(--loss); background: var(--loss-soft); }
.equity-line { display: grid; gap: 2px; }
.equity-line .label { font-size: 11px; }
.equity-line strong { font-size: 24px; }
.equity-line span.num { font-size: 13px; }
.rule-rows { display: grid; gap: 14px; }
.rule-rows li { display: grid; gap: 6px; }
.rule-top { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.rule-top .num { color: var(--muted-strong); font-size: 12px; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 3px; transition: width 400ms ease; }
.meter-target span { background: var(--accent); }
.meter-loss span { background: var(--loss); }
.meter-accent span { background: var(--accent); }
.days { display: flex; gap: 6px; }
.days span { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); }
.days span.on { background: var(--profit); }
.rules-preview { display: grid; }
.rules-preview li { display: flex; justify-content: space-between; padding-block: 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.verdict { display: grid; gap: 8px; padding: 12px; border-radius: var(--radius-sm); justify-items: start; font-size: 13px; }
.verdict-passed { background: var(--profit-soft); border-left: 3px solid var(--profit); }
.verdict-failed { background: var(--loss-soft); border-left: 3px solid var(--loss); }
.button-quiet { border-color: var(--line-control); }

/* ── Tables ── */
.tables { display: flex; flex-direction: column; min-height: 260px; }
.table-scroll { overflow: auto; flex: 1; max-height: 340px; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 720px; }
.grid-table th { position: sticky; top: 0; background: var(--bg); text-align: left; font-weight: 500; font-size: 11px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.grid-table td.num, .grid-table .r { text-align: right; }
.grid-table small { display: block; font-size: 11px; color: inherit; opacity: 0.85; }
.grid-table tbody tr:hover { background: var(--surface); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions button { min-height: 32px; padding: 0 10px; background: var(--surface); border: 1px solid var(--line-control); border-radius: 4px; color: var(--ink); font-size: 12px; }
.row-actions button:hover:not(:disabled) { border-color: var(--line-control-hover); }
.row-actions .danger:hover:not(:disabled) { border-color: var(--loss); color: var(--loss); }
@media (pointer: coarse) { .row-actions button, .presets button { min-height: 44px; } }
.edit-row td { background: var(--surface); }
.bracket-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 6px 0; }
.bracket-form label { display: grid; gap: 4px; font-size: 11px; color: var(--muted); }
.empty-row { padding: 24px 16px; color: var(--muted); font-size: 13px; }

/* ── Toast and foot ── */
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 60; max-width: min(92vw, 420px); display: none; }
.toast-ok, .toast-err { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line-strong); border-left-width: 3px; border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); font-size: 13px; }
.toast-ok { border-left-color: var(--profit); }
.toast-err { border-left-color: var(--loss); }
.toast button { flex: none; display: grid; place-items: center; width: 28px; height: 28px; background: none; border: 0; color: var(--muted); border-radius: 4px; }
.term-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; padding: 8px 16px; background: var(--bg); color: var(--muted); font-size: 11px; }
.term-foot a { color: var(--muted-strong); }
.skip-link:focus { z-index: 200; }

.rules-model + .rules-model { margin-top: 14px; }
.rules-model .label { font-size: 11px; color: var(--muted-strong); }
.rules-terms { display: grid; margin-top: 4px; }
.rules-terms > div { display: flex; justify-content: space-between; gap: 12px; padding-block: 8px; border-bottom: 1px solid var(--line); font-size: 12px; }
.rules-terms dt { color: var(--muted); }
.rules-terms dd { text-align: right; }

.save-dot { width: 8px; height: 8px; margin: 10px auto; border-radius: 50%; background: var(--muted); }
.save-dot.is-saved { background: var(--profit); }
.save-dot.is-pending { background: var(--warn); }
.save-dot.is-error { background: var(--loss); }
@media (max-width: 759px) { .save-dot { margin: auto 10px; flex: none; } }

.sym-btn span { font-family: var(--font-mono); font-size: 12px; }
.menu-sym { width: min(340px, calc(100vw - 24px)); gap: 6px; padding: 8px; }
.menu-sym input { width: 100%; min-height: 40px; padding: 0 10px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 4px; color: var(--ink); font: inherit; }
.menu-sym ul { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.menu-sym li button { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t p" "v p"; gap: 0 10px; width: 100%; min-height: 44px; padding: 6px 8px; background: none; border: 0; border-radius: 4px; color: var(--ink); text-align: left; }
.menu-sym li button:hover, .menu-sym li button:focus-visible { background: var(--surface); }
.menu-sym li strong { grid-area: t; font-family: var(--font-mono); font-size: 12.5px; overflow-wrap: anywhere; }
.menu-sym li span { grid-area: v; color: var(--muted); font-size: 11.5px; }
.menu-sym li .num { grid-area: p; align-self: center; color: var(--ink); font-family: var(--font-mono); font-size: 12px; }
.menu-empty { margin: 4px 8px; color: var(--muted); font-size: 12.5px; }
.seg-scale button { min-width: 34px; }

/* Drawing tool groups and the floating bar of a selected drawing */
.tool-group .tool-btn { position: relative; }
.group-mark { position: absolute; right: 3px; bottom: 3px; width: 0; height: 0; border-left: 4px solid transparent; border-bottom: 4px solid currentColor; opacity: .7; }
.menu-tools { z-index: 60; min-width: 240px; max-height: calc(100vh - 80px); overflow-y: auto; }
.menu > button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent-text); }
.obj-bar { position: absolute; top: 44px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 2px; padding: 3px; max-width: calc(100% - 16px); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); }
.obj-bar .tool-btn.text { min-width: 52px; }
.obj-pop { top: calc(100% + 6px); left: 0; min-width: 160px; }
.obj-pop.swatches { grid-template-columns: repeat(4, 32px); gap: 6px; min-width: 0; }
.obj-pop.swatches button { width: 32px; height: 32px; padding: 0; border: 2px solid transparent; border-radius: 50%; }
.obj-pop.swatches button[aria-checked="true"] { border-color: var(--ink); }
.swatch { display: block; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-strong); }
.line-sample { display: block; width: 28px; border-top: 2px solid currentColor; }
.obj-pop > button .line-sample { position: absolute; left: 8px; }
.obj-text input { width: 132px; height: 32px; padding: 0 8px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 4px; font: inherit; font-size: 13px; }
@media (max-width: 759px) { .obj-bar { top: 52px; } .obj-text input { width: 96px; } }

/* Price-axis switches, visible on touch as well as desktop. */
.axis-switches { position: absolute; left: 8px; bottom: 30px; z-index: 4; display: flex; gap: 3px; }
.axis-switches button { display: grid; place-items: center; width: 25px; height: 25px; padding: 0; border: 1px solid var(--line-control); border-radius: 3px; background: var(--surface); color: var(--muted-strong); font: 600 13px var(--font-body); cursor: pointer; }
.axis-switches button:hover { color: var(--ink); border-color: var(--accent-text); }
.axis-switches button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-on-fill); }
.axis-switches button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
@media (pointer: coarse) { .axis-switches { gap: 5px; } .axis-switches button { width: 32px; height: 32px; } }
.meter-warn span { background: var(--warn); }
.rule-daily-warn .rule-left { color: var(--warn); }
.rule-daily-danger .rule-left { color: var(--loss); }
.rule-daily-warn, .rule-daily-danger { padding: 8px 10px; margin-inline: -10px; border-radius: 6px; }
.rule-daily-warn { background: var(--warn-soft); }
.rule-daily-danger { background: var(--loss-soft); }
