/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #1B3A6B;
  --accent-dark: #122850;
  --accent-light: #e8edf5;
  --bg: #F5F0E8;
  --surface: #ffffff;
  --border: #ddd8cc;
  --text: #1B3A6B;
  --text-light: #6c757d;
  --shadow: 0 2px 8px rgba(27,58,107,0.10);
  --shadow-md: 0 4px 16px rgba(27,58,107,0.13);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 60px;
  --nav-w: 220px;
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== HEADER ===== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(27,58,107,0.3);
}

.header-logo {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: white;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo span {
  font-weight: 300;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Mini switcher paniers dans le header */
.cart-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cart-switcher-btn {
  position: relative;
  background: rgba(255,255,255,0.15);
  border: 2px solid transparent;
  color: white;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  transition: background 0.15s, border-color 0.15s;
}
.cart-switcher-btn:hover {
  background: rgba(255,255,255,0.25);
}
.cart-switcher-btn.active {
  background: rgba(255,255,255,0.3);
  border-color: rgba(255,255,255,0.7);
}
.cart-switcher-btn .sw-qty {
  display: block;
  font-size: 9px;
  font-weight: 400;
  opacity: 0.8;
}
.cart-switcher-add {
  background: rgba(255,255,255,0.1);
  border: 2px dashed rgba(255,255,255,0.4);
  color: white;
  border-radius: 8px;
  width: 26px;
  height: 26px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.cart-switcher-add:hover {
  background: rgba(255,255,255,0.25);
}

.btn-icon {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 1.1rem;
  position: relative;
  flex-shrink: 0;
}

.btn-icon:hover, .btn-icon:active {
  background: rgba(255,255,255,0.28);
}

.cart-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: white;
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.menu-toggle {
  display: none;
}

/* ===== LAYOUT ===== */
.app-body {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* ===== SIDEBAR / BRAND NAV ===== */
.brand-nav {
  width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 900;
  transition: transform var(--transition);
  padding: 8px 0;
}

.brand-nav-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 12px 16px 6px;
}

.brand-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  border-left: 3px solid transparent;
  user-select: none;
}

.brand-nav-item:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.brand-nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 700;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  flex-shrink: 0;
}

.nav-separator {
  height: 1px;
  background: var(--border);
  margin: 8px 16px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--nav-w);
  flex: 1;
  padding: 20px;
  min-width: 0;
}

/* ===== VIEWS ===== */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* ===== CATEGORY FILTERS ===== */
.category-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ===== PRODUCT GRID ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.product-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.product-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.product-grid.cols-10 { grid-template-columns: repeat(10, 1fr); }

@media (max-width: 600px) {
  .product-grid.cols-5 { grid-template-columns: repeat(3, 1fr); }
  .product-grid.cols-10 { grid-template-columns: repeat(4, 1fr); }
}

/* Barre outils grille */
.grid-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 10px;
}
.grid-cols-label {
  font-size: 12px;
  color: var(--text-light);
  margin-right: 4px;
}
.grid-cols-btn {
  width: 32px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.grid-cols-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.product-card:active {
  transform: scale(0.98);
}

.product-img-wrap {
  aspect-ratio: 1 / 1;
  width: 100%;
  background: #f5f5f5;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.product-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: white;
  transition: transform 0.3s ease;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.product-card:hover .product-img {
  transform: scale(1.04);
}

.product-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 2.5rem;
  background: linear-gradient(135deg, #f5f5f5, #ebebeb);
}

.product-info {
  padding: 8px 10px 6px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.product-ref {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-category-tag {
  font-size: 0.68rem;
  color: var(--text-light);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-add-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(27,58,107,0.3);
  transition: background var(--transition), transform var(--transition);
  z-index: 2;
  line-height: 1;
}

.product-add-btn:hover {
  background: var(--accent-dark);
  transform: scale(1.12);
}

/* ===== PRODUCT DETAIL ===== */
.product-detail {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.product-detail.open {
  display: flex;
}

.detail-card {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  position: relative;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.08);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background var(--transition);
}

.detail-close:hover {
  background: rgba(0,0,0,0.16);
}

.detail-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #f5f5f5;
}

.detail-img-placeholder {
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #f5f5f5, #ebebeb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: var(--text-light);
  border-radius: var(--radius) var(--radius) 0 0;
}

.detail-body {
  padding: 20px;
}

.detail-brand {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.detail-ref {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.detail-category {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.qty-btn {
  background: var(--bg);
  border: none;
  padding: 8px 14px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
  font-weight: 700;
}

.qty-btn:hover {
  background: var(--border);
}

.qty-value {
  padding: 8px 12px;
  font-weight: 700;
  font-size: 1rem;
  min-width: 36px;
  text-align: center;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.size-input {
  flex: 1;
  min-width: 120px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}

.size-input:focus {
  border-color: var(--accent);
}

.btn-add-cart {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
  width: 100%;
  margin-top: 8px;
}

.btn-add-cart:hover {
  background: var(--accent-dark);
}

/* ===== CART VIEW ===== */
.cart-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.cart-empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.cart-empty h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--text);
}

.cart-table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  margin-bottom: 20px;
}

.cart-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
  font-size: 0.88rem;
}

.cart-table th {
  background: var(--bg);
  padding: 12px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

.cart-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.cart-table tr:last-child td {
  border-bottom: none;
}

.cart-table tr:hover td {
  background: var(--bg);
}

.cart-qty-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-qty-btn {
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--text);
}

.cart-qty-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cart-qty-btn.delete:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.cart-qty-num {
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

.cart-size-input {
  width: 90px;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  outline: none;
}

.cart-size-input:focus {
  border-color: var(--accent);
}

.cart-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--text-light);
}

.btn-danger {
  background: #fff0f0;
  color: #c00;
  border: 1.5px solid #fcc;
}

.btn-danger:hover {
  background: #c00;
  color: white;
  border-color: #c00;
}

/* ===== ORDER EXPORT FORM ===== */
.export-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  max-width: 600px;
}

.export-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

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

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
  background: var(--surface);
  color: var(--text);
}

.form-control:focus {
  border-color: var(--accent);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* ===== WEEKLY REPORT VIEW ===== */
.report-table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  margin-bottom: 20px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
  font-size: 0.85rem;
}

.report-table th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.report-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.report-table tr:last-child td {
  border-bottom: none;
}

.report-input {
  width: 100%;
  min-width: 80px;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  outline: none;
  background: var(--surface);
}

.report-input:focus {
  border-color: var(--accent);
}

.btn-add-row {
  background: none;
  border: 1.5px dashed var(--border);
  color: var(--text-light);
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  width: 100%;
  transition: all var(--transition);
  margin-top: 8px;
}

.btn-add-row:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-remove-row {
  background: #fee;
  border: 1px solid #fcc;
  color: #c0392b;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all var(--transition);
}

.btn-remove-row:hover {
  background: #c0392b;
  color: white;
  border-color: #c0392b;
}

/* ===== LOADING ===== */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.85);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.loading-overlay.show {
  display: flex;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 500;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 320px;
  pointer-events: auto;
}

.toast.success { background: #2d8a55; }
.toast.error { background: var(--accent); }
.toast.info { background: #2d6ea4; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== OFFLINE BANNER ===== */
.offline-banner {
  display: none;
  background: #f0ad4e;
  color: #333;
  text-align: center;
  padding: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  z-index: 800;
}

.offline-banner.show {
  display: block;
}

/* ===== SETTINGS PANEL ===== */
.settings-panel {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 340px;
  background: var(--surface);
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  z-index: 2500;
  overflow-y: auto;
  padding: 24px;
}

.settings-panel.open {
  display: block;
}

.settings-panel h2 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 20px;
}

.settings-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-light);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* ===== UPDATE BANNER ===== */
.update-banner {
  display: none;
  background: var(--primary);
  color: white;
  padding: 14px 20px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  gap: 16px;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 12px rgba(0,0,0,0.3);
}

.update-banner.show {
  display: flex;
}

.btn-update {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

/* ===== SECTION HEADER in PRODUCT GRID ===== */
.section-header {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 8px 0 4px;
  border-bottom: 2px solid var(--accent-light);
  margin-top: 8px;
}

/* ===== OVERLAY backdrop ===== */
.overlay-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 850;
}

.overlay-backdrop.show {
  display: block;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root {
    --nav-w: 0px;
  }

  .brand-nav {
    transform: translateX(-220px);
    width: 220px;
  }

  .brand-nav.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 12px;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .form-row {
    flex-direction: column;
  }

  .cart-actions {
    flex-direction: column;
  }

  .cart-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

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

/* ===== PRINT ===== */
@media print {
  .app-header, .brand-nav, .cart-actions { display: none; }
  .main-content { margin-left: 0; }
}

/* ===== SAFE AREA (iPhone notch) ===== */
@supports (padding: max(0px)) {
  .app-header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .main-content {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}

/* ===== NOUVEAUTÉS & BADGES ===== */
.badge-new {
  display: inline-block;
  background: #C0392B;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.badge-dispo {
  display: inline-block;
  background: #1b6e3a;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  margin-bottom: 4px;
  margin-left: 4px;
}

/* ===== PRIX ===== */
.product-price {
  font-size: 13px;
  font-weight: 600;
  color: #1B3A6B;
  margin-top: 2px;
}

/* ===== STOCK ===== */
.product-stock, .detail-stock {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
  margin-top: 2px;
}
.stock-ok { background: #d4edda; color: #155724; }
.stock-rupture { background: #f8d7da; color: #721c24; }
.stock-faible { background: #fff3cd; color: #856404; }
.stock-unknown { background: #e2e3e5; color: #383d41; }

/* ===== FICHE DÉTAIL ===== */
.detail-description {
  font-size: 13px;
  color: #555;
  margin: 8px 0;
  line-height: 1.5;
}
.detail-prices {
  display: flex;
  gap: 16px;
  margin: 8px 0;
}
.price-pa {
  font-size: 13px;
  color: #666;
}
.price-pp {
  font-size: 15px;
  font-weight: 700;
  color: #1B3A6B;
}
.detail-qty {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

/* ===== COMPTEUR MARQUE ===== */
.brand-count {
  display: inline-block;
  background: #1B3A6B;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: auto;
}
.brand-nav-name {
  flex: 1;
}
.brand-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== FILTRE NOUVEAUTÉS ===== */
.filter-new {
  background: #1B3A6B !important;
  color: white !important;
}

/* ===== COMPTEUR PRODUITS MARQUE ===== */
.brand-product-count {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  padding: 12px 16px 4px;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--accent-light);
  margin-bottom: 8px;
}

/* ===== DESCRIPTION COURTE ===== */
.product-desc-short {
  font-size: 11px;
  color: #666;
  margin-top: 3px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== SPECS (diamètre, étanchéité) ===== */
.product-spec {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

/* ===== PRIX PA/PP ===== */
.product-prices-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  flex-wrap: wrap;
}
.product-pa {
  font-size: 11px;
  color: #888;
}
.product-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

/* ===== BOUTONS +/- PANIER ===== */
.product-cart-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px 8px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  margin-top: auto;
  flex-shrink: 0;
}
.product-qty-btn {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--accent);
  background: white;
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
}
.product-qty-btn:hover {
  background: var(--accent);
  color: white;
}
.product-qty-display {
  min-width: 28px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

/* ===== SPECS DÉTAIL ===== */
.detail-specs {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px 0;
}
.detail-spec {
  font-size: 12px;
  color: #666;
  background: var(--accent-light);
  padding: 3px 8px;
  border-radius: 4px;
}

/* ===== FILTRES COMBINABLES ===== */
.filter-subrow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 4px 12px;
  border-left: 3px solid var(--accent-light);
  margin-top: 2px;
  width: 100%;
}
.filter-sub {
  font-size: 11px !important;
  padding: 3px 10px !important;
  background: var(--bg) !important;
  opacity: 0.85;
}
.filter-sub.active {
  background: var(--accent) !important;
  color: white !important;
  opacity: 1;
}
.filter-new-btn.active {
  background: #C0392B !important;
  border-color: #C0392B !important;
  color: white !important;
}

/* ===== SELECT TAILLE BAGUE ===== */
.bague-size-select {
  height: 32px;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  background: white;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  cursor: pointer;
  width: 160px;
  max-width: 100%;
}

/* ===== BOUTON MAJ FLOTTANT ===== */
.refresh-fab {
  display: block;
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(27,58,107,0.35);
  z-index: 1500;
  animation: pulse 2s infinite;
}
.refresh-fab.show { display: block; }
/* toujours visible */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ===== HAUTEUR UNIFORME CARTES ===== */
.product-grid .product-card {
  height: 100%;
}
.product-img-wrap {
  height: 0;
  padding-bottom: 100%;
  position: relative;
}
.product-img-wrap img,
.product-img-wrap .product-img-placeholder {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* ===== RÉCAP PANIER PAR MARQUE ===== */
.cart-recap {
  margin: 24px 0 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cart-recap-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  margin: 0;
}
.recap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.recap-table th {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  padding: 8px 12px;
  text-align: left;
}
.recap-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.recap-brand { font-weight: 700; color: var(--text); }
.recap-qty { color: var(--text-light); }
.recap-pa { color: var(--text-light); }
.recap-pp { font-weight: 700; color: var(--accent); }
.recap-total td {
  background: var(--accent);
  color: white !important;
  font-weight: 700;
  border: none;
}

/* ===== BARRE DE RECHERCHE ===== */
.search-bar-wrap {
  position: relative;
  margin: 8px 0 4px;
  display: flex;
  align-items: center;
}
.search-bar {
  width: 100%;
  padding: 10px 40px 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
  box-sizing: border-box;
}
.search-bar:focus { border-color: var(--accent); }
.search-clear {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 14px;
  cursor: pointer;
  display: none;
  padding: 4px;
}
.search-clear:hover { color: var(--accent); }

/* ===== RETOUR EN HAUT ===== */
.back-to-top {
  display: none;
  position: fixed;
  bottom: 70px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(27,58,107,0.3);
  z-index: 1400;
  transition: opacity var(--transition), transform var(--transition);
}
.back-to-top.show { display: flex; align-items: center; justify-content: center; }
.back-to-top:hover { transform: translateY(-2px); }

/* ===== BADGE MARQUES ===== */
.cart-brands-badge {
  display: none;
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-light);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  padding: 1px 5px;
  border-radius: 8px;
  border: 1px solid var(--accent);
}
#btnCart { position: relative; }

/* ===== MODALE CONFIRMATION ===== */
.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.confirm-modal h3 { margin: 0 0 8px; color: var(--text); font-size: 16px; }
.confirm-modal p { margin: 0 0 20px; color: var(--text-light); font-size: 14px; }
.confirm-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== GAMME SUR CARTE ===== */
.product-gamme {
  font-size: 10px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== REF + BOUTON COPIE ===== */
.product-ref-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}
.copy-ref-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 13px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
  flex-shrink: 0;
}
.product-card:hover .copy-ref-btn { opacity: 1; }
.copy-ref-btn:hover { color: var(--accent); }

/* ===== LONGUEUR ORUS ===== */
.orus-longueur {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 600;
  white-space: nowrap;
}

/* ===== ONGLETS PANIERS ===== */
.cart-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.cart-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.cart-tab:hover { color: var(--accent); background: var(--accent-light); }
.cart-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--accent-light);
}
.cart-tab-badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.cart-tab-badge:empty { display: none; }

/* ===== ONGLETS PANIERS DYNAMIQUES ===== */
.cart-tab {
  cursor: pointer;
  position: relative;
}
.cart-tab-name {
  cursor: pointer;
}
.cart-tab-remove {
  background: none;
  border: none;
  color: #aaa;
  font-size: 11px;
  cursor: pointer;
  padding: 0 0 0 4px;
  line-height: 1;
}
.cart-tab-remove:hover { color: #c0392b; }
.cart-tab-add {
  background: none;
  border: 2px dashed var(--border);
  border-radius: 6px 6px 0 0;
  padding: 6px 14px;
  font-size: 18px;
  color: var(--text-light);
  cursor: pointer;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.cart-tab-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* ===== FICHES ===== */
.fiche-tab-btn {
  padding: 8px 16px; border-radius: 8px; border: 2px solid #1b3a6b;
  background: white; color: #1b3a6b; font-weight: 600; font-size: 13px;
  cursor: pointer; transition: all 0.15s;
}
.fiche-tab-btn.active { background: #1b3a6b; color: white; }
.fiche-tab-btn:hover { background: #1b3a6b; color: white; }
.fiche-panel { display: none; }
.fiche-panel.active { display: block; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
