:root{
  --bg:#F5F6F8; --card:#FFFFFF; --ink:#111827; --muted:#4B5563; --line:#E5E7EB; --soft:#EEF0F3;
  --blue:#1D4ED8; --blue-ink:#1E3A8A; --blue-soft:#EEF3FF;
  --gain:#0B6B42; --gain-soft:#E6F4EC; --loss:#B4330B; --loss-ink:#9A2C09; --loss-soft:#FCEAE3;
  --navy:#0F1B33; --navy-2:#2A3A5C; --navy-ink:#C7D2E6; --mint:#6EE7A8;
  --warn-bg:#FFF7E6; --warn-line:#F3D79A; --warn-ink:#5C4A12;
  --r:16px;
}
*{box-sizing:border-box}
html,body{margin:0;background:var(--bg);color:var(--ink);font-family:Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;-webkit-text-size-adjust:100%}
body{min-height:100vh}
a{color:var(--blue)}
button,input,select{font:inherit;color:inherit}
.app{max-width:520px;margin:0 auto;min-height:100vh;display:flex;flex-direction:column}
.view{flex:1;padding:max(env(safe-area-inset-top),20px) 16px 96px;display:flex;flex-direction:column;gap:12px}
.hdr{display:flex;justify-content:space-between;align-items:flex-end;gap:12px;padding:16px 4px 4px}
.hdr h1{margin:0;font-size:24px;font-weight:700}
.sub{font-size:13px;color:var(--muted)}
.small{font-size:12px;color:var(--muted)}
.card{background:var(--card);border-radius:var(--r);padding:16px;display:flex;flex-direction:column;gap:12px}
.card.row{flex-direction:row}
.card h2{margin:0;font-size:15px;font-weight:600}
.card h3{margin:0;font-size:13px;font-weight:600;color:var(--muted)}
.row{display:flex;justify-content:space-between;align-items:center;gap:10px}
.col{display:flex;flex-direction:column;gap:2px}
.grid3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.stat{background:var(--card);border-radius:14px;padding:12px;display:flex;flex-direction:column;gap:4px}
.stat .k{font-size:11px;color:var(--muted)} .stat .v{font-size:15px;font-weight:600}
.card .stat{background:var(--bg)}
.sym{font-size:15px;font-weight:600}
.gain{color:var(--gain)} .loss{color:var(--loss)}
.b{font-weight:600}
.divider{height:1px;background:var(--soft)}
.pill{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:600;padding:6px 10px;border-radius:999px;white-space:nowrap}
.pill .dot{width:8px;height:8px;border-radius:50%;background:currentColor}
.pill.ok{background:var(--gain-soft);color:var(--gain)}
.pill.off{background:var(--loss-soft);color:var(--loss-ink)}
.pill.idle{background:#E8EAEE;color:#374151}
.pill.paper{background:var(--warn-bg);color:var(--warn-ink)}
.chip{font-size:11px;font-weight:600;background:#F1F2F4;color:#374151;padding:4px 8px;border-radius:999px}
.chip.blue{background:var(--blue-soft);color:var(--blue-ink)}
.chip.gain{background:var(--gain-soft);color:var(--gain)}
.chip.loss{background:var(--loss-soft);color:var(--loss-ink)}
.chips{display:flex;gap:6px;flex-wrap:wrap}
.hero{background:var(--navy);color:#fff;border-radius:20px;padding:20px;display:flex;flex-direction:column;gap:12px}
.hero .lbl{font-size:13px;color:var(--navy-ink)}
.hero .big{font-size:38px;font-weight:700;letter-spacing:-.5px}
.hero .big.pos{color:var(--mint)} .hero .big.neg{color:#FDBA9A}
.bar{height:8px;background:var(--navy-2);border-radius:999px;overflow:hidden}
.bar>div{height:100%;background:var(--mint);border-radius:999px}
.range{position:relative;height:8px;border-radius:999px}
.range .now{position:absolute;top:-5px;width:4px;height:18px;margin-left:-2px;border-radius:2px;background:var(--ink)}
.btn{display:flex;justify-content:center;align-items:center;gap:8px;min-height:48px;padding:0 16px;border-radius:14px;border:1px solid transparent;font-size:15px;font-weight:600;text-decoration:none;cursor:pointer;background:var(--card);color:var(--ink);border-color:#D1D5DB}
.btn.primary{background:var(--blue);color:#fff;border-color:var(--blue)}
.btn.danger{background:var(--loss);color:#fff;border-color:var(--loss)}
.btn.soft-danger{background:#FFF6F2;border-color:#F0B9A5;color:var(--loss-ink)}
.btn.small{min-height:44px;font-size:14px;border-radius:12px}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btn svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.iconbtn{width:44px;height:44px;border-radius:12px;border:0;background:var(--card);display:inline-flex;align-items:center;justify-content:center;position:relative;cursor:pointer}
.iconbtn svg{width:22px;height:22px;fill:none;stroke:var(--ink);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.badge{position:absolute;top:6px;right:6px;min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:var(--loss);color:#fff;font-size:10px;font-weight:700;display:flex;align-items:center;justify-content:center}
label.f{display:flex;flex-direction:column;gap:6px;font-size:12px;color:var(--muted)}
.input{height:46px;border:1px solid #D1D5DB;border-radius:10px;padding:0 12px;background:#fff;font-size:15px;color:var(--ink);width:100%}
.input:focus{outline:2px solid var(--blue);outline-offset:1px;border-color:var(--blue)}
.stepper{display:flex;align-items:center;border:1px solid #D1D5DB;border-radius:10px;height:46px;background:#fff}
.stepper button{width:44px;height:44px;border:0;background:transparent;font-size:20px;cursor:pointer}
.stepper input{border:0;text-align:center;width:100%;font-weight:600;font-size:15px;outline:none;background:transparent}
.switch{width:50px;height:30px;border:0;border-radius:999px;background:#C9CED6;position:relative;padding:0;cursor:pointer;flex-shrink:0}
.switch::after{content:"";position:absolute;top:3px;left:3px;width:24px;height:24px;border-radius:50%;background:#fff;transition:left .15s}
.switch[aria-checked="true"]{background:var(--blue)}
.switch[aria-checked="true"]::after{left:23px}
.list .item{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:12px 0;border-bottom:1px solid var(--soft)}
.list .item:last-child{border-bottom:0}
.results{display:flex;flex-direction:column;background:#fff;border-radius:12px;border:1px solid var(--line);overflow:hidden}
.results button{display:flex;justify-content:space-between;gap:8px;padding:12px;border:0;border-bottom:1px solid var(--soft);background:#fff;text-align:left;cursor:pointer;min-height:48px}
.results button:last-child{border-bottom:0}
.preview{background:var(--blue-soft);border-radius:var(--r);padding:14px 16px}
.notice{border-radius:var(--r);padding:12px 16px;font-size:13px;line-height:1.45}
.notice.warn{background:var(--warn-bg);border:1px solid var(--warn-line);color:var(--warn-ink)}
.notice.err{background:var(--loss-soft);border:1px solid #F0B9A5;color:var(--loss-ink)}
.notice.ok{background:var(--gain-soft);color:var(--gain)}
.tabs{display:flex;background:#E8EAEE;border-radius:10px;padding:3px}
.tabs button{height:34px;padding:0 12px;border:0;border-radius:8px;background:transparent;font-size:13px;color:#374151;cursor:pointer}
.tabs button[aria-pressed="true"]{background:#fff;font-weight:600;color:var(--ink)}
.ev{display:flex;gap:10px;padding:12px 0;border-bottom:1px solid var(--soft)}
.ev:last-child{border-bottom:0}
.ev .d{width:8px;height:8px;border-radius:50%;margin-top:6px;flex-shrink:0;background:#9CA3AF}
.ev .d.success{background:#12925A}.ev .d.warn{background:#D97706}.ev .d.error{background:var(--loss)}.ev .d.info{background:var(--blue)}
.ev .m{font-size:14px;line-height:1.4}
.empty{text-align:center;color:var(--muted);font-size:14px;padding:24px 8px}
.code{font-family:ui-monospace,Menlo,monospace;font-size:12px;background:var(--bg);padding:8px 10px;border-radius:8px;word-break:break-all}
.nav{position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:100%;max-width:520px;display:flex;justify-content:space-around;background:#fff;border-top:1px solid var(--line);padding:6px 4px calc(8px + env(safe-area-inset-bottom));z-index:5}
.nav a{display:flex;flex-direction:column;align-items:center;gap:3px;min-width:60px;min-height:48px;justify-content:center;font-size:11px;font-weight:500;color:var(--muted);text-decoration:none}
.nav a svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.nav a[aria-current="page"]{color:var(--blue);font-weight:600}
.modal{position:fixed;inset:0;background:rgba(15,27,51,.45);display:flex;align-items:flex-end;justify-content:center;z-index:20}
.modal[hidden]{display:none}
.sheet{background:#fff;width:100%;max-width:520px;border-radius:20px 20px 0 0;padding:20px 16px calc(20px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:14px;max-height:90vh;overflow:auto}
.sheet h2{margin:0;font-size:18px}
.toast{position:fixed;left:50%;transform:translateX(-50%);bottom:88px;background:var(--navy);color:#fff;padding:12px 16px;border-radius:12px;font-size:14px;max-width:92%;z-index:30;box-shadow:0 6px 20px rgba(0,0,0,.2)}
.toast.err{background:var(--loss)}
.center{min-height:80vh;justify-content:center}
.logo{width:64px;height:64px;border-radius:16px}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
