[hidden] { display: none !important; }
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f2f6);
  --text: var(--tg-theme-text-color, #111418);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #e5484d;
  --ok: #2fb35f;
  --line: rgba(127, 127, 127, .18);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #17191d; --bg2: #0f1013; --text: #f2f3f5; --hint: #8b919b;
    --link: #5aa9f0; --btn: #3a8ee6;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg2); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg); width: 100%;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none;
}
input:focus, textarea:focus { border-color: var(--btn); }
textarea { resize: vertical; min-height: 64px; }

#topbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line);
}
#topbar h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#who { font-size: 12px; color: var(--hint); }
.icon-btn { font-size: 30px; line-height: 1; padding: 0 8px 4px 0; color: var(--link); }

#view { flex: 1; padding: 12px 16px calc(180px + env(safe-area-inset-bottom)); }

#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: var(--bg);
  display: flex; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  max-width: 560px; margin: 0 auto;
}
#tabs button { flex: 1; min-height: 78px; padding: 10px 2px 12px; font-size: 14px; color: var(--hint); position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; }
#tabs button .ti { font-size: 26px; filter: grayscale(1); opacity: .7; }
#tabs button.on { color: var(--btn); font-weight: 600; }
#tabs button.on .ti { filter: none; opacity: 1; }
#cartBadge {
  position: absolute; top: 2px; left: 50%; margin-left: 8px; background: var(--danger); color: #fff;
  font-size: 11px; border-radius: 10px; padding: 0 6px; min-width: 18px; line-height: 18px;
}

#cartbar {
  position: fixed; left: 0; right: 0; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 6; padding: 8px 16px;
  max-width: 560px; margin: 0 auto;
}

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: var(--btn); color: var(--btn-text); border-radius: 12px; padding: 14px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.btn.big { padding: 16px; font-size: 17px; }
.btn.sec { background: var(--bg); color: var(--link); box-shadow: none; border: 1px solid var(--line); }
.btn.ok { background: var(--ok); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); box-shadow: none; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.mt { margin-top: 12px; } .mt2 { margin-top: 20px; }
.hint { color: var(--hint); font-size: 13px; }
.center { text-align: center; }

.card { background: var(--bg); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin: 18px 4px 8px; }
.list { background: var(--bg); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 500; }
.item .s { font-size: 13px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.item:active { background: var(--bg2); }
.chev { color: var(--hint); font-size: 20px; }

.search { position: sticky; top: 53px; z-index: 4; background: var(--bg2); padding: 4px 0 8px; margin: 0 -2px; }
.search input { font-size: 18px; padding: 14px 16px; border-radius: 14px; }
.search.phone input { font-size: 22px; letter-spacing: .03em; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; padding: 7px 12px; border-radius: 20px; background: var(--bg); font-size: 14px; border: 1px solid var(--line); }
.chip.on { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }

.prod .price { font-weight: 600; white-space: nowrap; text-align: right; }
.prod .price small { display: block; font-weight: 400; color: var(--hint); font-size: 11px; }
.add { width: 38px; height: 38px; border-radius: 50%; background: var(--btn); color: var(--btn-text); font-size: 22px; flex: 0 0 auto; }
.stepper { display: flex; align-items: center; background: var(--bg2); border-radius: 20px; flex: 0 0 auto; }
.stepper button { width: 36px; height: 36px; font-size: 20px; color: var(--link); }
.stepper input { width: 46px; text-align: center; padding: 4px 0; border: 0; background: transparent; font-weight: 600; }

.phone-big { font-size: 24px; font-weight: 700; letter-spacing: .02em; }
.addr { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.addr:last-child { border-bottom: 0; }
.addr input[type=radio], .chk { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; accent-color: var(--btn); }

.order-card .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.mnum { font-weight: 800; font-size: 18px; color: var(--btn); }
.order-card ul { margin: 6px 0; padding: 0; list-style: none; font-size: 14px; }
.order-card li { padding: 2px 0; display: flex; gap: 8px; }
.order-card li span:first-child { flex: 1; }
.total { font-weight: 700; }
.copy-btn { padding: 6px 12px; border-radius: 10px; background: var(--bg2); color: var(--link); font-size: 14px; font-weight: 500; }

.empty { text-align: center; color: var(--hint); padding: 40px 20px; }
.empty .e { font-size: 48px; margin-bottom: 8px; }
.banner { background: #fff4d6; color: #6b4e00; border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.success { text-align: center; padding: 30px 10px 10px; }
.success .e { font-size: 64px; }
.success .m { font-size: 40px; font-weight: 800; color: var(--btn); }

#toast {
  position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%) translateY(20px);
  background: rgba(20,20,20,.9); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 20; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.lock { text-align: center; padding: 60px 20px; }
.lock .e { font-size: 60px; }
code.id { font-size: 22px; background: var(--bg); padding: 6px 12px; border-radius: 8px; display: inline-block; margin: 10px 0; }
.stock { font-size: 13px; font-weight: 600; margin-top: 4px; }
.stock.available { color: var(--ok); }
.stock.unavailable { color: var(--danger); }
.product-grid { display: grid; gap: 10px; }
.live-product { display: block; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); }
.live-product:last-child { border-bottom: 1px solid var(--line); }
.live-product .t { font-size: 16px; line-height: 1.35; font-weight: 650; overflow-wrap: anywhere; }
.live-product .s { margin-top: 3px; white-space: normal; line-height: 1.35; overflow-wrap: anywhere; }
.live-product .stock { display: inline-flex; align-items: center; gap: 6px; margin-top: 9px; padding: 3px 8px; border-radius: 6px; font-size: 12px; line-height: 18px; font-weight: 500; }
.live-product .stock::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.live-product .stock.available { background: rgba(47,179,95,.10); }
.live-product .stock.unavailable { background: rgba(229,72,77,.09); }
.product-purchase { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.live-product .price { font-size: 21px; line-height: 1.25; text-align: left; }
.live-product .price-unit { color: var(--hint); font-size: 12px; font-weight: 400; }
.live-product .price small { margin-top: 5px; font-size: 12px; line-height: 1.4; white-space: normal; }
.live-product .price small b { font-weight: 500; }
.live-product .stepper { height: 42px; margin: 0; border: 1px solid var(--line); border-radius: 12px; }
.live-product .stepper button { width: 38px; height: 40px; font-size: 23px; }
.live-product .stepper input { width: 38px; font-size: 16px; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input { -moz-appearance: textfield; }
.product-actions { display: flex; gap: 8px; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
.product-actions button { flex: 1; min-width: 0; min-height: 40px; padding: 8px 6px; border-radius: 9px; background: var(--bg2); color: var(--link); font-size: 13px; line-height: 1.25; }
.product-actions button:active { opacity: .7; }
@media (max-width: 350px) {
  .live-product { padding: 12px; }
  .product-purchase { gap: 8px; }
  .live-product .price { font-size: 19px; }
}
form label { display: block; margin-bottom: 12px; }
.role-picker { margin-top: 10px; }
.role-picker summary { display: block; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); color: var(--link); cursor: pointer; min-height: 48px; list-style: none; }
.role-picker summary::-webkit-details-marker { display: none; }
.role-options { display: grid; gap: 6px; margin-top: 8px; }
.role-options button { padding: 14px; min-height: 48px; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); }
.role-options button[aria-pressed="true"] { border-color: var(--btn); color: var(--link); font-weight: 600; }
.user-access .row { flex-wrap: wrap; }
.user-access .row .btn { min-width: 130px; font-size: 14px; }
