/* ──────────────────────────────────────────────────────────────
   Telegram Mini App — payout requests CRM
   Dark theme only. Tokens are seeded from Telegram theme params
   in app.js (window.__tgVars), with fallbacks below.
   ──────────────────────────────────────────────────────────── */

:root {
  /* Surface palette */
  --bg: #110b09;
  --surface-1: #2e2827;
  --surface-2: #413c3a;
  --surface-3: #544f4e;
  --hairline: rgba(255, 255, 255, 0.06);
  --hairline-strong: rgba(255, 255, 255, 0.10);

  /* Text */
  --text: #fbf5f2;
  --text-hint: #a18a82;
  --text-dim: #6e5e58;

  /* Accent — vermilion / red-orange */
  --accent: #ff5a3c;
  --accent-2: #ff8866;
  --accent-3: #d8341a;
  --accent-glow: rgba(255, 90, 60, 0.34);
  --accent-soft: rgba(255, 90, 60, 0.14);

  /* Status */
  --paid: #4ad48f;
  --paid-bg: rgba(74, 212, 143, 0.14);
  --failed: #f43f5e;
  --failed-bg: rgba(244, 63, 94, 0.14);
  --open: #fbbf24;
  --open-bg: rgba(251, 191, 36, 0.14);

  /* Geometry */
  --r-card: 18px;
  --r-input: 13px;
  --r-pill: 999px;
  --r-tile: 16px;

  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

/* Override Pico.css background/color tokens so our palette wins */
:root {
  --pico-background-color: var(--bg);
  --pico-color: var(--text);
  --pico-muted-color: var(--text-hint);
  --pico-primary: var(--accent);
  --pico-primary-hover: var(--accent-2);
  --pico-card-background-color: var(--surface-1);
  --pico-card-border-color: var(--hairline);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; background: var(--bg); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  /* Ambient accent wash from top */
  background-image:
    radial-gradient(80% 50% at 50% -10%, rgba(255, 90, 60, 0.20), transparent 70%),
    radial-gradient(60% 40% at 100% 0%, rgba(255, 138, 60, 0.10), transparent 70%),
    radial-gradient(60% 40% at 0% 100%, rgba(255, 60, 30, 0.08), transparent 70%);
  background-attachment: fixed;
}

button, input, textarea { font-family: inherit; color: inherit; }
input, textarea { -webkit-appearance: none; appearance: none; }
a { color: var(--accent); text-decoration: none; }

/* tabular numbers everywhere there's a digit-heavy element */
.num, .balance, .metric-value, .pill-count, .log-amount, .stat-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* ───────── App shell ───────── */
#app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 14px);
}

.view {
  padding: 18px 16px 8px;
  max-width: 720px;
  margin: 0 auto;
}

/* ───────── Page header ───────── */
.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding-top: 6px;
}
.page-head .titles { flex: 1; min-width: 0; }
.page-head h1 {
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.5px;
  font-weight: 800;
  margin: 0 0 2px;
  color: var(--text);
}
.page-head .sub {
  color: var(--text-hint);
  font-size: 13.5px;
  margin: 0;
}

/* avatar */
.avatar {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ff5a3c, #ffaa3c 85%);
  color: #fff;
  box-shadow:
    0 6px 20px rgba(255, 90, 60, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* ───────── Hero balance card ───────── */
.hero {
  position: relative;
  border-radius: var(--r-card);
  padding: 22px 20px 18px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-3) 100%);
  color: #fff;
  overflow: hidden;
  box-shadow:
    0 14px 38px rgba(255, 90, 60, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.20);
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 60% at 110% -10%, rgba(255, 255, 255, 0.22), transparent 60%),
    radial-gradient(45% 70% at -10% 110%, rgba(255, 255, 255, 0.10), transparent 60%);
  pointer-events: none;
}
.hero .label {
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.82;
  font-weight: 600;
  margin-bottom: 4px;
  position: relative;
}
.hero .balance {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1.02;
  margin: 2px 0 4px;
  position: relative;
}
.hero .balance .cents { font-size: 26px; opacity: 0.78; letter-spacing: -0.5px; }
.hero .balance-sub {
  font-size: 13px;
  opacity: 0.86;
  position: relative;
}
.hero .divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.22);
  margin: 16px -4px 14px;
  position: relative;
}
.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  position: relative;
}
.metric { min-width: 0; }
.metric-label {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.78;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-label .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  display: inline-block;
}
.metric-label.is-open .dot { background: #ffd98a; }
.metric-label.is-failed .dot { background: #ff9d9d; }
.metric-label.is-total .dot { background: rgba(255, 255, 255, 0.6); }
.metric-value {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* ───────── Quick actions ───────── */
.section-title {
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-hint);
  font-weight: 600;
  margin: 22px 4px 10px;
}

.qa-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.qa {
  border-radius: var(--r-tile);
  padding: 16px 14px 14px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 96px;
  color: var(--text);
}
.qa:hover { background: var(--surface-2); border-color: var(--hairline-strong); }
.qa:active { transform: scale(0.97); }
.qa-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text);
}
.qa-icon svg { width: 19px; height: 19px; }
.qa-title { font-weight: 650; font-size: 15px; line-height: 1.1; }
.qa-sub { font-size: 12.5px; color: var(--text-hint); line-height: 1.25; }

.qa.is-accent {
  background: linear-gradient(180deg, rgba(255,90,60,0.22), rgba(255,90,60,0.06));
  border-color: rgba(255, 90, 60, 0.36);
}
.qa.is-accent .qa-icon {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px var(--accent-glow);
}

/* ───────── Cards ───────── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 16px;
}
.card + .card { margin-top: 12px; }

/* ───────── Wallet card ───────── */
.wallet-card { padding: 14px 16px; }
.wallet-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wallet-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--accent-2);
  flex: 0 0 auto;
}
.wallet-icon svg { width: 18px; height: 18px; }
.wallet-input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font-family: var(--font-mono);
  font-size: 13.5px;
  letter-spacing: 0;
  color: var(--text);
  min-width: 0;
  padding: 6px 0;
}
.wallet-input::placeholder { color: var(--text-dim); }
.wallet-status {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.wallet-status.is-saved {
  color: var(--paid);
  background: var(--paid-bg);
}
.wallet-status.is-empty {
  color: var(--text-hint);
  background: var(--surface-3);
}
.wallet-hint {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--text-hint);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ───────── Settings-style link list ───────── */
.link-list {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  overflow: hidden;
}
.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  background: transparent;
  border: 0;
  width: 100%;
  color: inherit;
  text-align: left;
  transition: background 0.12s ease;
}
.link-row:hover { background: var(--surface-2); }
.link-row:active { transform: scale(0.99); }
.link-row + .link-row { border-top: 1px solid var(--hairline); }
.link-row .link-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-hint);
  flex: 0 0 auto;
}
.link-row .link-icon svg { width: 16px; height: 16px; }
.link-row .link-title { flex: 1; font-size: 14.5px; font-weight: 550; }
.link-row .chev { color: var(--text-dim); }

/* ───────── Search bar ───────── */
.search {
  position: relative;
  margin-bottom: 12px;
}
.search input {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-input);
  padding: 11px 14px 11px 40px;
  font-size: 14.5px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search input::placeholder { color: var(--text-dim); }
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.search-icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-hint);
  pointer-events: none;
}
.search-icon svg { width: 17px; height: 17px; display: block; }

/* ───────── Segmented control ───────── */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}
.segmented button {
  background: transparent;
  border: 0;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-hint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}
.segmented button.is-active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset;
}
.pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 700;
}
.segmented button.is-active .pill-count {
  background: var(--accent);
  color: #fff;
}

/* ───────── Log card ───────── */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.log {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 14px 16px 14px 18px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  text-align: left;
  width: 100%;
  color: inherit;
  display: block;
  overflow: hidden;
}
.log:hover { background: var(--surface-2); border-color: var(--hairline-strong); }
.log:active { transform: scale(0.985); }
.log .stripe {
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 4px;
  border-radius: 0 4px 4px 0;
}
.log.is-paid .stripe { background: var(--paid); box-shadow: 0 0 16px rgba(74,212,143,0.4); }
.log.is-failed .stripe { background: var(--failed); box-shadow: 0 0 16px rgba(244, 63, 94, 0.42); }
.log.is-open .stripe { background: var(--open); box-shadow: 0 0 16px rgba(251, 191, 36, 0.42); }

.log-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.log-user {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-hint);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}
.status-pill .sp-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-pill.is-paid { background: var(--paid-bg); color: var(--paid); }
.status-pill.is-paid .sp-dot { background: var(--paid); }
.status-pill.is-failed { background: var(--failed-bg); color: var(--failed); }
.status-pill.is-failed .sp-dot { background: var(--failed); }
.status-pill.is-open { background: var(--open-bg); color: var(--open); }
.status-pill.is-open .sp-dot { background: var(--open); }

.log-amount {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin: 2px 0 8px;
}
.log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.meta-pill {
  font-size: 11.5px;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta-pill .meta-k {
  color: var(--text-hint);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.log-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.log-foot .date { color: var(--text-hint); }
.log-foot .id { font-family: var(--font-mono); }

/* ───────── Detail screen ───────── */
.detail .hero-detail {
  position: relative;
  border-radius: var(--r-card);
  padding: 20px 18px 22px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-3) 100%);
  color: #fff;
  overflow: hidden;
  box-shadow:
    0 14px 38px rgba(255, 90, 60, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.20);
  margin-bottom: 16px;
}
.detail .hero-detail::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 60% at 110% -10%, rgba(255, 255, 255, 0.22), transparent 60%);
  pointer-events: none;
}
.hero-detail .row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  position: relative;
}
.hero-detail .id-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  backdrop-filter: blur(4px);
}
.hero-detail .status-pill {
  background: rgba(255, 255, 255, 0.22) !important;
  color: #fff !important;
}
.hero-detail .status-pill .sp-dot {
  background: #fff !important;
  box-shadow: 0 0 8px #fff;
}
.hero-detail .user-mono {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
  position: relative;
  margin-bottom: 2px;
}
.hero-detail .amount {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1.02;
  margin: 4px 0 6px;
  position: relative;
}
.hero-detail .amount .cents { font-size: 26px; opacity: 0.78; }
.hero-detail .submeta {
  font-size: 12.5px;
  font-family: var(--font-mono);
  opacity: 0.88;
  position: relative;
}

/* key-value list */
.kv-list {
  display: flex;
  flex-direction: column;
}
.kv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  font-size: 14px;
}
.kv-row + .kv-row { border-top: 1px solid var(--hairline); }
.kv-row .k {
  color: var(--text-hint);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: 0 0 86px;
}
.kv-row .v {
  flex: 1;
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 13px;
}
.kv-row .v.link { color: var(--accent-2); }
.kv-row .v.plain { font-family: var(--font-sans); font-size: 14px; }

/* preformatted log text */
.code-block {
  background: #06090e;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #d6dde8;
  max-height: 240px;
  overflow: auto;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

/* submitter card */
.submitter {
  display: flex;
  align-items: center;
  gap: 12px;
}
.submitter .avatar { width: 38px; height: 38px; font-size: 13px; }
.submitter .who { flex: 1; min-width: 0; }
.submitter .who .name { font-weight: 650; font-size: 14.5px; }
.submitter .who .uname { font-size: 12.5px; color: var(--text-hint); font-family: var(--font-mono); }
.submitter-wallet {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 8px;
}
.submitter-wallet .icon { color: var(--accent-2); }
.submitter-foot {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.not-in-bot {
  font-size: 11px;
  color: var(--open);
  opacity: 0.8;
}

/* note textarea */
.note-area {
  width: 100%;
  background: #06090e;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  min-height: 92px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: var(--font-sans);
}
.note-area:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.note-foot {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
}

/* status change buttons */
.status-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.status-btn {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--hairline);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
  background: var(--surface-1);
  color: var(--text);
}
.status-btn:active { transform: scale(0.97); }
.status-btn.paid {
  background: linear-gradient(180deg, rgba(74, 212, 143, 0.22), rgba(74, 212, 143, 0.08));
  border-color: rgba(74, 212, 143, 0.4);
  color: var(--paid);
}
.status-btn.failed {
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.22), rgba(244, 63, 94, 0.08));
  border-color: rgba(244, 63, 94, 0.42);
  color: var(--failed);
}
.status-btn.open {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.22), rgba(251, 191, 36, 0.08));
  border-color: rgba(251, 191, 36, 0.42);
  color: var(--open);
}
.status-btn.is-current {
  opacity: 0.55;
  cursor: default;
}
.status-btn.is-current::after {
  content: "текущий";
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-left: 4px;
}

/* ───────── Empty / skeleton states ───────── */
.empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-hint);
}
.empty .empty-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  margin: 0 auto 14px;
  color: var(--text-dim);
}
.empty .empty-icon svg { width: 24px; height: 24px; }
.empty .empty-title { font-size: 15px; font-weight: 650; color: var(--text); margin-bottom: 4px; }
.empty .empty-sub { font-size: 13px; }

.skel {
  background: linear-gradient(
    90deg,
    var(--surface-1) 0%,
    var(--surface-2) 50%,
    var(--surface-1) 100%
  );
  background-size: 200% 100%;
  animation: skelShimmer 1.6s ease-in-out infinite;
  border-radius: 10px;
}
@keyframes skelShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-card {
  height: 110px;
  border-radius: var(--r-card);
  border: 1px solid var(--hairline);
}
.skel-stack { display: flex; flex-direction: column; gap: 10px; }
.skel-hero { height: 188px; border-radius: var(--r-card); border: 1px solid var(--hairline); }

/* ───────── Bottom tab bar ───────── */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: grid;
  align-items: end;
  padding: 6px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(17, 11, 9, 0.70);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--hairline);
}
.tabbar.is-user  { grid-template-columns: 1fr 76px 1fr; }
.tabbar.is-admin { grid-template-columns: 1fr 1fr 76px 1fr; }

.tabbar button {
  background: transparent;
  border: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 4px;
  cursor: pointer;
  color: var(--text-hint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.15s ease, transform 0.12s ease;
  min-height: 48px;
}
.tabbar button:active { transform: scale(0.92); }
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.is-active { color: var(--accent); }

/* FAB */
.tabbar .fab-slot {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  height: 64px;
}
.fab {
  position: absolute;
  top: -22px;
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.2, 1);
  isolation: isolate;
}
.fab:active { transform: scale(0.93); }

/* outer halo + glow ring */
.fab::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 65%);
  z-index: -2;
  opacity: 0.85;
  filter: blur(2px);
}
.fab .fab-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(
    from 220deg,
    rgba(255, 255, 255, 0.0) 0deg,
    var(--accent-2) 60deg,
    var(--accent) 180deg,
    var(--accent-3) 300deg,
    rgba(255, 255, 255, 0.0) 360deg
  );
  opacity: 0.85;
  z-index: -1;
  animation: fabSpin 6s linear infinite;
}
@keyframes fabSpin { to { transform: rotate(360deg); } }

.fab .fab-core {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--accent-2) 0%, var(--accent) 55%, var(--accent-3) 100%);
  display: grid; place-items: center;
  color: #fff;
  box-shadow:
    0 12px 28px var(--accent-glow),
    0 2px 6px rgba(255, 90, 60, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}
.fab .fab-core::after {
  /* glossy top highlight */
  content: "";
  position: absolute;
  top: 4px; left: 12px; right: 12px;
  height: 16px;
  border-radius: 50% / 80%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.fab svg {
  width: 24px; height: 24px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.15));
}
.fab:hover .fab-core { filter: brightness(1.05); }

/* ───────── Telegram simulator chrome (only in preview shell) ───────── */
.tg-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(17, 11, 9, 0.86);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--hairline);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.tg-header .tg-back {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: transparent;
  border: 0;
  color: var(--text-hint);
  cursor: pointer;
}
.tg-header .tg-back.is-hidden { visibility: hidden; }
.tg-header .tg-title { flex: 1; }
.tg-header .tg-dots {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--text-hint);
}

/* ───────── Telegram MainButton (DOM fallback when shim is active) ───────── */
.tg-main-button {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 70;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(17, 11, 9, 0.70);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--hairline);
  transform: translateY(110%);
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.tg-main-button.is-visible { transform: translateY(0); }
.tg-main-button button {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 0;
  background: var(--tg-button-color, var(--accent));
  color: var(--tg-button-text-color, #fff);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, filter 0.15s ease;
  box-shadow: 0 8px 28px var(--accent-glow);
}
.tg-main-button button:active { transform: scale(0.98); }
.tg-main-button button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.tg-main-button .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* When MainButton is visible, push the tabbar up */
.has-main-btn .tabbar { transform: translateY(110%); }
.has-main-btn #app { padding-bottom: 80px; }
.tabbar { transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1); }

/* ───────── Telegram-native popup shim ───────── */
.tg-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease-out;
}
.tg-popup-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.tg-popup {
  width: 100%;
  max-width: 300px;
  background: #1d2733;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: scale(0.94);
  transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.tg-popup-overlay.is-visible .tg-popup { transform: scale(1); }
.tg-popup-body {
  padding: 18px 18px 16px;
  text-align: center;
}
.tg-popup-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text);
}
.tg-popup-msg {
  font-size: 13.5px;
  color: #c5cdd9;
  margin: 0;
  line-height: 1.45;
  white-space: pre-line;
}
.tg-popup-actions {
  display: flex;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.tg-popup-actions button {
  flex: 1;
  padding: 13px 12px;
  background: transparent;
  border: 0;
  font-size: 15px;
  color: var(--accent-2);
  cursor: pointer;
  font-weight: 600;
}
.tg-popup-actions button:active { background: rgba(255,255,255,0.05); }
.tg-popup-actions button + button { border-left: 1px solid rgba(255,255,255,0.08); }
.tg-popup-actions button.is-destructive { color: var(--failed); }
.tg-popup-actions button.is-default { font-weight: 700; }

/* Utility */
.spacer-12 { height: 12px; }
.spacer-20 { height: 20px; }
.no-scroll { overflow: hidden; }
