:root {
  /* Webull-style dark palette (same as the terminal) */
  --bg: #0e0f13; --panel: #17181d; --panel-2: #1f2027; --line: #26272e; --line-2: #33353d;
  --text: #e7e8eb; --dim: #8d909b; --faint: #5d606a; --accent: #2f7bff; --up: #00b97b; --dn: #f6465d; --warn: #f0b90b;
  --mono: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.4 var(--sans); font-variant-numeric: tabular-nums; overscroll-behavior: none; }
body { overflow: hidden; display: flex; flex-direction: column; height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); user-select: none; -webkit-user-select: none; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.up { color: var(--up); } .dn { color: var(--dn); } .dim { color: var(--dim); } .warn { color: var(--warn); }

.bar { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bar .grow { flex: 1; }
.brand { font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
.brand b { background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 4px; margin-right: 4px; }
.btn { height: 32px; min-width: 32px; padding: 0 10px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; white-space: nowrap; font-weight: 500; touch-action: manipulation; }
.btn:active { filter: brightness(1.3); }
.btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { height: 28px; padding: 0 8px; font-size: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg .btn { border: 0; border-radius: 0; background: var(--panel-2); min-width: 30px; padding: 0 8px; }
.seg .btn + .btn { border-left: 1px solid var(--line-2); }
.seg .btn.on { background: var(--accent); }
input[type=date], input[type=time], input[type=number], input[type=text], input[type=password], select {
  height: 32px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 8px; min-width: 0;
}
input[type=number] { width: 84px; }
.clock { font-family: var(--mono); font-weight: 500; white-space: nowrap; }
.status { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.status.err { color: var(--dn); }

main.charts { flex: 1; display: flex; min-height: 0; position: relative; }
main.charts.stack { flex-direction: column; }
.pane { flex: 1; position: relative; min-width: 0; min-height: 0; border: 1px solid transparent; }
.pane + .pane { border-left-color: var(--line); }
main.charts.stack .pane + .pane { border-left-color: transparent; border-top-color: var(--line); }
.pane.active { box-shadow: inset 0 0 0 1px rgba(47,123,255,.55); }
.pane canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.pane .sel { position: absolute; right: 70px; top: 3px; z-index: 2; }
.empty-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--dim); padding: 24px; pointer-events: none; }
.empty-msg b { color: var(--text); }

.pb { display: flex; gap: 10px; padding: 4px 8px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.pb::-webkit-scrollbar { display: none; }
.pb span b { font-weight: 600; }
.trade { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 6px; padding: 6px 8px; background: var(--panel); border-top: 1px solid var(--line); align-items: center; }
.trade .row2 { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.big { height: 46px; font-weight: 700; font-size: 15px; border: 0; border-radius: 8px; color: #fff; cursor: pointer; touch-action: manipulation; }
.big small { display: block; font-weight: 500; font-size: 11px; opacity: .85; }
.buy { background: var(--up); } .sell { background: var(--dn); }
.big:active { filter: brightness(1.2); }
.qty { display: flex; align-items: center; gap: 2px; }
.qty input { width: 42px; text-align: center; padding: 0; }
.pos { display: flex; gap: 12px; padding: 5px 8px; background: #121317; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 12px; flex-wrap: wrap; }
.pos .k { color: var(--dim); font-family: var(--sans); margin-right: 3px; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet .card { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px 14px 0 0; width: min(760px, 100%); max-height: 88dvh; overflow: auto; padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); user-select: text; -webkit-user-select: text; }
@media (min-width: 800px) { .sheet { align-items: center; } .sheet .card { border-radius: 14px; } }
.card h2 { font-size: 16px; margin: 4px 0 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .grow { flex: 1; }
.card h3 { font-size: 13px; margin: 16px 0 6px; color: var(--dim); text-transform: uppercase; letter-spacing: .6px; }
.card label { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.card label > span:first-child { min-width: 170px; color: var(--dim); }
.card p, .card li { color: var(--dim); }
.card ol { padding-left: 20px; }
.card code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12px; color: var(--text); }
table.log { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 11.5px; }
table.log th, table.log td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.log th { color: var(--dim); font-family: var(--sans); font-weight: 500; position: sticky; top: 0; background: var(--panel); }
.tablewrap { overflow: auto; max-height: 52dvh; border: 1px solid var(--line); border-radius: 8px; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #2a2c33; color: var(--text); padding: 8px 14px; border-radius: 8px; z-index: 60; font-size: 13px; max-width: 90vw; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast.err { background: #5a1d24; }
.linemenu { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(160px + env(safe-area-inset-bottom)); z-index: 55; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px; display: flex; gap: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }

@media (max-width: 520px) {
  .hide-sm { display: none !important; }
  .bar { gap: 4px; padding: 4px 6px; }
  .btn { padding: 0 7px; height: 30px; }
  .seg .btn { min-width: 26px; padding: 0 6px; }
  select { height: 30px; padding: 0 4px; }
  .clock { font-size: 12px; }
  .card label > span:first-child { min-width: 130px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .trade { grid-template-columns: auto 110px 110px auto 1fr; }
  .trade .row2 { grid-column: auto; }
  .big { height: 38px; }
  .pb { display: none; }
}

.tools { position: absolute; left: 6px; top: 24px; z-index: 3; display: flex; flex-direction: column; gap: 3px; }
.tools .btn { width: 28px; height: 26px; min-width: 0; padding: 0; background: rgba(31,32,39,.88); font-size: 14px; line-height: 1; }
.tools .btn.on { background: #2b7c99; border-color: #7ee0ff; color: #fff; }
