/* ============================================================
   StoreWeb Design System — "Đất nung" (Terracotta)
   Một file duy nhất cho toàn bộ giao diện: tokens + reset +
   layout + components. Viết tay, không build step.
   Bảng màu trung tính ấm nền kem, điểm nhấn màu đất nung,
   font Be Vietnam Pro (hỗ trợ tiếng Việt đầy đủ).
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  /* Màu */
  --color-bg: #f6f1e8;
  --color-surface: #fffdf9;
  --color-surface-alt: #efe7d8;
  --color-text: #2b241c;
  --color-text-muted: #847867;
  --color-border: #e3d9c8;
  --color-border-strong: #cbbfa9;
  --color-accent: #b0512c;
  --color-accent-hover: #8f3f20;
  --color-accent-soft: #f6e3d8;
  --color-danger: #b03a30;
  --color-danger-soft: #f8e4e1;
  --color-success: #2e7d52;
  --color-success-soft: #e2f1e8;
  --color-warning: #96691b;
  --color-warning-soft: #f7ecd6;
  --color-info: #34648f;
  --color-info-soft: #e4edf5;

  /* Spacing (base 4px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  /* Type scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;

  /* Font */
  --font-sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Shadow (tint ấm) */
  --shadow-sm: 0 1px 2px rgba(74, 58, 38, 0.08);
  --shadow-md: 0 6px 18px rgba(74, 58, 38, 0.12);

  /* Control sizing */
  --control-h: 44px;
}

/* ---------- 2. Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--color-accent); }

h1, h2, h3 { font-weight: 600; line-height: 1.25; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 3. Skip link + toast ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: #fff;
  border-radius: 0 0 var(--radius-md) 0;
  font-size: var(--text-sm);
  font-weight: 500;
}
.skip-link:focus {
  left: 0;
  color: #fff;
}

#toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-info);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.hide { opacity: 0; transform: translateY(6px); }
.toast-success { border-left-color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-info { border-left-color: var(--color-info); }

/* ---------- 4. Layout: header / nav / footer ---------- */
.container {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: var(--space-4);
}
main { min-height: 60vh; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.site-header__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-block: var(--space-2);
}

/* Hamburger (checkbox hack) */
.nav-group { position: relative; display: flex; align-items: center; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-toggle__btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 40px;
  padding: 0;
  background: transparent;
  border: 0;
  flex-shrink: 0;
}
.nav-toggle__icon {
  display: block;
  width: 22px; height: 2px;
  background: var(--color-text);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle:checked ~ .nav-toggle__btn .nav-toggle__icon:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle:checked ~ .nav-toggle__btn .nav-toggle__icon:nth-child(2) { opacity: 0; }
.nav-toggle:checked ~ .nav-toggle__btn .nav-toggle__icon:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav-toggle:focus-visible ~ .nav-toggle__btn { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.site-nav { display: none; }
.nav-toggle:checked ~ .site-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 60;
}
.site-nav a {
  display: flex;
  align-items: center;
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
}
.site-nav a:hover { background: var(--color-accent-soft); color: var(--color-accent); }
.mobile-menu-logout { margin-top: var(--space-2); }
.mobile-menu-logout .btn { width: 100%; }

@media (min-width: 768px) {
  .site-header__inner {
    flex-direction: row;
    align-items: center;
    gap: var(--space-4);
  }
  .nav-toggle__btn { display: none; }
  .site-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
    position: static;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .site-nav a { padding: 8px var(--space-3); }
  .mobile-menu-logout { margin-top: 0; }
  .mobile-menu-logout .btn { width: auto; }
}

/* Search shell trong header public */
.mobile-search-shell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  justify-content: flex-end;
}
.search-toggle { flex-shrink: 0; }
.search-form {
  display: flex;
  gap: var(--space-2);
  flex: 1;
  max-width: 420px;
}
.desktop-header-actions {
  display: none;
  align-items: center;
  gap: var(--space-3);
}
.cart-link {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}
.logout-form { display: inline-flex; }

@media (max-width: 767px) {
  .site-header__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .mobile-search-shell { flex: 0 0 auto; }
  .search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    cursor: pointer;
  }
  .search-toggle:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
  }
  /* Form neo vào .site-header (sticky = positioned): trượt ngay dưới header */
  .search-form {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-width: none;
    padding: var(--space-2) var(--space-4) var(--space-3);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
  }
  .mobile-search-shell.is-open .search-form { display: flex; }
}
@media (min-width: 768px) {
  .mobile-search-shell { margin-left: auto; }
  /* .mobile-search-shell .search-toggle: đặc hiệu 0,2,0 để thắng .btn (0,1,0) */
  .mobile-search-shell .search-toggle { display: none; }
  .desktop-header-actions { display: flex; }
  /* Item mobile-only trong nav: desktop dùng .desktop-header-actions thay */
  .site-nav .mobile-menu-cart,
  .site-nav .mobile-menu-logout { display: none; }
}

.cart-badge {
  display: inline-block;
  min-width: 20px;
  margin-left: var(--space-1);
  padding: 1px 6px;
  background: var(--color-accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  border-radius: 999px;
}
.cart-badge.hidden { display: none; }

.site-footer {
  max-width: 1180px;
  margin-inline: auto;
  padding: var(--space-7) var(--space-4);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ---------- 5. Components: buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-hover); color: #fff; }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover { border-color: var(--color-accent); color: var(--color-accent); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #93302a; color: #fff; }
.btn-sm { min-height: 32px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-block { width: 100%; }
.btn-wide { min-width: 200px; }
.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 6. Cards / panels ---------- */
.card,
.admin-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}
.admin-card--flush,
.admin-card--wide {
  padding: 0;
  overflow: hidden;
}
.admin-card--wide { width: 100%; }
.admin-card + .admin-card { margin-top: var(--space-4); }
.admin-card > h1, .admin-card > h2, .card > h1 { margin-bottom: var(--space-3); }
.card p { margin-bottom: var(--space-3); }
.category-grid { margin-block: var(--space-3); }
.category-grid + p { margin-top: var(--space-3); }
.narrow-card {
  max-width: 520px;
  margin-inline: auto;
  padding: var(--space-7);
}
.page-heading {
  font-size: var(--text-2xl);
  font-weight: 600;
  margin-bottom: var(--space-6);
}

/* ---------- 7. Forms ---------- */
.form-field { margin-bottom: var(--space-4); }
.form-field:last-child { margin-bottom: 0; }
.form-field label,
.label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}
.input,
.form-field input:not([type="checkbox"]),
.form-field select,
.form-field textarea,
.checkout-form input[type="text"],
.checkout-form input[type="tel"],
.checkout-form textarea {
  display: block;
  width: 100%;
  min-height: var(--control-h);
  padding: 8px var(--space-3);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
}
.search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: var(--control-h);
  padding: 8px var(--space-3);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
}
.search-form input[type="search"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}
.form-field textarea,
.checkout-form textarea { min-height: 80px; resize: vertical; padding-block: var(--space-2); }
.input:focus,
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.checkout-form input:focus,
.checkout-form textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}
.select, .form-field select { appearance: auto; }
.help-text {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.field-error {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-danger);
}
.required { color: var(--color-danger); }
.price-label { font-size: var(--text-sm); font-weight: 500; }
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 640px) {
  .form-row-2 { grid-template-columns: 1fr 1fr; }
}
.form-group-upper {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-block: var(--space-5);
}
@media (min-width: 640px) {
  .form-group-upper { grid-template-columns: 2fr 1fr; }
}

/* Nhóm collapsible trong form sản phẩm */
.form-group-collapsible {
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}
.form-group-collapsible.cost-group { border-color: var(--color-border-strong); }
.collapse-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-alt);
  border: 0;
  font-weight: 600;
  text-align: left;
}
.collapse-toggle:hover { background: var(--color-accent-soft); }
.collapse-toggle .caret { font-size: var(--text-xs); }
.collapse-body { padding: var(--space-4); }

/* Checkbox kiểu chuyển đổi (Uiverse-style) */
.checkbox-container {
  display: inline-flex;
  align-items: center;
  margin-bottom: var(--space-4);
  cursor: pointer;
}
.checkbox-container .custom-checkbox {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.checkmark {
  display: inline-block;
  width: 18px; height: 18px;
  flex-shrink: 0;
  background: var(--color-surface);
  border: 2px solid var(--color-border-strong);
  border-radius: 4px;
  position: relative;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.custom-checkbox:checked + .checkmark {
  background: var(--color-accent);
  border-color: var(--color-accent);
}
.custom-checkbox:checked + .checkmark::after {
  content: "";
  position: absolute;
  left: 4px; top: 0;
  width: 4px; height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.custom-checkbox:focus-visible + .checkmark {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.custom-checkbox:disabled + .checkmark { opacity: 0.4; cursor: not-allowed; }
.checkbox-field { display: flex; align-items: center; }
.checkbox-label { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.checkbox-label .checkbox-container { margin-bottom: 0; }

/* Ô chọn danh mục (tile) */
.category-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.category-check:hover { background: var(--color-surface-alt); }
.category-check:has(input:checked) { border-color: var(--color-accent); background: var(--color-accent-soft); }
.category-check .checkbox-container { margin-bottom: 0; padding-top: 2px; }
.category-check .cat-name { font-weight: 600; }
.category-check .cat-keywords {
  display: block;
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}
@media (min-width: 640px) {
  .category-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- 8. Alerts / flash ---------- */
.alert {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.alert-error {
  background: var(--color-danger-soft);
  border-color: #ecc8c4;
  color: #7c261f;
}
.alert-success {
  background: var(--color-success-soft);
  border-color: #bcdcc9;
  color: #1e5638;
}
.flash-zone { margin-bottom: var(--space-4); }
.delete-warning { margin-bottom: var(--space-6); }

/* ---------- 9. Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-available { background: var(--color-success-soft); border-color: #bcdcc9; color: var(--color-success); }
.badge-out_of_stock { background: var(--color-warning-soft); border-color: #e8d5ac; color: var(--color-warning); }
.badge-discontinued,
.badge-neutral,
.badge-order-cancelled { background: var(--color-surface-alt); border-color: var(--color-border); color: var(--color-text-muted); }
.badge-maxed { background: var(--color-danger-soft); border-color: #ecc8c4; color: var(--color-danger); }
.badge-order-pending { background: var(--color-info-soft); border-color: #c4d7e8; color: var(--color-info); }
.badge-order-confirmed { background: #ece5f6; border-color: #d4c6ea; color: #5f4391; }
.badge-order-packed { background: var(--color-warning-soft); border-color: #e8d5ac; color: var(--color-warning); }
.badge-order-shipped { background: var(--color-info-soft); border-color: #c4d7e8; color: var(--color-info); }
.badge-order-delivered { background: var(--color-success-soft); border-color: #bcdcc9; color: var(--color-success); }
.badge-primary {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--color-accent);
  color: #fff;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

/* ---------- 10. Tables ---------- */
.table-scroll { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table th {
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: rgba(240, 232, 218, 0.4); }
.price-cell, .unit-price, .line-total, .cod-cell {
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}
.cod-cell { font-weight: 600; color: var(--color-accent); }
.actions-cell { white-space: nowrap; text-align: center; }
.actions-cell > * + * { margin-left: var(--space-2); }
.cart-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: var(--radius-sm); display: inline-block; vertical-align: middle; }
.cart-thumb-size { width: 80px; height: 80px; vertical-align: middle; }
.cart-thumb + .product-name,
.thumb-placeholder + .product-name { margin-left: var(--space-2); }
.cart-maxed-badge { margin-left: var(--space-2); }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm); }
.thumb-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px; height: 48px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  color: var(--color-border-strong);
}
td .thumb-placeholder, td .cart-thumb { vertical-align: middle; }
.product-name { font-weight: 600; }
.qty-muted { color: var(--color-text-muted); }
.cart-item-row.is-maxed-in-cart td { background: var(--color-warning-soft); }

.pay-input {
  width: 90px;
  min-height: 36px;
  padding: 4px var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--color-surface);
}
.pay-input:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 2px var(--color-accent-soft); }

/* Link hành động */
.link-accent { color: var(--color-accent); font-weight: 500; }
.link-accent:hover { text-decoration: underline; }
.link-danger { color: var(--color-danger); font-weight: 600; background: none; border: 0; padding: 0; }
.link-danger:hover { color: #8c2b23; text-decoration: underline; }
.order-id { font-weight: 500; }
.order-id:hover { text-decoration: underline; }

/* ---------- 11. Pagination ---------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-4);
  justify-content: flex-start;
}
.pagination--center { justify-content: center; }
.pagination .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: 500;
}
.pagination a.page-link:hover { border-color: var(--color-accent); color: var(--color-accent); }
.pagination .page-link.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.pagination .page-link.page-current {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  font-weight: 600;
}
.pagination .page-ellipsis { padding: 0 var(--space-1); color: var(--color-text-muted); }
.pagination .page-goto {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.pagination .page-goto input {
  width: 64px;
  min-height: 36px;
  padding: 4px var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  text-align: center;
}
.pagination .page-goto button {
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: var(--text-sm);
}
.pagination .page-goto button:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* ---------- 12. Chips (lọc danh mục) ---------- */
.category-filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  background: var(--color-surface);
  font-size: var(--text-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip:hover { border-color: var(--color-accent); color: var(--color-accent); }
.chip.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  font-weight: 500;
}
.kw-tag {
  display: inline-block;
  padding: 1px var(--space-2);
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ---------- 13. Lưới sản phẩm + thẻ sản phẩm ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
@media (min-width: 480px) { .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-5); } }

.stagger-children > * { animation: rise-in 0.35s ease both; }
.stagger-children > *:nth-child(1) { animation-delay: 40ms; }
.stagger-children > *:nth-child(2) { animation-delay: 80ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 160ms; }
.stagger-children > *:nth-child(n+5) { animation-delay: 200ms; }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.animate-fade-in-down { animation: fade-down 0.35s ease both; }
@keyframes fade-down {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

.product-card-wrapper { position: relative; }
.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: visible;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.product-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.product-card:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.product-card.is-dimmed { opacity: 0.72; }
.product-card-wrapper.is-maxed-in-cart .product-card { opacity: 0.72; }
.product-card-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--color-surface-alt);
}
.product-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card-thumb .badge {
  position: absolute;
  bottom: var(--space-2);
  left: var(--space-2);
  z-index: 1;
}
.product-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%; height: 100%;
  font-size: var(--text-2xl);
  color: var(--color-border-strong);
}
.product-card-body { padding: var(--space-4); flex: 1; }
.product-card-name {
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.4;
  height: 2.8em;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card-price {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
}
.product-card-stock {
  margin-top: var(--space-1);
  min-height: 1.55em;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.add-cart-form { position: absolute; right: var(--space-3); top: var(--space-3); z-index: 2; }
.add-cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease;
}
.add-cart:hover { background: var(--color-accent-hover); }
.add-cart:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.add-cart svg { width: 20px; height: 20px; }
.add-cart.is-disabled,
.add-cart:disabled {
  background: var(--color-border-strong);
  cursor: not-allowed;
}
.product-edit-btn {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}
.product-edit-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
.product-edit-btn svg { width: 14px; height: 14px; }

/* ---------- 14. Trang chi tiết sản phẩm ---------- */
.product-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
@media (min-width: 768px) {
  .product-detail { flex-direction: row; }
  .product-gallery { width: 380px; flex-shrink: 0; }
  .product-info { margin-top: 0; }
}
.product-gallery { width: 100%; }
.main-image-box {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.main-image-box img { width: 100%; height: 100%; object-fit: contain; }
.main-placeholder { font-size: var(--text-2xl); color: var(--color-border-strong); }
.gallery-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.gallery-thumb {
  width: 72px; height: 72px;
  padding: 0;
  background: none;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb:hover { border-color: var(--color-border-strong); }
.gallery-thumb.is-active { border-color: var(--color-accent); }
.gallery-thumb:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.product-info { flex: 1; min-width: 0; margin-top: 0; }
.product-info h1 { margin-bottom: var(--space-2); }
.product-price {
  font-size: var(--text-3xl);
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}
.product-status { margin-bottom: var(--space-4); }
.add-to-cart-form { max-width: 380px; margin-bottom: var(--space-6); }
.cart-cta { width: 100%; }
.out-of-stock-note { color: var(--color-danger); font-size: var(--text-sm); margin-bottom: var(--space-2); }
.product-meta { margin-bottom: var(--space-6); }
.product-meta-row { display: flex; gap: var(--space-2); margin-bottom: var(--space-1); }
.product-meta-row dt { font-size: var(--text-sm); color: var(--color-text-muted); }
.product-meta-row dd { margin: 0; }
.product-description {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-6);
  margin-top: var(--space-6);
}
.product-description h2 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.product-description p { white-space: pre-line; color: #4a4136; }

.result-count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}
.search-results { scroll-margin-top: 96px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-7);
  text-align: center;
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
}
.empty-state p { color: var(--color-text-muted); }

.contact-strip {
  margin-top: var(--space-7);
  padding: var(--space-7);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
}
.contact-strip h2 { font-size: var(--text-sm); margin-bottom: var(--space-1); }
.contact-strip p { color: var(--color-text-muted); margin-bottom: var(--space-6); }

/* ---------- 15. Giỏ hàng ---------- */
.checkout-form {
  display: grid;
  gap: var(--space-4);
}
.suggest-wrapper { position: relative; }
.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding-block: var(--space-4);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-6);
}
.cart-total-label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }
.cart-selected-count { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 400; }
.cart-total-value {
  font-size: var(--text-3xl);
  font-weight: 600;
  color: var(--color-accent);
  font-family: var(--font-mono);
}
.cart-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.cart-qty-form { display: flex; align-items: center; gap: var(--space-2); }
.cart-qty-input {
  width: 60px;
  min-height: var(--control-h);
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  text-align: center;
  font-family: var(--font-mono);
  background: var(--color-surface);
}
.checkout-section {
  margin-top: var(--space-7);
  padding-top: var(--space-7);
  border-top: 1px solid var(--color-border);
}
.checkout-section h2 { margin-bottom: var(--space-4); }
.honeypot {
  position: absolute !important;
  left: -9999px;
  width: 1px; height: 1px;
  opacity: 0;
}
.suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  margin-top: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 30;
  max-height: 288px;
  overflow-y: auto;
}
.suggestions-dropdown.hidden { display: none; }
.suggestion-item {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--color-border);
}
.suggestion-item:last-child { border-bottom: 0; }
.suggestion-item:hover { background: var(--color-surface-alt); }
.suggestion-name { font-size: var(--text-sm); font-weight: 600; }
.suggestion-phone { font-size: var(--text-sm); font-family: var(--font-mono); color: var(--color-accent); }
.suggestion-address {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 16. Auth + trang lỗi ---------- */
.login-wrapper {
  display: flex;
  justify-content: center;
  padding-block: var(--space-8);
}
.login-card {
  width: 100%;
  max-width: 420px;
  padding: var(--space-7);
}
.login-card h1 { margin-bottom: var(--space-6); }
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-4);
  text-align: center;
}
.error-page .display {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-text);
}

/* ---------- 17. Admin: khung chung ---------- */
.admin-page {
  max-width: 1180px;
  margin-inline: auto;
  padding: var(--space-6) var(--space-4);
}
.admin-header {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
@media (min-width: 640px) {
  .admin-header { flex-direction: row; align-items: center; }
}
.admin-header .header-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.back-link {
  display: inline-block;
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-accent);
}
.back-link:hover { text-decoration: underline; }
.inline-form { display: inline; }
.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-6);
}
.payment-form { margin-top: var(--space-4); }

/* Stats */
.stats-group { padding: var(--space-6); border-bottom: 1px solid var(--color-border); }
.stats-group:last-child { border-bottom: 0; }
.stats-group-title {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-4);
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stats-grid.stats-grid--3 { grid-template-columns: 1fr; }
@media (min-width: 640px) { .stats-grid.stats-grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .stats-grid.stats-grid--3 { grid-template-columns: repeat(3, 1fr); } }
.stat-card {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.stat-label { font-size: var(--text-sm); color: var(--color-text-muted); }
.stat-value {
  margin-top: var(--space-1);
  font-size: var(--text-2xl);
  font-weight: 600;
}
.stat-value--display { font-size: var(--text-3xl); color: var(--color-accent); }
.stat-value.is-success { color: var(--color-success); }
.stat-value.is-warning { color: var(--color-warning); }
.stat-value.is-muted { color: var(--color-text-muted); }
.stat-hint { margin-top: var(--space-2); font-size: var(--text-sm); color: var(--color-text-muted); }
.stat-note { margin-top: var(--space-2); font-size: var(--text-sm); color: var(--color-warning); }
.status-breakdown { list-style: none; padding: 0; }
.status-breakdown li { border-top: 1px solid var(--color-border); }
.status-breakdown li:first-child { border-top: 0; }
.status-breakdown a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
}
.status-breakdown a:hover { background: var(--color-surface); }

/* Bộ lọc đơn hàng */
.order-filter {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.order-filter-native {
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
@media (max-width: 767px) { .order-filter-native { display: none; } }
@media (min-width: 768px) { .custom-select.order-filter-mobile { display: none; } }
.custom-select { position: relative; }
.custom-select__button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--control-h);
  min-width: 200px;
  padding: 0 var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
}
.custom-select.is-open .custom-select__button { border-color: var(--color-accent); }
.custom-select__dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 50;
  max-height: 300px;
  overflow-y: auto;
}
.custom-select.is-open .custom-select__dropdown { display: block; }
.custom-select__option {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: 0;
  text-align: left;
  font-size: var(--text-sm);
}
.custom-select__option:hover { background: var(--color-surface-alt); }
.custom-select__option.active { background: var(--color-accent-soft); color: var(--color-accent); font-weight: 600; }

/* Chi tiết đơn */
.order-section {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-6);
  margin-top: var(--space-6);
}
.order-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.order-section h2 { font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-2); }
.order-meta {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: var(--space-2);
}
.order-meta dt { font-size: var(--text-sm); color: var(--color-text-muted); }
.order-meta dd { margin: 0; }
.order-meta-wide { grid-template-columns: 180px 1fr; }
.mono { font-family: var(--font-mono); }
.cod-cell-inline { font-weight: 600; color: var(--color-accent); font-family: var(--font-mono); }
.payment-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
}
.narrow-page { max-width: 672px; }
.order-terminal { color: var(--color-text-muted); }
.order-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  list-style: none;
  padding: 0 0 var(--space-7);
  margin: 0;
  overflow-x: auto;
}
.order-progress li {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
  padding-right: var(--space-5);
}
.order-progress li:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: var(--space-3);
  height: 1px;
  background: var(--color-border-strong);
}
.order-progress .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--color-border-strong);
  flex-shrink: 0;
}
.order-progress li.is-done { color: var(--color-success); }
.order-progress li.is-done .dot { background: var(--color-success); }
.order-progress li.is-current { color: var(--color-text); font-weight: 600; }
.order-progress li.is-current .dot { background: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
.input-narrow { width: 160px; }

/* ---------- 18. Gallery form sản phẩm (JS gán class trực tiếp) ---------- */
.gallery-section { margin-bottom: var(--space-6); }
.gallery-section h3 { margin-bottom: var(--space-1); }
.gallery-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-block: var(--space-3);
  border-radius: var(--radius-md);
}
.gallery-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.gallery-item img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); }
.gallery-item .badge-primary { position: absolute; top: var(--space-1); left: var(--space-1); z-index: 1; }
.gallery-actions { display: flex; justify-content: center; gap: var(--space-1); }
.reorder-btn,
.delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  padding: 0;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  line-height: 1;
}
.reorder-btn:hover:not(:disabled) { border-color: var(--color-accent); color: var(--color-accent); }
.reorder-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.delete-btn { color: var(--color-danger); }
.delete-btn:hover { background: var(--color-danger-soft); border-color: var(--color-danger); }
.gallery-upload { display: flex; gap: var(--space-2); }
.paste-received { animation: paste-flash 0.6s ease; }
@keyframes paste-flash {
  0% { outline: 3px solid var(--color-accent); outline-offset: 2px; background: var(--color-accent-soft); }
  100% { outline: 3px solid transparent; outline-offset: 2px; background: transparent; }
}

/* ---------- 19. Utilities cục bộ ---------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.muted { color: var(--color-text-muted); }
.hidden { display: none; }
