/* ASIT Sales App - Styles (vanilla CSS)
   NOTE: stylesheet is intentionally lightweight and focuses on core layout/components.
*/

/* Reset */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #F8F9FA;
  --color-surface: #FFFFFF;
  --color-primary: #0066CC;
  --color-primary-dark: #0052A3;
  --color-primary-light: #E6F2FF;
  --color-secondary: #28A745;
  --color-accent: #FF6B35;

  --color-text: #212529;
  --color-text-light: #6C757D;
  --color-text-muted: #ADB5BD;
  --color-border: #DEE2E6;
  --color-badge: #DC3545;

  --shadow: 0 2px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Links */
a { color: inherit; }

/* ===== TOP NAVIGATION ===== */
.top-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 8px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  min-height: var(--nav-height);
}

.nav-logo {
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
}

.nav-back {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  background: var(--color-bg);
  padding: 3px;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 1;
  min-width: 0;
  justify-content: center;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  border: none;
  background: transparent;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-light);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.nav-tab:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.nav-tab.active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.nav-actions { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }

.btn-icon {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-light);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover { background: var(--color-primary-light); color: var(--color-primary); }

.btn-back {
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-weight: 700;
  font-size: 14px;
  transition: background 0.15s;
}

.btn-back:hover { background: rgba(0,0,0,0.04); }

.badge {
  background: var(--color-badge);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 14px;
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--color-badge);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
}

/* ===== VIEWS ===== */
.main-content { flex: 1; position: relative; overflow-x: clip; }
.view {
  display: none;
  min-height: calc(100vh - var(--nav-height));
  width: 100%;
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}
.view.active { display: block; }

/* ===== DASHBOARD ===== */
.dashboard-container { max-width: 1400px; margin: 0 auto; padding: 24px 16px; }
.dashboard-header h1 { font-size: 28px; font-weight: 800; }
.dashboard-subtitle { color: var(--color-text-light); margin-top: 4px; }

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-value { font-size: 22px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--color-text-light); }

.dashboard-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.dashboard-action-btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  transition: box-shadow 0.15s;
}
.dashboard-action-btn:hover { box-shadow: var(--shadow); }

/* ===== CATALOG SELECTION ===== */
.catalog-selection { padding: 24px 16px; max-width: 1400px; margin: 0 auto; }
.view-header { text-align: center; margin-bottom: 20px; }
.view-header h1 { font-size: 26px; font-weight: 800; }
.view-subtitle { color: var(--color-text-light); margin-top: 4px; }

.catalog-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.catalog-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 0;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 200px;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}

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

.catalog-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
}

.catalog-card-overlay.no-image {
  background: transparent;
}

.catalog-card-icon {
  font-size: 2.5rem;
}

.catalog-card-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.catalog-card-overlay.no-image .catalog-card-title {
  color: #fff;
  text-shadow: none;
}

/* ===== BRAND SELECTION ===== */
.brand-selection { padding: 24px 16px; max-width: 1400px; margin: 0 auto; }
.brand-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.brand-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 28px 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 200px;
}
.brand-card:hover { 
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg); 
}

.brand-card-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.brand-card-logo {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.brand-card-logo img {
    max-width: 90%;
    max-height: 100%;
    object-fit: contain;
}

.brand-card:hover .brand-card-logo {
    transform: scale(1.05);
}

.brand-card-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--color-text);
}

/* ===== PRODUCT LIST VIEW ===== */
.product-list-view { padding: 0 0 18px; }

.product-toolbar-sticky {
  position: sticky;
  top: var(--nav-height);
  z-index: 95;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  padding-bottom: 4px;
}

.product-list-header {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-bar {
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
  position: relative;
  z-index: 3;
}
.search-bar input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  background: var(--color-surface);
  font-size: 16px; /* Prevents iOS zoom */
}

.btn-toggle-search {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-text-light);
}

.search-bar input:focus { border-color: var(--color-primary); }

/* Search suggestions */
.search-suggestions {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(100% - 2px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
  z-index: 10;
}

.search-suggestion {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  cursor: pointer;
}
.search-suggestion:last-child { border-bottom: none; }
.search-suggestion:hover { background: var(--color-primary-light); }

.suggestion-code { font-weight: 900; font-size: 13px; }
.suggestion-text { font-size: 12px; color: var(--color-text-light); margin-top: 2px; }
.suggestion-meta { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }

/* ===== PRODUCT FILTERS ===== */
.product-filters {
  display: flex;
  gap: 6px;
  padding: 4px 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-check {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

.filter-check input { accent-color: var(--color-primary); }

.filter-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.filter-range-label { font-size: 12px; font-weight: 800; color: var(--color-text-light); white-space: nowrap; }
.filter-range-inputs { display: inline-flex; align-items: center; gap: 6px; }
.filter-range-inputs input {
  width: 80px;
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  outline: none;
  font-size: 13px;
}
.filter-range-inputs input:focus { border-color: var(--color-primary); }
.filter-range-sep { color: var(--color-text-muted); font-weight: 900; }

.btn-clear-filters { padding: 5px 10px; border-radius: 999px; font-weight: 700; font-size: 11px; }

.btn-lang-toggle {
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  border: 2px solid var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-lang-toggle:hover {
  background: var(--color-primary);
  color: white;
}

.brand-filter {
  display: flex;
  gap: 5px;
  padding: 2px 16px 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.brand-filter::-webkit-scrollbar { display: none; }

.brand-chip {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.brand-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* ===== CATALOG LAYOUT (sidebar + products) ===== */
.catalog-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
  padding: 0 16px;
}

.category-sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  height: fit-content;
  position: sticky;
  top: calc(var(--toolbar-bottom, var(--nav-height)) + 8px);
  max-height: calc(100vh - var(--toolbar-bottom, var(--nav-height)) - 24px);
  overflow-y: auto;
  z-index: 90;
}

.category-header {
  padding: 12px 14px;
  font-weight: 800;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

.category-list { padding: 6px; }

.category-item {
  padding: 9px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text);
  transition: background 0.15s;
}

.category-item:hover { background: rgba(0,0,0,0.04); }

.category-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
}

/* Gerarchia a 2 livelli nella sidebar */
.category-item-parent {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.category-expand-arrow {
  margin-left: auto;
  font-size: 14px;
  opacity: 0.5;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.category-series-list {
  padding-left: 8px;
  border-left: 2px solid rgba(74, 144, 226, 0.2);
  margin-left: 8px;
  margin-bottom: 4px;
}

.category-item-series {
  font-size: 12px;
  padding: 6px 8px;
  color: var(--color-text-light);
}

.category-item-series.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.category-item-series:hover {
  background: rgba(0,0,0,0.04);
}

.product-list {
  min-height: 240px;
}


.product-count { color: var(--color-text-light); font-weight: 800; font-size: 12px; }

.btn-sort-price {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 12px;
  color: var(--color-text);
  white-space: nowrap;
  transition: box-shadow 0.15s;
}
.btn-sort-price:hover { box-shadow: var(--shadow); }
.btn-sort-price.active { border-color: rgba(0, 102, 204, 0.45); background: var(--color-primary-light); color: var(--color-primary); }
.sort-icon { font-weight: 900; }

/* ===== PRODUCT CARD ===== */
.product-card {
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  gap: 0 16px;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
.product-card:hover { box-shadow: var(--shadow-md); }
.product-card:active { transform: scale(0.99); }

/* Image */
.pc-image {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0,0,0,0.06);
  overflow: hidden;
  flex-shrink: 0;
}
.pc-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.pc-image img.placeholder { opacity: 0.25; }

/* Details: SKU + description */
.pc-details {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pc-sku {
  font-weight: 800;
  font-size: 14px;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pc-desc {
  font-size: 13px;
  color: var(--color-text-light);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Price area */
.pc-price-area {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  white-space: nowrap;
  min-width: 130px;
}
.pc-discount-badge {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}
.pc-prices {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.pc-list-price {
  font-size: 12px;
  color: var(--color-text-muted);
}
.pc-list-label { font-weight: 400; }
.pc-list-value {
  text-decoration: line-through;
  font-weight: 600;
}
.pc-net-price {
  font-size: 16px;
  font-weight: 800;
  color: var(--color-primary);
}

/* Cart button */
.pc-cart-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.pc-cart-btn:hover { background: var(--color-primary-dark, #0052a3); transform: scale(1.1); }
.pc-cart-btn:active { transform: scale(0.95); }

/* Cart quantity badge on product card */
.pc-image { position: relative; }

.pc-cart-qty-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: #2e7d32;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 2;
  pointer-events: none;
  line-height: 1;
}

.pc-cart-qty-badge-pop {
  animation: cartBadgePop 0.3s ease;
}

@keyframes cartBadgePop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.product-card.in-cart {
  border-left: 3px solid #2e7d32;
}

.product-card.added-to-cart-flash {
  animation: cartFlash 0.7s ease;
}

@keyframes cartFlash {
  0%   { background: var(--color-surface); }
  30%  { background: rgba(46,125,50,0.10); }
  100% { background: var(--color-surface); }
}

/* Legacy classes kept for detail modal */
.product-code { font-weight: 800; font-size: 14px; }
.product-description { color: var(--color-text-light); font-size: 13px; margin-top: 4px; }
.product-availability { font-size: 12px; color: var(--color-text-muted); margin-top: 6px; }
.product-availability.unavailable { color: #b00020; font-weight: 700; }
.product-prices { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.product-price-list, .product-price-net { display: flex; gap: 6px; font-size: 12px; }
.price-label { color: var(--color-text-muted); }
.price-value { font-weight: 800; }
.price-net { color: var(--color-primary); }
.price-strikethrough { text-decoration: line-through; color: var(--color-text-muted); font-weight: 700; }

.product-qty-controls { display: inline-flex; gap: 6px; align-items: center; margin-top: 4px; }
.btn-qty {
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: border-color 0.15s;
}
.btn-qty:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-qty:hover:not(:disabled) { border-color: var(--color-primary); }
.product-qty-value { min-width: 18px; text-align: center; font-weight: 800; }

/* ===== CUSTOMERS ===== */
.customers-layout { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - var(--nav-height)); }
.customers-sidebar { background: var(--color-surface); border-right: 1px solid var(--color-border); }
.customer-search-bar { padding: 12px; border-bottom: 1px solid var(--color-border); position: relative; }
.customer-search-bar input {
  width: 100%;
  border: 1px solid var(--color-border);
  padding: 10px 12px 10px 36px;
  border-radius: 8px;
  outline: none;
  font-size: 16px; /* Prevents iOS zoom */
}
.customer-search-bar input:focus { border-color: var(--color-primary); }
.btn-clear-search {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--color-text-muted);
}
.customer-list { padding: 8px; overflow-y: auto; max-height: calc(100vh - 140px); }
.customer-item {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
.customer-item:hover { box-shadow: var(--shadow); }
.customer-item.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.customer-name { font-weight: 800; font-size: 14px; }
.customer-code { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.customer-item.active .customer-code { color: rgba(255,255,255,0.85); }

.customer-detail-panel { background: var(--color-surface); overflow-y: auto; }
.customer-detail-header { padding: 12px 16px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.customer-detail-header h1 { font-size: 18px; }
.customer-tabs { display: flex; gap: 0; padding: 0 16px; border-bottom: 1px solid var(--color-border); overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.customer-tabs::-webkit-scrollbar { display: none; }
.customer-tab {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 10px 12px;
  color: var(--color-text-muted);
  border-bottom: 3px solid transparent;
  font-weight: 700;
  white-space: nowrap;
  font-size: 13px;
  transition: color 0.15s, border-color 0.15s;
}
.customer-tab.active { color: var(--color-text); border-bottom-color: var(--color-primary); }
.customer-detail { padding: 16px; }

/* ===== ADMIN VIEW (dashboard — sfondo chiaro: NO testo bianco) ===== */
#viewAdmin .admin-tabs-row {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  scrollbar-width: none;
}
#viewAdmin .admin-tabs-row::-webkit-scrollbar { display: none; }
#viewAdmin .admin-tab {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: color 0.15s, border-color 0.15s;
}
#viewAdmin .admin-tab:hover {
  color: var(--color-text-light);
}
#viewAdmin .admin-tab.active {
  color: var(--color-text);
  border-bottom-color: var(--color-primary);
}

.admin-hint-box {
  margin-bottom: 24px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  line-height: 1.45;
}
.admin-hint-box strong { color: var(--color-text); }
.admin-hint-box__text {
  margin: 8px 0 0 0;
  opacity: 0.92;
  color: var(--color-text-light);
}

/* ===== CART ===== */
.cart-header { 
    padding: 14px 16px; 
    background: var(--color-surface); 
    border-bottom: 1px solid var(--color-border); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    position: sticky;
    top: var(--nav-height);
    z-index: 100;
    gap: 8px;
}

.cart-content { 
    padding: 16px; 
    max-width: 1400px; 
    margin: 0 auto; 
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Cart Summary Header */
.cart-summary {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.cart-summary-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 18px;
}

@media (max-width: 820px) {
    .cart-summary-grid {
        grid-template-columns: 1fr;
    }
    .cart-footer-totals,
    .cart-margin-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .cart-footer-grand { text-align: left; }
}

.cart-summary-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cart-summary-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.cart-summary-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

/* Cart Items */
.cart-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-item {
    display: grid;
    grid-template-columns: 80px minmax(120px, 1fr) minmax(160px, 200px) 100px minmax(100px, 120px) 40px;
    gap: 12px;
    align-items: center;
    padding: 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease;
}

.cart-item > * { min-width: 0; }

.cart-item:hover {
    box-shadow: var(--shadow-md);
}

.cart-item-image { 
    width: 80px; 
    height: 80px; 
    object-fit: contain; 
    background: #fff; 
    border-radius: var(--radius-md); 
    border: 1px solid rgba(0,0,0,0.06); 
}

.cart-item-clickable {
    cursor: pointer;
}
.cart-item-clickable:hover {
    opacity: 0.8;
}

.cart-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cart-item-code { 
    font-weight: 800; 
    font-size: 14px; 
    color: var(--color-primary); 
}

.cart-item-brand {
    font-size: 11px;
    color: var(--color-text-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.cart-item-desc { 
    color: var(--color-text); 
    font-size: 13px; 
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cart-item-notes input {
    margin-top: 6px;
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 12px;
    background: var(--color-bg);
}

.cart-item-notes input:focus {
    border-color: var(--color-primary);
    background: #fff;
    outline: none;
}

/* Price & Discounts Section */
.cart-item-pricing {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    min-width: 0;
    overflow-wrap: break-word;
}

.cart-margin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
}
.cart-margin-badge.warning {
    background: #fff3e0;
    color: #e65100;
    border-color: #ffcc80;
}
.cart-margin-badge.critical {
    background: #ffebee;
    color: #c62828;
    border-color: #ef9a9a;
    animation: marginPulse 1.6s ease-in-out infinite;
}
@keyframes marginPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(198,40,40,0.0); }
    50% { box-shadow: 0 0 0 4px rgba(198,40,40,0.15); }
}

/* ==========================================================
   Modale "Discount Auth" — design pulito e moderno
   ========================================================== */
.disc-auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: discAuthFadeIn 0.18s ease-out;
}
@keyframes discAuthFadeIn { from { opacity: 0; } to { opacity: 1; } }

.disc-auth-card {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.32);
    display: flex;
    flex-direction: column;
    position: relative;
    animation: discAuthSlideUp 0.22s cubic-bezier(.2,.8,.2,1);
}
@keyframes discAuthSlideUp { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.disc-auth-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.85);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    z-index: 2;
    color: #333;
}
.disc-auth-close:hover { background: #fff; }

.disc-auth-header {
    padding: 22px 24px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    overflow: hidden;
}
.disc-auth-header::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(255,255,255,0.18), transparent 60%);
    pointer-events: none;
}
.disc-auth-modal.is-warning .disc-auth-header {
    background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
}
.disc-auth-modal.is-critical .disc-auth-header {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
}

.disc-auth-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.22);
    border: 2px solid rgba(255,255,255,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

.disc-auth-titles { flex: 1; min-width: 0; }
.disc-auth-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 6px;
}
.disc-auth-subtitle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    opacity: 0.95;
}
.disc-auth-pill {
    background: rgba(255,255,255,0.22);
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    font-size: 11px;
}
.disc-auth-sku {
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    opacity: 0.95;
}

.disc-auth-body {
    padding: 22px 24px 18px;
    overflow-y: auto;
    flex: 1;
}

.disc-auth-hero {
    text-align: center;
    margin-bottom: 18px;
}
.disc-auth-hero-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 4px;
}
.disc-auth-hero-value {
    font-size: 44px;
    font-weight: 800;
    line-height: 1;
    color: #0f172a;
    letter-spacing: -1px;
}
.disc-auth-hero-value span {
    font-size: 22px;
    margin-left: 4px;
    color: #64748b;
    font-weight: 600;
}
.disc-auth-modal.is-critical .disc-auth-hero-value { color: #dc2626; }
.disc-auth-modal.is-warning  .disc-auth-hero-value { color: #ea580c; }

.disc-auth-hero-max {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}
.disc-auth-hero-max b { color: #0f172a; }

.disc-auth-bar {
    position: relative;
    height: 8px;
    background: #f1f5f9;
    border-radius: 999px;
    margin-top: 14px;
    overflow: hidden;
}
.disc-auth-bar-fill {
    position: absolute; left: 0; top: 0; bottom: 0;
    background: linear-gradient(90deg, #fbbf24, #ea580c);
    border-radius: 999px;
    transition: width 0.3s ease;
}
.disc-auth-modal.is-critical .disc-auth-bar-fill {
    background: linear-gradient(90deg, #ea580c, #dc2626);
}
.disc-auth-bar-over {
    position: absolute; right: 0; top: 0; bottom: 0;
    background: repeating-linear-gradient(45deg,
        #dc2626, #dc2626 6px, #991b1b 6px, #991b1b 12px);
    border-radius: 999px;
    box-shadow: 0 0 8px rgba(220,38,38,0.5);
}
.disc-auth-bar-marker {
    position: absolute;
    right: 0; top: -4px; bottom: -4px;
    width: 2px;
    background: #0f172a;
    border-radius: 1px;
}

.disc-auth-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.disc-auth-cell {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.disc-auth-cell.highlight {
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-color: #c7d2fe;
}
.disc-auth-cell-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #64748b;
    font-weight: 600;
}
.disc-auth-cell-value {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}
.disc-auth-cell-hint {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}
.disc-auth-cell.highlight .disc-auth-cell-hint { color: #4338ca; font-weight: 600; }

.disc-auth-alert {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 14px;
    align-items: flex-start;
}
.disc-auth-alert b { font-weight: 700; }
.disc-auth-alert-icon {
    flex-shrink: 0;
    font-size: 18px;
    line-height: 1;
    margin-top: 1px;
}
.disc-auth-alert.warning {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}
.disc-auth-alert.critical {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.disc-auth-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 6px;
}
.disc-auth-label .req { color: #dc2626; }
.disc-auth-textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    color: #0f172a;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.disc-auth-textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.disc-auth-footer {
    padding: 14px 18px 18px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.disc-auth-btn {
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.15s ease;
    line-height: 1;
}
.disc-auth-btn:active { transform: translateY(1px); }
.disc-auth-btn.ghost {
    background: #fff;
    border-color: #cbd5e1;
    color: #475569;
}
.disc-auth-btn.ghost:hover { background: #f1f5f9; color: #0f172a; }
.disc-auth-btn.primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    box-shadow: 0 4px 14px rgba(79,70,229,0.32);
}
.disc-auth-btn.primary:hover { box-shadow: 0 6px 18px rgba(79,70,229,0.4); }
.disc-auth-modal.is-critical .disc-auth-btn.primary {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    box-shadow: 0 4px 14px rgba(220,38,38,0.35);
}
.disc-auth-modal.is-critical .disc-auth-btn.primary:hover {
    box-shadow: 0 6px 18px rgba(220,38,38,0.45);
}

@media (max-width: 520px) {
    .disc-auth-grid { grid-template-columns: 1fr; }
    .disc-auth-hero-value { font-size: 38px; }
    .disc-auth-header { padding: 18px 18px; }
    .disc-auth-body { padding: 18px 18px 14px; }
    .disc-auth-footer { flex-direction: column-reverse; }
    .disc-auth-btn { width: 100%; justify-content: center; }
}

.cart-item-unit-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cart-item-unit-row label {
    font-size: 11px;
    color: var(--color-text-muted);
}

.cart-item-unit-row input {
    width: 80px;
    padding: 5px;
    text-align: right;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
}

.cart-item-discounts-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.cart-discount-stepper {
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
    height: 32px;
}

.cart-discount-stepper-btn {
    width: 26px;
    height: 32px;
    background: var(--color-bg);
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1;
    transition: background 0.15s;
    flex-shrink: 0;
}
.cart-discount-stepper-btn:hover { background: var(--color-border); }

.cart-discount-input {
    width: 46px;
    height: 32px;
    padding: 0 2px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-surface);
    -moz-appearance: textfield;
}
.cart-discount-input::-webkit-outer-spin-button,
.cart-discount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Quantity Control */
.cart-item-qty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
}

.cart-qty-btn {
    width: 32px;
    height: 32px;
    background: var(--color-bg);
    border: none;
    cursor: pointer;
    font-weight: 700;
    color: var(--color-text);
    transition: background 0.15s;
}

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

.cart-qty-input {
    width: 40px;
    height: 32px;
    border: none;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    text-align: center;
    font-weight: 600;
    -moz-appearance: textfield;
}

/* Total Price */
.cart-item-total {
    text-align: right;
    font-weight: 800;
    font-size: 15px;
    color: var(--color-text);
    overflow-wrap: break-word;
    word-break: break-word;
}

.cart-item-remove { 
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none; 
    background: rgba(220, 53, 69, 0.1); 
    cursor: pointer; 
    color: var(--color-badge); 
    border-radius: 8px; 
    transition: background 0.2s;
    flex-shrink: 0;
}
.cart-item-remove:hover { background: rgba(220, 53, 69, 0.2); }

/* Cart Footer */
.cart-footer {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.cart-total-row {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 16px;
}

.cart-total-label { font-weight: 600; color: var(--color-text-muted); }
.cart-total-value { font-weight: 900; color: var(--color-primary); font-size: 22px; }

/* Cart footer totals grid + margin bar grid */
.cart-footer-totals,
.cart-margin-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    align-items: center;
}
.cart-footer-label {
    font-size: 10px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
    white-space: nowrap;
}
.cart-footer-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-text);
    overflow-wrap: break-word;
    word-break: break-word;
}
.cart-footer-grand { text-align: right; }

/* ===== BUTTONS ===== */
.btn-primary {
  border: none;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
  transition: box-shadow 0.15s;
}
.btn-secondary:hover { box-shadow: var(--shadow); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 40px 16px; color: var(--color-text-muted); }

/* ===== PILLS ===== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.pill-neutral { background: rgba(0,0,0,0.06); color: var(--color-text); }
.pill-success { background: rgba(40, 167, 69, 0.12); color: #1f7a3f; }
.pill-danger { background: rgba(220, 53, 69, 0.12); color: #a42828; }

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 2000;
}

.modal-content, .modal-dialog {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  width: min(980px, 96vw);
  max-height: 92vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.modal-close {
  position: absolute;
  right: 8px;
  top: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 28px;
  color: var(--color-text-light);
  padding: 6px 10px;
  border-radius: 10px;
  z-index: 1;
}

.modal-close:hover { background: rgba(0,0,0,0.06); }

/* ===== PRODUCT DETAIL MODAL ===== */
.product-modal-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 16px;
  padding: 18px;
}

.product-modal-image {
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  padding: 12px;
  border: 1px solid var(--color-border);
}

.product-modal-image img {
  width: 100%;
  height: 380px;
  min-width: 100%;
  min-height: 380px;
  object-fit: contain;
  border-radius: var(--radius-lg);
  background: #fff;
  display: block;
  transition: opacity 0.2s ease;
}

@keyframes loading-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.product-modal-image img:hover {
  opacity: 0.9;
}

.product-modal-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.product-modal-brand { color: var(--color-text-light); font-weight: 900; font-size: 12px; letter-spacing: 0.02em; text-transform: uppercase; }
.product-modal-title { font-size: 18px; font-weight: 900; margin-top: 6px; }
.product-modal-category { color: var(--color-text-light); margin-top: 4px; font-size: 13px; }

.product-modal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.product-modal-grid .label { color: var(--color-text-muted); font-size: 12px; font-weight: 800; }
.product-modal-grid .value { font-size: 14px; font-weight: 900; margin-top: 4px; }
.product-modal-grid .value-strong { color: var(--color-primary); }

.product-modal-actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== LOADING ===== */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

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

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

/* ===== IMAGE ZOOM OVERLAY ===== */
.image-zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.image-zoom-overlay.show { opacity: 1; }

.image-zoom-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 1;
}

.image-zoom-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.image-zoom-btn:hover { background: rgba(255,255,255,0.18); }
.image-zoom-close { font-size: 18px; padding: 6px 10px; }

.image-zoom-stage {
  width: min(1100px, 96vw);
  height: min(760px, 86vh);
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.image-zoom-img {
  max-width: 100%;
  max-height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  transform: translate(0px, 0px) scale(1);
}

/* ===== CUSTOMER IMPORT MAPPING ===== */
.mapping-row {
  display: grid;
  grid-template-columns: 160px 1fr 1fr 40px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--color-bg);
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--color-border);
}

.mapping-row.required {
  border-color: rgba(211, 47, 47, 0.4);
  background: rgba(211, 47, 47, 0.03);
}

.mapping-field-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text);
}

.mapping-field-label.required::after {
  content: ' *';
  color: #d32f2f;
}

.mapping-csv-column,
.mapping-target-field {
  padding: 7px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  font-size: 13px;
  width: 100%;
}

.mapping-csv-column:focus,
.mapping-target-field:focus {
  border-color: var(--color-primary);
  outline: none;
}

.mapping-matched {
  background: rgba(40, 167, 69, 0.1);
  border-color: rgba(40, 167, 69, 0.3);
}

.mapping-section-title {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 16px 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--color-border);
}

.mapping-section-title:first-child {
  margin-top: 0;
}

/* ===== SEARCH SUGGESTIONS ===== */
.empty-state-with-suggestions {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.search-suggestions-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

.search-suggestions-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--color-text);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.search-suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-suggestion-item:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  transform: translateX(4px);
}

.suggestion-keyword {
  font-weight: 600;
  color: var(--color-text);
  font-size: 14px;
}

.suggestion-score {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 700;
  background: rgba(0,0,0,0.05);
  padding: 2px 8px;
  border-radius: 12px;
}

/* ===== ORDER TYPE MODAL ===== */
.order-type-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.order-type-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.order-type-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.order-type-card.active,
.order-type-card.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.25);
}

.order-type-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.order-type-icon svg {
  stroke: white;
  width: 24px;
  height: 24px;
}

.order-type-content {
  flex: 1;
  min-width: 0;
}

.order-type-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 2px;
}

.order-type-desc {
  font-size: 12px;
  color: var(--color-text-light);
}

.order-type-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.order-type-check svg {
  stroke: white;
}

.order-type-card.active .order-type-check,
.order-type-card.selected .order-type-check {
  display: flex;
}

/* Detail grid for customer details */
.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  font-size: 14px;
}

.detail-label {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 13px;
}

.detail-value {
  color: var(--color-text);
}

/* ===== FOOTER ===== */
.app-footer {
  background: var(--color-surface);
  padding: 16px 20px;
  text-align: center;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 12px;
}

.app-footer img {
  height: 30px;
  object-fit: contain;
  opacity: 0.5;
  margin-bottom: 8px;
}

.app-footer .footer-credit {
  font-size: 11px;
  opacity: 0.7;
}

.app-footer .footer-credit strong {
  color: var(--color-text-light);
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* ===== TABLET (max-width: 980px) ===== */
@media (max-width: 980px) {
  .catalog-layout { grid-template-columns: 1fr; }
  
  .category-sidebar {
    position: sticky;
    top: var(--nav-height);
    max-height: none;
    border-radius: var(--radius-lg);
    z-index: 90;
  }
  
  .category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .category-item {
    padding: 7px 12px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  
  .category-item.active {
    border-color: var(--color-primary);
  }
  
  .customers-layout { grid-template-columns: 1fr; }
  .customers-sidebar { 
    border-right: none; 
    border-bottom: 1px solid var(--color-border);
    max-height: 280px;
    overflow-y: auto;
  }
  .customer-list { max-height: 200px; }
  
  .product-card { grid-template-columns: 70px 1fr auto; }
  .pc-image { width: 70px; height: 70px; }
  .pc-price-area { min-width: 110px; }
  .pc-cart-btn {
    grid-column: 1 / -1;
    width: 100%;
    border-radius: var(--radius-md);
    height: 34px;
    margin-top: 4px;
  }
  
  .product-modal-layout { grid-template-columns: 1fr; }
  .product-modal-image img { height: 280px; min-height: 280px; }
  
  .modal-dialog { width: 96%; margin: 8px; max-height: 94vh; }
  .product-modal-layout { padding: 14px; }
  
  /* Cart tablet */
  .cart-item {
    grid-template-columns: 70px 1fr auto 40px;
    grid-template-rows: auto auto auto;
    gap: 8px 10px;
  }
  .cart-item > * { min-width: 0; }
  
  .cart-item-image { grid-row: 1 / 3; width: 70px; height: 70px; }
  .cart-item-info { grid-column: 2 / 3; }
  
  .cart-item-pricing { 
    grid-row: 2; 
    grid-column: 2 / 5;
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .cart-item-qty {
    grid-row: 3;
    grid-column: 2;
    justify-content: flex-start;
  }
  
  .cart-item-total {
    grid-column: 3;
    grid-row: 1;
    white-space: nowrap;
  }
  
  .cart-item-remove {
    grid-column: 4;
    grid-row: 1;
  }
  
  .cart-footer-totals,
  .cart-margin-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .cart-footer-grand { text-align: left; }
  
  .mapping-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  
  .mapping-field-label {
    grid-column: 1 / -1;
  }
}

/* ===== SMALL TABLET / LARGE PHONE (max-width: 768px) ===== */
@media (max-width: 768px) {
  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .catalog-cards {
    grid-template-columns: 1fr;
  }
  
  .brand-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .brand-card {
    padding: 20px 14px;
    min-height: 160px;
  }
  
  .brand-card-logo {
    height: 70px;
  }
  
  .brand-card-title {
    font-size: 1.1rem;
  }
  
  #brandLogoHeader {
    height: 70px !important;
  }
  #brandLogoImg {
    max-width: 180px !important;
  }
  
  .product-modal-grid { grid-template-columns: 1fr 1fr; }
  
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 4px 0;
  }
  
  .detail-label {
    margin-top: 8px;
  }
}

/* ===== PHONE (max-width: 520px) ===== */
@media (max-width: 520px) {
  :root {
    --nav-height: 54px;
  }
  
  /* Navigation */
  .top-nav {
    padding: 6px 10px;
    gap: 4px;
    grid-template-columns: auto 1fr auto;
  }

  .nav-logo {
    height: 30px;
  }
  
  .nav-tabs {
    padding: 2px;
    gap: 2px;
  }
  
  .nav-tab {
    padding: 7px 10px;
    font-size: 13px;
    gap: 4px;
  }
  
  .nav-actions {
    gap: 2px;
  }
  
  .btn-icon {
    width: 34px;
    height: 34px;
  }
  
  .btn-icon svg {
    width: 18px;
    height: 18px;
  }
  
  /* View headers */
  .view-header h1 { font-size: 22px; }
  .view-subtitle { font-size: 13px; }
  
  /* Catalog selection */
  .catalog-selection { padding: 16px 10px; }
  .catalog-cards { grid-template-columns: 1fr; gap: 12px; }
  
  .catalog-card { padding: 14px; }
  .catalog-card-title { font-size: 2em !important; }
  .catalog-card-category { font-size: 0.95em !important; }
  
  /* Brand selection */
  .brand-selection { padding: 16px 10px; }
  .brand-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .brand-card {
    padding: 16px 10px;
    min-height: 130px;
  }
  .brand-card-logo {
    height: 55px;
  }
  .brand-card-title {
    font-size: 0.9rem;
  }
  
  /* Search bar */
  .search-bar { 
    padding: 0 10px 8px; 
  }
  .search-bar input {
    padding: 9px 10px;
  }
  
  /* Filters */
  .product-filters { 
    padding: 2px 10px; 
    gap: 5px; 
  }
  
  .filter-check {
    padding: 4px 7px;
    font-size: 10px;
  }
  
  .filter-range { 
    width: 100%; 
    justify-content: space-between; 
  }
  .filter-range-inputs input { width: 70px; }
  
  .brand-filter { padding: 2px 10px 4px; }
  
  /* Catalog layout */
  .catalog-layout { padding: 0 10px; }
  
  .category-sidebar {
    position: sticky;
    top: var(--nav-height);
    border-radius: var(--radius-md);
    z-index: 90;
  }
  
  .category-header {
    padding: 10px 12px;
    font-size: 12px;
  }
  
  .category-list {
    gap: 3px;
    padding: 6px;
  }
  
  .category-item {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  /* Product cards */
  .product-card { 
    grid-template-columns: 60px 1fr;
    gap: 8px;
    padding: 10px;
  }
  .pc-image { width: 60px; height: 60px; }
  .pc-sku { font-size: 13px; }
  .pc-desc { font-size: 12px; -webkit-line-clamp: 1; }
  .pc-price-area {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
    border-top: 1px solid var(--color-border);
    padding-top: 8px;
  }
  .pc-prices { flex-direction: row; gap: 8px; align-items: center; }
  .pc-net-price { font-size: 14px; }
  .pc-cart-btn {
    grid-column: 1 / -1;
    width: 100%;
    border-radius: var(--radius-md);
    height: 34px;
    margin-top: 4px;
  }
  
  /* Product list header */
  .product-list-header { 
    padding: 8px 0;
    flex-wrap: wrap; 
  }
  .product-count { font-size: 11px; }
  
  #brandLogoHeader {
    height: 40px !important;
    margin-left: 8px !important;
  }
  #brandLogoImg {
    max-width: 120px !important;
  }
  
  /* Dashboard */
  .dashboard-container { padding: 16px 10px; }
  .dashboard-header h1 { font-size: 22px; }
  .dashboard-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 11px; }
  
  /* Customers */
  .customers-sidebar {
    max-height: 220px;
  }
  .customer-list { max-height: 160px; }
  .customer-search-bar { padding: 10px; }
  .customer-detail-header { 
    padding: 10px 12px; 
    flex-direction: column;
    align-items: flex-start;
  }
  .customer-detail-header h1 { font-size: 16px; }
  .customer-actions {
    width: 100%;
  }
  .customer-tabs { padding: 0 10px; }
  .customer-tab { padding: 8px 10px; font-size: 12px; }
  .customer-detail { padding: 12px; }
  
  .customer-import-panel {
    padding: 12px !important;
  }
  
  /* Cart */
  .cart-header { 
    padding: 10px 12px;
    position: static;
  }
  .cart-header h1 { font-size: 18px !important; }
  
  .cart-content { padding: 10px; gap: 14px; }
  
  .cart-summary { padding: 12px; }
  .cart-summary-grid { 
    grid-template-columns: 1fr; 
    gap: 12px; 
  }
  .cart-summary-value { font-size: 13px; }

  .cart-footer-totals,
  .cart-margin-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .cart-footer-value { font-size: 15px; }
  .cart-footer-grand { text-align: left; }
  
  /* Cart items - mobile card layout */
  .cart-item {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 12px;
    position: relative;
  }
  
  /* Row 1: Image + Info + Remove */
  .cart-item-image { 
    width: 56px; 
    height: 56px;
    flex-shrink: 0;
    margin-right: 10px;
  }
  
  .cart-item-info {
    flex: 1;
    min-width: 0;
    padding-right: 36px; /* Space for remove button */
  }
  
  .cart-item-code { font-size: 13px; }
  .cart-item-desc { font-size: 12px; -webkit-line-clamp: 2; }
  
  .cart-item-remove {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
  }
  
  /* Row 2: Pricing + Qty + Total */
  .cart-item-pricing {
    width: 100%;
    border-top: 1px solid var(--color-border);
    padding-top: 10px;
    margin-top: 10px;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }
  
  .cart-item-unit-row { width: 100%; justify-content: space-between; }
  .cart-item-unit-row input { width: 80px; }
  .cart-item-discounts-row { width: 100%; }
  .cart-discount-stepper { flex: 1; min-width: 0; }
  .cart-discount-input { flex: 1; min-width: 0; width: auto; }
  
  .cart-item-qty { 
    width: 100%;
    margin-top: 8px;
    justify-content: flex-start;
  }
  
  .cart-item-total {
    width: 100%;
    text-align: left;
    font-size: 16px;
    color: var(--color-primary);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border);
  }
  
  .cart-footer {
    align-items: stretch;
    gap: 12px;
  }
  
  .cart-total-row {
    justify-content: space-between;
    font-size: 14px;
  }
  
  .cart-total-value { font-size: 20px; }
  
  .cart-footer > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  
  .cart-footer > div:last-child .btn-primary,
  .cart-footer > div:last-child .btn-secondary {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
  
  /* Modals */
  .modal { padding: 6px; }
  .modal-content, .modal-dialog { 
    width: 100%; 
    max-height: 96vh;
    border-radius: var(--radius-lg);
  }
  
  .product-modal-layout { padding: 12px; gap: 12px; }
  .product-modal-image { padding: 8px; }
  .product-modal-image img { height: 200px; min-height: 200px; }
  .product-modal-title { font-size: 16px; }
  .product-modal-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .product-modal-grid div:last-child { grid-column: 1 / -1; }
  .product-modal-actions { 
    flex-direction: column; 
    gap: 6px; 
  }
  .product-modal-actions .btn-primary,
  .product-modal-actions .btn-secondary,
  .product-modal-actions a {
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 10px;
  }
  
  /* Order type modal */
  .order-type-card { padding: 12px; gap: 10px; }
  .order-type-icon { width: 40px; height: 40px; }
  .order-type-icon svg { width: 20px; height: 20px; }
  .order-type-title { font-size: 13px; }
  .order-type-desc { font-size: 11px; }
  
  /* Mapping modal */
  .mapping-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
  }
  
  .mapping-field-label {
    font-size: 12px;
  }
  
  /* Admin */
  h1 { font-size: 20px !important; }
  
  /* Footer */
  .app-footer {
    padding: 12px 16px;
  }
  
  /* Empty state */
  .empty-state { padding: 24px 12px; }
}

/* ===== VERY SMALL PHONE (max-width: 360px) ===== */
@media (max-width: 360px) {
  .nav-logo { height: 24px; }
  .nav-tab {
    padding: 5px 8px;
    font-size: 12px;
  }
  
  .nav-tab span:not(.badge) {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .brand-cards {
    grid-template-columns: 1fr;
  }
  
  .dashboard-stats {
    grid-template-columns: 1fr;
  }
  
  .cart-summary-grid {
    grid-template-columns: 1fr;
  }
  
  .product-modal-grid {
    grid-template-columns: 1fr;
  }
  
  .product-card {
    grid-template-columns: 50px 1fr;
    gap: 6px;
    padding: 8px;
  }
  .pc-image { width: 50px; height: 50px; }
  .pc-sku { font-size: 12px; }
  .pc-desc { font-size: 11px; }
  
  .brand-card {
    min-height: 110px;
    padding: 12px 8px;
  }
  
  .brand-card-logo {
    height: 45px;
  }
  
  .brand-card-title {
    font-size: 0.8rem;
  }
}

@media (max-width: 400px) {
  .cart-footer-totals,
  .cart-margin-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* ===== TOUCH IMPROVEMENTS ===== */
@media (hover: none) and (pointer: coarse) {
  .product-card:hover { box-shadow: var(--shadow); transform: none; }
  .brand-card:hover { transform: none; box-shadow: var(--shadow); }
  .catalog-card:hover { transform: none; box-shadow: var(--shadow); }
  .customer-item:hover { box-shadow: none; }
  .order-type-card:hover { transform: none; box-shadow: none; }
  .search-suggestion-item:hover { transform: none; }
  
  /* Larger touch targets */
  .btn-qty { width: 36px; height: 36px; }
  .cart-qty-btn { width: 36px; height: 36px; }
  .cart-qty-input { height: 36px; }
  
  .customer-item { padding: 14px; }
  .category-item { padding: 10px 12px; }
  
  /* Better tap feedback */
  .product-card:active { transform: scale(0.98); }
  .brand-card:active { transform: scale(0.97); }
  .catalog-card:active { transform: scale(0.97); }
  .btn-primary:active { transform: scale(0.97); }
  .btn-secondary:active { transform: scale(0.97); }
}

/* ===== SORT BAR ===== */
.product-sort-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 16px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  flex-wrap: wrap;
}
.sort-label {
  font-size: 11px;
  color: #6b7280;
  font-weight: 600;
  margin-right: 2px;
}

/* ===== SORT CHIPS ===== */
.sort-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 18px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.sort-chip:hover {
  background: #e5e7eb;
}
.sort-chip.active {
  background: #1f2937;
  color: #fff;
  border-color: #1f2937;
}

.product-list-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

@media (max-width: 768px) {
  .sort-chip { padding: 4px 10px; font-size: 11px; }
  .product-sort-bar { gap: 4px; padding: 5px 6px; }
}

/* ===== LANDSCAPE PHONE ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .modal-content, .modal-dialog {
    max-height: 98vh;
  }
  
  .product-modal-layout {
    grid-template-columns: 200px 1fr;
  }
  
  .product-modal-image img {
    height: 180px;
    min-height: 180px;
  }
}
/* === Vista CLIENT: nasconde elementi non pertinenti === */
body.role-client .admin-tab,
body.role-client #adminTab,
body.role-client .btn-eol,
body.role-client [data-eol-only],
body.role-client .product-purchase-price,
body.role-client .product-promo-price,
body.role-client .cart-discount-input,
body.role-client .cart-discount-stepper-btn,
body.role-client .cart-margin-badge,
body.role-client .cart-item-discounts-row,
body.role-client .cart-item-pricing > div:not(:first-child) { display: none !important; }

body.role-client .product-card .price-discount,
body.role-client .product-card .price-net { display: none !important; }

