:root {
  --bg: #0b0e11;
  --panel: #12161c;
  --panel-2: #171c24;
  --panel-3: #1d232d;
  --border: #222a35;
  --border-soft: #1a2029;
  --text: #d6dae2;
  --text-dim: #9aa3b2;
  --muted: #5f6878;
  --green: #0ecb81;
  --green-dim: rgba(14, 203, 129, 0.14);
  --red: #f6465d;
  --red-dim: rgba(246, 70, 93, 0.14);
  --accent: #f0b90b;
  --accent-dim: rgba(240, 185, 11, 0.14);
  --blue: #3b82f6;
  --app-bg: #06080a;
  --row-line: #10141a;
  --scroll-thumb: #2a3340;
  --btn-hover-border: #2f3947;
  --on-accent: #111;
  --on-green: #04150c;
  --on-red: #fff;
  --toast-liq-bg: #2a1016;
  --modal-bg: rgba(4, 6, 8, 0.78);
  --shadow: rgba(0, 0, 0, 0.55);
  --chart-grid: #171c24;
  --chart-cross: #3a4454;
  --chart-cross-label: #2a3340;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --fs: 12px;
  color-scheme: dark;
}

/* Light theme — opt-in via the ☀/☾ toggle; dark stays the default */
:root[data-theme="light"] {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f3f5f8;
  --panel-3: #e7ebf1;
  --border: #d5dbe4;
  --border-soft: #e4e8ee;
  --text: #1c2430;
  --text-dim: #4b5668;
  --muted: #7d8795;
  --green: #089981;
  --green-dim: rgba(8, 153, 129, 0.12);
  --red: #e5333f;
  --red-dim: rgba(229, 51, 63, 0.12);
  --accent: #c48a00;
  --accent-dim: rgba(196, 138, 0, 0.14);
  --blue: #2563eb;
  --app-bg: #dfe4ec;
  --row-line: #eef1f5;
  --scroll-thumb: #c3cad6;
  --btn-hover-border: #b9c2cf;
  --on-accent: #fff;
  --on-green: #fff;
  --on-red: #fff;
  --toast-liq-bg: #fde8ea;
  --modal-bg: rgba(40, 48, 60, 0.45);
  --shadow: rgba(20, 30, 45, 0.18);
  --chart-grid: #eceff3;
  --chart-cross: #9aa4b4;
  --chart-cross-label: #4b5668;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--fs);
  line-height: 1.35;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

.up { color: var(--green) !important; }
.down { color: var(--red) !important; }
.flat { color: var(--text-dim) !important; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.r { text-align: right; }
.k { color: var(--muted); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; }
.v { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

#app {
  display: grid;
  grid-template-rows: 44px 1fr 24px;
  height: 100vh;
  width: 100vw;
}

/* ============================== TOP BAR ============================== */
#topbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark { color: var(--accent); font-size: 14px; letter-spacing: -2px; }
.brand-name { font-weight: 700; letter-spacing: 0.12em; font-size: 13px; }
.brand-accent { color: var(--accent); }
.brand-sub { font-size: 10px; color: var(--muted); border: 1px solid var(--border); padding: 1px 6px; border-radius: 2px; letter-spacing: 0.06em; }

.tape-wrap { overflow: hidden; height: 100%; display: flex; align-items: center; mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); min-width: 0; }
.tape { display: inline-flex; gap: 28px; white-space: nowrap; animation: tape 90s linear infinite; will-change: transform; }
.tape:hover { animation-play-state: paused; }
.tape .t { display: inline-flex; gap: 6px; font-size: 11px; }
.tape .t .s { color: var(--text-dim); font-weight: 600; }
@keyframes tape { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.acct-stats { display: flex; gap: 18px; }
.acct-stats .stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.acct-stats .stat .v { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.acct-stats.logged-out { opacity: 0.35; }

.user-box { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.user-box .who { color: var(--text-dim); }
.user-box .who b { color: var(--accent); font-weight: 600; }

.btn { border: 1px solid var(--border); border-radius: 2px; padding: 5px 10px; font-size: 11px; letter-spacing: 0.06em; font-weight: 600; background: var(--panel-2); transition: background .12s, border-color .12s; }
.btn:hover { background: var(--panel-3); border-color: var(--btn-hover-border); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.icon { padding: 4px 7px; font-size: 13px; line-height: 1; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(246,70,93,.35); background: transparent; }
.btn.danger:hover { background: var(--red-dim); }
.btn.small { padding: 3px 8px; font-size: 10px; }

/* ============================== MAIN GRID ============================== */
#main {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr) 270px;
  gap: 4px;
  padding: 4px;
  min-height: 0;
  background: var(--app-bg);
}
#watchlist-panel { grid-column: 1; grid-row: 1 / 3; }
#chart-panel { grid-column: 2; grid-row: 1; }
#bottom-panel { grid-column: 2; grid-row: 2; }
#right-col { grid-column: 3; grid-row: 1 / 3; display: flex; flex-direction: column; gap: 4px; min-height: 0; min-width: 0; }
#ticket-panel { flex: 1 1 auto; min-height: 0; }
#lb-panel { flex: 0 0 270px; }
#lb-panel.collapsed { flex: 0 0 auto; }
#lb-panel.collapsed .lb-sub, #lb-panel.collapsed .table-wrap { display: none; }
#lb-panel .panel-head .tabs { flex: 1; min-width: 0; }
#lb-panel .tab { padding: 0 6px; white-space: nowrap; }
#lb-toggle { white-space: nowrap; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 8px; height: 32px; min-height: 32px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--panel-2);
}
.panel-head .title { font-size: 10.5px; letter-spacing: 0.1em; color: var(--text-dim); font-weight: 600; }

.tabs { display: flex; gap: 2px; height: 100%; }
.tab { padding: 0 10px; font-size: 10.5px; letter-spacing: 0.08em; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; height: 100%; }
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 4px; border-radius: 8px; background: var(--panel-3); color: var(--text-dim); font-size: 10px; text-align: center; }

.search { background: var(--bg); border: 1px solid var(--border); border-radius: 2px; padding: 3px 6px; width: 86px; font-size: 11px; outline: none; }
.search:focus { border-color: var(--accent); }
.wl-head { padding: 0 4px; }
.wl-head .tabs { width: 100%; overflow-x: auto; scrollbar-width: none; }
.wl-head .tabs::-webkit-scrollbar { display: none; }
.wl-head .tab { padding: 0 6px; font-size: 9.5px; letter-spacing: .05em; white-space: nowrap; }
.wl-search-row { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-bottom: 1px solid var(--border-soft); }
.wl-search-row .search { flex: 1; width: auto; min-width: 0; }
.wl-count { font-size: 10px; color: var(--muted); white-space: nowrap; }
.local-price { font-size: 11px; color: var(--muted); margin-left: 4px; }
.local-price:empty { display: none; }
.session-line { font-size: 10.5px; color: var(--muted); margin-top: 1px; font-family: var(--sans); }
.session-line:empty { display: none; }
.session-line.closed { color: var(--red); }
.session-line.open { color: var(--text-dim); }
.wl-row.closed .px, .wl-row.closed .ch { opacity: .55; }
.submit.closed { background: var(--panel-3); color: var(--muted); filter: none; cursor: not-allowed; }
.btn-close:disabled { opacity: .35; cursor: not-allowed; }
.btn-close:disabled:hover { border-color: var(--border); color: var(--text-dim); background: transparent; }
.wl-row .tag.idx { color: var(--accent); }
.wl-row .tag.fx { color: var(--blue); }

/* ============================== WATCHLIST ============================== */
.wl-header, .wl-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 80px 62px; gap: 6px; padding: 0 10px; align-items: center;
}
.wl-header { height: 22px; font-size: 10px; color: var(--muted); letter-spacing: .06em; border-bottom: 1px solid var(--border-soft); }
.wl-body { overflow-y: auto; flex: 1; }
.wl-row { height: 38px; cursor: pointer; border-left: 2px solid transparent; border-bottom: 1px solid var(--row-line); transition: background .1s; }
.wl-row:hover { background: var(--panel-2); }
.wl-row.active { background: var(--panel-3); border-left-color: var(--accent); }
.wl-row .sym { font-weight: 700; font-size: 12px; }
.wl-row .nm { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--sans); }
.wl-row .px { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.wl-row .ch { text-align: right; font-variant-numeric: tabular-nums; font-size: 11px; }
.wl-row .tag { display: inline-block; font-size: 8.5px; padding: 0 3px; margin-left: 5px; border-radius: 2px; vertical-align: 1px; letter-spacing: .05em; background: var(--panel-3); color: var(--muted); }
.wl-row.has-pos .sym::after { content: '●'; color: var(--accent); font-size: 7px; margin-left: 5px; vertical-align: 2px; }
.flash-up { animation: flashUp .7s ease-out; }
.flash-down { animation: flashDown .7s ease-out; }
@keyframes flashUp { 0% { background: rgba(14,203,129,.35); } 100% { background: transparent; } }
@keyframes flashDown { 0% { background: rgba(246,70,93,.35); } 100% { background: transparent; } }

/* ============================== CHART ============================== */
.chart-head { display: flex; align-items: center; gap: 20px; padding: 6px 12px; border-bottom: 1px solid var(--border-soft); background: var(--panel-2); min-height: 56px; }
.sym-line { display: flex; align-items: baseline; gap: 8px; }
.sym-line .sym { font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.sym-type { font-size: 9px; padding: 1px 5px; border: 1px solid var(--border); color: var(--muted); border-radius: 2px; letter-spacing: .08em; }
.sym-name { color: var(--muted); font-family: var(--sans); font-size: 12px; }
.mkt-badge { font-size: 9px; padding: 1px 6px; border-radius: 2px; background: var(--green-dim); color: var(--green); letter-spacing: .08em; }
.mkt-badge.closed { background: var(--red-dim); color: var(--red); }
.mkt-badge.ext { background: var(--accent-dim); color: var(--accent); }
.mkt-badge.sim { background: rgba(59,130,246,.15); color: var(--blue); }
.price-line { display: flex; align-items: baseline; gap: 10px; margin-top: 2px; }
.big-price { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.chg { font-size: 12px; font-variant-numeric: tabular-nums; }
.ohlc { display: flex; gap: 18px; margin-left: 8px; }
.ohlc > div { display: flex; flex-direction: column; line-height: 1.2; }
.ohlc .v { font-size: 11.5px; }
.intervals { margin-left: auto; display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: 2px; padding: 2px; }
.intervals button { padding: 3px 8px; font-size: 10.5px; color: var(--muted); border-radius: 2px; font-weight: 600; }
.intervals button:hover { color: var(--text); }
.intervals button.active { background: var(--panel-3); color: var(--accent); }
#chart { flex: 1; min-height: 0; position: relative; }
.chart-note { position: absolute; }
.chart-note:not(:empty) { position: static; padding: 2px 10px; font-size: 10px; color: var(--muted); border-top: 1px solid var(--border-soft); }

/* ============================== ORDER TICKET ============================== */
.ticket { padding: 8px 10px; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; }
.ticket > * { flex-shrink: 0; } /* short viewports: scroll the ticket, never squash its rows */
.ticket .calc { padding: 6px 8px; gap: 4px 12px; }
.ticket .submit { padding: 10px 0; }
.ticket .pct-row button { padding: 3px 0; }
.side-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border); border-radius: 2px; overflow: hidden; }
.side { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0; font-weight: 700; letter-spacing: .06em; background: var(--panel-2); transition: background .12s, color .12s; }
.side .k { font-size: 11.5px; font-weight: 800; letter-spacing: .09em; color: inherit; }
.side .side-px { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; opacity: .85; }
.side .side-px em { font-style: normal; font-size: 9px; opacity: .8; }
.side.buy { color: var(--green); }
.side.sell { color: var(--red); }
.side:not(.active) .side-px { color: var(--text-dim); }
.side:not(.active):hover { background: var(--panel-3); }
.side.buy.active { background: var(--green); color: var(--on-green); }
.side.sell.active { background: var(--red); color: var(--on-red); }
.side.active .side-px { color: inherit; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seg { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: 2px; padding: 2px; }
.seg button { padding: 3px 7px; font-size: 10.5px; color: var(--muted); border-radius: 2px; font-weight: 600; min-width: 30px; }
.seg button.active { background: var(--panel-3); color: var(--text); }
.seg.lev button.active { color: var(--accent); }
.seg.lev button[data-l="20"].active, .seg.lev button[data-l="10"].active { color: var(--red); }
.seg.lev button:disabled { opacity: 0.25; }
.row > .k { white-space: nowrap; }
.lev-note { margin-left: 6px; padding: 0 4px; border-radius: 2px; background: var(--accent-dim); color: var(--accent); font-size: 9px; letter-spacing: .08em; white-space: nowrap; }
.lev-note:empty { display: none; }
.field { display: flex; flex-direction: column; gap: 4px; }
.input-wrap { display: flex; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 2px; padding: 0 8px; height: 34px; min-width: 0; }
.input-wrap:focus-within { border-color: var(--accent); }
.input-wrap .pre { color: var(--muted); margin-right: 4px; }
.input-wrap input { flex: 1; background: none; border: none; outline: none; font-size: 15px; font-weight: 600; min-width: 0; font-variant-numeric: tabular-nums; }
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.pct-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pct-row button { border: 1px solid var(--border); border-radius: 2px; padding: 4px 0; font-size: 10px; color: var(--text-dim); background: var(--panel-2); }
.pct-row button:hover { border-color: var(--accent); color: var(--accent); }
.calc { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 8px; background: var(--bg); border: 1px solid var(--border-soft); border-radius: 2px; }
.calc > div { display: flex; flex-direction: column; line-height: 1.2; }
.calc .v { font-size: 11.5px; font-weight: 500; }
.submit { width: 100%; padding: 12px 0; font-weight: 700; letter-spacing: .08em; font-size: 12.5px; border-radius: 2px; transition: filter .12s; }
.submit.buy { background: var(--green); color: var(--on-green); }
.submit.sell { background: var(--red); color: var(--on-red); }
.submit.neutral { background: var(--accent); color: var(--on-accent); }
.submit:hover { filter: brightness(1.1); }
.submit:disabled { filter: grayscale(.6); }
.verify-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--accent); border-radius: 2px; background: var(--accent-dim); font-family: var(--sans); font-size: 11px; color: var(--text-dim); }
.verify-bar b { color: var(--accent); }
.verify-bar.hidden { display: none; }
.tk-msg { min-height: 14px; font-size: 10.5px; color: var(--red); }
.tk-msg.ok { color: var(--green); }

/* ============================== TABLES ============================== */
.table-wrap { flex: 1; overflow: auto; min-height: 0; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
thead th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-size: 10px; letter-spacing: .06em; font-weight: 600; text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; z-index: 1; }
thead th:first-child, tbody td:first-child { text-align: left; }
thead th.l, tbody td.l { text-align: left; }
tbody td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--row-line); white-space: nowrap; font-size: 11.5px; }
tbody tr:hover { background: var(--panel-2); }
tbody tr.me { background: var(--accent-dim); }
tbody tr.me td:first-child { border-left: 2px solid var(--accent); }
.side-pill { display: inline-block; padding: 0 5px; border-radius: 2px; font-size: 10px; font-weight: 700; letter-spacing: .05em; }
.side-pill.long { background: var(--green-dim); color: var(--green); }
.side-pill.short { background: var(--red-dim); color: var(--red); }
.lev-pill { display: inline-block; padding: 0 4px; border-radius: 2px; background: var(--panel-3); color: var(--accent); font-size: 10px; font-weight: 700; margin-left: 3px; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); font-family: var(--sans); font-size: 12px; }
.empty b { color: var(--text-dim); }
.btn-close { border: 1px solid var(--border); border-radius: 2px; padding: 2px 8px; font-size: 10px; color: var(--text-dim); letter-spacing: .05em; }
.btn-close:hover { border-color: var(--red); color: var(--red); background: var(--red-dim); }
.reason { font-size: 9.5px; letter-spacing: .06em; color: var(--muted); }
.reason.liquidation, .reason.margin_call { color: var(--red); font-weight: 700; }
.reason.settlement { color: var(--accent); }
.rank-1 { color: #ffd700; font-weight: 700; }
.rank-2 { color: #c0c0c0; font-weight: 700; }
.rank-3 { color: #cd7f32; font-weight: 700; }
.lb-sub { padding: 4px 10px; font-size: 10px; color: var(--muted); border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; font-family: var(--sans); }
.lb-sub b { color: var(--text-dim); font-weight: 600; }

.acct-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 12px; }
.acct-grid > div { background: var(--bg); border: 1px solid var(--border-soft); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.acct-grid .v { font-size: 15px; font-weight: 600; }
.acct-note { padding: 0 12px 12px; color: var(--muted); font-family: var(--sans); font-size: 11.5px; line-height: 1.5; }
.acct-note b { color: var(--text-dim); }

/* ============================== STATUS BAR ============================== */
#statusbar { display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--panel); border-top: 1px solid var(--border); font-size: 10.5px; color: var(--text-dim); letter-spacing: .04em; white-space: nowrap; overflow: hidden; }
#statusbar .sep { color: var(--border); }
#statusbar .grow { flex: 1; }
.dot { font-size: 9px; }
.dot.on { color: var(--green); }
.dot.off { color: var(--red); }
.dot.sim { color: var(--blue); }

/* ============================== TOASTS ============================== */
#toasts { position: fixed; right: 14px; bottom: 34px; display: flex; flex-direction: column; gap: 6px; z-index: 50; pointer-events: none; }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 8px 12px; min-width: 260px; max-width: 360px; font-size: 11.5px; box-shadow: 0 6px 24px var(--shadow); animation: toastIn .18s ease-out; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.liq { border-left-color: var(--red); background: var(--toast-liq-bg); }
.toast .t { font-weight: 700; letter-spacing: .06em; font-size: 10.5px; margin-bottom: 2px; }
.toast .d { color: var(--text-dim); font-family: var(--sans); }
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================== MODAL ============================== */
.modal { position: fixed; inset: 0; background: var(--modal-bg); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { width: 380px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--border); box-shadow: 0 20px 60px var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
.modal-head .x { color: var(--muted); font-size: 12px; }
.modal-head .x:hover { color: var(--text); }
#auth-tabs { height: 34px; padding: 0 8px; border-bottom: 1px solid var(--border-soft); background: var(--panel-2); }
#auth-form { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
#auth-form input { background: var(--bg); border: 1px solid var(--border); border-radius: 2px; padding: 8px 10px; outline: none; font-size: 13px; }
#auth-form input:focus { border-color: var(--accent); }
.auth-err { min-height: 14px; font-size: 11px; color: var(--red); }
.demo-hint { width: 100%; text-align: left; border: 1px dashed var(--border); border-radius: 2px; padding: 7px 10px; font-size: 11px; color: var(--text-dim); background: var(--bg); }
.demo-hint:hover { border-color: var(--accent); color: var(--text); }
.demo-hint b { color: var(--accent); font-weight: 600; }
.auth-note { margin: 4px 0 0; color: var(--muted); font-family: var(--sans); font-size: 11.5px; line-height: 1.5; }
.auth-note b { color: var(--text-dim); }

/* ============================== BROKER TICKET & BLOTTERS ============================== */
.input-wrap.slim { height: 28px; }
.input-wrap.slim input { font-size: 12.5px; }
#price-row .input-wrap, #tif-row .seg { width: 150px; }
.qty-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.qty-grid > * { min-width: 0; }
.ticket .row { flex-wrap: wrap; }
.seg.lev { flex: 1 1 auto; min-width: 0; }
.seg.lev button { flex: 1; min-width: 0; padding: 3px 4px; }
.ohlc .book .v { font-weight: 700; }
.cell-input { width: 78px; background: var(--bg); border: 1px solid var(--border); border-radius: 2px; padding: 2px 5px; font-size: 11px; text-align: right; outline: none; font-variant-numeric: tabular-nums; }
.cell-input:focus { border-color: var(--accent); }
.btn-mini { border: 1px solid var(--border); border-radius: 2px; padding: 2px 6px; font-size: 9.5px; color: var(--text-dim); letter-spacing: .05em; vertical-align: middle; }
.btn-mini:hover { border-color: var(--accent); color: var(--accent); }
tbody tr.dim td { color: var(--muted); }
.acct-note p { margin: 0 0 8px; }
.reason.tp, .reason.sl { color: var(--text-dim); }
/* keep the chart header on single lines; the price scale area is wide enough at desktop widths */
.sym-block { flex: 0 0 auto; }
.sym-line, .price-line, .session-line { white-space: nowrap; }
.sym-type, .mkt-badge, .sym-name, .local-price { white-space: nowrap; }
.ohlc { gap: 14px; overflow: hidden; }
.ohlc > div { flex: 0 0 auto; white-space: nowrap; }
.field > .k { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.cell-input { width: 66px; }
#bottom-panel tbody td { padding: 5px 6px; }
@media (max-width: 1750px) { .ohlc > div:nth-child(n+7) { display: none; } }
@media (max-width: 1550px) { .ohlc > div:nth-child(n+5) { display: none; } }

/* ============================== RESPONSIVE ============================== */
@media (max-width: 1180px) {
  .ohlc { display: none; }
  .acct-stats { gap: 10px; }
}
@media (max-width: 980px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; grid-template-rows: auto 1fr 24px; }
  #topbar { grid-template-columns: 1fr auto; grid-auto-rows: auto; padding: 6px 12px; gap: 8px; height: auto; }
  .tape-wrap { display: none; }
  .acct-stats { grid-column: 1 / -1; justify-content: space-between; }
  #main { grid-template-columns: 1fr; grid-template-rows: 320px 480px auto 300px auto; }
  #right-col { display: contents; }
  #watchlist-panel, #chart-panel, #ticket-panel, #bottom-panel, #lb-panel { grid-column: 1; grid-row: auto; }
  #lb-panel:not(.collapsed) { height: 320px; }
  #statusbar { position: sticky; bottom: 0; }
}
