[hidden] { display: none !important; }

:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --surface: var(--tg-theme-secondary-bg-color, #191c22);
  --surface-2: #212530;
  --text: var(--tg-theme-text-color, #f2f4f8);
  --muted: var(--tg-theme-hint-color, #8b93a4);
  --accent: var(--tg-theme-button-color, #4a8cff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --border: rgba(255, 255, 255, 0.08);
  --good: #34c77b;
  --warn: #ffb020;
  --bad: #ff5a5a;
  --radius: 14px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 78px;
}

/* -------------------------------------------------------------- boot --- */
.boot {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-shop { font-weight: 650; font-size: 16px; }
.topbar-user { color: var(--muted); font-size: 12.5px; }
.balance-chip {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
}

main { padding: 16px; }

/* ------------------------------------------------------------- cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 12px;
}
.card-tap { cursor: pointer; transition: transform 0.12s ease, border-color 0.12s ease; }
.card-tap:active { transform: scale(0.985); border-color: var(--accent); }

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 22px 0 10px;
  font-weight: 600;
}
.section-title:first-child { margin-top: 0; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.title { font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.price { font-weight: 700; color: var(--accent); white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ------------------------------------------------------------ badges --- */
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.good { background: rgba(52, 199, 123, 0.16); color: var(--good); }
.badge.warn { background: rgba(255, 176, 32, 0.16); color: var(--warn); }
.badge.bad  { background: rgba(255, 90, 90, 0.16); color: var(--bad); }

/* ----------------------------------------------------------- buttons --- */
button { font-family: inherit; font-size: 15px; }
.btn {
  width: 100%;
  border: 0;
  border-radius: 11px;
  padding: 13px 16px;
  font-weight: 650;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: rgba(255, 90, 90, 0.16); color: var(--bad); }
.btn-row { display: flex; gap: 9px; }
.btn-row .btn { width: auto; flex: 1; }

/* ------------------------------------------------------------ inputs --- */
.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 550;
}
input, textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 13px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ----------------------------------------------------------- tabbar --- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  background: none; border: 0; cursor: pointer;
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 10px;
  font-size: 11px;
  font-weight: 550;
}
.tab.active { color: var(--accent); }
.tab-icon { font-size: 19px; line-height: 1; }

/* --------------------------------------------------------- payment --- */
.pay-amount {
  font-size: 25px;
  font-weight: 700;
  text-align: center;
  padding: 6px 0 2px;
  word-break: break-all;
}
.copy-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  margin-top: 6px;
}
.copy-box code {
  flex: 1;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  word-break: break-all;
  color: var(--text);
}
.copy-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: 0; border-radius: 7px;
  padding: 6px 11px;
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.qr { display: block; margin: 12px auto 4px; background: #fff; padding: 9px; border-radius: 10px; }
.notice {
  background: rgba(255, 176, 32, 0.1);
  border: 1px solid rgba(255, 176, 32, 0.25);
  color: #ffce70;
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.55;
}
.notice ul { margin: 6px 0 0; padding-left: 18px; }

.delivered {
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 9px;
}

.empty { text-align: center; color: var(--muted); padding: 46px 20px; }
.empty-icon { font-size: 40px; display: block; margin-bottom: 10px; opacity: 0.6; }

.back {
  background: none; border: 0; color: var(--accent);
  padding: 0 0 12px; cursor: pointer; font-weight: 600; font-size: 14px;
}

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--border); }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 600; text-align: right; }

.toast {
  position: fixed; left: 50%; bottom: 92px;
  transform: translateX(-50%);
  background: #2a2f3a; color: #fff;
  padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 550;
  z-index: 100;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
  max-width: 88vw; text-align: center;
}
.toast.bad { background: #b3352f; }
