:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2f6ffe);
  --accent: #2f6ffe;
  --accent-text: #fff;
  --line: rgba(127, 127, 127, .18);
  --ok: #1f9d55; --warn: #d97706; --err: #d64545;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg2); color: var(--text); font: 14px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.view { display: none; min-height: 100vh; }
.view.active { display: block; }
.small { font-size: 12px; color: var(--hint); }
.btn { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; }
.link { background: none; border: 0; color: var(--link); }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 12px 6px; box-shadow: 0 1px 0 var(--line); }
.search { display: flex; align-items: center; gap: 6px; background: var(--search, var(--bg2)); border-radius: 12px; padding: 0 10px; }
.search input { border: 0; background: none; padding: 10px 0; }
.crumbs { font-size: 12px; color: var(--hint); margin: 6px 2px 0; display: flex; gap: 4px; flex-wrap: wrap; }
.crumbs a { color: var(--link); text-decoration: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); background: var(--bg); border-radius: 16px; padding: 6px 12px; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip small { opacity: .6; margin-left: 4px; }
.banner { margin: 10px 12px 0; border-radius: 14px; overflow: hidden; }
.banner img { width: 100%; display: block; }
.closed { background: #fff4e5; color: #9a5b00; padding: 10px 12px; border-radius: 12px; margin-bottom: 8px; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 10px; }
.card { background: var(--bg); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.card .img { aspect-ratio: 1; background: var(--bg2) center/cover no-repeat; display: grid; place-items: center; font-size: 34px; color: var(--hint); }
.card .b { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .n { font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 34px; }
.price { font-weight: 700; }
.price.big { font-size: 22px; margin: 8px 0; }
.stock { font-size: 11px; color: var(--ok); }
.stock.low { color: var(--warn); } .stock.no { color: var(--err); }
.card .add { margin-top: auto; border: 0; background: var(--accent); color: var(--accent-text); border-radius: 9px; padding: 7px; font-weight: 600; }
.card .add.in { background: var(--bg2); color: var(--text); }
.more { height: 40px; }
.empty { text-align: center; color: var(--hint); padding: 40px 0; }

.head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--bg); padding: 10px 12px; box-shadow: 0 1px 0 var(--line); }
.head h1 { font-size: 17px; margin: 0; flex: 1; }
.back { border: 0; background: none; font-size: 26px; line-height: 1; padding: 0 6px; color: var(--link); }
.box { background: var(--bg); margin: 10px; border-radius: 14px; padding: 12px; }
.box.warn { border: 1px solid var(--warn); display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; justify-content: space-between; padding: 4px 0; }
.row.total { font-size: 17px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.lbl { font-weight: 600; margin: 10px 0 6px; }
.lbl:first-child { margin-top: 0; }
.seg { display: flex; background: var(--bg2); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 8px; }
.seg button.on { background: var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.promo { display: flex; gap: 6px; }
.promo button { border: 1px solid var(--accent); color: var(--accent); background: none; border-radius: 10px; padding: 0 12px; }

.ci { display: flex; gap: 10px; background: var(--bg); margin: 10px; border-radius: 14px; padding: 10px; align-items: center; }
.ci .img { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 10px; background: var(--bg2) center/cover no-repeat; display: grid; place-items: center; color: var(--hint); }
.ci .info { flex: 1; min-width: 0; }
.ci .n { font-size: 13px; }
.qty { display: inline-flex; align-items: center; background: var(--bg2); border-radius: 10px; }
.qty button { border: 0; background: none; width: 34px; height: 34px; font-size: 18px; }
.qty input { width: 48px; text-align: center; border: 0; background: none; padding: 0; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; }

.order { background: var(--bg); margin: 10px; border-radius: 14px; padding: 12px; }
.order .st { display: inline-block; border-radius: 8px; padding: 2px 8px; font-size: 12px; color: #fff; margin-top: 4px; }

.sheetBg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; }
.sheetBg[hidden] { display: none; }
.sheet { background: var(--bg); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; }
.sheetImg { aspect-ratio: 1.2; background: var(--bg2) center/contain no-repeat; display: grid; place-items: center; font-size: 60px; color: var(--hint); }
.sheetBody { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheetBody h2 { font-size: 18px; margin: 0 0 4px; }
.desc { white-space: pre-wrap; color: var(--hint); font-size: 13px; margin-bottom: 12px; }
.sheetAct { display: flex; gap: 10px; align-items: center; }
.sheetAct .btn { flex: 1; }

.done { text-align: center; padding: 70px 24px; }
.done .big { font-size: 64px; }
.done h1 { font-size: 20px; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--bg); box-shadow: 0 -1px 0 var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; border: 0; background: none; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; font-size: 18px; position: relative; color: var(--hint); }
.tabbar button span { font-size: 11px; }
.tabbar button.on { color: var(--accent); }
.tabbar b { position: absolute; top: 4px; left: 55%; background: var(--err); color: #fff; border-radius: 9px; font-size: 10px; padding: 0 5px; }
/* ---------- Kabinet (bosh menyu va bo'limlar) ---------- */
.appbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; background: var(--bg); padding: 10px 14px; box-shadow: 0 1px 0 var(--line); }
.abName { flex: 1; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abIcon { position: relative; border: 0; background: none; width: 40px; height: 40px; display: grid; place-items: center; padding: 0; }
.abIcon svg, .mic svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.abIcon b { position: absolute; top: 2px; right: 0; background: var(--err); color: #fff; border-radius: 9px; font-size: 10px; padding: 0 5px; }
.abAva { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.who { display: flex; flex-direction: column; padding: 12px 18px 0; }
.who:empty { display: none; }
.menu { background: var(--bg); margin: 12px; border-radius: 18px; border: 1px solid var(--line); overflow: hidden; }
.mi { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; padding: 12px 14px; text-align: left; border-top: 1px solid var(--line); }
.mi:first-child { border-top: 0; }
.mi:active { background: var(--bg2); }
.mic { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 12px; background: var(--bg2); display: grid; place-items: center; }
.mit { flex: 1; font-size: 16px; }
.mia { color: var(--hint); font-size: 22px; }
.pbar { position: sticky; top: 50px; z-index: 4; background: var(--bg2); padding: 2px 10px 0; }
.dates { display: flex; gap: 6px; align-items: center; padding-bottom: 6px; }
.dates input { padding: 8px; }
.dates .btn { padding: 9px 12px; }
.bcard { margin: 10px; border-radius: 16px; padding: 16px; color: #fff; background: var(--accent); }
.bcard.debt { background: linear-gradient(135deg, #d64545, #b83232); }
.bcard.ok { background: linear-gradient(135deg, #1f9d55, #17804a); }
.bcard .small { color: rgba(255,255,255,.85); }
.bcard .bv { font-size: 28px; font-weight: 800; margin-top: 4px; }
.ctiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 10px; }
.ctile { background: var(--bg); border: 0; border-radius: 14px; padding: 12px; text-align: left; min-width: 0; }
.ctile .cv { font-size: 18px; font-weight: 700; margin: 4px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dr { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); cursor: pointer; }
.box .dr:first-of-type, .box .lbl + .dr { border-top: 0; }
.dr > div:first-child { min-width: 0; }
.dr b { white-space: nowrap; }
.dr > div:first-child b { white-space: normal; }
.dr .r { text-align: right; flex-shrink: 0; }
.sumbox { display: flex; justify-content: space-between; align-items: center; }
.neg { color: var(--err); }
.pos { color: var(--ok); }
.btn.wide { width: 100%; margin-top: 10px; }
#toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: rgba(0,0,0,.8); color: #fff; padding: 9px 14px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 30; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }
