:root {
  --bg: var(--tg-theme-bg-color, #0f1720);
  --panel: var(--tg-theme-secondary-bg-color, #182431);
  --panel-2: #213141;
  --text: var(--tg-theme-text-color, #f5f7fa);
  --muted: var(--tg-theme-hint-color, #8fa1b3);
  --accent: var(--tg-theme-button-color, #2f80c4);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(255,255,255,.08);
  --danger: #ff7474;
  --ok: #5fd19a;
  --shadow: 0 20px 60px rgba(0,0,0,.32);
}
* { box-sizing: border-box; }
html, body { margin:0; min-height:100%; background:var(--bg); color:var(--text); font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif; }
body { padding:0 0 calc(94px + env(safe-area-inset-bottom)); }
button,input,textarea { font:inherit; }
button { -webkit-tap-highlight-color:transparent; }
.app-shell { max-width:760px; margin:0 auto; padding:18px 14px 20px; }
.topbar { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:3px 2px 16px; }
h1,h2 { margin:0; letter-spacing:-.02em; }
h1 { font-size:26px; }
h2 { font-size:24px; }
.eyebrow { color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.08em; margin-bottom:5px; }
.test-pill { font-weight:800; font-size:11px; letter-spacing:.08em; color:#ffd76d; border:1px solid rgba(255,215,109,.4); background:rgba(255,215,109,.09); padding:7px 9px; border-radius:999px; }
.search-wrap { position:relative; display:flex; align-items:center; background:var(--panel); border:1px solid var(--line); border-radius:16px; min-height:54px; box-shadow:0 8px 25px rgba(0,0,0,.13); }
.search-icon { width:44px; text-align:center; color:var(--muted); font-size:25px; transform:rotate(-15deg); }
.search-wrap input { flex:1; height:52px; border:0; outline:0; background:transparent; color:var(--text); padding:0 8px 0 0; font-size:17px; min-width:0; }
.search-wrap input::placeholder { color:var(--muted); }
.icon-btn { width:40px; height:40px; border:0; border-radius:12px; background:transparent; color:var(--muted); font-size:26px; cursor:pointer; }
.tabs { display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px; margin:12px 0 14px; }
.tab { border:0; border-radius:12px; color:var(--muted); background:transparent; padding:10px 8px; font-weight:650; cursor:pointer; }
.tab.active { color:var(--text); background:var(--panel); }

.category-breadcrumb { display:flex; align-items:center; gap:8px; margin-bottom:10px; min-height:38px; }
.category-back { border:1px solid var(--line); background:var(--panel); color:var(--text); border-radius:11px; padding:8px 11px; cursor:pointer; }
.category-path { min-width:0; color:var(--muted); font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.category-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.category-card { min-height:92px; text-align:left; border:1px solid var(--line); background:var(--panel); color:var(--text); border-radius:16px; padding:14px; cursor:pointer; box-shadow:0 8px 24px rgba(0,0,0,.10); }
.category-card-name { font-size:18px; font-weight:800; line-height:1.2; margin-bottom:7px; }
.category-card-meta { font-size:12px; color:var(--muted); line-height:1.35; }

.product-list { display:flex; flex-direction:column; gap:9px; }
.product-card { background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:13px; display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px; align-items:center; }
.product-main { min-width:0; }
/* +30% относительно v0.1: 12→16 и 16→21 */
.product-card .line-name { font-size:16px; color:var(--muted); margin-bottom:5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.product-card .product-name { font-size:21px; font-weight:760; line-height:1.18; }
.availability { display:inline-flex; align-items:center; gap:5px; margin-top:7px; font-size:12px; color:var(--ok); }
.availability.off { color:var(--muted); }
.controls { display:flex; flex-direction:column; align-items:flex-end; gap:8px; }
.fav-btn { width:34px; height:30px; border:0; background:transparent; color:#9cacbb; font-size:23px; cursor:pointer; }
.fav-btn.active { color:#ffd15f; }
.qty-box { display:flex; align-items:center; background:var(--panel-2); border-radius:12px; overflow:hidden; min-height:38px; }
.qty-btn { width:38px; height:38px; border:0; background:transparent; color:var(--text); font-size:20px; cursor:pointer; }
.qty-btn:disabled { color:#526170; cursor:default; }
.qty-value { width:35px; text-align:center; font-weight:750; font-variant-numeric:tabular-nums; }
.quick-row { display:flex; gap:4px; }
.quick-btn { border:0; background:rgba(47,128,196,.18); color:#9fd0fb; border-radius:9px; padding:5px 7px; font-size:11px; font-weight:700; cursor:pointer; }
.status { padding:10px 12px; border-radius:12px; background:var(--panel); color:var(--muted); margin-bottom:10px; font-size:13px; }
.empty { min-height:210px; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; color:var(--muted); gap:6px; padding:30px; }
.empty strong { color:var(--text); }
.empty-icon { font-size:40px; opacity:.5; }
.cart-bar { position:fixed; z-index:20; left:50%; transform:translateX(-50%); bottom:calc(12px + env(safe-area-inset-bottom)); width:min(calc(100% - 28px),732px); min-height:58px; border:0; border-radius:17px; background:var(--accent); color:var(--accent-text); display:flex; align-items:center; justify-content:space-between; padding:0 18px; font-weight:750; font-size:16px; box-shadow:var(--shadow); cursor:pointer; }
.sheet-backdrop { position:fixed; z-index:50; inset:0; background:rgba(0,0,0,.55); display:flex; align-items:flex-end; justify-content:center; }
.sheet { width:min(100%,760px); max-height:92vh; overflow:auto; background:var(--bg); border-radius:24px 24px 0 0; padding:9px 14px calc(18px + env(safe-area-inset-bottom)); box-shadow:var(--shadow); }
.sheet-handle { width:44px; height:5px; border-radius:99px; background:#667684; margin:0 auto 11px; opacity:.55; }
.sheet-head { display:flex; align-items:center; justify-content:space-between; position:sticky; top:-9px; background:var(--bg); padding:8px 0 11px; z-index:2; }
.cart-list { display:flex; flex-direction:column; gap:13px; }
.cart-group { display:flex; flex-direction:column; gap:7px; }
.cart-group-title { display:flex; align-items:center; gap:8px; padding:2px 2px 1px; font-size:16px; font-weight:820; }
.cart-group-count { color:var(--muted); font-size:11px; font-weight:650; }
.cart-row { background:var(--panel); border-radius:14px; padding:11px 12px; display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px; align-items:center; }
.cart-product-top { display:flex; flex-wrap:wrap; align-items:center; gap:7px; margin-bottom:3px; }
.cart-row .product-name { font-size:17px; font-weight:750; line-height:1.2; }
.weight-badge { display:inline-flex; align-items:center; justify-content:center; min-width:46px; padding:4px 8px; border:1px solid rgba(159,208,251,.45); background:rgba(47,128,196,.14); color:#b9dcfb; border-radius:8px; font-size:12px; font-weight:850; white-space:nowrap; }
.checkout-block { border-top:1px solid var(--line); margin-top:14px; padding-top:14px; display:flex; flex-direction:column; gap:13px; }
label { display:flex; flex-direction:column; gap:6px; font-size:13px; font-weight:650; }
input,textarea { width:100%; border:1px solid var(--line); border-radius:12px; background:var(--panel); color:var(--text); padding:12px; outline:none; }
textarea { resize:vertical; }
.payment-fieldset { margin:0; padding:0; border:0; display:flex; flex-direction:column; gap:8px; }
.payment-fieldset legend { font-size:13px; font-weight:750; margin-bottom:7px; }
.required { color:var(--danger); }
.payment-option { display:grid; grid-template-columns:auto 1fr; align-items:center; gap:10px; background:var(--panel); border:1px solid var(--line); border-radius:13px; padding:11px 12px; cursor:pointer; }
.payment-option:has(input:checked) { border-color:rgba(47,128,196,.72); background:rgba(47,128,196,.13); }
.payment-option input { width:18px; height:18px; margin:0; accent-color:var(--accent); }
.field-help,.comment-hint { color:var(--muted); font-size:11px; font-weight:500; }
.comment-hint { margin-top:1px; }
.primary-btn { border:0; border-radius:14px; min-height:52px; background:var(--accent); color:var(--accent-text); font-weight:800; cursor:pointer; }
.primary-btn:disabled { opacity:.5; cursor:default; }
.muted,.fineprint { color:var(--muted); }
.fineprint { margin:0; font-size:11px; line-height:1.35; }
.toast { position:fixed; z-index:100; left:50%; transform:translateX(-50%); bottom:calc(84px + env(safe-area-inset-bottom)); width:min(calc(100% - 32px),600px); padding:12px 14px; border-radius:13px; background:#26384a; color:#fff; text-align:center; box-shadow:var(--shadow); }
.hidden { display:none !important; }
@media (max-width:430px) {
  .app-shell { padding-left:10px; padding-right:10px; }
  .product-card { padding:11px; gap:7px; }
  .quick-row { display:none; }
  .category-list { grid-template-columns:1fr 1fr; gap:8px; }
  .category-card { min-height:82px; padding:12px; }
  .category-card-name { font-size:16px; }
}

/* v0.3 */
.account-btn { border:1px solid var(--line); background:var(--panel); color:var(--text); min-height:38px; padding:8px 11px; border-radius:12px; font-size:12px; font-weight:800; cursor:pointer; white-space:nowrap; }
.category-card-meta { font-size:13px; font-weight:700; color:var(--muted); }
.primary-btn.is-blocked { opacity:.5; cursor:pointer; }
.secondary-btn { width:100%; border:1px solid var(--line); border-radius:14px; min-height:48px; background:var(--panel); color:var(--text); font-weight:800; cursor:pointer; padding:10px 13px; }
.text-btn { width:100%; border:0; background:transparent; color:var(--muted); min-height:42px; font-weight:700; cursor:pointer; }
.danger-outline { border-color:rgba(255,116,116,.35); color:#ffb2b2; }
.account-sheet { min-height:72vh; }
.account-tabs { display:grid; grid-template-columns:1.25fr .9fr .9fr; gap:6px; margin:2px 0 14px; }
.account-tab { border:0; border-radius:11px; padding:10px 7px; background:transparent; color:var(--muted); font-size:12px; font-weight:750; cursor:pointer; }
.account-tab.active { background:var(--panel); color:var(--text); }
.account-section { display:flex; flex-direction:column; gap:10px; }
.order-history { display:flex; flex-direction:column; gap:10px; }
.order-card { background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:13px; display:flex; flex-direction:column; gap:9px; }
.order-card-head { display:flex; gap:10px; align-items:flex-start; justify-content:space-between; }
.order-summary { color:var(--muted); font-size:12px; white-space:nowrap; }
.order-payment { display:inline-flex; align-self:flex-start; border:1px solid var(--line); background:var(--panel-2); padding:5px 8px; border-radius:8px; font-size:11px; font-weight:750; }
.muted-small { color:var(--muted); font-size:11px; margin-top:3px; }
.order-details summary { color:var(--muted); font-size:12px; cursor:pointer; }
.history-items { display:flex; flex-direction:column; gap:5px; margin-top:8px; }
.history-item { display:flex; gap:10px; justify-content:space-between; font-size:12px; border-top:1px solid var(--line); padding-top:6px; }
.history-item span { min-width:0; }
.history-item strong { white-space:nowrap; }
.account-simple-list { display:flex; flex-direction:column; gap:7px; }
.account-list-row { display:flex; align-items:center; justify-content:space-between; gap:10px; background:var(--panel); border-radius:12px; padding:10px 12px; }
.account-list-row span:first-child { display:flex; flex-direction:column; min-width:0; }
.account-list-row small { color:var(--muted); margin-top:3px; }
.empty-inline { color:var(--muted); text-align:center; padding:25px 10px; }
.profile-telegram { color:var(--muted); font-size:12px; background:var(--panel); border-radius:12px; padding:11px 12px; }
.dialog-card { width:min(calc(100% - 28px),520px); margin:auto 14px max(18px, env(safe-area-inset-bottom)); background:var(--bg); border:1px solid var(--line); border-radius:20px; padding:18px; box-shadow:var(--shadow); display:flex; flex-direction:column; gap:11px; }
.dialog-card h3 { margin:0; font-size:20px; }
.dialog-card p { margin:0 0 3px; color:var(--muted); line-height:1.45; font-size:13px; }
.dialog-subtitle { font-size:12px; font-weight:800; color:var(--muted); margin:4px 0 6px; }
.unavailable-dialog { max-height:82vh; overflow:auto; }
.unavailable-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:9px; align-items:center; background:var(--panel); border-radius:12px; padding:10px; margin-bottom:7px; }
.unavailable-row div, .insufficient-row { display:flex; flex-direction:column; gap:3px; }
.unavailable-row small, .insufficient-row small { color:var(--muted); font-size:11px; line-height:1.35; }
.bell-btn { width:42px; height:42px; border:1px solid var(--line); border-radius:11px; background:var(--panel-2); color:var(--text); cursor:pointer; font-size:19px; }
.bell-btn.active { border-color:rgba(95,209,154,.6); background:rgba(95,209,154,.12); }
.insufficient-row { background:var(--panel); border-radius:12px; padding:10px; margin-bottom:7px; }
@media (max-width:430px) {
  .topbar { gap:8px; }
  .account-btn { font-size:11px; padding:8px 9px; }
  .account-tabs { grid-template-columns:1.2fr .9fr .9fr; }
  .account-tab { font-size:11px; padding:9px 5px; }
}

/* v0.4 */
body.sheet-open { position:fixed; left:0; right:0; width:100%; overflow:hidden; }
.sheet-backdrop { overscroll-behavior:contain; touch-action:none; }
.sheet, .dialog-card { overscroll-behavior:contain; touch-action:pan-y; }
.sheet { -webkit-overflow-scrolling:touch; }

.search-examples { background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:16px; display:flex; flex-direction:column; gap:10px; color:var(--muted); }
.search-examples > strong { color:var(--text); font-size:16px; }
.search-example-list { display:flex; flex-wrap:wrap; gap:7px; }
.search-example-list span { border:1px solid rgba(159,208,251,.22); background:rgba(47,128,196,.10); color:#b9dcfb; border-radius:999px; padding:7px 9px; font-size:12px; font-weight:700; }
.search-examples small { line-height:1.45; }

.product-card .availability { display:none !important; }
.qty-controls-wrap { display:flex; flex-direction:column; align-items:flex-end; gap:5px; }
.quick-row { display:flex; gap:4px; }
.quick-btn { min-width:34px; min-height:30px; }

.cart-row { align-items:center; }
.cart-item-main { min-width:0; display:flex; flex-direction:column; align-items:flex-start; gap:5px; }
.cart-badge-row { min-height:26px; display:flex; align-items:center; }
.cart-row .weight-badge { order:0; }
.cart-row .product-name { order:1; }
.clear-cart-btn { margin-top:14px; }
.danger-solid { background:#8d3131; color:#fff; }

.repeat-order-btn { width:100%; min-height:54px; border:1px solid rgba(95,209,154,.58); border-radius:14px; background:rgba(95,209,154,.14); color:#aef0cf; font-size:15px; font-weight:850; cursor:pointer; }
.order-details { width:100%; }
.order-details summary { list-style:none; }
.order-details summary::-webkit-details-marker { display:none; }
.order-details-btn { display:flex; align-items:center; justify-content:center; }
.history-items { gap:9px; }
.history-order-item { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px; align-items:center; border-top:1px solid var(--line); padding-top:9px; }
.history-item-info { min-width:0; display:flex; flex-direction:column; align-items:flex-start; gap:3px; }
.history-item-info strong { font-size:14px; }
.history-item-info small { color:var(--muted); font-size:11px; line-height:1.35; }
.danger-text { color:#ff9b9b !important; }
.unavailable-history-item { grid-template-columns:minmax(0,1fr) auto; }
.account-favorite-row { align-items:center; }
.account-favorite-row > span:first-child { flex:1; }

.account-tabs { grid-template-columns:1.25fr .9fr .9fr .9fr; overflow-x:auto; }
.admin-head { display:flex; flex-direction:column; gap:10px; background:var(--panel); border-radius:14px; padding:12px; }
.admin-head > div { display:flex; flex-direction:column; gap:4px; }
.admin-head small { color:var(--muted); line-height:1.4; }
.admin-add-btn { min-height:44px; }
.admin-subhead { margin:8px 0 6px; color:var(--muted); font-size:12px; font-weight:850; text-transform:uppercase; letter-spacing:.04em; }
.admin-hierarchy-list { display:flex; flex-direction:column; gap:6px; }
.admin-node { margin-left:calc((var(--level) - 1) * 16px); background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:9px 10px; display:flex; align-items:center; justify-content:space-between; gap:8px; }
.admin-node.is-disabled { opacity:.5; }
.admin-node.is-invalid { border-color:rgba(255,116,116,.55); }
.admin-node-main { min-width:0; display:flex; flex-direction:column; gap:3px; }
.admin-node-main small { color:var(--muted); font-size:10px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.admin-node-actions { display:flex; gap:5px; flex-shrink:0; }
.mini-btn { border:1px solid var(--line); background:var(--panel-2); color:var(--text); border-radius:9px; min-height:34px; padding:6px 8px; font-size:11px; font-weight:750; cursor:pointer; }
.admin-issue { display:flex; align-items:center; justify-content:space-between; gap:9px; background:rgba(255,116,116,.07); border:1px solid rgba(255,116,116,.20); border-radius:11px; padding:9px 10px; margin-bottom:6px; }
.admin-issue span { min-width:0; display:flex; flex-direction:column; gap:3px; }
.admin-issue small { color:var(--muted); font-size:10px; line-height:1.35; }
.admin-ok { background:rgba(95,209,154,.08); border:1px solid rgba(95,209,154,.20); color:#aef0cf; border-radius:11px; padding:9px 10px; font-size:12px; }
.admin-editor select { width:100%; border:1px solid var(--line); border-radius:12px; background:var(--panel); color:var(--text); padding:12px; outline:none; }
.check-row { flex-direction:row; align-items:center; gap:9px; }
.check-row input { width:18px; height:18px; margin:0; accent-color:var(--accent); }

@media (max-width:430px) {
  .quick-row { display:flex !important; }
  .product-card { grid-template-columns:minmax(0,1fr) auto; align-items:center; }
  .controls { gap:6px; }
  .qty-btn { width:36px; height:38px; }
  .qty-value { width:32px; }
  .quick-btn { padding:5px 6px; min-width:32px; }
  .cart-row { display:flex; flex-direction:column; align-items:stretch; gap:9px; }
  .cart-item-main { align-items:flex-start; }
  .cart-row .qty-controls-wrap { flex-direction:row; align-items:center; justify-content:flex-end; }
  .history-order-item { display:flex; flex-direction:column; align-items:stretch; }
  .history-order-item .qty-controls-wrap { flex-direction:row; align-items:center; justify-content:flex-end; }
  .unavailable-history-item { flex-direction:row; align-items:center; }
  .account-favorite-row { flex-direction:column; align-items:stretch; }
  .account-favorite-row .qty-controls-wrap { flex-direction:row; align-items:center; justify-content:flex-end; }
  .account-tabs { grid-template-columns:1.25fr .9fr .9fr .9fr; min-width:100%; }
  .admin-node { margin-left:calc((var(--level) - 1) * 10px); align-items:flex-start; flex-direction:column; }
  .admin-node-actions { width:100%; }
  .admin-node-actions .mini-btn { flex:1; }
}

/* v0.5.0 access control */
.access-gate { min-height:100dvh; display:flex; align-items:center; justify-content:center; padding:22px; background:var(--bg); }
.access-card { width:min(100%,460px); background:var(--panel); border:1px solid var(--line); border-radius:20px; padding:22px; box-shadow:var(--shadow); display:flex; flex-direction:column; gap:12px; }
.access-card h1 { margin:0; font-size:25px; line-height:1.15; }
.access-card p { margin:0 0 4px; color:var(--muted); line-height:1.5; }
.client-list { display:flex; flex-direction:column; gap:14px; }
.client-group { display:flex; flex-direction:column; gap:7px; }
.client-card { background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:11px; display:flex; flex-direction:column; gap:9px; }
.client-card-head { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; }
.client-card-main { min-width:0; display:flex; flex-direction:column; gap:4px; }
.client-card-main small { color:var(--muted); font-size:10px; line-height:1.35; overflow-wrap:anywhere; }
.client-status { flex-shrink:0; border:1px solid var(--line); border-radius:999px; padding:5px 7px; font-size:10px; font-weight:800; }
.client-status.approved { color:#aef0cf; border-color:rgba(95,209,154,.38); background:rgba(95,209,154,.10); }
.client-status.pending { color:#ffe09a; border-color:rgba(255,195,76,.38); background:rgba(255,195,76,.10); }
.client-status.preapproved { color:#b9dcfb; border-color:rgba(91,165,224,.38); background:rgba(91,165,224,.10); }
.client-status.blocked, .client-status.rejected { color:#ffb2b2; border-color:rgba(255,116,116,.38); background:rgba(255,116,116,.09); }
.client-actions { display:flex; gap:7px; flex-wrap:wrap; }
.client-actions .mini-btn { flex:1; min-width:110px; }
.invite-box { display:flex; gap:7px; align-items:center; background:var(--panel-2); border-radius:10px; padding:8px; }
.invite-box code { min-width:0; flex:1; color:var(--muted); font-size:10px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.account-tabs { grid-template-columns:1.25fr .9fr .9fr .9fr .9fr; }
@media (max-width:430px) {
  .access-gate { padding:16px; }
  .access-card { padding:18px; }
  .account-tabs { grid-template-columns:1.25fr .9fr .9fr .9fr .9fr; }
  .client-card-head { flex-direction:column; }
  .client-status { align-self:flex-start; }
}
