/* LaneGecko Trade Desk — app styles (SPEC §11.8). Design tokens on :root (dark default) and
   :root[data-theme="light"]; up/down colours swap with :root[data-up="red"]. No external fonts. */

/* LaneGecko site tokens (BRIEF "Fit with the user's live site"): the exact values of the LaneGecko
   Market Intelligence site, so the desk reads as one product. Buy/long = lime, sell/short = coral,
   info = cyan, warnings = amber. The app-level names below map onto them.
   Token alignment: live styles.css line 15 (font), line 60 (button radius/weight), line 79
   (faint), line 80 (active cyan), line 90 (shadow). Numeric labels use the site's Consolas stack. */
:root {
  --surface: #0d1215;
  --surface-2: #11181b;
  --line: #263034;
  --line-soft: #182125;
  --lime: #b7f34b;
  --cyan: #42d4d1;
  --amber: #f3b83f;
  --coral: #ff7066;
  --blue: #738cff;

  --bg: #080b0d;
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --panel-3: #172024;
  --border: var(--line);
  --grid: var(--line-soft);
  --text: #e8eee9;
  --muted: #a0abb0;
  --faint: #718087;
  --accent: var(--cyan);
  --tab-active: var(--cyan);
  --accent-ink: #080b0d;
  --info: var(--cyan);
  --up-green: var(--lime);
  --down-red: var(--coral);
  --up: var(--up-green);
  --down: var(--down-red);
  --up-ink: #080b0d;       /* text on a filled buy/long (lime) or sell/short (coral) button */
  --down-ink: #080b0d;
  --up-bg: color-mix(in srgb, var(--up) 12%, transparent);
  --down-bg: color-mix(in srgb, var(--down) 12%, transparent);
  --warn: var(--amber);
  --warn-bg: rgba(243, 184, 63, 0.12);
  --danger: var(--coral);
  --danger-ink: #080b0d;
  --draw: var(--blue);
  --fib: #b388ff;
  --focus: var(--cyan);
  --shadow: 0 14px 35px rgba(0, 0, 0, 0.16);
  --card-surface: linear-gradient(145deg, rgba(17, 24, 27, 0.96), rgba(11, 16, 18, 0.96));
  --radius: 8px;
  --radius-sm: 4px;
  --gutter: 16px;
  --header-h: 56px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: Consolas, monospace;
  color-scheme: dark;
}

/* Light theme (the site itself is dark-only): the same hues, darkened for contrast on white. */
:root[data-theme="light"] {
  --bg: #f3f6f4;
  --panel: #ffffff;
  --panel-2: #f5f8f6;
  --panel-3: #e9efec;
  --border: #d3dcd8;
  --grid: #e8eeeb;
  --text: #0d1215;
  --muted: #55636a;
  --faint: #8a979c;
  --accent: #0f7f7c;
  --tab-active: #0f7f7c;
  --accent-ink: #ffffff;
  --info: #0f7f7c;
  --up-green: #4a7d00;
  --down-red: #c43d33;
  --up-ink: #ffffff;
  --down-ink: #ffffff;
  --warn: #a8740a;
  --warn-bg: rgba(168, 116, 10, 0.1);
  --danger: #c43d33;
  --danger-ink: #ffffff;
  --draw: #4c63d9;
  --fib: #7b4dd6;
  --focus: #0f7f7c;
  --shadow: 0 10px 30px rgba(13, 18, 21, 0.15);
  --card-surface: linear-gradient(145deg, #ffffff, #f5f8f6);
  color-scheme: light;
}

:root[data-up="red"] {
  --up: var(--down-red);
  --down: var(--up-green);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

[hidden] { display: none !important; }

h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 14px; margin: 0; }

.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.block { display: block; }
.center { text-align: center; }
.right { text-align: right; }
.wrap { word-break: break-all; white-space: pre-wrap; }
.pad { padding: 12px; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }
.up-bg { background: var(--up); }
.down-bg { background: var(--down); }
.warn-text { color: var(--warn); }
.error-text { color: var(--danger); }
.danger { color: var(--danger); }
.offscreen { position: absolute; left: -9999px; top: 0; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

/* ---------------------------------------------------------------- buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--panel-3); color: var(--text); cursor: pointer; font-weight: 700; white-space: nowrap;
}
.btn:hover { border-color: var(--focus); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: var(--danger); color: var(--danger-ink); }
.btn-ghost.danger { color: var(--danger); border-color: var(--down-bg); }
.btn-buy { background: var(--up); color: var(--up-ink); }
.btn-sell { background: var(--down); color: var(--down-ink); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { min-height: 44px; font-size: 15px; }
.btn-block { width: 100%; }
.btn.loading { opacity: 0.7; }
.link-btn { background: none; border: 0; padding: 0; color: var(--info); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--muted);
}
.icon { display: inline-block; width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.125em; font-size: 16px; }
.icon-btn .icon { font-size: 18px; }
.tool-btn, .chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.more-btn .icon { margin-left: 4px; transition: transform .15s; }
.more-btn[aria-expanded="true"] .icon { transform: rotate(180deg); }
.bn-icon .icon { font-size: 20px; }
.banner-x .icon, .toast-close .icon { font-size: 18px; }
.tk-symbol .icon { margin-left: 4px; color: var(--muted); font-size: 12px; }
.site-item .icon { margin-left: 6px; }
.rank-1 .icon { color: var(--amber); }
.rank-2 .icon { color: var(--muted); }
.rank-3 .icon { color: #c98a52; }
[class*="rank-"] .icon { margin-right: 6px; }
.ob-last .icon { margin-left: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon-btn:hover { color: var(--text); background: var(--panel-3); }
.mini-btn {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 8px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--panel-2); cursor: pointer; font-size: 12px; white-space: nowrap;
}
.mini-btn:hover { border-color: var(--muted); }
.mini-btn.danger { color: var(--danger); }
.mini-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tool-btn {
  min-height: 28px; padding: 0 8px; border-radius: 4px; border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 12px; white-space: nowrap;
}
.tool-btn:hover, .tool-btn.active { color: var(--text); background: var(--panel-3); }
.chip {
  min-height: 30px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel-2);
  cursor: pointer; font-size: 12px; font-weight: 600;
}
.chip-hot { border-color: var(--warn); color: var(--warn); }

.input {
  width: 100%; min-height: 36px; padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); outline: none;
}
.input:focus { border-color: var(--focus); }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input[readonly] { opacity: 0.85; }
.input-sm, .select-sm { min-height: 30px; padding: 3px 8px; font-size: 13px; width: auto; }
.input-xs { min-height: 26px; padding: 2px 6px; font-size: 12px; width: 80px; }
.textarea { min-height: 70px; resize: vertical; }
.select { appearance: auto; }
.input-group { display: flex; align-items: stretch; gap: 0; }
.input-group > .input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; min-width: 0; }
.input-group > :last-child:not(.input) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-unit, .input-addon {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border: 1px solid var(--border); border-left: 0;
  background: var(--panel-3); color: var(--muted); font-size: 12px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.input-unit:empty { display: none; }
.input-group .select-sm, .input-group .unit-btn, .input-group .seg { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group > .input-unit:not(:last-child) { border-radius: 0; }
.unit-btn, .mini-btn.unit-btn { min-height: 36px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.field-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.field-hint { font-size: 12px; color: var(--faint); }
.field-error { font-size: 12px; color: var(--danger); min-height: 0; }
.field.has-error .input { border-color: var(--danger); }
.form-error { color: var(--danger); min-height: 18px; margin: 6px 0; }
.check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; padding: 4px 0; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.check.pref { display: flex; padding: 6px 0; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.switch-ui { position: absolute; inset: 0; border-radius: 10px; background: var(--panel-3); border: 1px solid var(--border); pointer-events: none; }
.switch-ui::after { content: ""; position: absolute; width: 14px; height: 14px; top: 2px; left: 2px; border-radius: 50%; background: var(--muted); transition: transform 0.15s; }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--focus); }

/* segmented controls / tabs */
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg-btn { border: 0; background: transparent; padding: 5px 10px; border-radius: 4px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--panel-3); color: var(--text); box-shadow: inset 0 -2px var(--tab-active); }
.seg-sm .seg-btn { padding: 3px 8px; font-size: 12px; }
.seg-side { display: flex; width: 100%; }
.seg-side .seg-btn { flex: 1; padding: 8px; }
.ticket-spot .seg-side .seg-btn[data-value="buy"].active, .seg-side .seg-btn[data-value="buy"].active { background: var(--up); color: var(--up-ink); box-shadow: none; }
.seg-side .seg-btn[data-value="sell"].active { background: var(--down); color: var(--down-ink); box-shadow: none; }
.seg-type { display: flex; width: 100%; background: transparent; border: 0; padding: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.seg-type .seg-btn { border-radius: 0; padding: 6px 6px; font-size: 12.5px; border-bottom: 2px solid transparent; }
.seg-type .seg-btn.active { background: transparent; border-bottom-color: var(--tab-active); box-shadow: none; }
.tabs { display: flex; background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 0; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin; }
.tabs .seg-btn { border-radius: 0; padding: 8px 12px; border-bottom: 2px solid transparent; }
.tabs .seg-btn.active { background: transparent; color: var(--text); border-bottom-color: var(--tab-active); box-shadow: none; }
.tabs-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.tab-link { padding: 6px 12px; border-radius: var(--radius-sm); color: var(--muted); }
.tab-link.active { background: var(--panel-3); color: var(--text); }

.badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; background: var(--panel-3); color: var(--muted); margin-left: 4px; vertical-align: middle; }
.badge-spot { background: rgba(66, 212, 209, 0.15); color: var(--info); }
.badge-futures { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--down-bg); color: var(--danger); }
.badge-up { background: var(--up-bg); color: var(--up); }
.badge-accent { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.badge-muted { background: var(--panel-3); color: var(--muted); }
.status-filled { color: var(--up); }
.status-canceled { color: var(--muted); }
.status-rejected { color: var(--danger); }
.status-active { color: var(--up); }
.status-disabled, .status-deleted { color: var(--danger); }

/* ---------------------------------------------------------------- app shell */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.boot, .view-loading { padding: 48px var(--gutter); text-align: center; color: var(--muted); }
.fatal { max-width: 520px; margin: 80px auto; padding: 24px; text-align: center; }
.fatal h1 { margin-bottom: 12px; }

.app-header {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; min-height: var(--header-h);
  padding: 6px var(--gutter); background: var(--panel); border-bottom: 1px solid var(--border);
}
.hdr-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.hdr-right { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-sub { color: var(--muted); font-weight: 500; }
.desk-label { color: var(--text); font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.desk-label:hover { color: var(--info); text-decoration: none; }
.demo-badge {
  display: inline-block; padding: 4px 7px; border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: 0; background: var(--warn-bg); color: var(--warn);
  font: 11px var(--mono); letter-spacing: 0.04em;
}
.market-switch { flex-wrap: nowrap; }
.market-switch .seg-btn { padding: 4px 10px; }

.ticker-bar { display: flex; align-items: center; gap: 16px; min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 1; }
.ticker-bar::-webkit-scrollbar { display: none; }
.tk-main { display: flex; align-items: baseline; gap: 10px; flex-shrink: 0; }
.tk-symbol { background: none; border: 0; color: var(--text); font-weight: 700; font-size: 15px; cursor: pointer; padding: 0; white-space: nowrap; }
.tk-last { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tk-stat { display: flex; flex-direction: column; flex-shrink: 0; }
.tk-label { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.tk-val { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tk-stale { color: var(--warn); font-size: 11px; border: 1px solid var(--warn); border-radius: 0; padding: 0 4px; }
.ticker-bar:not(.is-perp) .tk-mark, .ticker-bar:not(.is-perp) .tk-index, .ticker-bar:not(.is-perp) .tk-funding { display: none; }
/* Ticker priorities: the strip is ordered last, change, mark, funding, index, high, low, volume. Narrower
   screens drop stats from the end (never mark or funding); at <= 1280px the strip takes its own row and
   on phones it wraps instead of scrolling out of view. */
@media (max-width: 1600px) {
  .ticker-bar.is-perp .tk-high, .ticker-bar.is-perp .tk-low, .ticker-bar.is-perp .tk-vol { display: none; }
}
@media (max-width: 1440px) {
  .ticker-bar { gap: 14px; }
  .ticker-bar.is-perp .tk-chg-abs { display: none; }
  .brand-sub { display: none; }
}

.acc-switch {
  display: grid; grid-template-columns: auto auto; align-items: center; gap: 0 6px; text-align: left; min-height: 40px;
  padding: 2px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel-2); cursor: pointer; max-width: 260px;
}
.acc-line { display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; }
.acc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.acc-sub { font-size: 11px; color: var(--muted); gap: 8px; }
.caret { grid-row: 1 / span 2; grid-column: 2; color: var(--muted); }
.acc-line, .acc-sub { grid-column: 1; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); display: inline-block; margin: 0 4px; }
.live-dot.mode-sse { background: var(--up); box-shadow: 0 0 0 3px var(--up-bg); }
.live-dot.mode-polling { background: var(--warn); }
.live-dot.mode-connecting { background: var(--info); }
.bell { position: relative; }
.bell-count {
  position: absolute; top: -2px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: var(--danger-ink); font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.user-btn { display: flex; align-items: center; gap: 6px; background: none; border: 0; cursor: pointer; padding: 4px; border-radius: var(--radius-sm); }
.user-btn:hover { background: var(--panel-3); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-3); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent); }
.user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* dropdowns */
.dropdown {
  position: fixed; z-index: 60; min-width: 200px; max-width: min(380px, calc(100vw - 16px)); overflow: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.dd-title { padding: 6px 8px; font-weight: 600; font-size: 13px; }
.dd-sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu-item {
  display: flex; flex-direction: column; align-items: stretch; width: 100%; text-align: left; padding: 8px; border: 0;
  border-radius: 4px; background: transparent; color: var(--text); cursor: pointer; min-height: 36px;
}
.menu-item:hover, .menu-item:focus { background: var(--panel-3); text-decoration: none; }
.menu-item.active { background: var(--panel-3); box-shadow: inset 3px 0 0 var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item:disabled { opacity: 0.45; cursor: not-allowed; }
.menu-sub { font-size: 12px; color: var(--muted); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; }
.acc-item { display: flex; flex-direction: column; gap: 2px; }
.acc-item-sub { font-size: 12px; color: var(--muted); }
.market-info .kv { display: flex; justify-content: space-between; gap: 16px; padding: 3px 8px; font-size: 13px; }
.market-info .kv span:first-child { color: var(--muted); }
.notif { display: flex; gap: 8px; padding: 6px 8px; border-radius: 4px; font-size: 13px; }
.notif.unread { background: var(--panel-2); }
.notif-time { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.notif-error .notif-text { color: var(--danger); }
.notif-warning .notif-text { color: var(--warn); }
.bell-menu { width: 380px; }

/* banners */
.banners { display: flex; flex-direction: column; }
.banner { display: flex; align-items: center; gap: 10px; padding: 4px var(--gutter); font-size: 13px; border-bottom: 1px solid var(--border); }
.banner .btn-sm { min-height: 26px; }
.banner-text { flex: 1; }
.banner-info { background: rgba(66, 212, 209, 0.08); }
.banner-warning { background: var(--warn-bg); color: var(--warn); }
.banner-danger { background: var(--down-bg); color: var(--danger); font-weight: 600; }
.banner-muted { background: var(--panel-2); color: var(--muted); }
.banner-accent { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.banner-x { background: none; border: 0; color: inherit; cursor: pointer; line-height: 1; padding: 0 4px; }
.card .banner { border: 0; border-radius: var(--radius-sm); margin-bottom: 10px; }

.main { flex: 1; min-width: 0; padding: 12px var(--gutter) 24px; }
.main:focus { outline: none; }
.main[data-route="trade"] { padding: 8px; }
.view { max-width: 1440px; margin: 0 auto; }
.view-trade { max-width: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.card { background: var(--card-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; min-width: 0; box-shadow: var(--shadow); }
.section-title { margin-bottom: 10px; }
.sub-title { margin: 14px 0 8px; font-size: 14px; }
.empty { padding: 20px; text-align: center; }
.app-footer { padding: 10px var(--gutter) 14px; font-size: 11px; color: var(--faint); text-align: center; border-top: 1px solid var(--border); }
.app-footer a { color: var(--muted); }
.app-footer .site-link { color: var(--info); font-weight: 600; }
.bottom-nav { display: none; }

/* ---------------------------------------------------------------- trade layout */
.trade-grid { display: grid; gap: 8px; min-width: 0; }
.trade-grid.advanced {
  grid-template-columns: minmax(0, 1fr) 300px 320px;
  grid-template-areas: "chart book ticket" "bottom bottom bottom";
  grid-template-rows: minmax(520px, 64vh) auto;
}
.trade-grid.simple {
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-areas: "chart ticket" "bottom bottom";
  grid-template-rows: minmax(480px, 62vh) auto;
}
.tg-chart, .tg-book, .tg-ticket, .tg-bottom { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.tg-chart { grid-area: chart; display: flex; flex-direction: column; overflow: hidden; }
.tg-book { grid-area: book; overflow: hidden; display: flex; flex-direction: column; }
.tg-ticket { grid-area: ticket; overflow-y: auto; }
.tg-bottom { grid-area: bottom; position: relative; min-height: 220px; }
.trade-bar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 4px 8px 0; }
.charts { flex: 1; display: grid; min-height: 0; }
.charts.split { grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); }
.sheet-toggle, .sheet-close { display: none; }

.chart-panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); }
.chart-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tf-bar { display: flex; gap: 2px; flex-wrap: wrap; }
.tf-btn { border: 0; background: transparent; color: var(--muted); padding: 3px 7px; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 600; }
.tf-btn:hover { color: var(--text); }
.tf-btn.active { color: var(--accent); background: var(--panel-3); }
.chart-tools { display: flex; align-items: center; gap: 4px; }
.draw-tools { display: flex; gap: 2px; border-right: 1px solid var(--border); padding-right: 4px; margin-right: 2px; }
.chart-area { position: relative; flex: 1; min-height: 280px; }
.chart-area.drag-hover { cursor: ns-resize; }
.chart-area.dragging { cursor: grabbing; }
.chart-host { position: absolute; inset: 0; }
.chart-legend { position: absolute; top: 6px; left: 8px; z-index: 3; font-size: 12px; pointer-events: none; display: flex; gap: 8px; flex-wrap: wrap; max-width: calc(100% - 80px); }
.lg-sym { font-weight: 700; }
.lg-ohlc b { font-weight: 600; margin-right: 2px; }
.lg-fills { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.chart-hint { position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%); z-index: 4; background: var(--panel-3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 10px; font-size: 12px; }
.chart-status { position: absolute; top: 30px; left: 8px; z-index: 3; font-size: 12px; color: var(--warn); }
.ind-menu { width: 260px; }
.ind-list .menu-row { font-size: 13px; }

/* book */
.tabbed { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tabs-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tabs-body > * { flex: 1; min-height: 0; }
.orderbook { display: flex; flex-direction: column; min-height: 0; font-size: 12px; }
.ob-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 8px; }
.ob-views { display: flex; gap: 2px; }
.ob-view { width: 26px; height: 24px; border: 1px solid transparent; border-radius: 4px; background: transparent; cursor: pointer; padding: 4px; display: flex; flex-direction: column; justify-content: space-between; }
.ob-view.active { border-color: var(--border); background: var(--panel-3); }
.ob-view-icon { display: block; width: 100%; height: 100%; border-radius: 2px; }
.ob-view-both .ob-view-icon { background: linear-gradient(var(--down) 0 45%, transparent 45% 55%, var(--up) 55% 100%); }
.ob-view-bids .ob-view-icon { background: var(--up); }
.ob-view-asks .ob-view-icon { background: var(--down); }
.ob-row {
  position: relative; display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 4px; padding: 1px 8px; width: 100%;
  border: 0; background: transparent; color: var(--text); font-size: 12px; text-align: right; cursor: pointer; font-variant-numeric: tabular-nums;
}
.ob-row > span:not(.ob-bar) { position: relative; z-index: 1; }
.ob-row > .ob-price { text-align: left; display: flex; align-items: center; gap: 4px; }
.ob-row:hover { background: var(--panel-3); }
.ob-cols { color: var(--muted); cursor: default; font-size: 11px; }
.ob-cols:hover { background: transparent; }
.ob-cols span:first-child { text-align: left; }
.ob-ask .ob-price { color: var(--down); }
.ob-bid .ob-price { color: var(--up); }
.ob-row > .ob-bar { position: absolute; top: 0; bottom: 0; right: 0; z-index: 0; opacity: 0.9; }
.ob-ask .ob-bar { background: var(--down-bg); }
.ob-bid .ob-bar { background: var(--up-bg); }
.own-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; }
.ob-side { flex: 1; overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; min-height: 0; }
.ob-side::-webkit-scrollbar { display: none; }
.ob-asks > :first-child { margin-top: auto; }
.orderbook[data-view="asks"] .ob-asks > :first-child { margin-top: 0; }
.ob-mid { display: flex; align-items: baseline; gap: 10px; padding: 6px 8px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.ob-last { font-size: 15px; font-weight: 700; }
.ob-spread { margin-left: auto; font-size: 11px; }
.ob-empty { padding: 16px; text-align: center; }
.orderbook.stale { opacity: 0.6; }
.tape { display: flex; flex-direction: column; min-height: 0; font-size: 12px; }
.tape .seg { margin: 6px 8px; }
.tp-row { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 1px 8px; font-variant-numeric: tabular-nums; text-align: right; }
.tp-row span:first-child { text-align: left; }
.tp-cols { color: var(--muted); font-size: 11px; }
.tp-list { overflow-y: auto; flex: 1; }
.depth { display: flex; flex-direction: column; min-height: 0; padding: 6px; }
.depth-canvas { width: 100%; flex: 1; min-height: 200px; }

/* ticket */
.ticket { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.ticket .field { margin-bottom: 0; }
.ticket-head { display: flex; align-items: center; gap: 8px; }
.ticket-head .seg-side { flex: 1; }
.ticket-head.chips { justify-content: flex-start; flex-wrap: wrap; }
.more-btn { flex-shrink: 0; }
.pct-slider { display: flex; flex-direction: column; gap: 4px; }
.pct-row { display: flex; align-items: center; gap: 8px; }
.pct-range { flex: 1; accent-color: var(--accent); }
.pct-out { width: 40px; text-align: right; color: var(--muted); font-size: 12px; }
.pct-marks { display: flex; gap: 4px; }
.pct-btn { flex: 1; border: 1px solid var(--border); background: var(--panel-2); border-radius: 4px; padding: 2px 0; cursor: pointer; font-size: 11px; color: var(--muted); }
.pct-btn.active, .pct-btn:hover { color: var(--text); border-color: var(--muted); }
.avail-row { display: flex; justify-content: space-between; font-size: 12px; }
.bracket-box { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.preview { font-size: 12px; }
.preview .summary { margin: 0; }
.preview-error { color: var(--danger); font-size: 12px; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.preview-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 2px 0; }
.preview-table td { text-align: right; padding: 2px 0 2px 6px; }
.preview-table thead th { text-align: right; }
.ticket-note { font-size: 12px; color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 6px 8px; }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.submit-btn { width: 100%; }
.gtd-input { margin-top: 4px; }
.lev-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; }
.lev-num { width: 80px; text-align: center; font-size: 20px; font-weight: 700; }
.lev-range { width: 100%; accent-color: var(--accent); }
.lev-presets { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0; }
.lev-presets .pct-btn { flex: 0 0 auto; padding: 3px 8px; }
.lev-warn { min-height: 20px; font-size: 13px; }
.lev-warn.warning { color: var(--warn); }
.lev-warn.danger { color: var(--danger); font-weight: 600; }

/* bottom panel and tables */
.tg-bottom .tabbed { height: auto; }
.tab-counts { position: absolute; right: 10px; top: 10px; }
.panel-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
.panel-toolbar.filters { justify-content: flex-start; }
.filter { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.filters { gap: 8px; }
.filters .input, .filters .select, .panel-toolbar .select { width: auto; min-width: 0; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 6px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; white-space: nowrap; }
.table tbody tr:hover { background: var(--panel-2); }
.table .num { text-align: right; }
.table tr.active-row { box-shadow: inset 3px 0 0 var(--accent); }
.table tr.warn-row td { color: var(--warn); }
.table tr.me-row { background: rgba(243, 184, 63, 0.08); }
.table tr.stale { opacity: 0.7; }
.row-actions { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.close-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.inline-close { display: inline-flex; gap: 2px; align-items: center; }
.margin-btns { display: inline-flex; gap: 2px; margin-left: 4px; }
.mr-bar { display: inline-block; width: 50px; height: 6px; background: var(--panel-3); border-radius: 3px; overflow: hidden; vertical-align: middle; margin-right: 4px; }
.mr-fill { display: block; height: 100%; background: var(--up); }
.mr-fill.risk-warning { background: var(--warn); }
.mr-fill.risk-danger, .mr-fill.risk-liquidation { background: var(--danger); }
.risk-text-warning { color: var(--warn); }
.risk-text-danger, .risk-text-liquidation { color: var(--danger); font-weight: 700; }
.liq { color: var(--warn); }
.load-more { margin: 8px auto; display: block; }
.note-btn { min-width: 26px; height: 26px; }
.note-btn.has-note { color: var(--accent); }
.history-table .table-wrap { max-height: none; }
.tg-bottom .table-wrap { max-height: 360px; overflow-y: auto; }
.algo-list { padding: 0 10px 10px; }
.partial-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; align-items: center; }
.partial-form .seg { grid-column: 1 / -1; }

/* summary lists */
.summary { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 6px 0; font-size: 13px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.summary dd.warn { color: var(--warn); text-align: left; }
.confirm-msg { margin-top: 0; }

/* modals */
.modal-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.modal-lg { width: min(680px, 100%); }
.modal-xl { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; }
.modal-body { padding: 14px; }
.modal-error { color: var(--danger); padding: 0 14px; min-height: 0; }
.modal-error:not(:empty) { padding-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--info); box-shadow: var(--shadow); font-size: 13px; transition: opacity 0.2s; }
.toast-success { border-left-color: var(--up); }
.toast-warning { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--danger); }
.toast.leaving { opacity: 0; }
.toast-text { flex: 1; }
.toast-close { background: none; border: 0; cursor: pointer; color: var(--muted); line-height: 1; }

/* tooltips */
.term { display: inline-flex; align-items: center; gap: 2px; }
.tip-btn { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); padding: 0; cursor: help; flex-shrink: 0; }
.tip-btn:hover { color: var(--text); border-color: var(--muted); }
.tip-pop { position: fixed; z-index: 95; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 13px; }
.tip-pop p { margin: 6px 0 0; color: var(--muted); }

/* tour */
.tour-layer { position: fixed; inset: 0; z-index: 85; pointer-events: none; }
.tour-hole { position: fixed; border-radius: var(--radius); box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55); border: 2px solid var(--accent); transition: all 0.2s; }
.tour-card { position: fixed; pointer-events: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.tour-card.centered { left: 50% !important; top: 40% !important; transform: translate(-50%, -50%); width: min(360px, calc(100vw - 32px)); }
.tour-title { margin-bottom: 6px; }
.tour-text { margin: 0 0 12px; color: var(--muted); }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-actions .small { margin-right: auto; }

/* auth */
.auth-page { width: 100%; max-width: 480px; margin: 0 auto; padding: 28px var(--gutter) 40px; }
.auth-context { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-eyebrow { color: var(--muted); font: 11px var(--mono); letter-spacing: .09em; }
.demo-notice { color: var(--muted); margin: 10px 0 18px; font-size: 13px; line-height: 1.6; }
.auth-card { background: var(--card-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.auth-card .seg { width: 100%; display: flex; margin: 10px 0; }
.auth-card .seg .seg-btn { flex: 1; }
.auth-h { font-size: 23px; margin-bottom: 8px; letter-spacing: -.035em; }
.form { display: flex; flex-direction: column; gap: 4px; }
.or { text-align: center; color: var(--muted); margin: 12px 0; font-size: 12px; }
.passkey-btn { margin-top: 4px; }
.btc-signer { display: flex; flex-direction: column; gap: 8px; }
.btc-step2 { display: flex; flex-direction: column; gap: 8px; }
.msg-box { font-size: 12px; min-height: 80px; }
.wallet-help { font-size: 13px; background: var(--panel-2); border-radius: var(--radius-sm); padding: 6px 10px; }
.wallet-help summary { cursor: pointer; color: var(--info); }
.wallet-help ul { padding-left: 18px; margin: 6px 0; }
.reauth { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }

/* portfolio, analytics */
.total-equity { display: flex; flex-direction: column; align-items: flex-end; }
.big { font-size: 22px; font-weight: 700; }
.acc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.acc-card { text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.acc-card:hover { border-color: var(--muted); }
.acc-card.active { border-color: var(--accent); }
.acc-card .big { font-size: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; min-width: 0; }
.card .kpi { background: var(--panel-2); }
.kpi-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.kpi-value { font-size: 17px; font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.kpi-sub { margin-top: 2px; }
.mini-chart { width: 100%; }
.mini-chart-host { width: 100%; position: relative; }
.bar { height: 10px; background: var(--panel-3); border-radius: 5px; overflow: hidden; margin: 8px 0; }
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar.alloc { background: var(--info); }
.alloc-btc { display: block; height: 100%; background: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-btc { background: var(--accent); }
.dot-usdt { background: var(--info); }
.calendar { display: flex; flex-direction: column; gap: 6px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-title { font-weight: 600; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-week span { text-align: center; color: var(--muted); font-size: 11px; }
.cal-cell { min-height: 52px; border-radius: 4px; background: var(--panel-2); padding: 4px; display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; position: relative; overflow: hidden; }
.cal-cell.empty { background: transparent; }
.cal-cell.future { opacity: 0.4; }
.cal-cell.today { outline: 1px solid var(--accent); }
.cal-day { color: var(--muted); }
.cal-pnl { font-weight: 600; text-align: right; font-size: 11px; overflow-wrap: anywhere; }
.cal-cell.up.lvl-1 { background: color-mix(in srgb, var(--up) 12%, transparent); }
.cal-cell.up.lvl-2 { background: color-mix(in srgb, var(--up) 22%, transparent); }
.cal-cell.up.lvl-3 { background: color-mix(in srgb, var(--up) 34%, transparent); }
.cal-cell.up.lvl-4 { background: color-mix(in srgb, var(--up) 48%, transparent); }
.cal-cell.down.lvl-1 { background: color-mix(in srgb, var(--down) 12%, transparent); }
.cal-cell.down.lvl-2 { background: color-mix(in srgb, var(--down) 22%, transparent); }
.cal-cell.down.lvl-3 { background: color-mix(in srgb, var(--down) 34%, transparent); }
.cal-cell.down.lvl-4 { background: color-mix(in srgb, var(--down) 48%, transparent); }
.cal-cell.up .cal-pnl { color: var(--up); }
.cal-cell.down .cal-pnl { color: var(--down); }
.cal-partial { position: absolute; top: 2px; right: 4px; color: var(--warn); }
.cal-totals { display: flex; flex-wrap: wrap; gap: 4px; }
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar { display: grid; grid-template-columns: 54px 1fr 90px; align-items: center; gap: 8px; font-size: 12px; }
.hbar-track { height: 8px; background: var(--panel-3); border-radius: 4px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; }
.hbar-val { text-align: right; }

/* lists, notes, settings */
.plain-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.note-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 8px; }
.note-text { white-space: pre-wrap; margin: 6px 0; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { border: 0; background: var(--panel-3); color: var(--info); border-radius: 10px; padding: 1px 8px; font-size: 12px; cursor: pointer; }
.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--header-h) + 12px); }
.settings-link { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--muted); }
.settings-link.active { background: var(--panel-3); color: var(--text); }
.secret-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--panel-2); border-radius: var(--radius-sm); padding: 8px 10px; margin: 6px 0; }
.secret { font-size: 15px; letter-spacing: 0.06em; }
.codes { background: var(--panel-2); border-radius: var(--radius-sm); padding: 10px; columns: 2; font-size: 14px; }
.qr-host { display: flex; justify-content: flex-start; margin: 6px 0; }
.qr { image-rendering: pixelated; border-radius: 4px; max-width: 100%; }
.steps { padding-left: 18px; margin: 0; }
.danger-zone { border-color: var(--down-bg); }
.glossary dt { font-weight: 700; margin-top: 10px; }
.glossary dd { margin: 2px 0 0; color: var(--muted); }
.quiz-q { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 0 0 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.quiz-q legend { padding: 0 4px; font-weight: 600; }
.closed-accounts { margin-top: 10px; color: var(--muted); }
.btc-balance { margin: 6px 0; }
.admin-settings .halt-switch { color: var(--danger); font-weight: 600; }
.drawer .modal-body { padding: 16px; }
.lb-me { margin-bottom: 8px; }
.js-error { display: none; }

/* ---------------------------------------------------------------- responsive (§11.8) */
@media (max-width: 1280px) {
  .trade-grid.advanced {
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-areas: "chart ticket" "chart book" "bottom bottom";
    grid-template-rows: auto minmax(260px, 1fr) auto;
  }
  .trade-grid.advanced .tg-chart { min-height: 560px; }
  .tg-book { max-height: 420px; }
  .brand-sub { display: none; }
}

@media (min-width: 901px) and (max-width: 1280px) {
  .app-header { flex-wrap: wrap; row-gap: 2px; }
  .ticker-bar { order: 10; flex-basis: 100%; }
  .ticker-bar.is-perp .tk-high, .ticker-bar.is-perp .tk-low, .ticker-bar.is-perp .tk-vol { display: flex; }
  .ticker-bar.is-perp .tk-chg-abs { display: inline; }
}

@media (max-width: 1100px) {
  .ticker-bar .tk-vol, .ticker-bar .tk-low, .ticker-bar.is-perp .tk-vol, .ticker-bar.is-perp .tk-low { display: none; }
  .user-name { display: none; }
}

@media (max-width: 900px) {
  :root { --header-h: 52px; }
  body { font-size: 15px; }
  .app-header { flex-wrap: wrap; gap: 6px 8px; padding: 6px var(--gutter); }
  .hdr-left, .hdr-right { display: contents; }
  .brand { order: 1; }
  .app-header .demo-badge { order: 2; }
  .app-header .bell { order: 3; margin-left: auto; }
  .user-btn { order: 4; }
  .market-switch { order: 5; }
  .acc-switch { order: 6; margin-left: auto; }
  .brand-text { display: none; }
  .ticker-bar { order: 7; flex-basis: 100%; gap: 4px 12px; flex-wrap: wrap; overflow: visible; }
  .ticker-bar .tk-high, .ticker-bar .tk-low, .ticker-bar .tk-vol { display: none; }
  .hdr-right .eye-btn, .hdr-right .live-dot { display: none; }
  .acc-switch { max-width: 170px; }
  .main { padding: 10px var(--gutter) 84px; }
  .main[data-route="trade"] { padding: 6px 6px 84px; }
  .trade-grid.advanced, .trade-grid.simple {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "chart" "book" "bottom";
    grid-template-rows: auto;
  }
  .tg-chart { min-height: 0; }
  .trade-grid.advanced .tg-chart { min-height: 0; }
  .chart-area { min-height: 0; height: clamp(240px, 42vh, 420px); flex: none; }
  .charts.split { grid-template-columns: 1fr; }
  .tg-book { max-height: 460px; }
  .tg-ticket {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; max-height: 86vh; border-radius: 14px 14px 0 0;
    transform: translateY(105%); transition: transform 0.2s ease-out; box-shadow: var(--shadow);
  }
  .tg-ticket.sheet-open { transform: translateY(0); }
  .sheet-close { display: inline-flex; position: absolute; top: 6px; right: 6px; z-index: 2; }
  .sheet-toggle { display: inline-flex; position: fixed; right: 16px; bottom: 76px; z-index: 65; min-height: 48px; padding: 0 22px; border-radius: 24px; box-shadow: var(--shadow); }
  .tab-counts { display: none; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--panel); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .bn-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; border: 0; background: none; color: var(--muted); font-size: 11px; cursor: pointer; }
  .bn-item.active { color: var(--accent); }
  .bn-item:hover { text-decoration: none; }
  .bn-icon { display: flex; align-items: center; line-height: 1; }
  .app-footer { padding-bottom: 76px; }
  .grid-2, .grid-3, .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { flex-direction: row; overflow-x: auto; position: static; }
  .input, .select, textarea { font-size: 16px; }
  .btn, .menu-item, .seg-btn, .mini-btn, .icon-btn { min-height: 40px; }
  .mini-btn { padding: 0 10px; }
  .tf-btn { padding: 6px 8px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; }
  .toasts { left: 16px; right: 16px; bottom: 72px; width: auto; }
  .partial-form { grid-template-columns: 1fr 1fr; }
  /* tables -> cards */
  .table.cardify thead { display: none; }
  .table.cardify, .table.cardify tbody, .table.cardify tr, .table.cardify td { display: block; width: 100%; }
  .table.cardify tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 8px 0; padding: 6px 8px; background: var(--panel); }
  .table.cardify td { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 0; padding: 4px 0; white-space: normal; text-align: right; }
  .table.cardify td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex-shrink: 0; }
  .table.cardify td[data-label=""]::before { content: none; }
  .table.cardify td .close-actions, .table.cardify td .row-actions { justify-content: flex-end; }
  .tg-bottom .table-wrap { max-height: none; }
}

@media (max-width: 480px) {
  :root { --gutter: 16px; }
  .market-switch .seg-btn { padding: 4px 6px; font-size: 12px; }
  .acc-switch { max-width: 130px; }
  .acc-sub { display: none; }
  .tk-last { font-size: 16px; }
  .ticker-bar .tk-change .tk-label, .ticker-bar .tk-mark .tk-label { font-size: 10px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .cal-cell { min-height: 40px; }
  .cal-pnl { font-size: 9px; }
  .codes { columns: 1; }
  .lev-presets .pct-btn { padding: 6px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
