:root {
  --bg: #0d1117; --card: #161b22; --line: #2a313c; --text: #e6edf3; --muted: #8b949e;
  --up: #2fbf8f; --down: #f0616d; --warn: #e8c468; --accent: #58a6ff;
  --r: 14px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
h3 { margin: 0 0 4px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }
.error { color: var(--down); min-height: 1.2em; margin: 8px 0 0; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: rgba(13,17,23,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--warn); color: #1b1400; }
.badge.live { background: var(--down); color: #fff; }
#updated { margin-left: auto; }
main { padding: 12px 14px calc(84px + var(--safe-b)); max-width: 900px; margin: 0 auto; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 5; }
.tabs button { flex: 1; padding: 14px 2px; background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; }
.tabs button.on { color: var(--text); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); }
.kpi b { font-size: 19px; font-variant-numeric: tabular-nums; }

.banner { border-radius: var(--r); padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.banner.danger { background: #3b1218; border: 1px solid var(--down); }

.pos { display: grid; gap: 4px; }
.pos-head { display: flex; align-items: center; gap: 8px; }
.pos-head b { font-size: 16px; }
.side { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 6px; }
.side.LONG { background: rgba(47,191,143,.18); color: var(--up); }
.side.SHORT { background: rgba(240,97,109,.18); color: var(--down); }
.pnl { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; font-size: 13px; }
.pos-grid span { color: var(--muted); display: block; font-size: 11px; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; margin-top: 6px; }
.chip.ok { background: rgba(47,191,143,.15); color: var(--up); }
.chip.none { background: var(--down); color: #fff; }
.chip.partial { background: rgba(232,196,104,.2); color: var(--warn); }
.empty { color: var(--muted); text-align: center; padding: 18px; }

.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { border-left: 3px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: 14px; white-space: pre-wrap; }
.alerts li.alta { border-color: var(--down); }
.alerts li.media { border-color: var(--warn); }
.alerts li time { display: block; font-size: 11px; color: var(--muted); }

.chart-bar, .report-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
#sym { flex: 1; min-width: 130px; text-transform: uppercase; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--card); color: var(--muted); border: 0; padding: 8px 11px; font: inherit; font-size: 13px; }
.seg button.on { background: var(--accent); color: #04111f; font-weight: 700; }
.chart { height: 62vh; min-height: 320px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.small-chart { height: 220px; min-height: 0; margin: 10px 0; }

.trade { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; cursor: pointer; }
.trade .meta { font-size: 12px; color: var(--muted); grid-column: 1 / -1; }
.trade .note { font-size: 13px; grid-column: 1 / -1; color: var(--text); opacity: .85; }
.report-text { white-space: pre-wrap; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; overflow-x: auto; }

input, select, textarea { width: 100%; background: #0b0f14; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; font: inherit; font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label input, label select, label textarea { margin-top: 4px; }
.form .check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
.form .check input { width: auto; }
.form .hint { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
.btn { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04111f; }
.btn.danger { border-color: var(--down); color: var(--down); }
.row { display: flex; gap: 8px; justify-content: flex-end; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-logo { width: 56px; height: 56px; }
.login .btn { width: 100%; margin-top: 4px; }

dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--r); width: min(520px, 94vw); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
.attribution { margin-top: 24px; }
