/* ============================================================================
   redesign.css — OKX Terminal · Fintech UI 2026
   Additive layer: loaded after style.css. No trading/API logic here.
   Device hooks: html[data-device="desktop|mobile|tv"]
   Theme hooks:  html[data-theme="dark|silver|white"]
   ========================================================================== */

/* ── 1. Design tokens ───────────────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg: #0B0E11;
  --bg-deep: #07090C;
  --panel: #131722;
  --panel2: #1C212E;
  --panel3: #222938;
  --line: #1E222D;
  --line-soft: #2A3040;
  --text: #E8EAF0;
  --dim: #8A93A6;
  --muted: #5E687A;
  --long: #0ECB81;
  --long-soft: rgba(14, 203, 129, .14);
  --long-strong: rgba(14, 203, 129, .52);
  --short: #F6465D;
  --short-soft: rgba(246, 70, 93, .13);
  --short-strong: rgba(246, 70, 93, .50);
  --accent: #F5B83D;
  --accent-soft: rgba(245, 184, 61, .12);
  --focus: #4D8DFF;
  --price: #4D8DFF;
  --liq: #FF9F1A;
  --shadow-1: 0 10px 30px rgba(0, 0, 0, .34);
  --shadow-2: 0 18px 50px rgba(0, 0, 0, .46);
  --radius: 8px;
  --radius-sm: 6px;
  --gap: 8px;
  color-scheme: dark;
}

[data-theme="silver"] {
  --bg: #0D1117;
  --bg-deep: #090D12;
  --panel: #151B24;
  --panel2: #1C232E;
  --panel3: #242D3B;
  --line: #303947;
  --line-soft: #3B4657;
  --text: #D6DEE9;
  --dim: #94A0B2;
  --muted: #69768A;
  --long: #3FB950;
  --long-soft: rgba(63, 185, 80, .15);
  --long-strong: rgba(63, 185, 80, .52);
  --short: #F85149;
  --short-soft: rgba(248, 81, 73, .15);
  --short-strong: rgba(248, 81, 73, .50);
  --accent: #D29922;
  --accent-soft: rgba(210, 153, 34, .12);
  --focus: #58A6FF;
  --price: #58A6FF;
  --liq: #F0883E;
  --shadow-1: 0 10px 30px rgba(0, 0, 0, .34);
  --shadow-2: 0 18px 50px rgba(0, 0, 0, .46);
  color-scheme: dark;
}

[data-theme="white"] {
  --bg: #EEF2F6;
  --bg-deep: #E5EBF1;
  --panel: #FFFFFF;
  --panel2: #F4F7FA;
  --panel3: #EAF0F5;
  --line: #D3DCE6;
  --line-soft: #BFCAD6;
  --text: #17202B;
  --dim: #5D6B7A;
  --muted: #8493A3;
  --long: #0B8F5C;
  --long-soft: rgba(11, 143, 92, .12);
  --long-strong: rgba(11, 143, 92, .40);
  --short: #D92D44;
  --short-soft: rgba(217, 45, 68, .10);
  --short-strong: rgba(217, 45, 68, .38);
  --accent: #A66A00;
  --accent-soft: rgba(166, 106, 0, .10);
  --focus: #0B63CE;
  --price: #0B63CE;
  --liq: #B65300;
  --shadow-1: 0 8px 22px rgba(28, 43, 58, .12);
  --shadow-2: 0 18px 50px rgba(28, 43, 58, .18);
  color-scheme: light;
}

/* ── 2. Base / typography ───────────────────────────────────────────────── */
html, body {
  background: var(--bg);
}

body {
  font: 12.5px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 380px at 50% -180px, rgba(77, 141, 255, .10), transparent 70%),
    var(--bg);
}

[data-theme="white"] body {
  background:
    radial-gradient(900px 300px at 50% -160px, rgba(11, 99, 206, .08), transparent 70%),
    var(--bg);
}

::selection { background: var(--focus); color: #fff; }

.num,
.tbl td,
.tbl th,
.r,
.kpi b,
#aEq, #aAv, #aUpl, #kPrice, #kSpread, #kLong, #kShort, #kPress,
#fsPx, #chSym, #ohlc, .dash, #pnlPanel {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-soft) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-soft);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--dim); background-clip: padding-box; }

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

/* ── 3. Header / status / mode badges ────────────────────────────────────── */
.bar {
  gap: 7px 12px;
  padding: 8px 14px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.02);
}

.brand { position: relative; padding-left: 10px; }
.brand::before {
  content: "";
  position: absolute;
  left: 0; top: 2px; bottom: 2px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--focus), var(--long));
}
.brand strong { font-size: 14px; letter-spacing: .2px; }
.brand span { color: var(--muted); font-size: 10.5px; letter-spacing: .1px; }

.ctl label {
  color: var(--dim);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .35px;
}

input, select {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 5px 8px;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
input:hover, select:hover { border-color: var(--line-soft); }
input:focus, select:focus { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(77,141,255,.12); }

.btn {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 5px 10px;
  font-weight: 500;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:hover { background: var(--panel3); border-color: var(--line-soft); }
.btn:active { transform: translateY(1px); }
.btn.main { background: var(--focus); border-color: var(--focus); color: #fff; box-shadow: 0 4px 14px rgba(77,141,255,.22); }
.btn.main.off { background: var(--short); border-color: var(--short); box-shadow: 0 4px 14px var(--short-soft); }
.btn.sm { padding: 3px 8px; font-size: 11px; border-radius: 5px; }

/* Status pills */
.st {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel2);
  color: var(--dim);
  font-size: 10.5px;
  white-space: nowrap;
}
.st .dot { width: 7px; height: 7px; }
.st.ok { color: var(--long); border-color: rgba(14,203,129,.28); background: var(--long-soft); }
.st.warn { color: var(--accent); border-color: rgba(245,184,61,.28); background: var(--accent-soft); }
.st.err { color: var(--short); border-color: rgba(246,70,93,.30); background: var(--short-soft); }

/* Account mode: add a visible security badge via redesign.js */
#mode { min-width: 152px; font-weight: 600; }
#mode[data-mode="live"],
html[data-account-mode="live"] #mode {
  border-color: var(--short) !important;
  color: var(--short) !important;
  background: var(--short-soft) !important;
}
html[data-account-mode="demo"] #mode {
  border-color: rgba(77,141,255,.35);
  color: var(--price);
}
.acct-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  min-height: 22px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .35px;
  text-transform: uppercase;
  border: 1px solid var(--line);
  color: var(--dim);
  background: var(--panel2);
  white-space: nowrap;
}
.acct-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.acct-badge.demo { color: var(--price); border-color: rgba(77,141,255,.35); background: rgba(77,141,255,.08); }
.acct-badge.live { color: var(--short); border-color: var(--short); background: var(--short-soft); animation: livePulse 2.2s ease-in-out infinite; }
.acct-badge.paper { color: var(--dim); }
@keyframes livePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(246,70,93,0); } 50% { box-shadow: 0 0 0 4px rgba(246,70,93,.10); } }

.kpis { gap: 12px; }
.kpi {
  min-width: 78px;
  padding: 4px 10px;
  border-left: 1px solid var(--line);
}
.kpi:first-child { border-left: 0; padding-left: 2px; }
.kpi small { color: var(--muted); font-size: 9.5px; text-transform: uppercase; letter-spacing: .45px; }
.kpi b { font-size: 14px; letter-spacing: .1px; }
.kpi .pbar { margin-top: 5px; height: 4px; background: var(--short-strong); }

.banner { padding: 7px 14px; letter-spacing: .25px; }
.banner.demo { background: var(--accent-soft); color: var(--accent); border-bottom: 1px solid rgba(245,184,61,.18); }
.banner.live { background: var(--short); color: #fff; box-shadow: 0 4px 16px rgba(246,70,93,.20); }
.note { border-bottom: 1px solid var(--line); background: var(--panel2); }

/* ── 4. Desktop shell / grid ────────────────────────────────────────────── */
.layout {
  gap: 10px;
  padding: 10px;
  grid-template-columns: 292px minmax(0, 1fr) 390px;
  grid-template-rows: minmax(0, 1fr) 204px;
  grid-template-areas: "lad chart ord" "lad tabs ord";
}
.a-chart .cwrap { min-height: 120px; }

.panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,.015), transparent 90px),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.panel > h2 {
  padding: 8px 12px;
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .7px;
  text-transform: uppercase;
  background: var(--panel2);
}
.panel:hover { border-color: var(--line-soft); }

/* ── 5. Orderbook / walls ───────────────────────────────────────────────── */
.a-lad .scroll { padding: 0 4px 4px; }
.lad { font-size: 11.5px; line-height: 1.2; }
.r {
  grid-template-columns: 68px minmax(0, 1fr) 58px;
  height: 21px;
  border-radius: 4px;
  margin: 0;
}
.r .p { padding-right: 7px; }
.r .s { padding: 0 7px; border-radius: 4px; }
.r.ask .s { background: linear-gradient(to right, var(--short-soft) var(--w), transparent var(--w)); }
.r.bid .s { background: linear-gradient(to right, var(--long-soft) var(--w), transparent var(--w)); }
.r.wall.ask .s { background: linear-gradient(to right, var(--short-strong) var(--w), transparent var(--w)); }
.r.wall.bid .s { background: linear-gradient(to right, var(--long-strong) var(--w), transparent var(--w)); }
.r .c { color: var(--muted); padding-right: 7px; }
.tw {
  border: 1px solid transparent;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 9px;
  line-height: 1.3;
  background: var(--panel3);
}
.r.ask .tw { color: var(--short); border-color: rgba(246,70,93,.22); }
.r.bid .tw { color: var(--long); border-color: rgba(14,203,129,.22); }
.r.fresh .tw { background: var(--accent); color: #111; border-color: var(--accent); }
.mid {
  margin: 3px 4px 5px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(90deg, var(--panel2), var(--panel3), var(--panel2));
}
.mid b { font-size: 15px; }
.mid small, .mid .hint { color: var(--muted); }

/* ── 6. Chart header / tooling ──────────────────────────────────────────── */
.a-chart { min-width: 0; }
 .ch1 {
  padding: 6px 10px;
  gap: 4px 8px;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.ch1::-webkit-scrollbar { display: none; }
.ch1 > * { flex-shrink: 0; }
.ch1 b#chSym { font-size: 13px; letter-spacing: .1px; }
.tfs { gap: 2px; }
.tfs button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--dim);
  min-height: 24px;
  padding: 2px 6px;
  border-radius: 5px;
}
.tfs button:hover { background: var(--panel3); color: var(--text); }
.tfs button.on { color: var(--text); background: var(--panel3); border-color: var(--line-soft); }
.fsbar {
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
}
.ohlc {
  color: var(--dim);
  font-size: 10.5px;
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
  padding-top: 2px;
  padding-bottom: 2px;
}
.cwrap { background: var(--bg-deep); }
.chsrow { background: var(--panel); border-top: 1px solid var(--line); }
.fsdock {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border-top: 1px solid var(--line);
  padding: 7px 10px 8px;
}
.fsrow { gap: 5px; }
.fsdock input, .fsdock select { height: 28px; }
.fsdock .chip { height: 26px; }

/* ── 7. Trade / order panel ────────────────────────────────────────────── */
.a-ord { border-color: var(--line); overflow-y: auto !important; overflow-x: hidden; }
.a-ord > h2 {
  order: -2;
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--panel2);
  color: var(--dim);
  letter-spacing: .7px;
  text-transform: uppercase;
}
.a-ord > .ordf {
  order: -1;
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}
.a-ord > #autoPanel,
.a-ord > #stDash,
.a-ord > #riskPanel,
.a-ord > #pnlPanel,
.a-ord > #journalPanel { order: 0; flex: 0 0 auto; }
.ordf { padding: 10px; gap: 9px; }
.acc {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel2);
}
.acc > div { padding: 7px 9px; border-right: 1px solid var(--line); }
.acc > div:last-child { border-right: 0; }
.acc small { color: var(--muted); font-size: 9.5px; text-transform: uppercase; letter-spacing: .35px; }
.acc b { font-size: 13px; }

.seg {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel2);
  padding: 2px;
  gap: 2px;
}
.seg button {
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--dim);
  min-height: 28px;
  font-weight: 600;
}
.seg button.on { background: var(--panel3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
#segSide button[data-v="long"].on { background: var(--long-soft); color: var(--long); box-shadow: inset 0 0 0 1px rgba(14,203,129,.25); }
#segSide button[data-v="short"].on { background: var(--short-soft); color: var(--short); box-shadow: inset 0 0 0 1px rgba(246,70,93,.25); }

.fld { gap: 4px; }
.fld > label, .ordf label { color: var(--dim); font-size: 10.5px; }
.row { display: flex; gap: 6px; }
.chips { gap: 4px; }
.chip {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--dim);
  min-height: 24px;
  padding: 2px 7px;
}
.chip:hover { border-color: var(--line-soft); color: var(--text); }
.chip.on { background: var(--focus); color: #fff; border-color: var(--focus); }

.go {
  border: 0;
  border-radius: var(--radius-sm);
  min-height: 38px;
  font-weight: 800;
  letter-spacing: .35px;
  text-transform: uppercase;
}
.go.long { background: var(--long); color: #04130c; box-shadow: 0 6px 18px var(--long-soft); }
.go.short { background: var(--short); color: #fff; box-shadow: 0 6px 18px var(--short-soft); }
.go:hover { filter: brightness(1.06); }
.go:active { transform: translateY(1px); }
#riskBtn { border-color: rgba(77,141,255,.35); color: var(--price); }

.dash {
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
}
#autoPanel { background: var(--panel); }
.tpl-bar { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
#stDash, #riskPanel, #pnlPanel, #journalPanel { border-radius: 0; }

/* ── 8. Bottom tabs / tables ────────────────────────────────────────────── */
.a-tabs { background: var(--panel); }
.tabbar {
  padding: 5px 7px;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  gap: 2px;
}
.tabbar button {
  border-radius: 5px;
  min-height: 28px;
  padding: 4px 9px;
  color: var(--dim);
  font-size: 11px;
}
.tabbar button:hover { background: var(--panel3); color: var(--text); }
.tabbar button.on { background: var(--panel3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-soft); }
.tabbar button span { color: var(--muted); font-size: 10px; }
#tabBody { padding: 0 6px; }
.tbl { border-collapse: separate; border-spacing: 0; }
.tbl th {
  background: var(--panel2);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.tbl td { border-bottom: 1px solid rgba(30,34,45,.62); padding: 6px 8px; }
[data-theme="white"] .tbl td { border-bottom-color: rgba(211,220,230,.7); }
.tbl tr:hover td { background: var(--panel2); }

/* Generic small badges created by existing modules */
.badge, .pill, .tag {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel3);
  color: var(--dim);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .25px;
}

/* ── 9. Settings drawer ─────────────────────────────────────────────────── */
details.set {
  background: transparent;
  border: 0;
  padding: 0 10px;
  flex-shrink: 0;
}
details.set > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  color: var(--dim);
  font-size: 11px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--panel);
  width: fit-content;
}
details.set > summary::-webkit-details-marker { display: none; }
details.set > summary:hover { color: var(--text); border-color: var(--line-soft); }
details.set[open] {
  position: fixed;
  z-index: 120;
  top: 64px;
  right: 12px;
  bottom: 12px;
  width: min(820px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: drawerIn .16s ease-out;
}
details.set[open]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(0, 0, 0, .42);
  backdrop-filter: blur(2px);
}
details.set[open] > summary {
  order: 0;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel2);
  padding: 10px 14px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: .3px;
}
details.set[open] > .set-toolbar {
  order: 1;
  flex-shrink: 0;
  padding: 8px 12px;
}
details.set[open] > .set-tabs {
  order: 2;
  flex-shrink: 0;
  padding: 7px 12px;
}
details.set[open] > .set-body {
  order: 3;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 12px 16px;
}
details.set:not([open]) > summary { margin-left: 0; }
.set-close {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--dim);
  border-radius: 5px;
  min-height: 24px;
  padding: 1px 7px;
}
.set-close:hover { color: var(--short); border-color: var(--short); }
.set-badge:not(:empty) {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
@keyframes drawerIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* Settings content hierarchy */
.set-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 12px;
  background: var(--panel);
}
.set-toolbar input { min-width: 180px; flex: 1 1 200px; }
.set-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 7px 12px; border-bottom: 1px solid var(--line); }
.set-tabs button {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--dim);
  background: var(--panel2);
  padding: 5px 11px;
  font-size: 11px;
}
.set-tabs button.on { background: var(--focus); border-color: var(--focus); color: #fff; }
.set-body { padding-top: 10px; }
.set-cat h4 {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .65px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
.set-cat label { color: var(--dim); }
.set-cat label.chk { color: var(--text); }
.set-adv summary { color: var(--dim); }
.set-adv summary:hover { color: var(--text); }

/* ── 10. Modals / popovers ──────────────────────────────────────────────── */
.pop {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
}
.pop h4 { color: var(--text); font-size: 13px; }
.pop label { color: var(--dim); }
.pop input, .pop select { border-color: var(--line); }
.modal { background: rgba(0,0,0,.62); }
.modal .mbox {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
}
.modal .mbox h3 { color: var(--text); }
.modal .btns .main { background: var(--focus); }

/* ── 11. Mobile tab bar / mobile layout ────────────────────────────────── */
.mnav { display: none; }

html[data-device="mobile"] body {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
html[data-device="mobile"] .bar {
  flex-shrink: 0;
  padding: 6px 8px;
  gap: 5px 8px;
}
html[data-device="mobile"] .brand { flex: 1 1 100%; padding-left: 9px; }
html[data-device="mobile"] .brand strong { font-size: 13px; }
html[data-device="mobile"] .brand span { display: none; }
html[data-device="mobile"] .ctl { flex-wrap: wrap; }
html[data-device="mobile"] .ctl label { display: none; }
html[data-device="mobile"] #instId { width: 54vw; min-height: 32px; }
html[data-device="mobile"] .kpis {
  width: 100%;
  margin: 1px 0 0;
  gap: 0;
  justify-content: space-between;
}
html[data-device="mobile"] .kpi { min-width: 0; flex: 1; padding: 2px 6px; }
html[data-device="mobile"] .kpi small { display: none; }
html[data-device="mobile"] .kpi b { font-size: 12px; }
html[data-device="mobile"] #kPress { display: none; }
html[data-device="mobile"] .bar #logoutBtn { display: none; }
html[data-device="mobile"] .banner { font-size: 10.5px; padding: 4px 8px; }
html[data-device="mobile"] .note { font-size: 10px; }

html[data-device="mobile"] .layout {
  flex: 1;
  min-height: 0;
  display: flex !important;
  flex-direction: column;
  padding: 6px 6px calc(64px + env(safe-area-inset-bottom));
  overflow: hidden;
  background: var(--bg);
}
html[data-device="mobile"] .layout > .panel { display: none !important; }
html[data-device="mobile"][data-mobile-view="chart"] .layout > .a-chart,
html[data-device="mobile"][data-mobile-view="book"] .layout > .a-lad,
html[data-device="mobile"][data-mobile-view="trade"] .layout > .a-ord,
html[data-device="mobile"][data-mobile-view="positions"] .layout > .a-tabs {
  display: flex !important;
  flex: 1 1 auto;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  border-radius: var(--radius);
}
html[data-device="mobile"] .layout > .a-chart { flex-direction: column; }
html[data-device="mobile"] .a-chart .cwrap { flex: 1; min-height: 0; }
html[data-device="mobile"] .a-chart .fsdock { display: none; }
html[data-device="mobile"] .a-lad { flex-direction: column; }
html[data-device="mobile"] .a-lad .scroll { flex: 1; }
html[data-device="mobile"] .a-ord { overflow: hidden; }
html[data-device="mobile"] .a-ord .ordf { flex: 1; overflow: auto; }
html[data-device="mobile"] .a-tabs { flex-direction: column; }
html[data-device="mobile"] .a-tabs .scroll { flex: 1; }

html[data-device="mobile"] .mnav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  min-height: calc(58px + env(safe-area-inset-bottom));
  padding: 4px 6px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0,0,0,.25);
  backdrop-filter: blur(10px);
}
html[data-device="mobile"] .mnav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  padding: 2px 1px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  font-size: 8.2px;
  line-height: 1.1;
  overflow: hidden;
}
html[data-device="mobile"] .mnav button span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html[data-device="mobile"] .mnav button b { font-size: 17px; line-height: 1; font-weight: 500; }
html[data-device="mobile"] .mnav button.on { color: var(--text); background: var(--panel3); }
html[data-device="mobile"] .mnav button.on b { color: var(--focus); }
html[data-device="mobile"] details.set:not([open]) { display: none; }
html[data-device="mobile"] details.set[open] {
  top: 8px;
  right: 8px;
  left: 8px;
  bottom: 8px;
  width: auto;
}
html[data-device="mobile"] .btn,
html[data-device="mobile"] select,
html[data-device="mobile"] input,
html[data-device="mobile"] .seg button,
html[data-device="mobile"] .chip,
html[data-device="mobile"] .tfs button,
html[data-device="mobile"] .tabbar button,
html[data-device="mobile"] .fsl,
html[data-device="mobile"] #levChips .chip {
  min-height: 44px;
}
html[data-device="mobile"] .btn.sm { min-height: 36px; }
html[data-device="mobile"] .go { min-height: 48px; font-size: 14px; }
html[data-device="mobile"] .a-ord .ordf { padding: 9px; }
html[data-device="mobile"] .a-ord .chips .chip { min-height: 36px; }
html[data-device="mobile"] .modal .mbox { width: calc(100vw - 16px) !important; max-height: calc(100vh - 16px); }
html[data-device="mobile"] .pop { width: calc(100vw - 16px) !important; max-height: calc(100vh - 16px); }

/* ── 12. TV: monitoring dashboard ──────────────────────────────────────── */
html[data-device="tv"] body {
  font-size: 16px;
  background:
    radial-gradient(1600px 500px at 50% -220px, rgba(77,141,255,.18), transparent 70%),
    var(--bg-deep);
}
html[data-device="tv"] .bar {
  padding: 14px 28px;
  gap: 12px 22px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-deep) 100%);
  border-bottom-color: var(--line-soft);
}
html[data-device="tv"] .brand strong { font-size: 25px; letter-spacing: .2px; }
html[data-device="tv"] .brand span { font-size: 14px; }
html[data-device="tv"] .kpi b { font-size: 22px; }
html[data-device="tv"] .kpi small { font-size: 11px; }
html[data-device="tv"] .kpis { gap: 24px; }
html[data-device="tv"] .ctl label { font-size: 12px; }
html[data-device="tv"] .btn { padding: 9px 16px; border-radius: 9px; font-size: 16px; }
html[data-device="tv"] .btn.sm { padding: 7px 12px; font-size: 15px; }
html[data-device="tv"] input, html[data-device="tv"] select { font-size: 16px; padding: 8px 11px; }
html[data-device="tv"] .layout {
  grid-template-columns: 380px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 300px;
  grid-template-areas: "lad chart" "lad tabs";
  gap: 16px;
  padding: 16px;
}
html[data-device="tv"] .a-ord { display: none !important; }
html[data-device="tv"] .fsdock,
html[data-device="tv"] .fsbar,
html[data-device="tv"] .chsrow .chs-end,
html[data-device="tv"] details.set { display: none !important; }
html[data-device="tv"] .panel { border-radius: 12px; box-shadow: var(--shadow-2); }
html[data-device="tv"] .panel > h2 { font-size: 13px; padding: 12px 16px; }
html[data-device="tv"] .a-chart .ch1 { padding: 11px 16px; font-size: 16px; }
html[data-device="tv"] .tfs button { min-height: 34px; font-size: 15px; padding: 5px 10px; }
html[data-device="tv"] .ohlc { font-size: 14px; padding: 7px 16px; }
html[data-device="tv"] .a-lad .lad { font-size: 14px; }
html[data-device="tv"] .r { height: 27px; grid-template-columns: 82px 1fr 68px; }
html[data-device="tv"] .a-tabs .tabbar button { min-height: 36px; font-size: 15px; padding: 6px 14px; }
html[data-device="tv"] .a-tabs .tbl { font-size: 14px; }
html[data-device="tv"] .a-tabs .tbl td, html[data-device="tv"] .a-tabs .tbl th { padding: 8px 10px; }
html[data-device="tv"] .mnav { display: none !important; }
html[data-device="tv"] :focus-visible { outline: 4px solid var(--focus) !important; outline-offset: 4px !important; }

/* ── 13. Light / silver theme polish ───────────────────────────────────── */
[data-theme="white"] .panel { box-shadow: var(--shadow-1); }
[data-theme="white"] .bar { background: linear-gradient(180deg, #fff 0%, var(--bg) 100%); }
[data-theme="white"] .btn { background: #fff; }
[data-theme="white"] .btn:hover { background: var(--panel2); }
[data-theme="white"] .mid { background: linear-gradient(90deg, var(--panel2), var(--panel3), var(--panel2)); }
[data-theme="white"] .mnav { background: rgba(255,255,255,.94); }
[data-theme="white"] details.set[open]::before { background: rgba(0,0,0,.25); }
[data-theme="silver"] .brand::before { background: linear-gradient(180deg, #58A6FF, #3FB950); }

/* ── 14. Responsive safety net ─────────────────────────────────────────── */
@media (max-width: 1400px) and (min-width: 1181px) {
  .layout { grid-template-columns: 264px minmax(0, 1fr) 360px; grid-template-rows: minmax(0,1fr) 190px; }
  .kpi { min-width: 68px; padding: 4px 7px; }
}
@media (max-width: 1180px) and (min-width: 761px) {
  html[data-device="desktop"] body { overflow: hidden; }
  html[data-device="desktop"] .layout {
    display: grid;
    grid-template-columns: 238px minmax(0, 1fr) 330px;
    grid-template-rows: minmax(0,1fr) 215px;
    grid-template-areas: "lad chart ord" "lad tabs ord";
    height: auto;
    min-height: 0;
    overflow: hidden;
  }
  html[data-device="desktop"] .a-lad, html[data-device="desktop"] .a-chart,
  html[data-device="desktop"] .a-tabs, html[data-device="desktop"] .a-ord { overflow: hidden; }
  html[data-device="desktop"] .ordf { overflow: auto; }
}
@media (max-width: 900px) {
  .bar { flex-wrap: wrap; }
  .kpis { width: 100%; margin-left: 0; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
