/* ─── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:      #0066cc;
  --blue-dark: #004fa3;
  --blue-light:#e8f0fb;
  --accent:    #0369a1;
  --green:     #16a34a;
  --red:       #dc2626;
  --orange:    #ea580c;
  --gray-50:   #f8fafc;
  --gray-100:  #f1f5f9;
  --gray-200:  #e2e8f0;
  --gray-300:  #cbd5e1;
  --gray-400:  #94a3b8;
  --gray-500:  #64748b;
  --gray-700:  #334155;
  --gray-900:  #0f172a;
  --white:     #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
  --radius:    8px;
  --radius-lg: 12px;
}

html { font-size: 15px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ─── Utilities ────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--gray-500); font-size: .85rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-bold { font-weight: 600; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: .5rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .75rem; font-weight: 600;
}
.badge-blue   { background: var(--blue-light); color: var(--blue-dark); }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: var(--gray-200); color: var(--gray-500); }

/* ─── Toasts ───────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999; display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  padding: .75rem 1.25rem; border-radius: var(--radius);
  color: #fff; font-size: .9rem; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: slideIn .2s ease;
  max-width: 320px;
}
.toast-success { background: var(--green); }
.toast-error   { background: var(--red); }
.toast-info    { background: var(--blue); }
@keyframes slideIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; border: none;
  transition: background .15s, opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--blue); color: #fff; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-success   { background: var(--green); color: #fff; }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-icon { padding: .4rem; border-radius: var(--radius); background: transparent; border: none; }
.btn-icon:hover { background: var(--gray-100); }

/* ─── Forms ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; color: var(--gray-700); }
.form-control {
  width: 100%; padding: .5rem .75rem;
  border: 1.5px solid var(--gray-300); border-radius: var(--radius);
  font-size: .9rem; font-family: inherit; background: var(--white);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,102,204,.12); }
.form-control.error { border-color: var(--red); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }

/* ─── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 1.25rem; }

/* ─── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .65rem 1rem; text-align: left; border-bottom: 1px solid var(--gray-200); }
th { font-weight: 600; color: var(--gray-500); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; background: var(--gray-50); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ─── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem; border-top: 1px solid var(--gray-200);
  display: flex; justify-content: flex-end; gap: .75rem;
}

/* ─── Login Page ───────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0a1628 0%, #0c2659 50%, #0a3d8f 100%);
}
.login-box {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 2.5rem; width: 100%; max-width: 380px;
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo img { height: 56px; margin: 0 auto; }
.login-logo h1 { font-size: 1.5rem; color: var(--blue); margin-top: .75rem; font-weight: 700; }
.login-logo p { color: var(--gray-500); font-size: .88rem; margin-top: .25rem; }

/* ─── App Header ───────────────────────────────────────────────────────── */
.app-header {
  background: var(--blue-dark); color: var(--white);
  padding: 0 1.5rem; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.app-header .logo { font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; }
.app-header .logo span { color: #7ec8ff; }
.app-header .user-info { font-size: .85rem; opacity: .9; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.cart-btn {
  display: flex; align-items: center; gap: .5rem;
  background: rgba(255,255,255,.15); border: none; color: #fff;
  padding: .45rem .9rem; border-radius: var(--radius); cursor: pointer;
  font-size: .9rem; font-weight: 500; transition: background .15s;
}
.cart-btn:hover { background: rgba(255,255,255,.25); }
.cart-count {
  background: #ff5b5b; color: #fff; font-size: .72rem;
  padding: 2px 7px; border-radius: 20px; font-weight: 700;
}

/* ─── Catalog Layout ───────────────────────────────────────────────────── */
.catalog-layout { display: flex; height: calc(100vh - 60px); }

/* Sidebar nav */
.catalog-nav {
  width: 240px; min-width: 240px; background: var(--white);
  border-right: 1px solid var(--gray-200); overflow-y: auto;
  padding: 1rem 0;
}
.catalog-nav .nav-section { padding: .5rem 1rem .25rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); }
.catalog-nav .nav-tab {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem 1rem; cursor: pointer; font-size: .88rem;
  border-left: 3px solid transparent; transition: all .12s;
  color: var(--gray-700); margin: 1px 0;
}
.catalog-nav .nav-tab:hover { background: var(--blue-light); color: var(--blue); }
.catalog-nav .nav-tab.active { background: var(--blue-light); color: var(--blue); border-left-color: var(--blue); font-weight: 600; }
.catalog-nav .nav-tab .count { margin-left: auto; background: var(--gray-200); color: var(--gray-500); border-radius: 10px; font-size: .72rem; padding: 1px 7px; }
.catalog-nav hr { border: none; border-top: 1px solid var(--gray-200); margin: .75rem 0; }

/* Main area */
.catalog-main {
  flex: 1; overflow-y: auto; padding: 1.5rem;
  background: var(--gray-100);
}
.catalog-main .search-bar { position: relative; margin-bottom: 1.5rem; }
.catalog-main .search-bar input {
  width: 100%; padding: .6rem 1rem .6rem 2.5rem;
  border: 1.5px solid var(--gray-300); border-radius: 20px;
  font-size: .9rem; background: var(--white);
}
.catalog-main .search-bar input:focus { outline: none; border-color: var(--blue); }
.catalog-main .search-bar .search-icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--gray-400); }

.cat-header { margin-bottom: 1.25rem; }
.cat-header h2 { font-size: 1.25rem; font-weight: 700; color: var(--gray-900); }
.cat-header p { color: var(--gray-500); font-size: .88rem; margin-top: .2rem; }

.subcat-title { font-size: .95rem; font-weight: 600; color: var(--gray-700); margin: 1.5rem 0 .75rem; padding-bottom: .4rem; border-bottom: 2px solid var(--blue-light); }

/* Products grid */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.products-list  { display: flex; flex-direction: column; gap: .6rem; }

/* Product card */
.product-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .15s, transform .15s;
  border: 1.5px solid transparent;
}
.product-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--blue-light); }
.product-card .img-wrap {
  aspect-ratio: 1; background: var(--gray-50);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.product-card .img-wrap img { width: 100%; height: 100%; object-fit: contain; padding: .5rem; }
.product-card .img-placeholder { color: var(--gray-300); font-size: 3rem; }
.product-card .card-info { padding: .75rem; flex: 1; display: flex; flex-direction: column; }
.product-card .sku { font-size: .72rem; color: var(--gray-400); font-weight: 600; font-family: monospace; }
.product-card .name { font-size: .88rem; font-weight: 600; margin: .25rem 0; color: var(--gray-900); line-height: 1.3; flex: 1; }
.product-card .desc { font-size: .78rem; color: var(--gray-500); margin-bottom: .5rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card .pressure { font-size: .75rem; color: var(--accent); font-weight: 500; margin-bottom: .4rem; }
.product-card .price { font-size: 1rem; font-weight: 700; color: var(--blue); }
.product-card .add-row { display: flex; align-items: center; gap: .4rem; margin-top: .75rem; }
.qty-input { width: 56px; padding: .3rem .4rem; border: 1.5px solid var(--gray-300); border-radius: var(--radius); font-size: .88rem; text-align: center; }
.qty-input:focus { outline: none; border-color: var(--blue); }
.btn-add { flex: 1; padding: .35rem; font-size: .82rem; background: var(--blue); color: #fff; border: none; border-radius: var(--radius); font-weight: 600; transition: background .15s; }
.btn-add:hover { background: var(--blue-dark); }

/* Packeri list row */
.product-row {
  background: var(--white); border-radius: var(--radius);
  padding: .65rem 1rem; display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm); border: 1.5px solid transparent;
  transition: border-color .12s;
}
.product-row:hover { border-color: var(--blue-light); }
/* p-code = SKU column */
.p-code { font-family: monospace; font-size: .82rem; font-weight: 700; color: var(--blue); width: 80px; flex-shrink: 0; }
/* p-meta = description + bar + price group */
.p-meta { flex: 1; display: flex; align-items: center; gap: 1rem; min-width: 0; }
.p-meta .desc { flex: 1; font-size: .88rem; color: var(--gray-700); min-width: 0; }
.p-meta .pressure { font-size: .8rem; color: var(--gray-500); width: 60px; text-align: center; flex-shrink: 0; }
.p-meta .price { font-weight: 700; color: var(--blue); width: 100px; text-align: right; flex-shrink: 0; }
.product-row .add-row { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }

/* ─── Cart Sidebar ─────────────────────────────────────────────────────── */
.cart-sidebar {
  width: 360px; min-width: 360px; background: var(--white);
  border-left: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .25s ease;
  position: fixed; right: 0; top: 60px; bottom: 0; z-index: 50;
  box-shadow: var(--shadow-lg);
}
.cart-sidebar.open { transform: translateX(0); }
.cart-sidebar .cart-header {
  padding: .85rem 1.25rem; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 1rem;
}
.cart-close-btn {
  background: none; border: none; cursor: pointer;
  color: var(--blue); font-size: .82rem; font-weight: 600;
  padding: .3rem .5rem; border-radius: var(--radius);
  transition: background .12s;
}
.cart-close-btn:hover { background: var(--blue-light); }
.btn-clear-cart {
  width: 100%; background: none; border: 1.5px solid var(--gray-200);
  color: var(--red); font-size: .82rem; padding: .45rem; border-radius: var(--radius);
  cursor: pointer; margin-bottom: .75rem; font-weight: 500;
  transition: all .12s;
}
.btn-clear-cart:hover { background: #fee2e2; border-color: var(--red); }
.cart-sidebar .cart-items { flex: 1; overflow-y: auto; padding: .75rem; }
.cart-sidebar .cart-footer { border-top: 1px solid var(--gray-200); padding: 1rem 1.25rem; }
.cart-item { display: flex; gap: .75rem; padding: .65rem; border-radius: var(--radius); margin-bottom: .5rem; border: 1px solid var(--gray-200); }
.cart-item .ci-info { flex: 1; min-width: 0; }
.cart-item .ci-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item .ci-sku  { font-size: .75rem; color: var(--gray-400); font-family: monospace; }
.cart-item .ci-price { font-size: .85rem; color: var(--blue); font-weight: 600; margin-top: .2rem; }
.cart-item .ci-qty { display: flex; align-items: center; gap: .3rem; margin-top: .4rem; }
.cart-item .ci-qty button { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--gray-300); background: var(--white); font-size: .9rem; line-height: 1; cursor: pointer; }
.cart-item .ci-qty span { font-size: .88rem; font-weight: 600; min-width: 24px; text-align: center; }
.cart-item .ci-remove { color: var(--gray-400); background: none; border: none; cursor: pointer; font-size: 1rem; padding: .2rem; align-self: flex-start; }
.cart-item .ci-remove:hover { color: var(--red); }
.cart-empty { text-align: center; padding: 2rem; color: var(--gray-400); }
.cart-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 1rem; margin-bottom: 1rem; }
.cart-total span:last-child { color: var(--blue); }

/* Cart notes */
.cart-notes textarea {
  width: 100%; padding: .5rem; border: 1.5px solid var(--gray-300); border-radius: var(--radius);
  font-size: .85rem; font-family: inherit; resize: vertical; min-height: 60px; margin-bottom: .75rem;
}

/* ─── Orders History ───────────────────────────────────────────────────── */
.order-status {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 600;
}
.status-pending    { background: #fff7ed; color: #c2410c; }
.status-confirmed  { background: #eff6ff; color: #1d4ed8; }
.status-processing { background: #f0fdf4; color: #15803d; }
.status-shipped    { background: #ecfdf5; color: #059669; }
.status-cancelled  { background: #fef2f2; color: #991b1b; }

/* ─── Admin Layout ─────────────────────────────────────────────────────── */
.admin-layout { display: flex; height: calc(100vh - 60px); }
.admin-sidebar {
  width: 220px; min-width: 220px; background: var(--gray-900);
  padding: 1.5rem 0; display: flex; flex-direction: column;
}
.admin-sidebar .nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem 1.25rem; color: #94a3b8; font-size: .9rem;
  cursor: pointer; transition: all .12s; border-left: 3px solid transparent;
}
.admin-sidebar .nav-item:hover  { background: rgba(255,255,255,.05); color: #fff; }
.admin-sidebar .nav-item.active { background: rgba(255,255,255,.08); color: #fff; border-left-color: var(--blue); }
.admin-sidebar .nav-item svg    { opacity: .7; }
.admin-content { flex: 1; overflow-y: auto; padding: 1.5rem; }
.admin-content h1 { font-size: 1.35rem; font-weight: 700; margin-bottom: 1.5rem; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow-sm); }
.stat-card .label { font-size: .78rem; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); margin-top: .25rem; }
.stat-card .sub   { font-size: .8rem; color: var(--gray-400); margin-top: .2rem; }

/* ─── Misc ─────────────────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; gap: .5rem; color: var(--gray-500); padding: 3rem; }
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--gray-200);
  border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 3rem; color: var(--gray-400); }
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1rem; color: var(--gray-600); }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; }

.action-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.action-bar .spacer { flex: 1; }

/* ─── Category Grid ─────────────────────────────────────────────────────── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  padding: 1.5rem;
}
.category-card {
  position: relative; border-radius: var(--radius-lg);
  overflow: hidden; cursor: pointer; background: var(--gray-100);
  aspect-ratio: 4/3;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
  border: 1.5px solid var(--gray-200);
}
.category-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.category-card-img { width: 100%; height: 100%; }
.category-card-img img { width: 100%; height: 100%; object-fit: cover; }
.category-card-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; background: var(--gray-100);
}
/* Dark blue gradient overlay, white text */
.category-card-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top,
    rgba(0, 20, 70, 0.92) 0%,
    rgba(0, 40, 120, 0.68) 50%,
    rgba(0, 80, 180, 0.0) 100%);
  padding: 1.8rem .9rem .85rem;
}
.category-card-name {
  font-size: .92rem; font-weight: 700; line-height: 1.25;
  color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.category-card-count {
  font-size: .75rem; margin-top: .2rem;
  color: rgba(255,255,255,.82);
}

/* Back button */
.btn-back {
  display: inline-flex; align-items: center; gap: .35rem;
  background: none; border: none; color: var(--blue);
  font-size: .85rem; font-weight: 600; cursor: pointer;
  padding: 0; margin-bottom: .5rem;
}
.btn-back:hover { text-decoration: underline; }

/* ─── Hamburger button ──────────────────────────────────────────────────── */
.hamburger-btn {
  display: none;
  flex-direction: column; justify-content: center; align-items: center;
  gap: 5px; width: 36px; height: 36px;
  background: rgba(255,255,255,.12); border: none;
  border-radius: var(--radius); cursor: pointer; padding: .4rem;
  flex-shrink: 0;
}
.hamburger-btn span {
  display: block; width: 20px; height: 2px;
  background: #fff; border-radius: 2px;
  transition: all .22s ease;
}
.hamburger-btn.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ─── Drawer overlay ────────────────────────────────────────────────────── */
.drawer-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 390;
}
.drawer-overlay.active { display: block; }

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ─── Tablet ─────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* ── Header ── */
  .app-header { padding: 0 .85rem; }
  .header-actions { gap: .4rem; }
  .user-info { display: none; }
  .cart-label { display: none; }     /* show only icon + count */
  .hamburger-btn { display: flex; }

  /* ── Catalog layout ── */
  .catalog-layout { flex-direction: column; height: auto; min-height: calc(100vh - 60px); }

  /* Catalog nav → slide-in drawer */
  .catalog-nav {
    position: fixed; left: -290px; top: 0; bottom: 0;
    width: 280px; z-index: 400;
    transition: left .25s ease;
    flex-direction: column !important;
    overflow-y: auto; overflow-x: hidden;
    padding: 0 0 2rem;
    border-right: 1px solid var(--gray-200);
    border-bottom: none;
    /* push content below sticky header */
    padding-top: 70px;
  }
  .catalog-nav.drawer-open { left: 0; }
  .catalog-nav .nav-section { display: block; }
  .catalog-nav hr { display: block; }
  .catalog-nav .nav-tab { white-space: normal; border-radius: 0; }

  /* catalog-main takes full width */
  .catalog-main { flex: 1; padding: .75rem; }
  .catalog-main .search-bar { margin-bottom: 1rem; }

  /* ── Category grid: 2 columns, slightly smaller cards ── */
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: .55rem; padding: 0;
  }
  .category-card { aspect-ratio: 3/2; }   /* shorter than default 4/3 */

  /* ── Products: single column, horizontal card ── */
  .products-grid {
    grid-template-columns: 1fr;
    gap: .6rem;
    padding: 0;
  }
  .product-card {
    flex-direction: row;
    border-radius: var(--radius);
    max-height: 108px;
  }
  .product-card .img-wrap {
    width: 90px; min-width: 90px;
    aspect-ratio: unset; height: 100%;
    border-radius: var(--radius) 0 0 var(--radius);
    border-right: 1px solid var(--gray-200);
  }
  .product-card .card-info {
    padding: .6rem .75rem;
    justify-content: center;
  }
  .product-card .name { font-size: .85rem; }
  .product-card .desc { display: none; }   /* hide desc on mobile for space */
  .product-card .add-row { margin-top: .4rem; }
  .qty-input { width: 46px; }
  .btn-add { font-size: .78rem; padding: .3rem .5rem; }

  /* ── Packeri row: vertical card on mobile ── */
  .packeri-header-row { display: none !important; }
  .product-row {
    flex-direction: column; align-items: flex-start; gap: .4rem;
    padding: .85rem 1rem;
  }
  .p-code { width: auto; font-size: .8rem; }
  .p-meta {
    width: 100%; flex-direction: column; gap: .25rem; align-items: flex-start;
  }
  .p-meta .desc {
    font-size: .9rem; font-weight: 600; color: var(--gray-900);
    white-space: normal; width: 100%;
  }
  .p-meta .pressure,
  .p-meta .price { width: auto; text-align: left; font-size: .85rem; }
  /* Code · bar · price inline row */
  .p-meta { flex-direction: row; flex-wrap: wrap; gap: .3rem .75rem; }
  .p-meta .desc { flex: 1 1 100%; order: -2; margin-bottom: .1rem; }
  .product-row .add-row { width: 100%; justify-content: flex-end; margin-top: .2rem; }

  /* ── Cart: full-screen overlay ── */
  .cart-sidebar {
    position: fixed; top: 0; right: -100%;
    width: 100%; height: 100vh;
    z-index: 500; transition: right .25s ease;
    border-left: none; max-width: 100%;
  }
  .cart-sidebar.open { right: 0; }

  /* ── Admin layout ── */
  .admin-layout { flex-direction: column; height: auto; min-height: calc(100vh - 60px); }

  .admin-sidebar {
    position: fixed; left: -270px; top: 0; bottom: 0;
    width: 260px; z-index: 400;
    transition: left .25s ease;
    flex-direction: column !important;
    overflow-y: auto; padding: 70px 0 2rem;
  }
  .admin-sidebar.drawer-open { left: 0; }
  .admin-sidebar .nav-item {
    flex-direction: row; white-space: normal;
    border-radius: 0; padding: .75rem 1.25rem;
    font-size: .9rem;
  }

  .admin-content { padding: .85rem; }
  .admin-content h1 { font-size: 1.15rem; margin-bottom: 1rem; }

  /* ── Tables ── */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 580px; }

  /* ── Dashboard cards ── */
  #dashboardCards { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* ── Settings ── */
  #section-settings > div:first-of-type { grid-template-columns: 1fr !important; }

  /* ── Catalog section grids ── */
  #section-catalog > div:first-of-type { grid-template-columns: 1fr !important; }

  /* ── Modals ── */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100% !important; width: 100% !important;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
  }

  /* ── Touch targets ── */
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .btn-add { min-height: 38px; }

  /* ── Page header ── */
  .page-header { flex-wrap: wrap; gap: .5rem; }
  .page-header h1 { font-size: 1.1rem; }

  /* ── Cat header with back btn ── */
  .cat-header { margin-bottom: .85rem; }
  .cat-header h2 { font-size: 1.05rem; }
}

/* ── Very small phones ── */
@media (max-width: 400px) {
  .category-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ─── Dashboard stat card accents ──────────────────────────────────────────── */
.stat-card:nth-child(1) { border-top: 3px solid var(--blue); }
.stat-card:nth-child(2) { border-top: 3px solid var(--orange); }
.stat-card:nth-child(3) { border-top: 3px solid var(--green); }
.stat-card:nth-child(4) { border-top: 3px solid #8b5cf6; }
.stat-card .value { line-height: 1.15; }

/* ─── Category card hover refinement ───────────────────────────────────────── */
.category-card:hover .category-card-overlay {
  background: linear-gradient(to top,
    rgba(0, 15, 60, 0.97) 0%,
    rgba(0, 30, 100, 0.78) 50%,
    rgba(0, 60, 150, 0.1) 100%);
}

/* ─── Back button enhancement ───────────────────────────────────────────────── */
.btn-back {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--blue-light); border: none; color: var(--blue-dark);
  font-size: .83rem; font-weight: 600; cursor: pointer;
  padding: .35rem .75rem; border-radius: var(--radius);
  margin-bottom: .75rem; transition: background .12s;
}
.btn-back:hover { background: #d1e4fb; text-decoration: none; }

/* ─── Product card "Add" button pulse on hover ──────────────────────────────── */
.btn-add:active { transform: scale(.96); }

/* ─── Order status badges in modals ────────────────────────────────────────── */
.order-status::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; background: currentColor; opacity: .6; }

/* ─── Profile info table ───────────────────────────────────────────────────── */
#profileInfoBox { font-size: .88rem; }
#profileInfoBox tr:last-child td { border-bottom: none; }

/* ─── Settings cards Telegram/Customer ─────────────────────────────────────── */
#section-settings > div:first-of-type {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

/* ─── Scrollable modal body for long order lists ───────────────────────────── */
.modal-body table { font-size: .85rem; }

/* ─── WC Workflow steps ─────────────────────────────────────────────────────── */
.wf-step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .75rem;
  overflow: hidden;
}
.wf-step-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--bg-secondary);
  font-size: .9rem;
}
.wf-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-500);
  font-size: .78rem;
  font-weight: 700;
  flex-shrink: 0;
}
.wf-step-num.ok   { background: #dcfce7; color: #15803d; }
.wf-step-num.warn { background: #fff7ed; color: #c2410c; }
.wf-step-num.err  { background: #fee2e2; color: #991b1b; }
.wf-step-body {
  padding: .75rem 1rem;
  font-size: .875rem;
}
.wf-check-row {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
}
.wf-check-row:last-child { border-bottom: none; }
.wf-check-icon { flex-shrink: 0; font-size: 1rem; margin-top: .05rem; }
.wf-check-fix  { color: var(--text-secondary); font-size: .82rem; margin-top: .15rem; }
.wf-payload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-bottom: .75rem;
}
@media (max-width: 600px) { .wf-payload-grid { grid-template-columns: 1fr; } }
.wf-payload-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  font-size: .82rem;
}
.wf-payload-box strong { display: block; margin-bottom: .25rem; color: var(--text-secondary); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }

/* ─── Print styles ─────────────────────────────────────────────────────────── */
@media print {
  .app-header,
  .catalog-nav,
  .cart-sidebar,
  #toast-container,
  .drawer-overlay,
  .hamburger-btn,
  #ordersModal,
  #orderDetailModal,
  #profileModal { display: none !important; }
  body { background: #fff; }
  .catalog-main { padding: 0; }
}

/* Keep extended navigation usable on smaller screens. */
@media (max-width: 1100px) {
  .app-header .header-actions { min-width: 0; overflow-x: auto; margin-left: 12px; padding: 5px 0; }
  .app-header .header-actions > * { flex-shrink: 0; }
  .app-header > :first-child { flex-shrink: 0; }
}

/* ─── Catalog dashboard + category hero images (Catalog UX fix) ─────────── */
.catalog-dash { padding: 1.25rem 1.5rem 2rem; }
.catalog-dash .cat-header { padding: 0 0 1rem; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.dash-card { display: flex; flex-direction: column; background: #fff; border: 1.5px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.dash-card.is-off { opacity: .75; }
.dash-card-img { position: relative; aspect-ratio: 16/9; background: linear-gradient(135deg, #0b2a6b, #1d6fd1); overflow: hidden; }
.dash-fam-tapasan .dash-card-img { background: linear-gradient(135deg, #0f4c3a, #2a9d6f); }
.dash-fam-nodig_hd .dash-card-img { background: linear-gradient(135deg, #4a2a6b, #8a5bd1); }
.dash-fam-legacy .dash-card-img { background: linear-gradient(135deg, #444b57, #7a8394); }
.dash-card-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 40%; }
.dash-card-glyph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; opacity: .85; z-index: 0; }
.dash-card-img img { z-index: 1; }
.dash-card-body { padding: .9rem 1rem 1rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.dash-card-body h3 { margin: 0; font-size: 1.05rem; }
.dash-desc { margin: 0; font-size: .85rem; color: var(--gray-600); flex: 1; }
.dash-count { margin: 0; font-size: .8rem; color: var(--gray-500); }
.dash-count.dash-off { color: var(--st-warn-fg, #92400e); }
.dash-level { display: flex; flex-direction: column; gap: .2rem; font-size: .75rem; color: var(--gray-500); }
.dash-level select { padding: .35rem .5rem; border: 1px solid var(--gray-300); border-radius: 6px; font-size: .85rem; }
.nt-list { list-style: none; margin: .4rem 0 .8rem; padding: 0; }
.nt-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .45rem .7rem; border: 1px solid var(--gray-200); border-radius: 6px; margin-bottom: .35rem; word-break: break-all; }
.tax-panel:not(:empty) { margin: .75rem 0 1rem; padding: .75rem 1rem; border: 1px solid var(--gray-300); border-left: 4px solid #164f81; border-radius: 6px; background: #f3f7fb; font-size: .88rem; }
.tax-panel .tax-text { margin: .35rem 0; }
.tax-panel .tax-warn { margin: .4rem 0; padding: .5rem .5rem .5rem 1.5rem; border-radius: 6px; background: #fff4e0; border: 1px solid #f0c987; color: #7a4a00; }
.dash-level-note { margin: 0; font-size: .74rem; line-height: 1.35; color: var(--gray-500); }
.level-badge { display: inline-block; margin: 0 0 .75rem; padding: .25rem .65rem; border-radius: 999px; background: var(--gray-100); border: 1px solid var(--gray-200); font-size: .78rem; color: var(--gray-600); }
.shell .dash-card .dash-open, .dash-card .dash-open { margin-top: .3rem; min-height: 44px; justify-content: center; }
.category-card:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
/* hero banner above the products of a category: bounded height, never taller than the viewport allows */
.cat-hero { margin: 0 1.5rem 1rem; border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 21/6; max-height: 220px; background: var(--gray-100); }
.cat-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 640px) {
  .catalog-dash { padding: 1rem 16px 1.5rem; }
  .dash-grid { grid-template-columns: 1fr; }
  .cat-hero { margin: 0 16px .75rem; aspect-ratio: 16/7; max-height: 140px; }
}
/* administration: category hero images */
.cc-group { margin-bottom: 1.25rem; }
.cc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.cc-item.cc-cover { border-color: var(--primary, #1f5fbf); box-shadow: inset 0 3px 0 var(--primary, #1f5fbf); }
.cc-item { border: 1px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.cc-thumb { aspect-ratio: 16/9; background: var(--gray-100); display: flex; align-items: center; justify-content: center; color: var(--gray-500); font-size: .8rem; overflow: hidden; }
.cc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cc-meta { padding: .6rem .75rem .75rem; display: flex; flex-direction: column; gap: .35rem; }
.cc-meta strong { font-size: .92rem; }
.cc-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.cc-preview { max-width: 100%; max-height: 220px; display: block; margin: .5rem auto; border-radius: 8px; }
.cc-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.cc-lib button { padding: 0; border: 2px solid transparent; border-radius: 8px; background: var(--gray-100); aspect-ratio: 1; overflow: hidden; cursor: pointer; }
.cc-lib button[aria-pressed="true"] { border-color: var(--blue); }
.cc-lib img { width: 100%; height: 100%; object-fit: cover; }
