:root {
  --bg: #0b0d12;
  --card: #141821;
  --card2: #1b202b;
  --line: #262c39;
  --text: #eef1f6;
  --muted: #8b93a7;
  --gold: #f5b93a;
  --gold2: #ffe08a;
  --green: #2ecc8f;
  --red: #ff5d6c;
  --blue: #5aa9ff;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px; background: rgba(11,13,18,.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; letter-spacing: .2px; }
.brand img { width: 32px; height: 32px; }
.brand b { color: var(--gold); }
.top-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: var(--card); border: 1px solid var(--line); border-radius: 12px; width: 40px; height: 40px;
  display: grid; place-items: center; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 16px 16px calc(96px + var(--safe-b)); max-width: 720px; margin: 0 auto; }

/* tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(15,18,25,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--safe-b)); z-index: 6; }
.tabs button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; color: var(--muted); font-size: 11px; }
.tabs button.active { color: var(--gold); }

/* blocks */
h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 16px; margin: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.section-head:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--card2); border-radius: 12px; padding: 8px 10px; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat .v { font-size: 16px; font-weight: 600; margin-top: 2px; }
.pos { color: var(--green); } .neg { color: var(--red); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.err { background: var(--red); }
.dot.wait { background: var(--gold); }
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--card2); color: var(--muted);
  border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { color: var(--green); border-color: rgba(46,204,143,.35); background: rgba(46,204,143,.1); }
.badge.warn { color: var(--gold); border-color: rgba(245,185,58,.35); background: rgba(245,185,58,.1); }
.badge.bad { color: var(--red); border-color: rgba(255,93,108,.35); background: rgba(255,93,108,.1); }
.spark { width: 100%; height: 44px; display: block; margin-top: 4px; }
.spark path { stroke-width: 2; }

/* buttons */
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 600; background: var(--card2); border: 1px solid var(--line); }
.btn.primary { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #1b1404; border: 0; }
.btn.danger { color: var(--red); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* copies inside account card */
.copy { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.copy-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* positions list */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.list li:last-child { border-bottom: 0; }
.side { font-weight: 700; font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.side.BUY { color: var(--green); background: rgba(46,204,143,.12); }
.side.SELL { color: var(--red); background: rgba(255,93,108,.12); }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input, select, textarea { width: 100%; background: var(--card2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px; font: inherit; font-size: 16px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { min-height: 70px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.note { background: rgba(245,185,58,.08); border: 1px solid rgba(245,185,58,.25); color: #f3d79a; border-radius: 12px;
  padding: 10px 12px; font-size: 13px; margin-top: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { background: none; border: 0; border-radius: 9px; padding: 10px; font-weight: 600; color: var(--muted); }
.seg button.on { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #1b1404; }
h3 .badge { vertical-align: middle; margin-left: 4px; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* auth screen */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box .brand { justify-content: center; font-size: 24px; margin-bottom: 6px; }
.auth-box .brand img { width: 44px; height: 44px; }
.auth-box p { text-align: center; }

/* bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 90vh; max-height: calc(100dvh - 24px); overflow: auto; background: var(--card);
  border-radius: 22px 22px 0 0; padding: 8px 18px calc(20px + var(--safe-b)); max-width: 720px; margin: 0 auto;
  animation: up .2s ease-out; }
.sheet-panel::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 6px auto 12px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); z-index: 30;
  background: #222937; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; max-width: 90vw; font-size: 14px; }
.toast.err { border-color: rgba(255,93,108,.5); color: #ffc2c8; }

.event { font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event time { color: var(--muted); font-size: 11px; display: block; }
