
:root{--bg:#f6f7f9;--card:#fff;--ink:#1b1f24;--mute:#6b7280;--line:#e5e7eb;--up:#0f9d74;--dn:#d6455d;--acc:#2f5bea;--warn:#b7791f}
@media (prefers-color-scheme:dark){:root{--bg:#0f1216;--card:#171b21;--ink:#e6e8eb;--mute:#8b95a3;--line:#262c35;--up:#2ec493;--dn:#ff6b81;--acc:#6f8fff;--warn:#e0a84a}}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:14px/1.45 -apple-system,"Segoe UI","Malgun Gothic",sans-serif}
header{display:flex;flex-wrap:wrap;gap:12px;align-items:center;padding:14px 16px;border-bottom:1px solid var(--line);background:var(--card);position:sticky;top:0;z-index:2}
h1{font-size:16px;margin:0 8px 0 0}h2{font-size:14px;margin:0 0 10px}
.pill{padding:3px 10px;border-radius:999px;font-size:12px;border:1px solid var(--line)}
.on{background:var(--up);color:#fff;border-color:var(--up)}.off{color:var(--mute)}.live{background:var(--dn);color:#fff;border-color:var(--dn)}
main{padding:16px;display:grid;gap:16px;max-width:1500px;margin:auto}
.card{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:14px;overflow:auto}
table{border-collapse:collapse;width:100%;font-variant-numeric:tabular-nums}th,td{padding:6px 8px;border-bottom:1px solid var(--line);text-align:right;white-space:nowrap}
th{color:var(--mute);font-weight:500;font-size:12px}td:first-child,th:first-child{text-align:left}
.tv-ok{color:var(--acc);font-weight:600}.up{color:var(--up)}.dn{color:var(--dn)}.mute{color:var(--mute)}.warn{color:var(--warn)}
button{font:inherit;padding:6px 12px;border-radius:7px;border:1px solid var(--line);background:var(--card);color:var(--ink);cursor:pointer}
button.p{background:var(--acc);color:#fff;border-color:var(--acc)}button.p.d2{background:var(--dn);border-color:var(--dn)}button.d{color:var(--dn)}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:10px 16px}
label{display:flex;flex-direction:column;gap:3px;font-size:12px;color:var(--mute)}
input,select,textarea{font:inherit;padding:6px 8px;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--ink)}
textarea{min-height:52px}/* summary: 3 PnL tiles in a row, then available + next trade; five in one row on a wide screen */
.stat{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:14px 12px;font-size:13px;font-variant-numeric:tabular-nums}.stat .t3{grid-column:span 2}.stat .t2{grid-column:span 3}.stat #balBox[style*="none"]+.t2{grid-column:1/-1}
.stat .t3,.stat .t2{display:flex;flex-direction:column;gap:2px;min-width:0}.stat .t3{justify-content:space-between}.stat .t3>span,.stat .t2>span{color:var(--mute);font-size:12px}.stat b{font-size:17px;line-height:1.3;overflow-wrap:anywhere}.stat .t2 b{font-size:15px}.stat .t3 b{font-size:18px}
.stat .sub{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:2px 14px;font-size:12px;border-top:1px solid var(--line);padding-top:10px}.stat #err{border-top:0;padding-top:0}.stat #err:empty{display:none}
html.xl .stat{grid-template-columns:repeat(5,minmax(0,1fr))}html.xl .stat .t3,html.xl .stat .t2{grid-column:span 1;justify-content:flex-start}html.xl .stat #balBox[style*="none"]+.t2{grid-column:span 2}html.xl .stat .t2 b{font-size:18px}
.tag{font-size:11px;padding:1px 6px;border-radius:4px;background:var(--line);margin-left:4px}
.sig{font-weight:600}.cb.bu{color:var(--up)}.cb.se{color:var(--dn)}button:disabled{opacity:.4;cursor:default}
.ft{cursor:pointer;user-select:none}.arr::before{content:"▾";color:var(--mute);font-size:12px}.fold.closed .arr::before{content:"▸"}.fold.closed .fb{display:none}.fold.closed h2{margin:0}
.cb.on2{background:var(--up);color:#fff;border-color:var(--up)}.cb.on2.off2{background:var(--dn);border-color:var(--dn)}
.mbg{position:fixed;inset:0;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center;z-index:10;padding:16px}
.mbox{width:100%;max-width:360px}.mbox label{margin-top:6px}.rad{flex-direction:row;align-items:center;gap:6px;color:var(--ink);font-size:14px}.cb{padding:1px 7px;font-size:11px;margin-left:4px;vertical-align:1px}#login{max-width:320px;margin:80px auto}
.ev{font-size:12px;max-height:280px;overflow:auto}.ev div{padding:2px 0;border-bottom:1px dashed var(--line)}
/* mobile layout (html.m, chosen automatically): tables become cards, one tab at a time, bottom tab bar */
#tabs{display:none}
html.m body{padding-bottom:calc(64px + env(safe-area-inset-bottom));-webkit-text-size-adjust:100%}
html.m header{padding:8px 12px;gap:6px 8px}html.m h1{font-size:14px;margin:0}html.m #langSel{order:-1}html.m h1{order:-2;white-space:nowrap}html.m #clock{display:none}html.m header::before{content:"";flex-basis:100%;height:0;order:0}html.m header>span.pill,html.m #autoBtn,html.m #memLink{order:1}html.m .pcOnly{display:none}
html.m main{padding:10px;gap:10px;display:block}
html.m main>section{display:none;margin-bottom:10px;padding:12px;overflow:visible}html.m main>section.cur{display:block}html.m #sec-orders.cur.empty{display:none}
html.m .arr{display:none}html.m .fold.closed .fb{display:block}html.m .fold.closed h2{margin:0 0 10px}html.m h2{display:flex;flex-wrap:wrap;gap:6px;align-items:center}html.m h2 button{float:none!important}
html.m input,html.m select,html.m textarea{font-size:16px;min-height:42px;width:100%}html.m input[type=radio]{width:auto;min-height:0}html.m .langpick{width:auto;max-width:108px;min-height:34px;padding:2px 4px}
html.m button{min-height:40px}html.m button.cb{padding:6px 12px;font-size:13px;margin-left:0;min-height:36px}
html.m table,html.m tbody{display:block}html.m thead{display:none}
html.m tbody{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(300px,100%),1fr));gap:10px}
html.m tr{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px 10px;border:1px solid var(--line);border-radius:10px;padding:10px;align-content:start}
html.m td{display:block;border:0;padding:0;text-align:left;white-space:normal!important;overflow-wrap:anywhere;min-width:0}
html.m td::before{content:attr(data-l);display:block;color:var(--mute);font-size:11px;font-weight:400}
html.m td[data-l=""]::before,html.m td:first-child::before{display:none}html.m td:first-child,html.m td[colspan],html.m td.wide{grid-column:1/-1}html.m td:empty{display:none}
html.m td.acts{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:8px}html.m td.acts::before{display:none}html.m td.acts button{flex:1}
html.m #watch tr{grid-template-columns:repeat(6,minmax(0,1fr));gap:8px;padding:12px;position:relative;cursor:pointer}html.m #watch td{font-size:15px;grid-column:span 2}html.m #watch td::before{font-size:12px;margin-bottom:1px}
html.m #watch td:nth-child(1){grid-column:1/5;order:-5;font-size:17px}html.m #watch td:nth-child(4){grid-column:5/7;order:-4;text-align:right;font-size:18px;font-weight:700}html.m #watch td:nth-child(4)::before,html.m #watch td:nth-child(3)::before,html.m #watch td:nth-child(11)::before{display:none}
html.m #watch td:nth-child(3){grid-column:1/-1;order:-3}html.m #watch td:nth-child(3) .tag,html.m #watch td:nth-child(3) .sig{font-size:14px;padding:3px 9px;margin:0 6px 0 0}html.m #watch td:nth-child(3) .sig{border-radius:4px;border:1px solid currentColor}html.m #watch td:nth-child(3) .mute{font-size:13px!important}
html.m #watch td:nth-child(7){order:-2}html.m #watch td:nth-child(8){order:-2}html.m #watch td:nth-child(10){order:-2}html.m #watch td:nth-child(9){grid-column:span 4;order:-1}html.m #watch td:nth-child(5),html.m #watch td:nth-child(6){grid-column:span 1;order:-1}
html.m #watch td.nil{display:none}html.m #watch td:nth-child(2),html.m #watch td:nth-child(11){grid-column:1/-1;display:none}html.m #watch tr.op td:nth-child(2),html.m #watch tr.op td:nth-child(11){display:flex}html.m #watch tr.op td:nth-child(2){order:8}html.m #watch tr.op td:nth-child(11){order:9}
html.m #watch tr.op td button{min-height:44px;font-size:15px}html.m #watch td.acts .bu{border-color:var(--up)}html.m #watch td.acts .se{border-color:var(--dn)}
html.m #watch tr::after{content:"▾";position:absolute;right:12px;bottom:8px;color:var(--mute);font-size:15px}html.m #watch tr.op::after{content:"▴"}html.m #watch tr.op{padding-bottom:34px;border-color:var(--acc)}
html.m #sec-watch h2{justify-content:space-between}html.m #scanNote{order:3;width:100%}.pz{display:none}html.m .pz{display:inline-block;background:var(--dn);color:#fff}
html.m .grid{grid-template-columns:repeat(auto-fill,minmax(min(150px,100%),1fr));align-items:end}html.m .saveBar{position:sticky;bottom:calc(60px + env(safe-area-inset-bottom));background:var(--card);padding:8px 0;margin:8px 0 0}
html.m .ev{max-height:none;overflow-wrap:anywhere;font-size:15px}html.m .ev div{border:0;padding:0}
html.m .ev .ed{color:var(--mute);font-size:13px;font-weight:600;padding:6px 0;margin-top:4px}
html.m .ev .ec{border:1px solid var(--line);border-left:4px solid var(--line);border-radius:8px;padding:10px 12px;margin-bottom:8px}html.m .ev .ec.up{border-left-color:var(--up)}html.m .ev .ec.dn{border-left-color:var(--dn)}html.m .ev .ec.warn{border-left-color:var(--warn)}html.m .ev .ec.acc{border-left-color:var(--acc)}html.m .ev .ec{color:var(--ink)}
html.m .ev .eh{display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px;margin-bottom:5px}html.m .ev .eh b{font-size:17px}html.m .ev .eh time{margin-left:auto;color:var(--mute);font-size:13px;font-variant-numeric:tabular-nums}html.m .ev .eh .tag{margin:0;font-size:13px;font-weight:600;padding:2px 8px}
html.m .ev .em{font-weight:600;line-height:1.45}html.m .ev .em i{font-style:normal;font-weight:400;color:var(--mute);font-size:14px}html.m .ev .el{font-size:14px;line-height:1.5;padding-left:14px;position:relative;margin-top:3px}html.m .ev .el::before{content:"·";position:absolute;left:3px;color:var(--mute)}html.m .ev .el.go::before{content:"→";left:-2px;color:var(--acc)}html.m .ev .el.fd{color:var(--mute);margin-top:5px;font-size:13px}html.m .dl a{display:block;margin-top:6px}html.m .dl button{width:100%}
html.m .mbg{align-items:flex-end;padding:0}html.m .mbox{max-width:none;border-radius:16px 16px 0 0;padding-bottom:calc(16px + env(safe-area-inset-bottom));max-height:calc(92vh / var(--z,1))}html.m .mbox p button{flex:1}
html.m #tabs{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:5;background:var(--card);border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom)}
html.m #tabs button{flex:1 1 0;min-width:0;min-height:56px;border:0;border-radius:0;background:none;font-size:11px;line-height:1.2;padding:4px 2px;color:var(--mute);overflow-wrap:anywhere}html.m #tabs button.cur{color:var(--acc);font-weight:700;box-shadow:inset 0 2px 0 var(--acc)}
html.m .tag{display:inline-block;white-space:nowrap}
/* positions: one full-width card each, unrealized PnL large at the top right, as many columns as fit */
html.m #pos{grid-template-columns:minmax(0,1fr)}html.m #pos tr{grid-template-columns:repeat(auto-fit,minmax(84px,1fr));grid-auto-flow:dense;gap:10px;padding:12px}
html.m #pos td:nth-child(1){grid-column:1/-2;order:-3;font-size:16px}html.m #pos td:nth-child(8){grid-column:-2/-1;order:-2;text-align:right;font-size:20px;font-weight:700;line-height:1.25}
html.m #pos td:nth-child(8)::before{font-weight:400}html.m #pos td:nth-child(7){order:-1}html.m #pos td[colspan]{grid-column:1/-1;font-size:inherit}
html.m #pos td:nth-child(9),html.m #pos td:nth-child(11),html.m #pos td:nth-child(16){grid-column:span 2}html.m #pos td:nth-child(18){grid-column:1/-1}
html.m.wide #pos td{font-size:15px}html.m.wide #pos tr{grid-template-columns:repeat(auto-fit,minmax(125px,1fr))}html.m.wide td::before{font-size:12px}html.m.wide #pos td:nth-child(8){font-size:24px}
html.m #login{margin:40px 16px;max-width:none}
