/* ============================================================
   TONFORGE — интерфейс мини-приложения
   ============================================================ */

:root {
  --bg: #060709;
  --bg-soft: #0a0c10;
  --card: #0d0f14;
  --card-2: #12151b;
  --line: #1b1f28;
  --line-soft: #151922;
  --text: #eef2f8;
  --muted: #7f8899;
  --muted-2: #5c6577;
  --green: #35e08c;
  --green-soft: rgba(53, 224, 140, 0.11);
  --green-line: rgba(53, 224, 140, 0.24);
  --gold: #f5c451;
  --blue: #4d9dff;
  --red: #ff6b6b;
  --radius: 18px;
  --nav-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

body.light {
  --bg: #eef1f6;
  --bg-soft: #f6f8fb;
  --card: #ffffff;
  --card-2: #f4f6fa;
  --line: #e2e7f0;
  --line-soft: #edf1f7;
  --text: #0b0f16;
  --muted: #6b7688;
  --muted-2: #98a1b1;
  --green: #0fae62;
  --green-soft: rgba(15, 174, 98, 0.1);
  --green-line: rgba(15, 174, 98, 0.22);
  --gold: #d99b1c;
  --blue: #2c7bec;
  --shadow: 0 18px 40px rgba(18, 28, 45, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
html { overflow-x: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  background:
    radial-gradient(60% 70% at 20% 0%, rgba(53, 224, 140, 0.14), transparent 65%),
    radial-gradient(50% 60% at 90% 0%, rgba(77, 157, 255, 0.12), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
body.light::before { opacity: 0.55; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--green); text-decoration: none; }

::-webkit-scrollbar { width: 0; height: 0; }

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 432px;
  min-height: 100vh;
  margin: 0 auto;
  background: transparent;
}
@media (min-width: 520px) {
  body { background: #030405; }
  .app { background: var(--bg); border-left: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }
  body.light { background: #dfe4ec; }
}

/* ---------------------------- шапка ---------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 10px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.user-chip { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1 1 auto; }

.avatar {
  position: relative;
  width: 34px; height: 34px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(145deg, #1d2330, #0f1218);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 15px;
  overflow: hidden;
}
body.light .avatar { background: linear-gradient(145deg, #eef2f8, #dfe6f0); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar::after {
  content: "";
  position: absolute; right: -1px; bottom: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--bg);
}

.user-meta { min-width: 0; }
.user-name {
  font-size: 13px; font-weight: 700; letter-spacing: -0.1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 132px;
}
.user-tag { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 132px; }

.brand {
  margin-left: auto;
  flex: none;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.005));
  font-size: 10px; font-weight: 800; letter-spacing: 0.11em;
  color: #cfd7e4;
  white-space: nowrap;
}
body.light .brand { color: #33405a; }
.brand-mark { color: #4d9dff; font-size: 11px; text-shadow: 0 0 12px rgba(77,157,255,.8); }

.icon-btn {
  position: relative;
  width: 36px; height: 36px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px;
  background: #f2f5f9; color: #08090c;
  font-size: 9px; font-weight: 800;
  display: grid; place-items: center;
  border: 2px solid var(--bg);
}
body.light .icon-btn .badge { background: #0d1016; color: #fff; }

/* ---------------------------- контент ---------------------------- */
.main { padding: 4px 12px calc(var(--nav-h) + 34px + var(--safe-b)); }

.tab { display: none; }
.tab.active { display: block; animation: fadeUp 0.22s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-head { margin: 16px 2px 8px; }
.section-head h3 { font-size: 15px; font-weight: 700; }
.section-head .link { font-size: 12px; color: var(--muted); }

.page-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 12px; }
.page-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }

.section-row { display: flex; align-items: center; justify-content: space-between; margin: 16px 2px 8px; }
.section-label { font-size: 10px; font-weight: 800; letter-spacing: 0.12em; color: var(--muted); }

.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.center { text-align: center; justify-content: center; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.tiny { font-size: 10.5px; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.gold { color: var(--gold); }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------------------------- карточки ---------------------------- */
.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.028), rgba(255,255,255,0) 46%),
    var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  overflow: hidden;
}
body.light .card { background: var(--card); }
.card.inner { background: var(--card-2); border-color: var(--line-soft); padding: 12px; }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; }

.balance-card { padding: 16px; background:
  radial-gradient(120% 140% at 0% 0%, rgba(53,224,140,0.10), transparent 55%),
  linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0) 50%),
  var(--card);
}
.balance-row { display: flex; align-items: baseline; gap: 8px; margin-top: 14px; }
.ton-glyph { color: var(--blue); font-size: 15px; transform: translateY(-3px); text-shadow: 0 0 14px rgba(77,157,255,0.6); }
.balance-amount { font-size: 31px; font-weight: 700; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.balance-unit { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 8px;
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 10.5px; font-weight: 600;
  white-space: nowrap;
}
.pill.green { background: var(--green-soft); border-color: var(--green-line); color: var(--green); }
.pill.gold { background: rgba(245,196,81,0.10); border-color: rgba(245,196,81,0.22); color: var(--gold); }
.pill.blue { background: rgba(77,157,255,0.10); border-color: rgba(77,157,255,0.22); color: var(--blue); }
.pill.red { background: rgba(255,107,107,0.10); border-color: rgba(255,107,107,0.22); color: var(--red); }
.pill.dark { color: #c6cfdd; }
body.light .pill.dark { color: #4a5568; }

/* ---------------------------- кнопки ---------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 17px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
  border: 1px solid transparent;
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: #f2f5f9; color: #08090c; }
body.light .btn.primary { background: #0d1016; color: #fff; }
.btn.light { background: #eef2f8; color: #0a0c10; }
body.light .btn.light { background: #0d1016; color: #fff; }
.btn.green { background: var(--green); color: #04140c; }
.btn.dark { background: var(--card-2); border-color: var(--line); color: var(--text); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.danger { background: rgba(255,107,107,0.12); color: var(--red); border-color: rgba(255,107,107,0.25); }
.btn.wide { width: 100%; height: 44px; font-size: 13.5px; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 11.5px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.chips { display: flex; gap: 7px; margin-bottom: 10px; }
.chips.scroll { overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; gap: 5px; }
.chips.scroll .chip { padding: 6px 10px; font-size: 10.5px; }
#adminTabs { flex-wrap: wrap; overflow: visible; }
.chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
  transition: 0.15s ease;
}
.chip.active { background: #f2f5f9; border-color: transparent; color: #08090c; }
body.light .chip.active { background: #0d1016; color: #fff; }
.chip.green { color: var(--green); border-color: var(--green-line); background: var(--green-soft); }

/* ---------------------------- поля ---------------------------- */
.input, .field input, .field select, select.input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}
.input:focus, .field input:focus, select.input:focus { border-color: var(--green-line); }
.input::placeholder { color: var(--muted-2); }

.field { display: block; margin-bottom: 11px; }
.field > span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input { padding-right: 58px; }
.input-wrap > span { position: absolute; right: 12px; font-size: 11px; font-weight: 700; color: var(--muted); }

.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; height: 42px; }

select.input { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px; background-size: 5px 5px; background-repeat: no-repeat; }

/* ---------------------------- майнер ---------------------------- */
.miner-card { padding: 14px 14px 12px; }
.miner-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.miner-power { text-align: right; }
.miner-power b { display: block; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.miner-spec { font-size: 10.5px; color: var(--muted); margin-top: 4px; }

.chart-wrap { position: relative; height: 128px; margin: 10px -2px 0; }
.chart-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart-axis {
  position: absolute; right: 0; top: 4px; bottom: 8px;
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 8.5px; color: var(--muted-2); text-align: right;
  pointer-events: none;
}
.chart-caption {
  position: absolute; left: 2px; top: 2px;
  font-size: 9.5px; color: var(--muted); letter-spacing: .04em;
}
.chart-caption b { color: #c7d0de; font-weight: 600; }
body.light .chart-caption b { color: #2c3546; }

.pending-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 2px; }
.pending-val { font-size: 27px; font-weight: 700; letter-spacing: -0.8px; font-variant-numeric: tabular-nums; line-height: 1.05; }
.pending-sub { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.pending-sub .up { color: var(--green); }

.miner-foot {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 10px; color: var(--muted);
}
.miner-foot b { color: var(--text); font-weight: 600; }

.selector {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  height: 42px;
  padding: 0 4px;
}
.selector span { font-size: 12px; font-weight: 600; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selector button { width: 36px; height: 34px; display: grid; place-items: center; color: var(--muted); border-radius: 9px; }
.selector button:active { background: var(--card-2); }
.selector svg { width: 16px; height: 16px; }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
}
.stat b { display: block; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: 9.5px; color: var(--muted); margin-top: 2px; }

/* ---------------------------- списки серверов ---------------------------- */
.list { display: flex; flex-direction: column; gap: 8px; }

.srv-row {
  display: flex; align-items: center; gap: 11px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 11px 12px;
}
.srv-ico {
  width: 38px; height: 38px; flex: none;
  border-radius: 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--green);
}
.srv-ico svg { width: 18px; height: 18px; }
.srv-ico.off { color: var(--muted); }
.srv-main { min-width: 0; flex: 1; }
.srv-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srv-sub { font-size: 10px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srv-right { text-align: right; flex: none; }
.srv-pending { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.srv-claim { margin-top: 3px; font-size: 10px; color: var(--green); font-weight: 700; }
.srv-claim.off { color: var(--muted-2); }

.empty {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.empty .empty-ico { width: 44px; height: 44px; margin: 0 auto 6px; border-radius: 14px; display: grid; place-items: center; background: var(--card-2); color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 13px; margin-bottom: 1px; }
.empty .btn { margin-top: 12px; }

/* ---------------------------- магазин ---------------------------- */
.item-card { padding: 12px 13px; }
.item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.item-name { font-size: 13px; font-weight: 700; line-height: 1.3; }
.tag { display: inline-block; padding: 2px 6px; border-radius: 6px; font-size: 8.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; margin-left: 5px; vertical-align: middle; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.gold { background: rgba(245,196,81,.12); color: var(--gold); }
.tag.blue { background: rgba(77,157,255,.12); color: var(--blue); }
.item-spec { font-size: 10px; color: var(--muted); margin-top: 3px; }
.price-tag { font-size: 10px; font-weight: 600; color: var(--muted); background: var(--card-2); border: 1px solid var(--line); padding: 3px 7px; border-radius: 7px; white-space: nowrap; }
.item-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.cell { background: var(--bg-soft); border-radius: 10px; padding: 7px 9px; }
.cell label { display: block; font-size: 9px; color: var(--muted); }
.cell b { display: block; font-size: 12.5px; font-weight: 700; margin-top: 1px; }
.item-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.item-cost { font-size: 11.5px; font-weight: 700; }
.item-cost small { display: block; font-size: 9px; color: var(--muted); font-weight: 500; margin-top: 1px; }

/* случайный сервер */
.random-card { padding: 14px; }
.random-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.random-head h3 { font-size: 14px; font-weight: 700; }
.random-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.random-actions .btn { height: 40px; }
.btn.outline-green { border-color: var(--green-line); color: var(--green); background: var(--green-soft); }
.btn.outline-gold { border-color: rgba(245,196,81,.28); color: var(--gold); background: rgba(245,196,81,.08); }

.preview-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.preview-row:first-child { border-top: 0; }
.preview-main { flex: 1; min-width: 0; }
.preview-name { font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-meta { font-size: 9.5px; color: var(--muted); margin-top: 2px; }
.preview-price { font-size: 10.5px; font-weight: 700; color: var(--gold); background: rgba(245,196,81,.09); border: 1px solid rgba(245,196,81,.18); border-radius: 999px; padding: 5px 9px; white-space: nowrap; }

/* буст */
.boost-card { display: flex; align-items: center; gap: 12px; }
.boost-main { flex: 1; min-width: 0; }
.boost-main h3 { font-size: 13.5px; font-weight: 700; }
.boost-main p { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.boost-price { text-align: right; }
.boost-price b { display: block; font-size: 13px; color: var(--gold); }
.boost-price span { font-size: 9px; color: var(--muted); }

/* калькулятор */
.calc-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 6px; }
.calc-row span { font-size: 11px; color: var(--muted); }
.calc-row b { font-size: 12px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  outline: none;
  margin: 6px 0 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: #f2f5f9;
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line), 0 2px 8px rgba(0,0,0,.4);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--line); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 3px solid var(--bg); border-radius: 50%; background: #f2f5f9; }
body.light input[type="range"]::-webkit-slider-thumb { background: #0d1016; }
body.light input[type="range"]::-moz-range-thumb { background: #0d1016; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.calc-actions { margin-top: 12px; }

/* ---------------------------- друзья ---------------------------- */
.invite-card { padding: 14px; }
.invite-link {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 10px;
  margin: 10px 0;
}
.invite-link span { flex: 1; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invite-link .icon-btn { width: 28px; height: 28px; border-radius: 8px; }
.invite-link .icon-btn svg { width: 14px; height: 14px; }

.invited-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 13px; }
.invited-ava { width: 30px; height: 30px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.invited-main { flex: 1; min-width: 0; }
.invited-main b { font-size: 12px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invited-main span { font-size: 9.5px; color: var(--muted); }
.invited-badge { font-size: 9px; color: var(--muted); background: var(--card-2); border: 1px solid var(--line); padding: 4px 7px; border-radius: 7px; white-space: nowrap; }

.top-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 13px; }
.top-row.me { border-color: var(--green-line); background: linear-gradient(90deg, var(--green-soft), var(--card) 55%); }
.rank { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; color: var(--muted); background: var(--card-2); border: 1px solid var(--line); }
.rank.r1 { background: linear-gradient(145deg, #f7d98a, #c9962e); color: #2c1e00; border: 0; }
.rank.r2 { background: linear-gradient(145deg, #e3eaf5, #9aa8bd); color: #1b2433; border: 0; }
.rank.r3 { background: linear-gradient(145deg, #e7b98a, #a46b35); color: #2b1600; border: 0; }
.top-main { flex: 1; min-width: 0; }
.top-main b { display: block; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-main span { font-size: 9.5px; color: var(--muted); }
.top-amount { font-size: 12px; font-weight: 700; color: var(--green); white-space: nowrap; }

/* ---------------------------- профиль ---------------------------- */
.profile-hero { display: flex; align-items: center; gap: 12px; padding: 10px 4px 14px; }
.profile-ava { width: 52px; height: 52px; border-radius: 50%; overflow: hidden; background: var(--card-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 20px; position: relative; }
.profile-ava img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 16px; font-weight: 700; }
.profile-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

.rows { padding: 4px 14px; }
.profile-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.profile-row:last-child { border-bottom: 0; }
.profile-row .p-ico { width: 30px; height: 30px; border-radius: 9px; background: var(--card-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); flex: none; }
.profile-row .p-ico svg { width: 15px; height: 15px; }
.profile-row .p-label { font-size: 12px; font-weight: 600; flex: 1; }
.profile-row .p-value { font-size: 11.5px; color: var(--muted); max-width: 52%; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-row .p-value.is-empty { color: var(--muted-2); }
.profile-row .chev { color: var(--muted-2); }
.profile-row .chev svg { width: 14px; height: 14px; }

.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { padding: 4px 9px; border-radius: 7px; font-size: 10px; font-weight: 700; color: var(--muted); }
.seg button.active { background: #eef2f8; color: #0a0c10; }
body.light .seg button.active { background: #0d1016; color: #fff; }

.hist-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: var(--card); border: 1px solid var(--line); border-radius: 13px; }
.hist-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--green-soft); color: var(--green); }
.hist-ico.out { background: rgba(255,107,107,.10); color: var(--red); }
.hist-ico svg { width: 15px; height: 15px; }
.hist-main { flex: 1; min-width: 0; }
.hist-main b { display: block; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-main span { display: block; font-size: 9.5px; color: var(--muted); margin-top: 1px; }
.hist-amount { text-align: right; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hist-amount small { display: block; font-size: 8.5px; font-weight: 500; color: var(--muted-2); margin-top: 2px; }

/* ---------------------------- нижняя навигация ---------------------------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  z-index: 40;
  width: 100%;
  max-width: 432px;
  display: flex;
  align-items: stretch;
  padding: 7px 6px calc(7px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.tab-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 0 3px;
  color: var(--muted-2);
  border-radius: 12px;
  transition: color .18s ease;
  min-width: 0;
}
.tab-btn svg { width: 20px; height: 20px; }
.tab-btn span { font-size: 9px; font-weight: 600; white-space: nowrap; }
.tab-btn.active { color: var(--green); }
.tab-btn.active svg { filter: drop-shadow(0 0 8px rgba(53,224,140,.35)); }
.tabbar.six .tab-btn span { font-size: 8px; }
.tabbar.six .tab-btn svg { width: 18px; height: 18px; }

/* ---------------------------- шторки ---------------------------- */
.backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  width: 100%;
  max-width: 432px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 6px 16px calc(16px + var(--safe-b));
  transform: translateY(104%);
  transition: transform .28s cubic-bezier(.22,.8,.3,1);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.sheet.open { transform: translateY(0); }
.sheet-chat { height: 86vh; }

.grab { width: 38px; height: 4px; border-radius: 999px; background: var(--line); margin: 4px auto 8px; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; flex: none; }
.sheet-head h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.sheet-head .icon-btn { width: 32px; height: 32px; border-radius: 10px; }
.sheet-head .icon-btn svg { width: 14px; height: 14px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; padding-bottom: 6px; }

/* история */
.hist-day { font-size: 10px; font-weight: 800; letter-spacing: .1em; color: var(--muted); margin: 14px 2px 7px; }
.hist-day:first-child { margin-top: 4px; }

/* вывод */
.withdraw-available { display: flex; justify-content: space-between; align-items: center; padding: 11px 13px; background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 13px; margin-bottom: 12px; }
.withdraw-available b { font-size: 14px; font-variant-numeric: tabular-nums; }
.quick-row { display: flex; gap: 6px; margin: -3px 0 12px; }
.quick-row button { flex: 1; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--card-2); font-size: 10.5px; font-weight: 700; color: var(--muted); }
.sum-line { display: flex; justify-content: space-between; font-size: 11.5px; padding: 4px 0; }
.sum-line b { font-weight: 700; }

/* чат */
.chat { display: flex; flex-direction: column; gap: 7px; padding: 6px 2px 10px; }
.msg { max-width: 84%; padding: 9px 12px; border-radius: 14px; font-size: 12.5px; line-height: 1.42; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--card-2); border: 1px solid var(--line); border-bottom-right-radius: 5px; }
.msg.staff { align-self: flex-start; background: var(--green-soft); border: 1px solid var(--green-line); border-bottom-left-radius: 5px; }
.msg-meta { font-size: 8.5px; color: var(--muted); margin-top: 4px; }
.msg.staff .msg-meta { color: rgba(53,224,140,.65); }
body.light .msg.staff .msg-meta { color: rgba(15,174,98,.7); }
.chat-input { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line-soft); flex: none; }
.chat-input input { flex: 1; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-soft); padding: 0 12px; font-size: 13px; outline: none; }
.chat-input .btn { height: 42px; padding: 0 16px; }
.chat-empty { text-align: center; color: var(--muted); font-size: 11.5px; padding: 30px 10px; }

/* ---------------------------- админка ---------------------------- */
.switch { position: relative; display: inline-block; width: 46px; height: 27px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #2a303b; border-radius: 999px; transition: background .2s ease; }
.switch .slider::before { content: ""; position: absolute; width: 21px; height: 21px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s ease; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(19px); }
body.light .switch .slider { background: #cfd7e3; }
body.light .switch input:checked + .slider { background: var(--green); }

.starter-card { padding: 14px; margin-bottom: 10px; }
.starter-card .item-name { font-size: 13.5px; }
.starter-card .tag { margin-left: 0; }
.starter-card .tag.starter-tag { text-transform: none; letter-spacing: 0.01em; font-size: 9.5px; }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.admin-stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; }
.admin-stat span { font-size: 9.5px; color: var(--muted); display: block; }
.admin-stat b { font-size: 17px; font-weight: 700; display: block; margin-top: 3px; font-variant-numeric: tabular-nums; }
.admin-stat b.green { color: var(--green); }
.admin-stat b.gold { color: var(--gold); }

.admin-list { display: flex; flex-direction: column; gap: 7px; }
.admin-row { background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 10px 11px; }
.admin-row-top { display: flex; align-items: center; gap: 9px; }
.admin-row-main { flex: 1; min-width: 0; }
.admin-row-main b { display: block; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-row-main span { display: block; font-size: 9.5px; color: var(--muted); margin-top: 1px; }
.admin-row-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.admin-row-actions .btn { height: 27px; padding: 0 10px; font-size: 10px; }
.admin-row-actions select { height: 27px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-soft); font-size: 10px; padding: 0 6px; max-width: 132px; }

.admin-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 11.5px; border: 1px dashed var(--line); border-radius: 14px; }
.search-wrap { position: relative; margin-bottom: 9px; }
.search-wrap svg { position: absolute; left: 11px; top: 12px; width: 15px; height: 15px; color: var(--muted); }
.search-wrap input { padding-left: 34px; }

.form-note { font-size: 10px; color: var(--muted); margin: -4px 0 10px; }

/* ---------------------------- прочее ---------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 26px + var(--safe-b));
  transform: translate(-50%, 12px);
  z-index: 100;
  max-width: 330px;
  background: #f2f5f9;
  color: #08090c;
  border-radius: 14px;
  padding: 11px 15px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 16px 40px rgba(0,0,0,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #2a1416; color: #ffb4b4; border: 1px solid rgba(255,107,107,.3); }
body.light .toast { background: #0d1016; color: #fff; }

.loader { display: flex; justify-content: center; padding: 60px 0; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* нижний лист на десктопе */
@media (min-width: 520px) {
  .sheet { border-radius: 24px; bottom: 16px; border-bottom: 1px solid var(--line); }
  .sheet.open { transform: translateY(0); }
  .sheet { transform: translateY(calc(104% + 16px)); }
}

.hidden { display: none !important; }
[hidden] { display: none !important; }

@media (max-width: 520px) {
  .input, .field input, .field select, select.input, .chat-input input { font-size: 16px; }
}

@media (max-width: 365px) {
  .brand { display: none; }
  .user-name, .user-tag { max-width: 100%; }
  .balance-amount { font-size: 28px; }
  .topbar { gap: 8px; }
}
