:root {
  color-scheme: dark;
  --bg: var(--tg-theme-bg-color, #07111d);
  --surface: var(--tg-theme-secondary-bg-color, #152638);
  --surface-2: #1d3043;
  --text: var(--tg-theme-text-color, #f6f8fb);
  --muted: var(--tg-theme-hint-color, #8fa5b8);
  --accent: var(--tg-theme-button-color, #2f7e9e);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #ff7b7b;
  --line: rgba(255, 255, 255, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top, #15283a 0, var(--bg) 38%); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(760px, 100%); margin: 0 auto; padding: 14px 12px calc(36px + env(safe-area-inset-bottom)); }
.hero { display: flex; justify-content: space-between; gap: 16px; align-items: center; background: rgba(21, 38, 56, .88); border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.22); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 22px; }
h2 { margin-bottom: 0; font-size: 21px; }
.hero p { color: var(--muted); margin-bottom: 0; }
.eyebrow { color: #83bfd7; font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; margin-bottom: 4px; }
.balance-card { min-width: 116px; background: rgba(7,17,29,.55); border: 1px solid var(--line); border-radius: 16px; padding: 12px; text-align: right; }
.balance-card span { color: var(--muted); font-size: 12px; }
.balance-card strong { display: block; color: var(--text); font-size: 20px; margin-top: 4px; }
.menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; margin: 8px 0 14px; }
.menu-button { min-height: 46px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font-weight: 760; }
.menu-button.primary, .menu-button.full { grid-column: 1 / -1; }
.menu-button.primary { background: var(--accent); color: var(--accent-text); }
.menu-button:active { transform: translateY(1px); }
.panel { display: none; background: rgba(12, 26, 40, .76); border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.panel.active { display: block; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ghost-button { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; }
.product-list, .order-list { display: grid; gap: 10px; }
.product-card, .order-card, .info-card { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 14px; }
.product-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; }
.product-card h3 { margin: 0 0 5px; font-size: 17px; }
.product-card p, .order-card p { color: var(--muted); margin: 0; line-height: 1.45; }
.price { margin-top: 9px; font-weight: 850; }
.stock { color: #8bd3ad; font-size: 12px; margin-left: 6px; }
.buy-button { border: 0; border-radius: 11px; background: var(--accent); color: var(--accent-text); padding: 11px 15px; font-weight: 800; }
.buy-button:disabled { opacity: .55; cursor: wait; }
.order-card { display: grid; gap: 6px; }
.order-head { display: flex; justify-content: space-between; gap: 12px; }
.status-delivered { color: #8bd3ad; }
.status-failed { color: var(--danger); }
.skeleton { color: var(--muted); padding: 20px 4px; text-align: center; }
dialog { border: 0; padding: 0; width: min(520px, calc(100% - 24px)); background: transparent; color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .7); backdrop-filter: blur(5px); }
.dialog-card { position: relative; background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 20px; box-shadow: 0 26px 80px rgba(0,0,0,.42); }
.dialog-close { position: absolute; right: 12px; top: 9px; border: 0; background: transparent; color: var(--muted); font-size: 28px; }
pre { white-space: pre-wrap; word-break: break-word; background: #07111d; border-radius: 12px; padding: 13px; color: #e9f5ff; max-height: 40vh; overflow: auto; }
label { display: grid; gap: 6px; color: var(--muted); margin: 14px 0; }
input { width: 100%; border: 1px solid var(--line); background: #07111d; color: var(--text); border-radius: 10px; padding: 11px; }
#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(30px); background: #f6f8fb; color: #07111d; border-radius: 999px; padding: 10px 14px; opacity: 0; pointer-events: none; transition: .2s ease; font-weight: 750; z-index: 10; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 480px) {
  .hero { align-items: stretch; }
  .balance-card { min-width: 100px; }
  .product-card { grid-template-columns: 1fr; }
  .buy-button { width: 100%; }
}
