:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --bg-2: #131820;
  --card: #171d27;
  --line: #2a3342;
  --text: #e7edf5;
  --muted: #c5ceda;
  --gold: #e0b15a;
  --gold-2: #8c6a2f;
  --green: #3dcb97;
  --red: #ff5d73;
  --blue: #8eb6ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); max-width: 100%; }
body { min-height: 100dvh; overflow-x: hidden; }
#app, .shell, .main, .card, .list, .item, .row { min-width: 0; max-width: 100%; }
p, h1, h2, button, .meta { overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }

#app { min-height: 100dvh; }

.login, .shell { min-height: 100dvh; }
.login {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 28px 20px 40px;
  background:
    radial-gradient(800px 240px at 10% -10%, rgba(224, 177, 90, 0.16), transparent 50%),
    var(--bg);
}
.brand { display: flex; flex-direction: column; gap: 6px; }
.brand h1 { margin: 0; font-size: 32px; letter-spacing: 0.08em; font-weight: 650; }
.brand p, .muted { color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
label { display: grid; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  background: #0e131b;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px;
  min-height: 44px;
}
textarea { min-height: 88px; }
.btn, .btn-ghost, .btn-danger, button, summary {
  touch-action: manipulation;
}
.btn, .btn-ghost, .btn-danger {
  min-height: 44px;
  border-radius: 12px;
  border: 0;
  padding: 0 14px;
}
.btn { background: var(--gold); color: #1a1408; font-weight: 700; }
.btn-buy, .btn-sell { min-height: 56px; font-size: 18px; font-weight: 750; }
.brand-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-btn { min-height: 44px; padding: 0 14px; letter-spacing: 0.08em; background: var(--green); color: #062117; }
.nav button.live-nav { color: var(--green); font-weight: 800; }
.badge { border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 800; }
.badge.buy { background: #123528; color: var(--green); }
.badge.sell { background: #3a1720; color: var(--red); }
.badge.sim { background: #3a2a12; color: #ffd7a8; margin-right: 6px; }
.badge.own { background: #1c2c4a; color: #d5e4ff; margin-right: 6px; }
.badge.real { background: #123528; color: var(--green); margin-right: 6px; }
.badge.paper { display: inline-block; background: #4a1d6a; color: #f4d8ff; font-size: 18px; letter-spacing: 0.08em; padding: 6px 12px; margin-right: 6px; }
#feed { max-height: calc(100dvh - 280px); overflow: auto; }
.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 90;
  background: #243044;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
}
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: #3a1720; color: #ffd0d6; border: 1px solid #6d3040; }
.emergency { background: #9d1c1c; color: white; border: 0; width: 100%; min-height: 52px; font-weight: 800; letter-spacing: 0.04em; }
.qr svg { width: 180px; height: 180px; background: white; }
.badge.live { background: #9d1c1c; color: white; }
.home-feed { max-height: 320px; overflow: auto; }
.tape-row p { margin: 4px 0; }
.totals { display: grid; gap: 12px; }
.totals .block { border-radius: 14px; padding: 12px; }
.totals .paper { background: #241c10; border: 1px solid #6a5428; }
.totals .real { background: #10241c; border: 1px solid #1f6b45; }
.hero-num { margin: 4px 0; font-size: 28px; font-weight: 750; line-height: 1.1; }
.hero-num.usd { font-size: 20px; color: var(--muted); }
.real-top { margin-bottom: 12px; }
.real-hero { font-size: clamp(28px, 9vw, 40px); word-break: break-word; }
.down { color: var(--red); }
@media (max-width: 420px) {
  .main { padding: 12px; }
  .real-hero { font-size: 32px; }
  .card { padding: 12px; }
}
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 120px; min-width: 0; }
.cmd-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cmd-row > * { flex: 0 0 auto; min-height: 44px; }
.error { color: var(--red); font-size: 14px; }
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(12, 15, 20, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top strong { letter-spacing: 0.12em; }
.settings-btn { min-height: 44px; padding: 8px 14px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  min-height: 44px;
}
.pill.paper { color: var(--blue); border-color: #31486e; }
.pill.live { color: var(--red); border-color: #6d3040; }
.pill.paused { color: var(--gold); }
.pill.ok { color: var(--green); }
.main { padding: 14px 14px calc(92px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
.nav {
  position: fixed;
  z-index: 15;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: #10151d;
  border-top: 1px solid var(--line);
}
.nav button {
  background: transparent;
  border: 0;
  color: var(--muted);
  min-height: 52px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.1;
  padding: 6px 2px;
  white-space: normal;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.nav-icon { width: 22px; height: 22px; }
.nav button.active { color: var(--gold); background: #221b10; }
h2 { font-size: 22px; margin: 0 0 8px; letter-spacing: -0.02em; }
.hero strong { display: block; font-size: 34px; letter-spacing: -0.03em; margin: 4px 0; }
.hero-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.hero-row span { display: block; color: var(--muted); font-size: 12px; }
.hero-row b { font-size: 16px; }
.up { color: var(--green); }
.down { color: var(--red); }
.pnl { font-size: 22px; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.pos .btn-sell { width: 100%; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--text); font-size: 13px; }
.chip.ok { color: var(--green); border-color: #1f6b4e; }
.chip.warn { color: #ffd7a8; border-color: #6d5430; }
details summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
.help { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.empty b { display: block; margin-bottom: 4px; }
.skel { height: 84px; border-radius: 16px; background: linear-gradient(90deg, #171d27 25%, #222a36 37%, #171d27 63%); background-size: 400% 100%; animation: sheen 1.2s ease infinite; }
.skel.hero { height: 148px; }
@keyframes sheen { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.stat span, .meta { font-size: 13px; }
.statgrid, .links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { display: grid; gap: 4px; }
.stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span, .meta { color: var(--muted); }
.list { display: grid; gap: 8px; }
.item { display: grid; gap: 4px; }
.item .top-line, .top-line { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.break { overflow-wrap: anywhere; }
@media (max-width: 420px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .stat b { font-size: 16px; }
  h1, h2 { overflow-wrap: anywhere; }
}
.buy { color: var(--green); }
.sell, .wait { color: var(--gold); }
.unknown { color: var(--muted); }
canvas.chart { width: 100%; height: 220px; background: #0e131b; border-radius: 12px; }
.chart-stage.expanded canvas.chart { height: 68dvh; }
.hero-price { font-size: 32px; margin: 4px 0; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.coin-row { width: 100%; text-align: left; }
.trade-buy, .trade-sell {
  width: 100%;
  min-height: 72px;
  border: 0;
  border-radius: 16px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin: 8px 0 16px;
}
.trade-buy { background: var(--green); color: #062117; }
.trade-sell { background: var(--red); color: #2a0b10; }
.trade-sell:disabled, .trade-buy:disabled { opacity: 0.45; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.search { margin-bottom: 8px; }
.dialog {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  align-items: end;
  z-index: 80;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
.dialog .card { margin: 12px; }
.terminal-log { max-height: 240px; overflow: auto; white-space: pre-wrap; }
.warn { color: #ffd7a8; }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 220px 1fr; }
  .nav {
    position: sticky;
    top: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    border-top: 0;
    border-right: 1px solid var(--line);
    padding-top: 18px;
  }
  .main { padding-bottom: 28px; }
  .statgrid { grid-template-columns: repeat(4, 1fr); }
}
