:root {
  --bg: #0b0d12;
  --card: #141821;
  --card-2: #1a1f2a;
  --line: #252b38;
  --text: #eef0f4;
  --muted: #8b93a5;
  --gold: #e8b547;
  --gold-2: #f6d27a;
  --green: #2fbf71;
  --red: #e5484d;
  --blue: #4c9eff;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: 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); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.err { color: var(--red); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; }

.screen {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-top)) 14px calc(28px + var(--safe-bottom));
}

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 14px; }
.login h1 { font-size: 26px; }
.login p.muted { margin: 4px 0 22px; }
.login input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 16px; margin-bottom: 12px; outline: none;
}
.login input:focus { border-color: var(--gold); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; flex: 1; }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted);
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.on .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(47,191,113,.18); }
.pill.on { color: var(--text); }
.pill.off .dot { background: var(--red); }
.pill.off { color: #ffb3b5; }
.icon-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  width: 38px; height: 34px; border-radius: 10px; font-size: 13px; letter-spacing: 1px;
}

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.num { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.num-sm { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; row-gap: 0; margin-bottom: 0; }
.grid2 .card { margin-bottom: 12px; }

/* hero */
.hero { background: linear-gradient(160deg, #1b1f2b 0%, #141821 60%); }
.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.run-state { font-size: 30px; font-weight: 800; letter-spacing: .02em; }
.run-state.on { color: var(--green); }
.run-state.off { color: var(--red); }
.status-text { margin: 10px 0 0; color: var(--muted); font-size: 14px; }

/* market */
.market-top { display: flex; justify-content: space-between; align-items: flex-end; }
.market .right { text-align: right; }
.price { font-size: 28px; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--gold-2); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 10px; }
.chip {
  font-size: 12.5px; padding: 5px 10px; border-radius: 999px; background: var(--card-2);
  border: 1px solid var(--line); color: var(--muted);
}
.chip.up { color: var(--green); border-color: rgba(47,191,113,.35); }
.chip.down { color: var(--red); border-color: rgba(229,72,77,.35); }
.news { display: flex; gap: 10px; align-items: baseline; font-size: 14px; }
.news .label { flex: none; }

/* entries */
.entries { display: flex; flex-direction: column; gap: 8px; }
.entry { background: var(--card-2); border-radius: 12px; padding: 10px 12px; border-left: 3px solid var(--muted); }
.entry.buy { border-left-color: var(--green); }
.entry.sell { border-left-color: var(--red); }
.entry-top { display: flex; align-items: center; gap: 8px; }
.entry-top .grow { flex: 1; color: var(--muted); font-size: 13px; }
.tag { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.tag.buy { background: rgba(47,191,113,.15); color: var(--green); }
.tag.sell { background: rgba(229,72,77,.15); color: var(--red); }
.entry-pl { font-weight: 650; font-variant-numeric: tabular-nums; }
.entry-bottom { margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: rgba(232,181,71,.15); color: var(--gold); }

/* lot */
.stepper { display: flex; gap: 10px; align-items: stretch; margin-bottom: 10px; }
.stepper input {
  flex: 1; min-width: 0; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); color: var(--text); outline: none;
}
.stepper input:focus { border-color: var(--gold); }

/* buttons */
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 13px 16px; font-size: 15px; font-weight: 700;
  color: #111; background: var(--card-2); cursor: pointer; transition: transform .06s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.full { width: 100%; display: block; }
.btn + .btn.full { margin-top: 8px; }
.btn-gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #1a1406; }
.btn-green { background: var(--green); color: #04150c; }
.btn-red, .btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-step { width: 56px; font-size: 24px; color: var(--text); background: var(--card-2); border: 1px solid var(--line); }
.btn-big { min-width: 150px; padding: 15px 18px; font-size: 15px; letter-spacing: .02em; }

/* activity */
.events { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.events li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.events li:first-child { border-top: 0; }
.events time { color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }

.foot { text-align: center; margin-top: 6px; }

/* sheet */
.sheet-wrap {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end;
  justify-content: center; z-index: 20; animation: fade .15s ease;
}
.sheet {
  width: 100%; max-width: 520px; background: var(--card); border-top-left-radius: 20px; border-top-right-radius: 20px;
  padding: 20px 16px calc(16px + var(--safe-bottom)); border: 1px solid var(--line); animation: up .18s ease;
}
.sheet h3 { font-size: 18px; margin-bottom: 6px; }
.sheet p { margin: 0 0 14px; font-size: 14px; }
.opt {
  display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 12px; background: var(--card-2);
  border: 1px solid var(--line); margin-bottom: 8px; font-size: 14.5px;
}
.opt input { accent-color: var(--gold); width: 18px; height: 18px; }
#sheetOptions:not(:empty) { margin-bottom: 12px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 28px); background: #222838; border: 1px solid var(--line); color: var(--text);
  padding: 11px 16px; border-radius: 12px; font-size: 14px; z-index: 30; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.ok { border-color: rgba(47,191,113,.6); }
.toast.err { border-color: rgba(229,72,77,.7); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
