:root {
  --bg: #eef4fb;
  --bg-deep: #e2ecf8;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --line: rgba(12, 45, 107, 0.1);
  --brand: #1d6fd4;
  --brand-dark: #0c2d6b;
  --brand-mid: #2563eb;
  --brand-soft: #dbeafe;
  --brand-light: #f0f6fc;
  --accent: #3b82f6;
  --danger: #dc2626;
  --ok: #1d6fd4;
  --warn: #d97706;
  --sidebar: #0c2d6b;
  --sidebar-ink: #c7d9f0;
  --shadow: 0 18px 40px rgba(12, 45, 107, 0.08);
  --radius: 18px;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
  --font-body: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(29, 111, 212, 0.12), transparent 28%),
    radial-gradient(circle at 85% 10%, rgba(59, 130, 246, 0.1), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before,
.login-page::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(10px);
  opacity: 0.55;
  animation: drift 12s ease-in-out infinite alternate;
}

.login-page::before {
  width: 320px;
  height: 320px;
  background: rgba(29, 111, 212, 0.18);
  top: -80px;
  left: -40px;
}

.login-page::after {
  width: 280px;
  height: 280px;
  background: rgba(59, 130, 246, 0.16);
  right: -60px;
  bottom: -40px;
  animation-delay: -4s;
}

@keyframes drift {
  from { transform: translateY(0); }
  to { transform: translateY(24px); }
}

.login-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(12, 45, 107, 0.08);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 40px 36px 34px;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(10px);
  animation: rise 0.7s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark .logo-dot {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--brand), var(--brand-mid));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  position: relative;
}

.brand-mark .logo-dot::after {
  content: "";
  position: absolute;
  inset: 11px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(35deg);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.login-card h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 560;
}

.login-card .lead {
  margin: 0 0 28px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus {
  border-color: rgba(29, 111, 212, 0.55);
  box-shadow: 0 0 0 4px rgba(29, 111, 212, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  width: 100%;
  margin-top: 8px;
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 0.92rem;
}

.alert-error {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.15);
}

.alert-success {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid rgba(29, 111, 212, 0.18);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #0c2d6b 0%, #061e47 100%);
  color: var(--sidebar-ink);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 4px 0 24px rgba(6, 30, 71, 0.15);
}

.sidebar .brand-name {
  color: #fff;
  font-size: 1.55rem;
}

.sidebar .brand-sub {
  margin-top: 6px;
  font-size: 0.82rem;
  opacity: 0.72;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.nav-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--sidebar-ink);
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.nav-list a:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(2px);
}

.nav-list a.active {
  background: var(--brand-mid);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  font-weight: 700;
}

.nav-icon {
  width: 22px;
  text-align: center;
  opacity: 0.9;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-chip {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.user-chip strong {
  color: #fff;
}

.user-chip span,
.logout-link {
  font-size: 0.85rem;
  opacity: 0.75;
}

.logout-link:hover {
  opacity: 1;
  color: #fff;
}

.content {
  padding: 28px 32px 40px;
  background: linear-gradient(180deg, var(--bg) 0%, #e8f0fe 100%);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 2vw, 2.2rem);
  letter-spacing: -0.03em;
  color: var(--brand-dark);
}

.topbar p {
  margin: 6px 0 0;
  color: var(--ink-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card,
.panel {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(12, 45, 107, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 20px;
  animation: rise 0.55s ease both;
}

.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }

.stat-card .label {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.stat-card .value {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: -0.03em;
  color: var(--brand-dark);
}

.stat-card .meta {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--brand);
}

.panel {
  padding: 22px;
}

.panel h2 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--brand-dark);
}

.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
}

table.data-table th,
table.data-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.94rem;
  white-space: nowrap;
}

table.data-table th {
  color: var(--ink-soft);
  font-weight: 650;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-active,
.badge-confirmed,
.badge-delivered {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.badge-pending,
.badge-new,
.badge-in_progress {
  background: #fff1df;
  color: var(--warn);
}

.badge-inactive,
.badge-cancelled {
  background: #fdecea;
  color: var(--danger);
}

.empty-state {
  padding: 28px 10px;
  color: var(--ink-soft);
  text-align: center;
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content {
    padding: 20px 16px 32px;
  }

  .topbar {
    flex-direction: column;
    align-items: start;
  }
}

@media (max-width: 560px) {
  .stats-grid,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 28px 22px;
  }
}

.btn-link {
  color: var(--brand);
  font-weight: 700;
  font-size: 0.88rem;
}

.btn-link:hover {
  color: var(--brand-dark);
}

.tree {
  display: grid;
  gap: 12px;
}

.tree-category,
.tree-subcategory {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.tree-category > summary,
.tree-subcategory > summary,
.tree-subsub li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.tree-category > summary::-webkit-details-marker,
.tree-subcategory > summary::-webkit-details-marker {
  display: none;
}

.tree-main {
  display: grid;
  gap: 4px;
}

.tree-meta,
.help {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.tree-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tree-thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.tree-thumb-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  color: var(--ink-soft);
  background: var(--brand-light);
}

.tree-children {
  padding: 0 12px 12px 28px;
  display: grid;
  gap: 10px;
}

.tree-subsub {
  list-style: none;
  margin: 0;
  padding: 0 0 0 18px;
}

.tree-subsub li {
  border-top: 1px solid var(--line);
  cursor: default;
}

.form-panel {
  max-width: 720px;
}

.stack-form .input,
.stack-form select,
.stack-form input[type="text"],
.stack-form input[type="number"],
.stack-form input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
}

.stack-form input[type="checkbox"] {
  width: auto;
}

.current-image {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.current-image img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.action-card {
  display: grid;
  gap: 8px;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.action-card:hover {
  transform: translateY(-2px);
  border-color: rgba(29, 111, 212, 0.35);
}

.action-card span {
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.topbar-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.search-row .input {
  flex: 1;
}

.table-thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
  color: var(--ink-soft);
}

.form-panel-wide {
  max-width: 920px;
}

.multi-select {
  min-height: 220px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.image-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
}

@media (max-width: 900px) {
  .action-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Catalog & categories ===== */
.catalog-page,
.categories-page {
  display: grid;
  gap: 18px;
}

.catalog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.catalog-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 2vw, 2.2rem);
  color: var(--brand-dark);
}

.catalog-header p {
  margin: 6px 0 0;
  color: var(--ink-soft);
}

.catalog-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.catalog-header-actions .btn {
  width: auto;
  margin-top: 0;
  white-space: nowrap;
}

.btn-header {
  padding: 12px 18px;
  min-height: 44px;
}

.btn-categories {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  min-height: 44px;
  border-radius: 14px;
  border: 2px solid var(--brand);
  background: linear-gradient(180deg, #fff 0%, var(--brand-soft) 100%);
  color: var(--brand-dark);
  font: inherit;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(29, 111, 212, 0.15);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-categories:hover {
  transform: translateY(-1px);
  background: var(--brand-soft);
  box-shadow: 0 6px 18px rgba(29, 111, 212, 0.22);
}

.btn-categories .btn-icon {
  font-size: 1rem;
  line-height: 1;
}

.catalog-header-actions .btn-primary {
  box-shadow: 0 4px 14px rgba(29, 111, 212, 0.25);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-ghost:hover {
  background: var(--brand-light);
  border-color: rgba(29, 111, 212, 0.25);
}

.btn-sm {
  padding: 8px 12px !important;
  font-size: 0.82rem !important;
}

.catalog-filters {
  padding: 18px 20px;
}

.filters-form {
  display: grid;
  gap: 14px;
}

.filters-row {
  display: grid;
  gap: 12px;
}

.filters-row-main {
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
}

.filters-row-extra {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto auto;
  align-items: end;
}

.filter-field {
  display: grid;
  gap: 6px;
}

.filter-field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-field .input,
.filters-form select.input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
}

.filter-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-bottom: 2px;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.85rem;
  cursor: pointer;
}

.check-chip input {
  accent-color: var(--brand);
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-actions .btn-primary {
  width: auto;
  min-width: 130px;
}

.stats-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.product-tile {
  display: grid;
  grid-template-rows: auto 1fr;
  background: #fff;
  border: 1px solid rgba(12, 45, 107, 0.08);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  color: inherit;
}

.product-tile:hover {
  transform: translateY(-4px);
  border-color: rgba(29, 111, 212, 0.28);
  box-shadow: 0 24px 48px rgba(12, 45, 107, 0.12);
}

.product-tile-image {
  position: relative;
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, var(--brand-light), #e2ecf8);
  overflow: hidden;
}

.product-tile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-tile-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  gap: 4px;
  color: var(--ink-soft);
  font-size: 1.6rem;
}

.product-tile-placeholder small {
  font-size: 0.75rem;
}

.product-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mini-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mini-badge.new { background: #dbeafe; color: #1d4ed8; }
.mini-badge.promo { background: #fdecea; color: #b42318; }
.mini-badge.halal { background: var(--brand-soft); color: var(--brand-dark); }

.product-tile-body {
  padding: 12px 13px 14px;
  display: grid;
  gap: 6px;
}

.product-tile-body h3 {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.35;
  font-weight: 700;
  min-height: 2.5em;
}

.product-tile-meta {
  font-size: 0.76rem;
  color: var(--ink-soft);
}

.product-tile-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.product-price {
  font-weight: 800;
  color: var(--brand-dark);
  font-size: 0.98rem;
}

.product-brand {
  font-size: 0.72rem;
  color: var(--ink-soft);
  background: var(--brand-light);
  padding: 3px 8px;
  border-radius: 999px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.page-btn {
  padding: 10px 16px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 700;
  color: var(--brand);
}

.page-btn:hover {
  background: var(--brand-soft);
}

.page-info {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.empty-catalog {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  font-size: 2.4rem;
  margin-bottom: 8px;
}

.empty-catalog h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
}

.empty-catalog p {
  color: var(--ink-soft);
  margin: 0 0 18px;
}

.empty-catalog .btn-primary {
  width: auto;
  display: inline-flex;
}

/* Categories page */
.categories-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.cat-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}

.cat-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: linear-gradient(90deg, var(--brand-soft), #fff);
  border-bottom: 1px solid var(--line);
}

.cat-card-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cat-card-title h2 {
  margin: 0;
  font-size: 1.05rem;
}

.cat-card-title p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.cat-card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.cat-card-body {
  padding: 14px 18px 18px;
  display: grid;
  gap: 12px;
}

.subcat-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #f5f9fd;
}

.subcat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.subcat-head strong {
  flex: 1;
  min-width: 160px;
}

.ssc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ssc-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.82rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ssc-tag:hover {
  background: var(--brand-soft);
  border-color: rgba(29, 111, 212, 0.25);
}

.level-pill {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  flex-shrink: 0;
}

.level-pill.l1 { background: var(--brand-soft); color: var(--brand-dark); }
.level-pill.l2 { background: #fff1df; color: var(--warn); }
.level-pill.l3 { background: #eef2ff; color: #4338ca; }

.cat-empty {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

@media (max-width: 1400px) {
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filters-row-main { grid-template-columns: 1fr 1fr; }
  .filters-row-extra { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters-row-main,
  .filters-row-extra { grid-template-columns: 1fr; }
  .stats-grid-3 { grid-template-columns: 1fr !important; }
}

@media (max-width: 640px) {
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-header {
    flex-direction: column;
    align-items: stretch;
  }
  .catalog-header-actions {
    width: 100%;
    justify-content: stretch;
  }
  .catalog-header-actions .btn,
  .catalog-header-actions .btn-categories {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .product-grid { grid-template-columns: 1fr; }
}

/* ===== Product form ===== */
.product-form-page {
  display: grid;
  gap: 18px;
  max-width: 980px;
}

.product-form {
  display: grid;
  gap: 16px;
}

.form-section {
  padding: 22px 24px;
}

.form-section-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.form-section-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.form-section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--brand-dark);
}

.form-section-head p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-field-wide {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.product-form .input,
.product-form select,
.product-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.product-form .input:focus,
.product-form select:focus,
.product-form textarea:focus {
  outline: none;
  border-color: rgba(29, 111, 212, 0.55);
  box-shadow: 0 0 0 4px rgba(29, 111, 212, 0.1);
}

.product-form textarea {
  min-height: 120px;
  resize: vertical;
}

.product-form .multi-select {
  min-height: 200px;
}

.input-file {
  padding: 16px !important;
  background: var(--brand-light) !important;
  border-style: dashed !important;
  cursor: pointer;
}

.form-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.flag-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.2s, background 0.2s;
}

.flag-chip:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.flag-chip input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}

.field-error {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
}

.form-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  position: sticky;
  bottom: 12px;
  z-index: 5;
  box-shadow: 0 8px 32px rgba(12, 45, 107, 0.12);
}

@media (max-width: 768px) {
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .form-section {
    padding: 18px 16px;
  }

  .form-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }

.form-actions-bar .btn {
    width: 100%;
  }
}

.form-section-note {
  background: linear-gradient(180deg, #fff 0%, var(--brand-light) 100%);
  border-color: rgba(29, 111, 212, 0.15);
}

.form-section-note .form-section-head {
  margin-bottom: 0;
  border-bottom: 0;
  padding-bottom: 0;
}

.help-block {
  margin-bottom: 14px;
}

.category-check-grid ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.category-check-grid li label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.2s, background 0.2s;
}

.category-check-grid li label:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.category-check-grid input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.product-price-note {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.country-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.country-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
  color: var(--ink-soft);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.country-tab:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
}

.country-tab.active {
  background: var(--brand-mid);
  border-color: var(--brand-mid);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.country-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(12, 45, 107, 0.08);
  font-size: 0.78rem;
}

.country-tab.active .country-tab-count {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.country-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.country-badge.country-kz {
  background: #dbeafe;
  color: #1d4ed8;
}

.country-badge.country-kg {
  background: #fef3c7;
  color: #b45309;
}

@media (max-width: 768px) {
  .category-check-grid ul {
    grid-template-columns: 1fr;
  }

  .country-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .country-tab {
    white-space: nowrap;
  }
}
