:root {
  --red: #d71920;
  --red-dark: #b01218;
  --red-soft: #fff1f2;
  --dark: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f8fafc;
  --white: #ffffff;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--dark);
  line-height: 1.5;
}

.container { width: min(1140px, calc(100% - 1.5rem)); margin: 0 auto; }

.brand-mark {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(145deg, #e11d24, #b91c1c); color: #fff; font-weight: 800; font-size: 1rem; letter-spacing: -.02em;
  box-shadow: 0 4px 14px rgba(215, 25, 32, .28); flex-shrink: 0;
}
.brand-mark.sm { width: 36px; height: 36px; font-size: .82rem; border-radius: 10px; }

.header { background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.header-top { display: flex; align-items: center; justify-content: space-between; padding: .75rem 0 .5rem; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: inherit; }
.brand-text strong { display: block; font-size: 1.05rem; color: var(--dark); }
.brand-text small { display: block; color: var(--muted); font-size: .75rem; }

.header-search-row { padding-bottom: .65rem; }
.search-wrap { position: relative; }
.search { display: flex; gap: .5rem; width: 100%; }
.search input {
  flex: 1; padding: .78rem 1rem; border: 1px solid var(--line); border-radius: 12px; font: inherit; background: #f9fafb;
}
.search input:focus { outline: 2px solid rgba(215,25,32,.12); border-color: var(--red); background: #fff; }
.search button {
  border: 0; background: var(--red); color: #fff; padding: 0 1.15rem; border-radius: 12px; font-weight: 700; cursor: pointer;
}
.search button:hover { background: var(--red-dark); }

.search-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + .35rem); z-index: 70;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  max-height: min(320px, 52vh); overflow: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.search-suggest-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .65rem; text-decoration: none; color: inherit; border-bottom: 1px solid #f1f5f9;
  min-height: 0;
}
.search-suggest-item:last-child { border-bottom: 0; }
.search-suggest-item:hover, .search-suggest-item:focus { background: #f8fafc; }
.search-suggest-item img {
  width: 42px; height: 42px; min-width: 42px; flex-shrink: 0;
  object-fit: cover; border-radius: 8px; background: #f1f5f9;
}
.search-suggest-body {
  flex: 1; min-width: 0; display: flex; flex-direction: row; align-items: center;
  justify-content: space-between; gap: .65rem;
}
.search-suggest-name {
  display: block; font-size: .82rem; font-weight: 600; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.search-suggest-meta { display: flex; align-items: baseline; gap: .35rem; flex-shrink: 0; }
.search-suggest-price {
  font-weight: 800; color: var(--red); font-size: .8rem; line-height: 1.2; text-align: right;
}
.search-suggest-price-old { color: var(--muted); font-size: .68rem; text-decoration: line-through; font-weight: 600; }
.search-suggest-empty, .search-suggest-foot {
  padding: .65rem .75rem; color: var(--muted); font-size: .8rem; text-align: center;
}
.search-suggest-foot a { color: var(--red); font-weight: 700; text-decoration: none; }

.search-backdrop {
  display: none; position: fixed; inset: 0; z-index: 85;
  background: rgba(15, 23, 42, .28); touch-action: none;
}
.search-backdrop.is-visible { display: block; }
body.search-open { overflow: hidden; }

@media (max-width: 768px) {
  .header-search-row { position: relative; z-index: 90; }
  .search-wrap.is-open { position: relative; z-index: 95; }
  .search input { font-size: 16px; padding: .65rem .8rem; min-height: 44px; }
  .search button { padding: 0 .85rem; font-size: .84rem; min-height: 44px; }

  .search-suggest.search-suggest--mobile {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px);
    max-height: min(26rem, 62vh); border-radius: 16px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .15);
    z-index: 96; padding: 0; overflow: hidden; background: #f8fafc;
    border: 1px solid #e2e8f0;
  }
  .search-suggest--mobile .search-suggest-head {
    padding: .6rem .85rem; font-size: .72rem; font-weight: 700;
    color: #64748b; background: #fff; border-bottom: 1px solid #eef2f7;
  }
  .search-suggest--mobile .search-suggest-list {
    display: flex; flex-direction: column; gap: .55rem;
    max-height: min(20rem, 50vh); overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; padding: .65rem;
  }
  .search-suggest--mobile .search-suggest-card {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    gap: .45rem; padding: .75rem .65rem .7rem;
    background: #fff; border: 1px solid #e8edf3; border-radius: 14px;
    text-decoration: none; color: inherit; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    -webkit-tap-highlight-color: transparent;
  }
  .search-suggest--mobile .search-suggest-card:active {
    transform: scale(.985); border-color: rgba(215, 25, 32, .25);
  }
  .search-suggest--mobile .search-suggest-thumb {
    display: flex; align-items: center; justify-content: center;
    width: 72px; height: 72px; border-radius: 12px;
    background: #f8fafc; border: 1px solid #eef2f7; overflow: hidden; flex-shrink: 0;
  }
  .search-suggest--mobile .search-suggest-thumb img {
    width: 100%; height: 100%; object-fit: contain; display: block;
  }
  .search-suggest--mobile .search-suggest-card .search-suggest-name {
    display: block; width: 100%; margin: 0;
    font-size: .8rem; line-height: 1.35; font-weight: 600; color: var(--dark);
    white-space: normal; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  }
  .search-suggest--mobile .search-suggest-prices {
    display: flex; flex-direction: column; align-items: center; gap: .12rem; width: 100%;
  }
  .search-suggest--mobile .search-suggest-card .search-suggest-price-old {
    display: block; font-size: .68rem; color: var(--muted);
    text-decoration: line-through; font-weight: 600; line-height: 1.2;
  }
  .search-suggest--mobile .search-suggest-card .search-suggest-price {
    display: block; font-size: .88rem; font-weight: 800; color: var(--red); line-height: 1.2;
  }
  .search-suggest--mobile .search-suggest-empty {
    padding: 1.1rem .85rem; font-size: .82rem; background: #fff;
  }
  .search-suggest--mobile .search-suggest-foot {
    padding: .65rem .85rem; font-size: .78rem; background: #fff;
    border-top: 1px solid #eef2f7; text-align: center;
  }
}

.table-wrap { overflow-x: auto; margin-bottom: .5rem; -webkit-overflow-scrolling: touch; }
.table-admin { min-width: 760px; }
.table-admin th { white-space: nowrap; }
.table-admin .th-label { display: inline-flex; align-items: center; gap: .35rem; }
.table-admin .th-icon { width: .95rem; height: .95rem; color: #94a3b8; flex-shrink: 0; }
.table-admin .col-num { text-align: right; }
.table-admin .col-center { text-align: center; }
.table-admin .col-product { min-width: 180px; }
.table-admin .col-barcode { min-width: 110px; }
.table-admin .col-category { min-width: 120px; }
.table-product-name { font-size: .88rem; line-height: 1.35; }
.table-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem;
  background: #f8fafc; padding: .15rem .35rem; border-radius: 6px;
}
.price-cell { color: var(--red); }
.stock-qty { font-size: .95rem; }
.stock-qty.stock-critical, .stock-qty.stock-out { color: #c2410c; }
.stock-qty.stock-low { color: #92400e; }
.stock-qty.stock-ok { color: #047857; }
.table-action {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px;
  border: 1px solid var(--line); color: var(--dark); background: #fff; text-decoration: none;
}
.table-action svg { width: 1rem; height: 1rem; }
.table-action:hover { border-color: rgba(215,25,32,.35); color: var(--red); background: var(--red-soft); }

@media (max-width: 900px) {
  .table-admin { min-width: 640px; }
  .table-admin .col-category, .table-admin .col-barcode { display: none; }
}
.header-cats { padding: 0 0 .65rem; border-top: 1px solid #f1f5f9; }
.header-cats-scroll { display: flex; gap: .5rem; overflow-x: auto; padding-top: .65rem; scrollbar-width: none; }
.header-cats-scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; padding: .45rem .85rem; border-radius: 999px; white-space: nowrap;
  background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--dark); font-weight: 600; font-size: .84rem;
}
.chip:hover { border-color: rgba(215,25,32,.35); color: var(--red); background: var(--red-soft); }
.chip-more { background: var(--dark); color: #fff; border-color: var(--dark); }
.chip-more:hover { background: #000; color: #fff; }

.cart-link {
  display: inline-flex; align-items: center; gap: .45rem; padding: .55rem .85rem; border-radius: 12px;
  background: var(--red); color: #fff; text-decoration: none; font-weight: 800;
}
.cart-link strong {
  display: inline-grid; place-items: center; min-width: 1.5rem; height: 1.5rem; border-radius: 8px; background: rgba(255,255,255,.2); font-size: .85rem;
}

.home-intro { padding: 1.25rem 0 .5rem; }
.home-tag { margin: 0; color: var(--red); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }
.home-intro h1 { margin: .35rem 0; font-size: clamp(1.35rem, 3vw, 1.85rem); line-height: 1.2; }
.home-meta { margin: 0; color: var(--muted); font-size: .92rem; }

.section { padding: 1.25rem 0 2rem; }
.section-head.compact { display: flex; justify-content: space-between; align-items: center; margin-bottom: .85rem; gap: .75rem; flex-wrap: wrap; }
.section-head.compact h2 { margin: 0; font-size: 1.1rem; }
.section-note { color: var(--muted); font-size: .78rem; font-weight: 600; }
.link-more { color: var(--red); font-weight: 700; text-decoration: none; font-size: .9rem; }
.home-more { text-align: center; margin-top: 1.25rem; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: .85rem; }
.card {
  background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  display: flex; flex-direction: column; transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-image { display: block; background: #f1f5f9; }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.card-body { padding: .75rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.card-brand { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.card-body h3 { font-size: .86rem; margin: 0; line-height: 1.35; min-height: 2.4rem; font-weight: 600; }
.card-body h3 a { color: inherit; text-decoration: none; }
.card-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: .5rem; margin-top: auto; padding-top: .35rem; }
.card-image { position: relative; }
.card-sale-badge {
  position: absolute; top: .5rem; left: .5rem; z-index: 2; background: var(--red); color: #fff;
  font-size: .68rem; font-weight: 800; padding: .22rem .5rem; border-radius: 999px; letter-spacing: .02em;
}
.card-sale-badge-lg { top: .75rem; left: .75rem; font-size: .78rem; padding: .3rem .65rem; }

.price-block { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .45rem; }
.price-block-sm .price-current { font-size: .98rem; }
.price-block-md .price-current { font-size: 1.05rem; }
.price-block-lg .price-current { font-size: 1.65rem; }
.price-current { color: var(--red); font-weight: 800; line-height: 1.1; }
.price-old { color: var(--muted); font-size: .82em; text-decoration: line-through; font-weight: 600; }
.price-badge {
  background: #fef2f2; color: var(--red); font-size: .68rem; font-weight: 800; padding: .12rem .4rem; border-radius: 999px;
}
.price-block-sale .price-current { color: var(--red); }

.product-detail-media { position: relative; }
.product-barcode { color: var(--muted); font-size: .88rem; }
.product-desc { line-height: 1.6; color: #374151; }
.product-add-form { margin-top: .5rem; }

.page-head { margin-bottom: 1rem; }
.page-head h1 { margin: 0 0 .2rem; }
.page-head p { margin: 0; color: var(--muted); font-size: .9rem; }

.cart-page { padding-bottom: 5rem; }
.cart-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1rem; align-items: start; }
.cart-items { display: grid; gap: .75rem; }
.cart-item {
  display: grid; grid-template-columns: 72px 1fr auto; gap: .75rem; align-items: start;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: .75rem;
}
.cart-item-image { display: block; border-radius: 10px; overflow: hidden; background: #f1f5f9; }
.cart-item-image img { width: 72px; height: 72px; object-fit: cover; display: block; }
.cart-item-body { min-width: 0; display: grid; gap: .45rem; }
.cart-item-name { font-weight: 700; font-size: .92rem; color: inherit; text-decoration: none; line-height: 1.35; }
.cart-item-side { display: grid; gap: .5rem; justify-items: end; }
.cart-line-total { color: var(--red); font-size: .95rem; white-space: nowrap; }

.qty-control {
  display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff;
}
.qty-btn {
  width: 36px; height: 36px; border: 0; background: #f8fafc; color: var(--dark); display: grid; place-items: center; cursor: pointer;
}
.qty-btn:disabled { opacity: .35; cursor: not-allowed; }
.qty-btn:not(:disabled):active { background: #eef2f7; }
.qty-value { min-width: 2rem; text-align: center; font-weight: 800; font-size: .92rem; }

.icon-btn {
  width: 38px; height: 38px; border: 1px solid #fecaca; border-radius: 10px; background: #fff5f5; color: #991b1b;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: #fee2e2; }

.cart-summary-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1rem; position: sticky; top: 5.5rem;
}
.cart-summary-card h2 { margin: 0 0 .85rem; font-size: 1.05rem; }
.summary-row { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; font-size: .95rem; }
.summary-row strong { color: var(--red); font-size: 1.1rem; }
.summary-note { margin: 0 0 .85rem; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.link-muted { display: block; text-align: center; margin-top: .65rem; color: var(--muted); font-weight: 600; font-size: .88rem; text-decoration: none; }

.cart-mobile-bar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  background: rgba(255,255,255,.98); border-top: 1px solid var(--line); padding: .65rem 1rem calc(.65rem + env(safe-area-inset-bottom));
  align-items: center; justify-content: space-between; gap: .75rem; backdrop-filter: blur(8px);
}
.cart-mobile-bar small { display: block; color: var(--muted); font-size: .72rem; }
.cart-mobile-bar strong { font-size: 1.05rem; color: var(--red); }

.empty-cart {
  text-align: center; background: #fff; border: 1px dashed var(--line); border-radius: 16px; padding: 2rem 1rem;
}
.empty-cart-icon { color: var(--muted); margin-bottom: .75rem; }
.empty-cart p { color: var(--muted); margin: 0 0 1rem; }

.field-hint { margin: .35rem 0 0; color: var(--muted); font-size: .82rem; }

@media (max-width: 768px) {
  .cart-layout { grid-template-columns: 1fr; }
  .cart-summary { display: none; }
  .cart-mobile-bar { display: flex; }
  .cart-page { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
  .cart-item { grid-template-columns: 64px 1fr auto; }
  .cart-item-image img { width: 64px; height: 64px; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--red); color: #fff; padding: .72rem 1rem; border-radius: 10px; text-decoration: none; border: 0;
  font: inherit; font-weight: 700; cursor: pointer; transition: background .15s;
}
.btn:hover { background: var(--red-dark); }
.btn-sm { width: 2.2rem; height: 2.2rem; padding: 0; border-radius: 10px; font-size: 1.2rem; line-height: 1; }
.btn-light { background: #fff; color: var(--red); border: 1px solid var(--line); }
.btn-light:hover { background: var(--red-soft); }
.btn-block { width: 100%; }
.btn-danger { background: #991b1b; }

.delivery-banner { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.delivery-banner-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 0; flex-wrap: wrap; }
.delivery-banner strong { display: block; }
.delivery-banner span { color: var(--muted); font-size: .88rem; }

.footer { margin-top: 1rem; background: var(--dark); color: #cbd5e1; padding: 1.5rem 0; }
.footer-inner { display: grid; gap: .75rem; text-align: center; }
.footer-brand { display: flex; align-items: center; justify-content: center; gap: .65rem; font-weight: 700; color: #fff; }
.footer-links { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }
.footer-links a { color: #cbd5e1; text-decoration: none; font-size: .9rem; }
.footer-copy { margin: 0; font-size: .82rem; color: #94a3b8; }

.whatsapp {
  position: fixed; right: 1rem; bottom: 1rem; background: #25d366; color: #fff; width: 48px; height: 48px;
  border-radius: 999px; display: grid; place-items: center; text-decoration: none; font-weight: 800; font-size: .72rem; box-shadow: var(--shadow); z-index: 60;
}

#toast-root { position: fixed; right: 1rem; bottom: 4.5rem; z-index: 80; display: grid; gap: .5rem; max-width: min(340px, calc(100vw - 2rem)); pointer-events: none; }
.toast {
  pointer-events: auto; background: #111827; color: #fff; padding: .8rem .95rem; border-radius: 12px; box-shadow: var(--shadow);
  display: flex; justify-content: space-between; gap: .75rem; align-items: center; opacity: 0; transform: translateY(8px); transition: .25s ease; font-size: .9rem;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #065f46; }
.toast-error { background: #991b1b; }
.toast-warn { background: #92400e; }
.toast a { color: #fff; font-weight: 700; white-space: nowrap; }

.page-title { margin: 0 0 .35rem; font-size: 1.75rem; }
.page-subtitle { margin: 0 0 1.25rem; color: var(--muted); }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .85rem; }
.category-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: inherit;
}
.category-icon {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); font-weight: 800;
}
.delivery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .85rem; }
.delivery-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem; }
.delivery-card span { color: var(--red); font-weight: 700; display: block; margin-top: .25rem; }
.product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.product-detail img { width: 100%; border-radius: 12px; aspect-ratio: 1; object-fit: cover; }
.product-meta h1 { margin: 0; font-size: 1.65rem; }
.stock-badge { display: inline-block; padding: .3rem .65rem; border-radius: 999px; background: #ecfdf5; color: #047857; font-size: .78rem; font-weight: 700; }
.stock-badge-last { background: #fff7ed; color: #c2410c; }
.alert { padding: .85rem 1rem; border-radius: 10px; background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: .75rem .9rem; border-bottom: 1px solid var(--line); text-align: left; font-size: .88rem; }
.table th { background: #f8fafc; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tbody tr:hover { background: #fafafa; }

.form { display: grid; gap: .85rem; max-width: 720px; }
.form label { display: grid; gap: .35rem; font-size: .88rem; font-weight: 600; }
.form input, .form select, .form textarea { padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; }

/* Admin */
.admin-page { min-height: 100vh; background: #eef2f7; }
.admin-login-page { background: linear-gradient(160deg, #111827, #1f2937); }
.admin-login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.admin-login-card { width: min(400px, 100%); background: #fff; border-radius: 16px; padding: 1.75rem; box-shadow: var(--shadow); }
.admin-login-brand { display: flex; justify-content: center; margin-bottom: 1rem; }
.admin-login-card h1 { margin: 0 0 .25rem; text-align: center; }
.admin-login-card p { margin: 0 0 1rem; text-align: center; color: var(--muted); font-size: .92rem; }

.admin-shell { display: flex; flex-direction: column; min-height: 100vh; background: #f1f5f9; }
.admin-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, #111827, #0f172a); color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.admin-header-top {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .65rem 1rem 0; min-height: 52px;
}
.admin-brand { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.admin-brand strong { display: block; font-size: .95rem; }
.admin-brand small { color: #94a3b8; font-size: .75rem; }
.admin-header-actions { display: flex; align-items: center; gap: .45rem; flex-shrink: 0; }
.admin-header-alert {
  background: var(--red); color: #fff; text-decoration: none; font-weight: 800; font-size: .75rem;
  padding: .35rem .6rem; border-radius: 999px; line-height: 1; white-space: nowrap;
}
.admin-header-link {
  color: #cbd5e1; text-decoration: none; font-weight: 600; font-size: .82rem;
  padding: .35rem .55rem; border-radius: 8px;
}
.admin-header-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-header-nav {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .25rem;
  padding: .45rem .65rem calc(.55rem + env(safe-area-inset-top, 0px));
}
.admin-nav-item {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; height: 44px; padding: 0 .45rem;
  color: #cbd5e1; text-decoration: none; border-radius: 10px; font-weight: 600; font-size: .82rem;
  box-sizing: border-box; -webkit-tap-highlight-color: transparent;
}
.admin-nav-icon {
  width: 1.1rem; height: 1.1rem; display: inline-flex; flex-shrink: 0;
}
.admin-nav-icon svg { width: 100%; height: 100%; display: block; }
.admin-nav-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.admin-nav-text-short { display: none; }
.nav-badge-slot { width: 1.1rem; flex-shrink: 0; display: flex; justify-content: center; align-items: center; }
.admin-nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-nav-item.active { background: var(--red); color: #fff; }
.admin-main { padding: 1rem; flex: 1; min-width: 0; }
.admin-panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 1.25rem; box-shadow: 0 1px 2px rgba(0,0,0,.04); }

.admin-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.admin-head h1 { margin: 0; font-size: 1.35rem; }
.admin-head p { margin: .2rem 0 0; color: var(--muted); font-size: .88rem; }
.admin-toolbar { display: flex; gap: .65rem; flex-wrap: wrap; margin: .85rem 0; }
.admin-filters { display: grid; grid-template-columns: 1fr 160px 140px auto; gap: .65rem; margin-bottom: 1rem; }
.admin-filters input, .admin-filters select { padding: .65rem .85rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.admin-alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: .85rem; font-weight: 600; font-size: .9rem; }
.admin-alert-success { background: #ecfdf5; color: #065f46; }
.admin-alert-error { background: #fef2f2; color: #991b1b; }
.admin-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; max-width: 880px; }
.admin-form-grid .full { grid-column: 1 / -1; }
.admin-form-grid .checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 600; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat-card { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: .9rem; }
.stat-card strong { display: block; font-size: 1.45rem; color: var(--red); }
.stat-card span { color: var(--muted); font-size: .82rem; }
.stat-card.warn strong { color: #b45309; }
.stat-card.danger strong { color: #991b1b; }
.stat-card-sales { background: linear-gradient(135deg, #111827, #1f2937); border-color: #111827; }
.stat-card-sales strong { color: #fff; font-size: 1.25rem; }
.stat-card-sales span { color: #94a3b8; }
.stat-card-link { text-decoration: none; color: inherit; display: block; }
.stat-card-link:hover { border-color: rgba(215,25,32,.25); box-shadow: var(--shadow); }
.order-delete-form { margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.admin-reset-box {
  margin: 0 0 1rem; padding: .85rem 1rem; border: 1px dashed #fecaca; border-radius: 12px; background: #fffafa;
}
.admin-reset-box summary { cursor: pointer; font-weight: 700; color: #991b1b; }
.admin-reset-form { display: grid; gap: .65rem; margin-top: .75rem; }
.admin-reset-form p { margin: 0; color: var(--muted); font-size: .86rem; }
.admin-reset-form label { display: grid; gap: .35rem; font-size: .86rem; font-weight: 600; }
.admin-reset-form input[type="text"] {
  padding: .65rem .85rem; border: 1px solid var(--line); border-radius: 10px; font: inherit;
}

.stock-pill { display: inline-block; padding: .18rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.stock-ok { background: #ecfdf5; color: #047857; }
.stock-low { background: #fef3c7; color: #92400e; }
.stock-critical { background: #ffedd5; color: #c2410c; }
.stock-out { background: #fee2e2; color: #991b1b; }
.badge-status { display: inline-block; padding: .25rem .55rem; border-radius: 999px; background: #eef2ff; color: #3730a3; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.status-new { background: #fee2e2; color: #991b1b; }
.status-preparing { background: #fef3c7; color: #92400e; }
.status-way { background: #dbeafe; color: #1d4ed8; }
.status-delivered { background: #ecfdf5; color: #047857; }
.status-cancelled { background: #f3f4f6; color: #6b7280; }
.pagination { display: flex; gap: .4rem; margin-top: .85rem; flex-wrap: wrap; }
.pagination a {
  display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; height: 2rem;
  padding: 0 .65rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--red);
  font-weight: 700; text-decoration: none; font-size: .85rem; box-sizing: border-box;
}
.pagination a.active { background: var(--red); color: #fff; border-color: var(--red); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; margin-bottom: 1rem; }
.detail-card { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: .9rem; }
.detail-card h3 { margin-top: 0; font-size: 1rem; }

/* Admin orders mobile */
.nav-badge {
  display: inline-grid; place-items: center; min-width: 1rem; height: 1rem; padding: 0 .22rem;
  border-radius: 999px; background: var(--red); color: #fff; font-size: .58rem; font-weight: 800; line-height: 1;
}
.admin-nav-item.active .nav-badge { background: rgba(255,255,255,.22); color: #fff; }

.status-tabs {
  display: flex; gap: .35rem; overflow-x: auto; margin-bottom: .85rem; scrollbar-width: none;
  padding: .2rem; background: #eef2f7; border-radius: 12px; height: 42px; align-items: center;
  -webkit-overflow-scrolling: touch; flex-wrap: nowrap;
}
.status-tabs::-webkit-scrollbar { display: none; }
.status-tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  height: 34px; min-width: 4.25rem; padding: 0 .75rem; border-radius: 9px; border: 0;
  background: transparent; text-decoration: none; color: #64748b; font-weight: 600; font-size: .78rem;
  line-height: 1; white-space: nowrap; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.status-tab.active {
  background: #fff; color: var(--dark);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}
.status-tab:active { opacity: .88; }

.admin-filters-mobile { grid-template-columns: 1fr auto !important; }
.admin-filters-mobile input { min-width: 0; }

.order-list { display: grid; gap: .65rem; }
.order-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; transition: box-shadow .15s, border-color .15s;
}
.order-card:active, .order-card:hover { border-color: rgba(215,25,32,.25); box-shadow: var(--shadow); }
.order-card-link { display: block; text-decoration: none; color: inherit; padding: .85rem .85rem .45rem; }
.order-card .order-phone {
  display: block; padding: .55rem .85rem .75rem; color: var(--dark); font-weight: 700; font-size: .86rem;
  text-decoration: none; border-top: 1px solid #f1f5f9;
}
.order-card .order-phone:active { background: #f8fafc; }
.order-card-unread { border-color: rgba(215,25,32,.45); background: #fffafa; }
.order-card-top, .order-card-foot { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.order-card-main { display: grid; gap: .15rem; margin: .55rem 0; }
.order-card-main strong { font-size: .98rem; }
.order-card-main span { color: var(--muted); font-size: .86rem; }
.order-no { font-size: 1rem; margin-right: .45rem; }
.order-time { color: var(--muted); font-size: .82rem; font-weight: 600; }
.order-total { color: var(--red); font-weight: 800; font-size: 1rem; }
.order-phone { color: var(--dark); }

.table-desktop-only { display: none; }
.empty-state {
  padding: 1.25rem; text-align: center; color: var(--muted); background: #f8fafc; border: 1px dashed var(--line); border-radius: 12px;
}
.section-label { margin: 1rem 0 .65rem; font-size: 1rem; }
.stat-card-link { text-decoration: none; color: inherit; }
.stat-card-link:active { opacity: .92; }

.order-detail-head { margin-bottom: 1rem; }
.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-weight: 700; font-size: .88rem; margin-bottom: .5rem; }
.order-detail-title { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.order-detail-title h1 { margin: 0; font-size: 1.5rem; }
.order-detail-meta { margin: .35rem 0 0; color: var(--muted); font-size: .88rem; }
.order-detail-total { margin-top: .5rem; font-size: 1.65rem; font-weight: 800; color: var(--red); }

.quick-actions {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin-bottom: 1rem;
}
.quick-action {
  display: grid; gap: .1rem; padding: .75rem; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  text-decoration: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.quick-action span { font-weight: 800; font-size: .92rem; }
.quick-action small { color: var(--muted); font-size: .75rem; }
.quick-action-wa { background: #ecfdf5; border-color: #bbf7d0; }
.quick-action-wa span { color: #047857; }

.detail-name { font-weight: 800; margin: 0 0 .35rem; }
.detail-address { margin: 0; line-height: 1.55; }
.detail-note { margin: .65rem 0 0; padding: .65rem; background: #fff7ed; border-radius: 10px; font-size: .88rem; }
.summary-rows { display: grid; gap: .55rem; }
.summary-rows div { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; }
.summary-rows span { color: var(--muted); }
.summary-total { padding-top: .45rem; border-top: 1px solid var(--line); font-size: 1rem !important; }

.order-items { display: grid; gap: .55rem; margin-bottom: 1rem; }
.order-item {
  display: flex; justify-content: space-between; gap: .75rem; align-items: start;
  padding: .75rem; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.order-item-main { display: grid; gap: .15rem; min-width: 0; }
.order-item-main strong { font-size: .9rem; line-height: 1.35; }
.order-item-main span { color: var(--muted); font-size: .82rem; }
.order-item-price { color: var(--red); font-weight: 800; white-space: nowrap; }

.order-status-panel { margin-bottom: 5rem; }

.order-status-panel {
  margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 16px; background: #f8fafc;
}
.order-status-head {
  display: flex; justify-content: space-between; align-items: start; gap: .75rem; margin-bottom: 1rem;
}
.order-status-head h3 { margin: 0 0 .2rem; font-size: 1rem; }
.order-status-head p { margin: 0; color: var(--muted); font-size: .84rem; }
.order-status-track {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0;
  margin-bottom: 1rem; padding: .65rem .35rem; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  overflow-x: auto; scrollbar-width: none;
}
.order-status-track::-webkit-scrollbar { display: none; }
.order-status-step {
  display: flex; flex-direction: column; align-items: center; gap: .35rem; flex: 1; min-width: 3.25rem; text-align: center;
}
.order-status-dot {
  display: grid; place-items: center; width: 1.65rem; height: 1.65rem; border-radius: 999px;
  background: #e2e8f0; color: #64748b; font-size: .68rem; font-weight: 800;
}
.order-status-step.done .order-status-dot { background: #dcfce7; color: #047857; }
.order-status-step.current .order-status-dot { background: var(--red); color: #fff; box-shadow: 0 0 0 3px rgba(215,25,32,.15); }
.order-status-label { font-size: .62rem; font-weight: 700; color: #64748b; line-height: 1.2; }
.order-status-step.current .order-status-label { color: var(--dark); }
.order-status-step.done .order-status-label { color: #047857; }
.order-status-line {
  flex: 0 0 1rem; height: 2px; background: #e2e8f0; margin-top: .82rem; border-radius: 999px;
}
.order-status-line.done { background: #86efac; }
.order-status-cancelled {
  margin-bottom: 1rem; padding: .75rem .85rem; border-radius: 10px; background: #f3f4f6; color: #6b7280; font-weight: 600; font-size: .88rem;
}
.order-status-primary { margin-bottom: .85rem; }
.order-status-next {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  min-height: 52px; padding: .65rem 1rem;
}
.order-status-next span { font-size: 1rem; font-weight: 800; }
.order-status-next small { font-size: .72rem; font-weight: 600; opacity: .88; }
.order-status-manual {
  margin-bottom: .85rem; padding: .65rem .75rem; border: 1px dashed var(--line); border-radius: 12px; background: #fff;
}
.order-status-manual summary {
  cursor: pointer; font-weight: 700; font-size: .84rem; color: #475569; list-style: none;
}
.order-status-manual summary::-webkit-details-marker { display: none; }
.order-status-manual-grid {
  display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .65rem;
}
.order-status-manual-grid form { margin: 0; }
.order-status-option {
  display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 .75rem;
  border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: .78rem; font-weight: 700;
  cursor: pointer; color: #475569;
}
.order-status-option:hover { border-color: rgba(215,25,32,.25); }
.order-status-option.danger { color: #991b1b; border-color: #fecaca; background: #fef2f2; }
.order-status-option.status-new { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.order-status-option.status-preparing { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.order-status-option.status-way { background: #dbeafe; border-color: #bfdbfe; color: #1d4ed8; }
.order-status-option.status-delivered { background: #ecfdf5; border-color: #bbf7d0; color: #047857; }

.status-action-grid { display: grid; gap: .55rem; }
.status-next { min-height: 48px; font-size: 1rem; }
.status-pill { min-height: 44px; }
.btn-danger-soft { color: #991b1b !important; border-color: #fecaca !important; background: #fef2f2 !important; }

.order-detail-sticky {
  display: none; position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 55; padding: .55rem 1rem calc(.55rem + env(safe-area-inset-bottom)); background: rgba(255,255,255,.98); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px); min-height: 64px;
}
.order-detail-sticky .btn { min-height: 46px; font-size: .95rem; }

@media (max-width: 900px) {
  .admin-header-top { padding: .55rem .65rem 0; min-height: 48px; }
  .admin-header-nav { padding: .4rem .45rem .5rem; gap: .15rem; }
  .admin-nav-item { flex-direction: column; gap: .15rem; height: 52px; min-height: 52px; padding: .35rem .15rem; font-size: .62rem; }
  .admin-nav-icon { width: 1rem; height: 1rem; }
  .admin-nav-text-full { display: none; }
  .admin-nav-text-short { display: block; }
  .nav-badge-slot { width: auto; position: absolute; top: .2rem; right: .15rem; }
  .admin-nav-item { position: relative; }
  .admin-main { padding: .75rem .75rem calc(.75rem + env(safe-area-inset-bottom)); }
  .admin-panel { padding: 1rem; border-radius: 14px; }
  .admin-filters { grid-template-columns: 1fr; }
  .admin-form-grid, .product-detail, .detail-grid { grid-template-columns: 1fr; }
  .order-status-panel { margin-bottom: 5rem; }
  .order-detail-sticky { display: block; }
  .admin-head h1 { font-size: 1.15rem; }
  .admin-brand small { display: none; }
  .admin-header-link { font-size: .75rem; padding: .3rem .4rem; }
}

@media (min-width: 901px) {
  .admin-header-nav { display: flex; justify-content: center; gap: .35rem; padding: 0 1rem .65rem; }
  .admin-nav-item { flex: 0 1 auto; min-width: 7.5rem; padding: 0 .85rem; }
  .admin-nav-text-full { display: block; }
  .admin-nav-text-short { display: none; }
  .order-list { display: none; }
  .table-desktop-only { display: table; }
  .order-status-panel { margin-bottom: 0; }
}

.stock-alerts { margin-bottom: 1rem; }
.stock-alerts-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .65rem; }
.stock-alerts-head .section-label { margin: 0; }
.stock-alert-list { display: grid; gap: .55rem; }
.stock-alert-item {
  display: flex; justify-content: space-between; align-items: start; gap: .75rem; flex-wrap: wrap;
  padding: .85rem; border: 1px solid #fed7aa; border-radius: 12px; background: #fff7ed;
}
.stock-alert-main { display: grid; gap: .2rem; min-width: 0; }
.stock-alert-main strong { font-size: .92rem; }
.stock-alert-main span { color: #9a3412; font-size: .86rem; font-weight: 600; }
.stock-alert-main small { color: var(--muted); font-size: .75rem; }
.stock-alert-actions { display: flex; align-items: center; gap: .65rem; flex-shrink: 0; }
.btn-sm-text { padding: .45rem .75rem; font-size: .82rem; min-height: auto; }
