@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root, [data-theme="dark"] {
  --bg: #0b0e11;
  --panel: #161a1e;
  --head: #181a20;
  --hover: #1e2329;
  --input: #2b3139;
  --line: #2b3139;
  --text: #eaecef;
  --muted: #848e9c;
  --yellow: #fcd535;
  --on-accent: #181a20;
  --up: #0ecb81;
  --dn: #f6465d;
  --font: "IBM Plex Sans", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
[data-theme="light"] {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --head: #ffffff;
  --hover: #eef1f6;
  --input: #ffffff;
  --line: #dce1ea;
  --text: #1e2329;
  --muted: #707a8a;
  --yellow: #f0b90b;
  --on-accent: #1e2329;
  --up: #0ecb81;
  --dn: #f6465d;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; }
a { color: var(--yellow); text-decoration: none; }
a:hover { color: var(--text); }
button, input, select { font-family: inherit; }
img { display: block; }
.mono, .px, .clock, .tick, .wrow, .ohlcrow, .wlast, .wchg, pre, .book, .trades, #stHi, #stLo, #stVol, #stPx {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}

.shell { display: flex; flex-direction: column; min-height: 100vh; }
.tape {
  display: flex; align-items: center; gap: 20px; height: 28px; padding: 0 12px;
  background: var(--head); border-bottom: 1px solid var(--line);
  font-size: 12px; overflow: hidden; white-space: nowrap;
}
.tape .tick { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; font-size: 12px; }
.up, .tick.up, .ch.up, .wchg.up, .wlast.up { color: var(--up); }
.dn, .tick.dn, .ch.dn, .wchg.dn, .wlast.dn { color: var(--dn); }
.livepill { color: var(--yellow); font-weight: 600; font-size: 11px; margin-right: 8px; }
.marquee { overflow: hidden; }
.marquee-track { display: inline-flex; gap: 24px; align-items: center; animation: ticker 32s linear infinite; }

.head {
  display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 16px;
  background: var(--head); border-bottom: 1px solid var(--line);
}
.toplogo {
  display: flex; align-items: center; gap: 8px; color: var(--yellow) !important;
  font-weight: 700; font-size: 20px; letter-spacing: -0.02em; margin-right: 8px;
}
.toplogo img { width: 28px; height: 28px; }
.navpills { display: flex; gap: 18px; }
.navpills a { color: var(--muted); font-size: 14px; font-weight: 500; }
.navpills a.on, .navpills a:hover { color: var(--text); }
.grow { flex: 1; }
.clock { color: var(--muted); font-size: 12px; }
.head form { margin: 0; }
.btn, a.btn, button[type="submit"], #startBtn, #saveBtn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--yellow); color: var(--on-accent); border: 0; border-radius: 4px;
  padding: 8px 16px; font-weight: 600; font-size: 14px; cursor: pointer;
}
button.ghost, a.ghost, #stopBtn {
  background: transparent; color: var(--text); border: 1px solid var(--line);
  border-radius: 4px; padding: 7px 12px; cursor: pointer; font-size: 13px;
}

.workspace { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.desk {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 300px;
  flex: 1;
  height: calc(100vh - 116px);
  min-height: 0;
  overflow: hidden;
}
body.term .desk { height: calc(100vh - 116px - 200px); min-height: 280px; }

.inst, .sidecol { background: var(--bg); overflow: hidden; display: flex; flex-direction: column; }
.inst { border-right: 1px solid var(--line); }
.sidecol { border-left: 1px solid var(--line); }
.colhead {
  padding: 10px 12px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between;
}
.colhead span { color: var(--yellow); font-size: 12px; font-weight: 500; }
.quotebar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--head);
}
.quotebar label { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.quotebar select {
  flex: 1; margin: 0; padding: 7px 8px; font-size: 13px; font-weight: 600;
}
#msearch {
  width: calc(100% - 16px); margin: 8px; padding: 8px 10px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--input); color: var(--text); font-size: 13px;
}
.watch { overflow: auto; flex: 1; min-height: 0; max-height: 100%; }
.news { max-height: 280px; overflow: auto; }
#asks, #bids { max-height: 180px; overflow: auto; }
#trades { max-height: 280px; overflow: auto; }
.whead, .wrow {
  display: grid; grid-template-columns: 1.15fr 1fr 0.85fr; gap: 4px;
  width: 100%; align-items: center; padding: 7px 12px; margin: 0;
}
.whead { color: var(--muted); font-size: 12px; }
.watch { overflow: auto; flex: 1; }
.wrow {
  background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text);
  cursor: pointer; text-align: left; font-size: 13px;
}
.wrow:hover, .wrow.on { background: var(--hover); }
.wsym { font-weight: 500; color: var(--text); }
.wsym small { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 2px; }
.wlast, .wchg { text-align: right; }
.sidehint { margin: 0; padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }

.chartcol { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chartbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.pairblock strong { font-size: 20px; color: var(--text); }
.px { font-size: 20px; font-weight: 600; margin-left: 12px; }
.ch { margin-left: 8px; font-size: 16px; }
.stats {
  display: flex; gap: 28px; padding: 6px 12px 10px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.stats div { display: flex; flex-direction: column; gap: 2px; }
.stats label { color: var(--muted); font-size: 12px; }
.stats b { font-size: 14px; font-weight: 500; color: var(--text); }
.charttools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.charttools select {
  width: auto; margin: 0; padding: 6px 8px; font-size: 12px; background: var(--input); color: var(--text);
}
.uipanel {
  position: absolute; right: 12px; top: 88px; z-index: 40; width: 260px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.uipanel[hidden] { display: none; }
.uipanel h3 { margin: 0 0 10px; font-size: 13px; }
.uipanel .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0; }
.uipanel input[type="color"] { width: 42px; height: 28px; padding: 0; border: 0; background: none; cursor: pointer; }
.modes { display: flex; gap: 6px; }
.modes button { flex: 1; }
.modes button.on { background: var(--yellow); color: var(--on-accent); border-color: var(--yellow); }
.head { position: relative; }
.tfs { display: flex; gap: 0; }
.tfs button {
  margin: 0; padding: 6px 10px; background: none; color: var(--muted);
  border: 0; font-size: 13px; cursor: pointer;
}
.tfs button.on, .tfs button:hover { color: var(--yellow); }
.chartstage { position: relative; }
.chartstage, .tv { flex: 1; min-height: 340px; width: 100%; background: var(--bg); }
.chart-fav {
  position: absolute; left: 8px; bottom: 28px; z-index: 3;
  width: 16px; height: 16px; opacity: 0.7; pointer-events: none;
  object-fit: contain;
}
.chartstage a[href*="tradingview"],
.tv a[href*="tradingview"],
a.tv-lightweight-charts-logo,
#tv a {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
#fallbackChart { display: none; width: 100%; height: 100%; }
.ohlcrow { padding: 4px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

.rtabs { display: flex; border-bottom: 1px solid var(--line); }
.rtabs button {
  flex: 1; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 10px 8px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.rtabs button.on { color: var(--yellow); border-bottom-color: var(--yellow); }
.rpanes { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.rpane { display: none; flex: 1; overflow: auto; min-height: 0; }
.rpane.on { display: flex; flex-direction: column; }

.bookhead, .bline {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px;
  padding: 4px 10px; font-size: 12px;
}
.bookhead { color: var(--muted); padding-top: 8px; }
.bline { position: relative; font-size: 12px; }
.bline span { position: relative; z-index: 1; }
.bline .bar {
  position: absolute; top: 0; bottom: 0; right: 0; opacity: 0.18; z-index: 0;
}
.asks .bline { color: var(--dn); }
.bids .bline { color: var(--up); }
.spread {
  display: flex; justify-content: space-between; padding: 8px 10px;
  background: var(--hover); font-size: 16px; font-weight: 600;
}
.trades .trow {
  display: grid; grid-template-columns: 1.1fr 1fr 0.9fr; padding: 3px 10px; font-size: 12px;
}
.trades .thead { color: var(--muted); padding-top: 8px; }

.panel { padding: 12px; border-bottom: 1px solid var(--line); }
.panel h2 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.kpi { font-size: 22px; margin: 0 0 4px; font-weight: 600; }
.kpi.on { color: var(--up); }
.kpi.off { color: var(--muted); }
.mini, .hint, .lede { color: var(--muted); font-size: 12px; line-height: 1.45; }
.btns { display: flex; gap: 8px; margin-top: 8px; }
.btns button { flex: 1; }
.sess { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; color: var(--muted); }
.sess.on { color: var(--up); }
.help { margin: 6px 0 0; padding-left: 16px; font-size: 12px; color: var(--muted); }
.news a { display: block; color: var(--text); padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.4; }
.nsrc { display: block; color: var(--yellow); font-size: 11px; }

.dock {
  border-top: 1px solid var(--line); background: var(--panel);
  height: 200px; max-height: 200px; display: flex; flex-direction: column;
  overflow: hidden; position: relative; z-index: 3; flex: 0 0 200px;
}
.dtabs { display: flex; border-bottom: 1px solid var(--line); }
.dtabs button {
  background: none; border: 0; color: var(--muted); padding: 8px 16px; font-size: 13px; cursor: pointer;
}
.dtabs button.on { color: var(--yellow); }
.dock .pane { display: none; padding: 12px 16px; overflow: auto; flex: 1; }
.dock .pane.on { display: block; }
.formgrid { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 8px 12px; }
.formgrid label, .panel label { margin: 0; font-size: 12px; color: var(--muted); display: block; }
input, select {
  width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--input); color: var(--text); font-size: 13px;
}
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13px; color: var(--muted); }
.check input { width: auto; margin: 0; }
.banner { background: var(--hover); padding: 10px; border-radius: 4px; }
.banner.bad { background: #35141c; color: var(--dn); }
pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  padding: 10px; min-height: 120px; margin: 0; overflow: auto; color: var(--muted); font-size: 11px; white-space: pre-wrap;
}
.statusbar {
  display: flex; gap: 16px; align-items: center; height: 24px; padding: 0 12px;
  background: var(--head); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px;
}
.statusbar b { color: var(--yellow); font-weight: 500; }
.liveok { color: var(--up); }

body.auth { min-height: 100vh; }
.auth-split { display: grid; grid-template-columns: 1.1fr 0.9fr; min-height: calc(100vh - 92px); }
.auth-visual {
  background: var(--head); padding: 48px; display: flex; flex-direction: column; justify-content: flex-end;
  border-right: 1px solid var(--line);
}
.auth-visual h2 { margin: 0 0 10px; font-size: 32px; color: var(--text); max-width: 16ch; }
.auth-visual p { color: var(--muted); max-width: 44ch; line-height: 1.55; }
.auth-quotes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 24px; }
.qmini { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 12px; }
.qmini b { display: block; color: var(--muted); font-size: 12px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { width: min(420px, 100%); }
.card .logo { width: 40px; height: 40px; margin-bottom: 16px; }
.eyebrow { color: var(--yellow); font-size: 12px; font-weight: 600; margin: 0 0 8px; }
h1 { margin: 0 0 8px; font-size: 28px; color: var(--text); }
.card label { margin-top: 14px; display: block; font-size: 12px; color: var(--muted); }
.card button { width: 100%; margin-top: 18px; padding: 12px; }
.legal { max-width: 720px; margin: 32px auto; padding: 0 20px 48px; line-height: 1.7; color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; font-size: 13px; }
.adminwrap { padding: 20px 24px 48px; }
.row { display: flex; gap: 8px; align-items: center; margin: 0; }
.row select, .row button { width: auto; margin: 0; }

@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

@media (max-width: 1100px) {
  .desk, .auth-split { grid-template-columns: 1fr; height: auto; }
  body.term .desk { height: auto; min-height: 0; }
  .workspace { overflow: visible; }
  .dock { height: auto; max-height: none; flex: none; }
  .formgrid { grid-template-columns: 1fr 1fr; }
  .chartstage, .tv { height: 50vh; min-height: 260px; flex: none; }
  .inst { max-height: 240px; }
  .sidecol { max-height: none; border-left: 0; border-top: 1px solid var(--line); }
  .head { height: auto; min-height: 52px; flex-wrap: wrap; padding: 8px 12px; }
  .navpills { gap: 10px; }
  .clock { display: none; }
  .tape { overflow-x: auto; }
  .marquee-track { animation: none; }
}

@media (max-width: 640px) {
  .formgrid { grid-template-columns: 1fr; }
  .pairblock strong { font-size: 16px; }
  .px { font-size: 16px; margin-left: 6px; }
  .stats { gap: 12px; }
  .toplogo { font-size: 16px; }
  .auth-split { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}
