:root {
  --brand: #1559b7;
  --brand-700: #0d428d;
  --brand-900: #082752;
  --brand-050: #f3f7ff;
  --brand-100: #e5efff;
  --ink: #101828;
  --muted: #667085;
  --line: #e5eaf3;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #057647;
  --success-bg: #ecfdf3;
  --warning: #a15c07;
  --warning-bg: #fffaeb;
  --shadow: 0 22px 55px rgba(8, 39, 82, 0.09);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --sidebar-width: 290px;
  --font: "Segoe UI", Tahoma, Arial, sans-serif;
}

[data-theme="dark"] {
  --ink: #eef4ff;
  --muted: #b9c6d9;
  --line: #1f3558;
  --surface: #0c1729;
  --surface-2: #081225;
  --brand-050: #0f203a;
  --brand-100: #112a50;
  --shadow: 0 22px 55px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: linear-gradient(135deg, var(--surface-2), var(--brand-050));
  color: var(--ink);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 6px 0 18px; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(470px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 34px;
  padding: 34px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-logo-wrap {
  width: 112px;
  height: 112px;
  margin: 0 auto 18px;
  border-radius: 30px;
  background: var(--brand-050);
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
}
.auth-logo-wrap img { width: 86px; height: 86px; object-fit: contain; }
.auth-card h1 { margin: 0 0 8px; font-size: 26px; }
.auth-card p { margin: 0 0 24px; color: var(--muted); line-height: 1.8; }
.auth-help {
  text-align: right;
  margin-top: 18px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--warning);
  line-height: 1.8;
  border: 1px solid #fedf89;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
}
.sidebar {
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: transform 0.2s ease;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
}
.brand-block img {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  object-fit: contain;
  background: var(--brand-050);
  border: 1px solid var(--line);
}
.brand-block strong { display: block; font-size: 18px; }
.brand-block span { color: var(--muted); font-size: 13px; }
.side-nav { display: grid; gap: 8px; }
.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: right;
  padding: 14px 16px;
  border-radius: 16px;
  font-weight: 700;
  transition: 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.nav-item > span { min-width: 0; }
.nav-alert-badge {
  min-width: 21px;
  height: 21px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e02424;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(224, 36, 36, 0.28);
  border: 2px solid var(--surface);
}
.nav-item.active .nav-alert-badge {
  background: #e02424;
  color: #fff;
  border-color: rgba(255,255,255,0.9);
}
.nav-item:hover { background: var(--brand-050); color: var(--brand-700); }
.nav-item.active {
  background: var(--brand);
  color: white;
  box-shadow: 0 14px 28px rgba(21, 89, 183, 0.22);
}
.sidebar-footer { margin-top: auto; }
.status-chip {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: var(--surface-2);
}
.dot { width: 10px; height: 10px; border-radius: 999px; background: var(--success); }

.main-area { min-width: 0; }
.topbar {
  height: 88px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title, .topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-title h2 { margin: 0; font-size: 24px; }
.topbar-title p { margin: 3px 0 0; color: var(--muted); }
.search-input {
  width: 280px;
  max-width: 35vw;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  padding: 13px 16px;
  color: var(--ink);
  outline: none;
}
.search-input:focus, input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(21, 89, 183, 0.10); }

.section { display: none; padding: 28px; }
.active-section { display: block; }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.metric-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.metric-card { padding: 22px; }
.metric-card span, .metric-card small { color: var(--muted); }
.metric-card strong { display: block; font-size: 34px; margin: 8px 0; color: var(--brand); }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { padding: 22px; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.panel-header h3 { margin: 0; font-size: 22px; }
.panel-header p { margin: 4px 0 0; color: var(--muted); }
.split { gap: 16px; }
.info-list { display: grid; gap: 12px; }
.info-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 16px;
  background: var(--brand-050);
}
.info-list span { color: var(--muted); }
.activity-list { display: grid; gap: 10px; }
.activity-item { padding: 13px; background: var(--brand-050); border-radius: 15px; }
.activity-item b { display: block; }
.activity-item span { color: var(--muted); font-size: 13px; }
.empty-list { color: var(--muted); padding: 16px; border: 1px dashed var(--line); border-radius: 16px; }

.btn, .icon-btn {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 800;
  background: var(--surface);
  color: var(--ink);
  transition: 0.18s ease;
}
.btn:hover, .icon-btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--brand); color: white; border-color: var(--brand); box-shadow: 0 14px 28px rgba(21, 89, 183, 0.18); }
.btn.ghost { background: var(--brand-050); color: var(--brand-700); }
.btn.danger-lite { background: var(--danger-bg); color: var(--danger); border-color: #ffd0cc; }
.btn.success-lite { background: var(--success-bg); color: var(--success); border-color: #abefc6; }
.btn.full { width: 100%; }
.icon-btn { width: 46px; height: 46px; display: grid; place-items: center; padding: 0; }

.form-stack, .form-grid { display: grid; gap: 15px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label span { display: block; color: var(--muted); font-weight: 800; margin-bottom: 8px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
}
textarea { resize: vertical; line-height: 1.8; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 15px; background: var(--brand-050); }
.check-row input { width: auto; }
.check-row span { margin: 0; color: var(--ink); }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.filters-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  background: var(--brand-050);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 18px;
}
.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 850px; }
.data-table th, .data-table td { padding: 16px 12px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table th { color: var(--muted); font-size: 13px; }
.product-cell { display: flex; align-items: center; gap: 12px; }
.product-thumb { width: 48px; height: 48px; border-radius: 14px; object-fit: cover; background: var(--brand-050); border: 1px solid var(--line); display: grid; place-items: center; color: var(--brand); font-weight: 900; }
.product-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; border-radius: 999px; background: var(--brand-050); color: var(--brand-700); font-size: 12px; font-weight: 900; }
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.warn { background: var(--warning-bg); color: var(--warning); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { padding: 9px 12px; }

.wizard-panel { max-width: 1120px; }
.wizard-steps {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.wizard-step {
  border: 1px solid var(--line);
  background: var(--brand-050);
  color: var(--muted);
  border-radius: 18px;
  padding: 14px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
}
.wizard-step b {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--brand-700);
}
.wizard-step.active { background: var(--brand); color: white; border-color: var(--brand); }
.wizard-step.active b { color: var(--brand); }
.wizard-page { display: none; min-height: 260px; }
.wizard-page.active { display: block; }
.category-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.category-card {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 20px;
  padding: 18px;
  text-align: right;
  min-height: 110px;
}
.category-card.selected { border-color: var(--brand); background: var(--brand-050); box-shadow: inset 0 0 0 2px rgba(21, 89, 183, 0.13); }
.category-card img { width: 42px; height: 42px; object-fit: contain; border-radius: 12px; margin-bottom: 10px; }
.upload-box {
  border: 1px dashed var(--brand);
  background: var(--brand-050);
  border-radius: 24px;
  padding: 20px;
  display: grid;
  gap: 16px;
}
.upload-preview {
  min-height: 180px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.upload-preview.small { width: 94px; height: 94px; min-height: 94px; }
.upload-preview img { max-width: 100%; max-height: 100%; object-fit: contain; display: none; }
.review-box { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.review-box div { padding: 14px; border-radius: 15px; background: var(--brand-050); }
.wizard-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; }

.categories-layout { grid-template-columns: 1.1fr 0.9fr; align-items: start; }
.category-list { display: grid; gap: 12px; }
.category-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  background: var(--brand-050);
  border-radius: 18px;
  border: 1px solid var(--line);
}
.category-row img { width: 48px; height: 48px; object-fit: contain; border-radius: 13px; background: var(--surface); }
.category-row .no-icon { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; background: var(--surface); color: var(--muted); }
.category-meta strong { display: block; }
.category-meta span { color: var(--muted); font-size: 13px; }
.compact-panel { max-width: 720px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 39, 82, 0.50);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal-card {
  width: min(640px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
}
.modal-close { position: absolute; left: 18px; top: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 20px; }
.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 200;
  background: var(--brand-900);
  color: white;
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: 0.2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; right: 0; z-index: 50; transform: translateX(var(--sidebar-width)); }
  .sidebar.open { transform: translateX(0); }
  
  .metrics-grid, .grid-two { grid-template-columns: 1fr 1fr; }
  .topbar { align-items: stretch; height: auto; padding: 18px; flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .search-input { width: 100%; max-width: none; }
}
@media (max-width: 720px) {
  .metrics-grid, .grid-two, .form-grid, .filters-row, .review-box, .categories-layout { grid-template-columns: 1fr; }
  .wizard-steps { grid-template-columns: repeat(2, 1fr); }
  .section { padding: 16px; }
}
.full-field { grid-column: 1 / -1; }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }
code { direction: ltr; unicode-bidi: bidi-override; background: rgba(21,89,183,0.08); padding: 2px 6px; border-radius: 6px; }

/* v10 refinements */
.wizard-steps { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.integrated-categories {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 18px;
  align-items: start;
}
.sub-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-2);
  padding: 18px;
}
.field-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.11) !important;
  background: color-mix(in srgb, var(--danger-bg) 45%, var(--surface-2)) !important;
}
.field-error {
  display: block;
  margin-top: 7px;
  color: var(--danger);
  font-weight: 800;
  line-height: 1.5;
}
.review-box {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}
.review-box .review-item {
  display: grid;
  gap: 8px;
  min-height: 78px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--brand-050));
  word-break: break-word;
  overflow-wrap: anywhere;
}
.review-box .review-item.full { grid-column: 1 / -1; }
.review-box .review-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.review-box .review-item strong {
  display: block;
  line-height: 1.8;
  white-space: normal;
}
input:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}
@media (max-width: 980px) {
  .integrated-categories { grid-template-columns: 1fr; }
  .wizard-steps { grid-template-columns: repeat(2, 1fr); }
}


/* v11 refinements */
.app-shell.sidebar-collapsed {
  grid-template-columns: 0 1fr;
}
.app-shell.sidebar-collapsed .sidebar {
  transform: translateX(var(--sidebar-width));
  pointer-events: none;
}
.app-shell.sidebar-collapsed .main-area {
  grid-column: 2;
}
.wizard-progress {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--brand-050));
  border-radius: 22px;
  padding: 16px;
  margin-bottom: 22px;
  box-shadow: 0 12px 28px rgba(21, 89, 183, 0.08);
}
.wizard-progress-info {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.wizard-progress-info span {
  color: var(--brand);
  font-weight: 900;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
}
.wizard-progress-info strong { font-size: 18px; }
.wizard-progress-info small { color: var(--muted); font-weight: 700; text-align: left; }
.progress-track {
  height: 10px;
  background: color-mix(in srgb, var(--brand-100) 55%, var(--surface));
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-track span {
  display: block;
  height: 100%;
  width: 8%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-700), var(--brand));
  transition: width .35s ease;
  position: relative;
}
.progress-track span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  animation: progressShine 1.8s ease-in-out infinite;
}
@keyframes progressShine { from { transform: translateX(110%); } to { transform: translateX(-110%); } }
.category-manager-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: 18px;
  align-items: start;
}
.category-editor-panel { grid-column: 1 / -1; }
.category-ready-panel {
  display: grid;
  align-content: center;
  gap: 14px;
  min-height: 220px;
}
.category-actions .btn { min-width: 76px; justify-content: center; }
#category-no-icon:checked + span::after {
  content: "";
}
@media (max-width: 980px) {
  .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
  .app-shell.sidebar-collapsed .sidebar { transform: translateX(110%); }
  .wizard-progress-info { grid-template-columns: 1fr; }
  .wizard-progress-info small { text-align: right; }
  .category-manager-grid { grid-template-columns: 1fr; }
}



/* v12: قسم المخزون */
.inventory-layout {
  display: grid;
  gap: 18px;
}

.inventory-hero {
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--brand) 12%, transparent), transparent 34%),
    var(--surface);
}

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

.inventory-stat {
  padding: 18px;
  border-radius: 22px;
  background: var(--brand-050);
  border: 1px solid var(--line);
}

.inventory-stat span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.inventory-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
  color: var(--brand);
}

.inventory-stat.warning strong { color: var(--warning); }
.inventory-stat.danger strong { color: var(--danger); }

.inventory-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inventory-alerts,
.inventory-products {
  display: grid;
  gap: 12px;
}

.inventory-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--brand-050);
}

.inventory-alert strong {
  display: block;
  margin-bottom: 4px;
}

.inventory-alert span {
  color: var(--muted);
  font-size: 14px;
}

.inventory-alert.warn {
  background: var(--warning-bg);
  border-color: color-mix(in srgb, var(--warning) 28%, var(--line));
}

.inventory-alert.danger {
  background: var(--danger-bg);
  border-color: color-mix(in srgb, var(--danger) 28%, var(--line));
}

.inventory-product-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
}

.inventory-product-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.inventory-product-main img,
.product-placeholder {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--brand-050);
  object-fit: cover;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.inventory-product-main strong,
.inventory-product-main span {
  display: block;
}

.inventory-product-main span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.inventory-stock-box {
  display: grid;
  gap: 5px;
  justify-items: start;
  padding: 12px;
  border-radius: 18px;
  background: var(--brand-050);
}

.inventory-stock-box small {
  color: var(--muted);
  font-weight: 800;
}

.inventory-stock-box b {
  color: var(--brand);
  font-size: 24px;
}

.inventory-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 1100px) {
  .inventory-product-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .inventory-card-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .inventory-stats {
    grid-template-columns: 1fr;
  }
  .inventory-alert {
    align-items: stretch;
    flex-direction: column;
  }
}

/* v13: استجابة كاملة للهاتف والتابلت + نقل زر الوضع الليلي للقائمة الجانبية */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

img, svg, video, canvas {
  max-width: 100%;
}

.sidebar {
  width: var(--sidebar-width);
  max-width: calc(100vw - 24px);
}

.sidebar-theme-btn {
  width: 100%;
  margin-bottom: 12px;
  justify-content: center;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  border: 0;
  background: rgba(8, 39, 82, 0.36);
  backdrop-filter: blur(2px);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  min-width: 760px;
}

.data-table th,
.data-table td {
  white-space: nowrap;
}

.modal-card {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

@media (max-width: 1280px) {
  :root { --sidebar-width: 260px; }
  .section { padding: 22px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 20px; }
}

@media (max-width: 1100px) {
  :root { --sidebar-width: min(320px, 86vw); }

  .app-shell,
  .app-shell.sidebar-collapsed {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    inset: 0 0 0 auto;
    height: 100dvh;
    z-index: 60;
    transform: translateX(calc(100% + 24px));
    box-shadow: -20px 0 55px rgba(8, 39, 82, 0.16);
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  .sidebar.open {
    transform: translateX(0) !important;
    pointer-events: auto !important;
  }

  .sidebar.open + .sidebar-backdrop {
    display: block;
  }

  .app-shell.sidebar-collapsed .sidebar {
    transform: translateX(calc(100% + 24px));
  }

  .app-shell.sidebar-collapsed .main-area,
  .main-area {
    grid-column: auto;
    width: 100%;
  }

  .topbar {
    min-height: 78px;
    height: auto;
    padding: 14px 16px;
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .topbar-title {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-title h2 { font-size: 22px; }
  .topbar-title p { font-size: 14px; line-height: 1.6; }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .topbar-actions .search-input {
    width: 100%;
    max-width: none;
    grid-column: 1 / -1;
  }

  .topbar-actions .btn {
    min-height: 44px;
  }

  .section { padding: 18px; }
  .grid-two { grid-template-columns: 1fr; }
  .category-manager-grid { grid-template-columns: 1fr; }
  .inventory-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  :root {
    --radius-lg: 22px;
    --radius-md: 16px;
  }

  .auth-screen { padding: 16px; }
  .auth-card { padding: 24px 18px; border-radius: 28px; }
  .auth-card h1 { font-size: 22px; }

  .section { padding: 14px; }
  .panel,
  .metric-card,
  .sub-panel {
    border-radius: 22px;
    padding: 16px;
  }

  .metrics-grid,
  .grid-two,
  .form-grid,
  .filters-row,
  .review-box,
  .categories-layout,
  .inventory-stats {
    grid-template-columns: 1fr !important;
  }

  .panel-header,
  .panel-header.split {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .panel-header h3 { font-size: 20px; }
  .panel-header p { line-height: 1.7; }

  .wizard-panel { padding: 14px; }
  .wizard-progress { border-radius: 18px; padding: 14px; }
  .wizard-progress-info {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .wizard-progress-info small { text-align: right; line-height: 1.6; }

  .category-item,
  .inventory-product-card,
  .inventory-alert {
    grid-template-columns: 1fr !important;
    align-items: stretch;
  }

  .category-actions,
  .row-actions,
  .inventory-card-actions,
  .inventory-actions,
  .modal-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .row-actions .btn,
  .category-actions .btn,
  .inventory-card-actions .btn,
  .inventory-actions .btn,
  .modal-actions .btn {
    width: 100%;
    justify-content: center;
    padding-inline: 10px;
  }

  .btn, .icon-btn, input, select, textarea {
    min-height: 44px;
  }

  .upload-box {
    grid-template-columns: 1fr !important;
  }

  .modal { padding: 12px; }
  .modal-card {
    width: 100%;
    max-width: 100%;
    border-radius: 22px;
    padding: 18px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    text-align: center;
  }
}

@media (max-width: 560px) {
  .brand-block img { width: 50px; height: 50px; border-radius: 16px; }
  .brand-block strong { font-size: 16px; }
  .side-nav { gap: 6px; }
  .nav-item { padding: 13px 14px; }

  .topbar {
    padding: 12px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .topbar-title {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    align-items: center;
  }

  .topbar-title h2 {
    font-size: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-title p {
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .topbar-actions {
    grid-template-columns: 1fr 1fr;
  }

  .topbar-actions .search-input {
    grid-column: 1 / -1;
  }

  .section { padding: 10px; }
  .metric-card strong { font-size: 28px; }
  .info-list div { flex-direction: column; gap: 6px; }
  .review-box .review-item { min-height: auto; }

  .category-manager-grid,
  .inventory-layout,
  .form-stack,
  .form-grid {
    gap: 12px;
  }

  .category-actions,
  .row-actions,
  .inventory-card-actions,
  .inventory-actions,
  .modal-actions {
    grid-template-columns: 1fr;
  }

  .data-table { min-width: 680px; }

  .btn { padding: 11px 12px; }
}
