:root {
  --bg: #111316;
  --panel: #1a1d22;
  --panel-2: #22262c;
  --line: #2c3139;
  --text: #e8eaed;
  --muted: #8b939e;
  --accent: #f5b53d;
  --buy: #6c9a1f;
  --buy-2: #82b62a;
  --sell: #2d7fd8;
  --sell-2: #3a93f0;
  --bad: #e0584f;
  --good: #7cc56a;
  --radius: 10px;
  --tabs-h: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }

a { color: var(--accent); text-decoration: none; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.coin { color: var(--accent); }
.net { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.net.testnet { color: var(--accent); }

main { padding: 14px 14px 24px; max-width: 760px; margin: 0 auto; }

h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.accent { color: var(--accent); }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.wrap { word-break: break-all; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
}
.card.link { display: block; color: inherit; }
.card.link:active { background: var(--panel-2); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stat { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.stat b { display: block; font-size: 15px; }
.stat span { font-size: 11px; color: var(--muted); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: var(--panel-2); color: var(--muted); }
.pill.on { background: rgba(124, 197, 106, .15); color: var(--good); }
.pill.off { background: rgba(224, 88, 79, .15); color: var(--bad); }
.pill.warn { background: rgba(245, 181, 61, .15); color: var(--accent); }

/* Стакан в духе торговой площадки Steam */
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .book { grid-template-columns: 1fr; } }

.side h4 { margin: 0 0 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.side h4 b { color: var(--text); }

table.levels { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.levels th { text-align: center; font-weight: 600; color: var(--muted); padding: 7px 4px; background: var(--panel-2); font-size: 12px; }
table.levels td { text-align: center; padding: 6px 4px; border-top: 1px solid var(--line); }
table.levels tr.more td { color: var(--muted); }
table.levels .empty { color: var(--muted); padding: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 8px; padding: 11px 16px; font: inherit; font-weight: 600;
  color: #fff; background: var(--panel-2); cursor: pointer; width: 100%;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.buy { background: linear-gradient(180deg, var(--buy-2), var(--buy)); }
.btn.sell { background: linear-gradient(180deg, var(--sell-2), var(--sell)); }
.btn.accent { background: var(--accent); color: #1a1406; }
.btn.danger { background: #5a2723; color: #ffd9d5; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.small { padding: 7px 10px; font-size: 13px; width: auto; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.list .item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list .item:first-child { border-top: 0; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--panel); border-top: 1px solid var(--line); z-index: 10;
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; }
.tabs a span { font-size: 19px; line-height: 1; margin-bottom: 3px; }
.tabs a b { font-weight: 500; }
.tabs a.active { color: var(--accent); }

.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 20; display: flex; align-items: flex-end; }
.sheet.hidden { display: none; }
.sheet-body {
  width: 100%; max-width: 760px; margin: 0 auto; background: var(--panel);
  border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto; border-top: 1px solid var(--line);
}
.sheet-body h3 { margin-top: 0; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 18px; }

.split { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.split .line { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.split .line.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 7px; font-weight: 700; }

.code-box {
  background: var(--panel-2); border: 1px dashed var(--accent); border-radius: 10px;
  padding: 14px; text-align: center; font: 700 20px/1.3 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px;
  word-break: break-all; user-select: all;
}

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px); transform: translateX(-50%);
  background: #2b3038; color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; z-index: 30; max-width: 92vw; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.toast.bad { border-color: var(--bad); }
.toast.hidden { display: none; }

.empty-state { text-align: center; color: var(--muted); padding: 36px 10px; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.back { display: inline-block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }
.list .item > div { min-width: 0; }
