/* ── CatWing Global Assortment Review ─────────────────────────────── */

:root {
  --cw-primary: #20b0a5;
  --cw-blue: #336699;
  --cw-dark: #1c1c1c;
  --cw-bg: #f5f7fa;
  --cw-sidebar-bg: linear-gradient(180deg, #f0f5fc 0%, #e8f0f7 100%);
  --cw-header-bg: linear-gradient(135deg, #336699 0%, #20b0a5 100%);

  --status-stock: #4CAF50;
  --status-notstock: #F44336;

  --zone-green: #4CAF50;
  --zone-yellow: #FFC107;
  --zone-orange: #FF9800;
  --zone-red: #F44336;

  --confirmed-bg: #E8F5E9;
  --confirmed-border: #4CAF50;
  --drift-bg: #FFF3E0;
  --drift-border: #FF9800;
  --sub-row-bg: #f0f4f8;

  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--cw-dark);
  background: var(--cw-bg);
  height: 100%;
}

#app {
  display: flex;
  height: 100vh;
}

/* ── Login ────────────────────────────────────────────────────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  background: var(--cw-bg);
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 3rem 2.5rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.login-card h1 {
  font-size: 2.4rem;
  font-weight: 700;
  background: var(--cw-header-bg);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.3rem;
}

.login-card .subtitle {
  color: #666;
  font-size: 1rem;
  margin-bottom: 2rem;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.login-card input[type="password"]:focus {
  border-color: var(--cw-blue);
}

.login-card button {
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--cw-header-bg);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
}

.login-card button:hover {
  box-shadow: 0 4px 16px rgba(51,102,153,0.4);
  transform: translateY(-1px);
}

.login-error {
  color: var(--status-notstock);
  margin-top: 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ── Layout ───────────────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--cw-sidebar-bg);
  border-right: 1px solid #dce3ed;
  padding: 1.2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-brand {
  text-align: center;
  padding: 0.5rem 0 0.8rem;
}

.sidebar-brand h2 {
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--cw-header-bg);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand .sub {
  font-size: 0.85rem;
  color: #666;
}

.sidebar hr {
  border: none;
  border-top: 1px solid #d0d8e4;
  margin: 0.5rem 0;
}

.sidebar h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--cw-blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}

.sidebar label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #555;
  margin-bottom: 0.2rem;
}

.sidebar select,
.sidebar input[type="text"] {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #cdd5e0;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  background: white;
  outline: none;
  margin-bottom: 0.5rem;
}

.sidebar select:focus,
.sidebar input[type="text"]:focus {
  border-color: var(--cw-blue);
}

.sidebar-actions {
  display: flex;
  gap: 0.4rem;
}

.btn {
  padding: 0.5rem 0.8rem;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background: var(--cw-header-bg);
  color: white;
}

.btn-primary:hover {
  box-shadow: 0 2px 8px rgba(51,102,153,0.3);
}

.btn-secondary {
  background: #e8edf4;
  color: var(--cw-blue);
}

.btn-secondary:hover {
  background: #dce3ed;
}

.btn-full { width: 100%; }
.btn-flex { flex: 1; }

.btn-danger {
  background: #ffebee;
  color: var(--status-notstock);
}

.btn-danger:hover {
  background: #ffcdd2;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Header ───────────────────────────────────────────────────────── */
.app-header {
  background: var(--cw-header-bg);
  padding: 1.2rem 1.5rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.app-header h1 {
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
}

.app-header p {
  color: rgba(255,255,255,0.9);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: rgba(255,255,255,0.9);
  font-size: 0.9rem;
  margin-top: 0.3rem;
}

.header-stat strong { font-weight: 700; }
.stock-count    { color: #A5D6A7; }
.notstock-count { color: #EF9A9A; }
.header-stat-sep { opacity: 0.5; }
.drift-stat { color: #FFE082; }

.progress-bar-container {
  background: rgba(255,255,255,0.2);
  border-radius: 6px;
  height: 16px;
  margin-top: 0.8rem;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: var(--status-stock);
  border-radius: 6px;
  transition: width 0.3s ease;
}

.progress-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  pointer-events: none;
}

.filtered-stat { color: #B3E5FC; }

/* ── Status cards ─────────────────────────────────────────────────── */
.status-cards {
  display: flex;
  gap: 0.8rem;
}

.status-card {
  flex: 1;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  text-align: center;
  background: white;
  box-shadow: var(--shadow);
}

.status-card .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--cw-blue);
}

.status-card .label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #666;
  text-transform: uppercase;
}

.status-card.stock .value { color: var(--status-stock); }
.status-card.notstock .value { color: var(--status-notstock); }

/* ── Table ────────────────────────────────────────────────────────── */
.table-container {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  flex: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

thead th {
  background: var(--cw-blue);
  color: white;
  padding: 0.6rem 0.7rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover {
  background: #2d5a87;
}

thead th .sort-arrow {
  margin-left: 0.3rem;
  font-size: 0.7rem;
  opacity: 0.6;
}

thead th .sort-arrow.active {
  opacity: 1;
}

/* Subcollection rows */
tr.sub-row {
  background: var(--sub-row-bg);
  cursor: pointer;
  border-bottom: 1px solid #dce3ed;
}

tr.sub-row:hover {
  background: #e4ebf3;
}

tr.sub-row td {
  padding: 0.55rem 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

tr.sub-row .chevron {
  display: inline-block;
  width: 16px;
  font-size: 0.75rem;
  transition: transform 0.15s;
  color: #666;
}

tr.sub-row .chevron.expanded {
  transform: rotate(90deg);
}

/* Product rows */
tr.product-row {
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}

tr.product-row:hover {
  background: #f8f9fb;
}

tr.product-row td {
  padding: 0.45rem 0.7rem;
  white-space: nowrap;
}

tr.product-row.confirmed {
  background: var(--confirmed-bg);
  border-left: 4px solid var(--confirmed-border);
}

tr.product-row.confirmed:hover {
  background: #d5ecd8;
}

tr.product-row.drift {
  background: var(--drift-bg);
  border-left: 4px solid var(--drift-border);
}

tr.product-row.drift:hover {
  background: #ffe8cc;
}

/* ── Status badge ─────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  color: white;
  font-weight: 600;
  font-size: 0.78rem;
  line-height: 1.4;
  background: #999;  /* fallback for unknown status values */
}

.status-badge.stock     { background: var(--status-stock); }
.status-badge.not-stock { background: var(--status-notstock); }
.status-badge.clickable { cursor: pointer; transition: opacity 0.15s; }
.status-badge.clickable:hover { opacity: 0.8; }
.status-badge.locked { cursor: not-allowed; opacity: 0.5; }
.btn-locked { background: #999; color: #fff; cursor: not-allowed; opacity: 0.6; }
.btn-locked:hover { background: #999; }

/* ── Zone dot ─────────────────────────────────────────────────────── */
.zone-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.zone-dot.green  { background: var(--zone-green); }
.zone-dot.yellow { background: var(--zone-yellow); }
.zone-dot.orange { background: var(--zone-orange); }
.zone-dot.red    { background: var(--zone-red); }

/* ── Inline select ────────────────────────────────────────────────── */
.inline-select {
  padding: 2px 4px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  background: white;
}

.inline-select:focus {
  border-color: var(--cw-blue);
  outline: none;
}

/* ── Confirmed checkmark ──────────────────────────────────────────── */
.confirmed-mark {
  color: var(--confirmed-border);
  font-size: 1.1rem;
  font-weight: bold;
}

.drift-mark {
  color: var(--drift-border);
  font-size: 1.1rem;
}

/* Sub-row confirm count */
.confirm-count {
  font-size: 0.8rem;
  font-weight: 500;
  color: #666;
}

.confirm-count.all-done {
  color: var(--confirmed-border);
  font-weight: 600;
}

/* ── Detail panel ─────────────────────────────────────────────────── */
.detail-panel {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.5rem;
  display: flex;
  gap: 1.2rem;
}

.detail-image {
  flex-shrink: 0;
}

.detail-image img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  border-radius: var(--radius);
  background: #f5f5f5;
}

.detail-image .placeholder {
  width: 180px;
  height: 180px;
  background: #e8e8e8;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 0.85rem;
}

.detail-info {
  flex: 1;
  min-width: 0;
}

.detail-info h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  color: var(--cw-dark);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.3rem 1.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
}

.detail-grid .field-label {
  font-weight: 600;
  color: #555;
}

.field-hint {
  color: #999;
  font-size: 0.78rem;
}

.detail-divider {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 0.5rem 0;
}

.detail-sku {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.4rem;
}

.detail-sku .field-label {
  font-weight: 600;
  color: #555;
}

/* ── Detail panel: status rows (CW rec + client status) ──────────── */
.detail-status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}

.detail-status-row .field-label {
  font-weight: 600;
  color: #555;
  min-width: 5.5rem;
}

.rec-reason {
  color: #555;
  font-style: italic;
}

.status-override-hint {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--drift-border);
}

.inv-zero {
  color: var(--status-notstock);
  font-weight: 600;
}

/* ── Detail panel: phase-out bar ─────────────────────────────────── */
.detail-phaseout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}

.phaseout-bar-container {
  width: 120px;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

.phaseout-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #FF9800, #F44336);
}

.phaseout-value {
  font-weight: 600;
  color: #666;
}

/* ── Status badge: outlined variant ──────────────────────────────── */
.status-badge.outlined {
  background: transparent;
}

.status-badge.outlined.stock {
  border: 1px solid var(--status-stock);
  color: var(--status-stock);
}

.status-badge.outlined.not-stock {
  border: 1px solid var(--status-notstock);
  color: var(--status-notstock);
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.detail-notes textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 60px;
  outline: none;
}

.detail-notes textarea:focus {
  border-color: var(--cw-blue);
}

/* ── Toast ────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius);
  color: white;
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 1000;
  animation: toast-in 0.3s ease-out;
}

.toast { display: flex; align-items: center; gap: 0.6rem; }
.toast.success { background: var(--status-stock); }
.toast.error   { background: var(--status-notstock); }
.toast.info    { background: var(--cw-blue); }

.toast-action {
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.5);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.toast-action:hover { background: rgba(255,255,255,0.4); }

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── Currency / number alignment ──────────────────────────────────── */
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Search highlight ─────────────────────────────────────────────── */
mark { background: #FFF59D; color: inherit; padding: 0 1px; border-radius: 2px; }

/* ── Brand progress bar ──────────────────────────────────────────── */
.brand-progress { margin: 0.5rem 0; }
.brand-progress-label { display:flex; justify-content:space-between; font-size:0.75rem; color:#555; font-weight:500; }
.brand-progress-bar { height:4px; background:#e0e0e0; border-radius:2px; overflow:hidden; margin-top:0.2rem; }
.brand-progress-fill { height:100%; background:var(--cw-primary); border-radius:2px; transition:width 0.3s ease; }

/* ── Footer text on sidebar ───────────────────────────────────────── */
.sidebar-footer {
  margin-top: auto;
  padding-top: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: #888;
}

/* ── Loading spinner ──────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100%;
  font-size: 1.1rem;
  color: #666;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #ddd;
  border-top-color: var(--cw-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.6rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Product thumbnails ──────────────────────────────────────────── */
.product-thumb {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 4px;
  background: #f5f5f5;
  flex-shrink: 0;
}

.product-thumb-placeholder {
  display: inline-block;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.product-cell.has-thumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.product-cell-text {
  min-width: 0;
  flex: 1;
}

/* Hover preview */
.thumb-preview {
  z-index: 500;
  background: white;
  padding: 4px;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  pointer-events: none;
}

.thumb-preview img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  display: block;
}

/* Hide hover preview on touch devices */
@media (hover: none) {
  .thumb-preview { display: none; }
}

/* Toggle button in table header */
.thumb-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  font-size: 0.75rem;
  padding: 0 0.25rem;
  vertical-align: middle;
  line-height: 1;
}

.thumb-toggle-btn:hover { opacity: 1; }
.thumb-toggle-btn.active { opacity: 0.9; }

/* ── Product labels (LAUNCH / DISC.) ─────────────────────────────── */
.product-label {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.4;
  vertical-align: middle;
  margin-left: 0.35rem;
}

.product-label.launch { background: #E8F5E9; color: #2E7D32; }
.product-label.disc   { background: #ECEFF1; color: #616161; }
.product-label.old    { background: #FFEBEE; color: #C62828; }
.product-label.gold   { background: #FFF8E1; color: #FF8F00; }

/* ── Responsive label toggle (full on desktop, short on phone) ────── */
.label-short { display: none; }

/* ── Product cell (2-line layout on phone) ────────────────────────── */
.product-cell { padding-left: 2rem; }
.product-meta { display: none; }

/* ── Confirm modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-card {
  background: white;
  border-radius: 10px;
  padding: 1.5rem 2rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.modal-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.6rem;
  color: var(--cw-dark);
}

.modal-card p {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.5;
  margin-bottom: 1.2rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ── Sidebar toggle hamburger (hidden on desktop) ────────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  z-index: 110;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: var(--cw-header-bg);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  transition: box-shadow 0.2s, transform 0.15s, left 0.25s ease, right 0.25s ease, top 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle:active {
  transform: scale(0.92);
}

/* Hamburger icon — 3 bars via span + pseudo-elements */
.hamburger-icon {
  width: 18px;
  height: 14px;
  position: relative;
}

.hamburger-icon span,
.hamburger-icon::before,
.hamburger-icon::after {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: white;
  border-radius: 1px;
  transition: transform 0.3s ease, opacity 0.2s ease;
}

.hamburger-icon::before { content: ''; top: 0; }
.hamburger-icon span     { top: 6px; }
.hamburger-icon::after  { content: ''; top: 12px; }

/* Open state → ✕ morph */
.sidebar-toggle.open .hamburger-icon::before {
  transform: translateY(6px) rotate(45deg);
}

.sidebar-toggle.open .hamburger-icon span {
  opacity: 0;
}

.sidebar-toggle.open .hamburger-icon::after {
  transform: translateY(-6px) rotate(-45deg);
}

/* Filter badge */
.toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #FF5252;
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ── Sidebar overlay backdrop (hidden on desktop) ────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0,0,0,0.4);
}

.sidebar-overlay.visible {
  display: block;
}

/* ══════════════════════════════════════════════════════════════════
   TABLET — ≤768 px
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Prevent horizontal scrollbar */
  html, body { overflow-x: hidden; }

  #app {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .main-content {
    min-width: 0;
    padding: 1rem 0.8rem;
  }

  /* Hamburger toggle visible, positioned over header area */
  .sidebar-toggle {
    display: flex;
    top: 1.6rem;
    left: 1.2rem;
  }

  /* When sidebar is open, move toggle up-right so it's reachable above sidebar */
  .sidebar-toggle.open {
    left: 220px;
    top: 0.5rem;
  }

  /* Make room for the hamburger button in the header title */
  .app-header h1 {
    padding-left: 2.4rem;
  }

  /* Sidebar: off-screen overlay, slides in */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding-top: 1rem;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Header stats: allow wrapping */
  .header-stats {
    flex-wrap: wrap;
  }

  /* Hide Stores (col 4) and Age (col 5) — thead, sub-rows, product-rows */
  thead th:nth-child(4),
  thead th:nth-child(5),
  tr.sub-row td:nth-child(4),
  tr.sub-row td:nth-child(5),
  tr.product-row td:nth-child(4),
  tr.product-row td:nth-child(5) {
    display: none;
  }

  /* Prevent double-tap-to-zoom on table rows (preserves tap/double-tap) */
  tr.product-row,
  tr.sub-row {
    touch-action: manipulation;
  }

  /* Detail panel: stack vertically */
  .detail-panel {
    flex-direction: column;
  }

  .detail-image img,
  .detail-image .placeholder {
    width: 140px;
    height: 140px;
  }
}

/* ══════════════════════════════════════════════════════════════════
   PHONE — ≤480 px
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Sidebar: full viewport width */
  .sidebar {
    width: 100%;
  }

  .main-content {
    padding: 0.8rem 0.5rem;
  }

  /* Adjust hamburger position for tighter phone padding */
  .sidebar-toggle {
    top: 1.2rem;
    left: 0.8rem;
  }

  /* When sidebar is open (full-width), position close button in top-right */
  .sidebar-toggle.open {
    left: auto;
    right: 0.8rem;
    top: 0.5rem;
  }

  /* Additionally hide Revenue (col 2) and Qty (col 3) */
  thead th:nth-child(2),
  thead th:nth-child(3),
  tr.sub-row td:nth-child(2),
  tr.sub-row td:nth-child(3),
  tr.product-row td:nth-child(2),
  tr.product-row td:nth-child(3) {
    display: none;
  }

  /* Swap full labels for short abbreviations */
  .label-full { display: none; }
  .label-short { display: inline; }

  /* Hide Zone column (col 6) — joins cols 2,3,4,5 already hidden */
  thead th:nth-child(6),
  tr.sub-row td:nth-child(6),
  tr.product-row td:nth-child(6) {
    display: none;
  }

  /* Show meta line below product name */
  .product-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.15rem;
    font-size: 0.7rem;
    color: #888;
  }

  /* Hide inline labels (they appear in meta row instead) */
  .product-labels-inline { display: none; }

  /* Smaller thumbnails on phone */
  .product-thumb,
  .product-thumb-placeholder {
    width: 28px;
    height: 28px;
  }

  /* Smaller product name */
  .product-name-text { font-size: 0.75rem; }

  /* Tighter indent */
  .product-cell { padding-left: 1rem; }

  /* Shrink status badge to save width */
  .status-badge { padding: 1px 5px; font-size: 0.7rem; }

  /* Hide notes in detail panel */
  .detail-notes { display: none; }

  /* Allow product name and subcollection text to wrap */
  tr.product-row td:first-child,
  tr.sub-row td:first-child {
    white-space: normal;
    word-break: break-word;
  }

  /* Smaller subcollection text to match product rows */
  tr.sub-row td:first-child { font-size: 0.75rem; }

  /* Smaller table text */
  table {
    font-size: 0.8rem;
  }

  /* Header: tighter padding */
  .app-header {
    padding: 0.8rem 1rem;
  }

  .app-header h1 {
    font-size: 1.2rem;
  }

  /* Header stats: stack vertically */
  .header-stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .header-stat-sep {
    display: none;
  }

  /* Detail panel: smaller image, centered, 1-col grid */
  .detail-image {
    text-align: center;
  }

  .detail-image img,
  .detail-image .placeholder {
    width: 120px;
    height: 120px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-phaseout {
    display: none;
  }

  /* Toast: full-width centered */
  .toast {
    left: 1rem;
    right: 1rem;
    text-align: center;
  }
}
