:root {
  --navy: #1F2241;
  --navy-2: #2A2D52;
  --orange: #FFB142;
  --orange-2: #FFC23A;
  --bg: #F4F4F8;
  --card: #ffffff;
  --line: #ECEAF2;
  --muted: #767696;
  /* F5 audit — dla małego tekstu (≤11-12px) WCAG AA wymaga 4.5:1. --muted (#767696)
     daje 4.27:1 na białym — za mało. --muted-strong (#5C5C7A) = 5.4:1, spełnia AA. */
  --muted-strong: #5C5C7A;
  --text: #1F2241;
  --soft: #F3F1F8;
  --green: #4FB37A;
  --green-bg: #E8F4ED;
  --red: #C0392B;
  --red-bg: #FBEDED;
  --blue: #295CE1;
  --blue-bg: #EAF1FA;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

/* TOPBAR */
.topbar {
  position: sticky; top: 0;
  background: var(--navy); color: #fff;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 220px 360px 1fr;
  gap: 24px;
  align-items: center;
  box-shadow: 0 4px 14px rgba(20,20,40,.10);
  z-index: 50;
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .12em; font-size: 14px; }
.brand b { color: var(--orange); }
.brand-logo { height: 26px; width: auto; display: block; }
.brand-app { font-weight: 500; opacity: .6; letter-spacing: .08em; font-size: 12px; text-transform: lowercase; }

.fridge-picker {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  padding: 6px 14px;
  transition: background .15s, border-color .15s;
}
.fridge-picker:hover {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.28);
}
.fridge-picker label { font-size: 11px; color: rgba(255,255,255,.7); text-transform: uppercase; letter-spacing: .12em; }
.fridge-picker select {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/></svg>")
    no-repeat right 2px center / 12px 8px;
  color: #fff; border: 0; font-size: 14px; font-weight: 700;
  padding: 4px 20px 4px 0; outline: none; width: 100%; appearance: none; cursor: pointer;
}
.fridge-picker select option { color: var(--text); }

.top-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 4px 4px 4px 12px;
}
.user-chip .user-name { color: #fff; font-weight: 700; font-size: 13px; }
.user-chip .user-role {
  font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
}
.user-chip .user-role.role-admin    { background: var(--orange); color: #fff; }
.user-chip .user-role.role-dostawca { background: #295CE1; color: #fff; }
.user-chip .btn.ghost { padding: 4px 12px; font-size: 11px; }

/* Permission table */
.perms-grid { background: #fff; border-radius: 12px; }
.perms-table input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* User role badge (w tabeli users) */
.user-role.role-admin    { display: inline-block; background: var(--orange); color: #fff; font-size: 11px; font-weight: 800; padding: 2px 10px; border-radius: 999px; text-transform: uppercase; }
.user-role.role-dostawca { display: inline-block; background: #295CE1; color: #fff; font-size: 11px; font-weight: 800; padding: 2px 10px; border-radius: 999px; text-transform: uppercase; }
.btn {
  appearance: none; border: 0; cursor: pointer;
  padding: 9px 16px; border-radius: 999px;
  font-weight: 700; font-size: 13px; font-family: inherit;
}
.btn { white-space: nowrap; }
.btn.primary { background: var(--orange); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.primary[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.14); }
.btn.ghost:hover { background: rgba(255,255,255,.14); }
.tab-actions .btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.tab-actions .btn.ghost:hover { background: var(--soft); }

/* LAYOUT */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 60px); }
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.nav-item {
  appearance: none; border: 0; background: transparent;
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px; font-weight: 700;
  color: var(--text);
  cursor: pointer; font-family: inherit;
}
.nav-item:hover { background: var(--soft); }
.nav-item.active { background: var(--navy); color: #fff; }
.nav-sep { height: 1px; background: var(--line); margin: 8px 0; }
.nav-foot { font-size: 11px; color: var(--muted); padding: 6px 14px; display: flex; flex-direction: column; gap: 6px; }
.version-pill {
  display: inline-block; align-self: flex-start;
  background: var(--soft); color: var(--text);
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 800;
  font-family: ui-monospace, Menlo, monospace;
  cursor: help;
}

/* CONTENT */
.content { padding: 24px 32px 80px; max-width: 1100px; }
/* Planogram używa pełnej szerokości ekranu (kalendarz po prawej + edytor po lewej) */
.content.content-wide { max-width: none; }
.tab { display: block; }
.tab[hidden] { display: none !important; }
.tab-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 18px; gap: 18px; flex-wrap: wrap;
}
.tab-head h2 { margin: 0; font-size: 22px; font-weight: 800; }
.tab-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.tab-head code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.tab-actions { display: flex; align-items: center; gap: 10px; }
.tab-actions .meta { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.tab-actions input[type="date"] { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-family: inherit; font-size: 13px; }
.meta-pill { display: inline-block; background: #fff; border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.section-h { margin: 28px 0 10px; font-size: 16px; font-weight: 800; }

/* notices */
.notice { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); }
.notice.err { background: var(--red-bg); color: var(--red); border-color: #f7c8c8; }
.notice.ok { background: var(--green-bg); color: var(--green); border-color: #c3e3cd; }

/* PLANOGRAM */
.planogram { display: flex; flex-direction: column; gap: 18px; }
/* Empty state — lodówka bez planogramu. Box wypełnia editor-pane na całą szerokość
   i wysokość kalendarza (po prawej), żeby nie wisiał maleńki pasek na środku. */
.planogram-empty {
  background: #fff; border: 2px dashed var(--line); border-radius: 16px;
  padding: 48px 32px; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; flex: 1; min-height: 360px;
}
.planogram-empty-ico { font-size: 64px; margin-bottom: 16px; opacity: 0.6; }
.planogram-empty h3 { margin: 0 0 10px; font-size: 22px; color: var(--text); }
.planogram-empty p { margin: 0; font-size: 15px; line-height: 1.5; max-width: 480px; }

.shelf {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  /* overflow visible żeby tooltip zamienników nie był ucinany.
     Header i shelf-slots mają własny background z border-radius — wizualnie OK. */
  overflow: visible;
}
.shelf-head { border-radius: 15px 15px 0 0; }
.shelf-slots:last-child { border-radius: 0 0 15px 15px; }
.shelf-head {
  background: var(--navy); color: #fff;
  padding: 10px 20px;
  font-weight: 800; font-size: 13px; letter-spacing: .14em; text-transform: uppercase;
  display: flex; align-items: center; justify-content: space-between;
}
.shelf-head .shelf-meta { font-weight: 600; font-size: 11px; letter-spacing: .08em; opacity: .7; text-transform: none; }
.shelf-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 12px;
  padding: 14px;
}
.slot.slot-add {
  background: transparent;
  border: 2px dashed #c8c4d6;
  color: var(--muted);
  font-family: inherit;
  font-size: inherit;
}
.slot.slot-add:hover { border-color: var(--orange); background: #fff8e6; color: var(--orange); }
.slot.slot-add .plus { background: #fff; color: var(--orange); border: 2px solid var(--orange); }
.slot {
  position: relative;
  background: var(--bg);
  border: 2px dashed #d6d3e0;
  border-radius: 12px;
  min-height: 170px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: border-color .15s, transform .08s, background .15s;
}
.slot:hover { border-color: var(--orange); background: #fff; color: var(--text); }
.slot:active { transform: scale(.98); }
.slot.filled {
  background: #fff;
  border: 1px solid var(--line);
  border-style: solid;
  color: var(--text);
}
.slot .plus {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--soft); color: var(--navy);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; margin-bottom: 6px;
}
.slot .empty-label { font-size: 11px; letter-spacing: .04em; }
.slot .thumb {
  width: 64px; height: 64px;
  background: var(--soft) center/contain no-repeat;
  border-radius: 10px; margin-bottom: 6px;
}
.slot .pname {
  font-size: 12px; font-weight: 700;
  line-height: 1.25;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  word-break: break-word;
}
.slot .qty-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--navy); color: #fff;
  font-weight: 800; font-size: 12px;
  padding: 2px 10px; border-radius: 999px;
  margin-top: 8px;
}
.slot .qty-badge::after { content: " szt."; opacity: .8; margin-left: 2px; }

/* Statystyki pod slotem: pierwsze włożenie do lodówki i sprzedaż z poprzedniego
   tygodnia. Dwa wiersze klucz–wartość, cienką linią odcięte od treści slotu. */
.slot-stats {
  width: 100%;
  margin-top: 8px; padding-top: 6px;
  border-top: 1px dashed var(--line);
  display: grid; gap: 2px;
  font-size: 10.5px; line-height: 1.25;
}
.slot-stat { display: flex; align-items: baseline; gap: 5px; justify-content: space-between; }
.slot-stat .ss-k { color: var(--muted); letter-spacing: .02em; white-space: nowrap; }
.slot-stat b { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Slot bez produktu (sama kategoria) statystyk nie dostaje — pusty box nie ma
   zajmować wysokości w rzędzie. */
.slot-stats:empty { display: none; }

/* Kandydat do zdjęcia z planogramu: najsłabsza sprzedaż w swojej kategorii
   (poza kategoriami świeżymi). Miga, bo ma zwrócić uwagę przy przeglądaniu półek,
   ale bez skakania layoutu — animujemy tylko kolor obramowania i poświatę. */
@keyframes slot-worst-blink {
  0%, 100% { border-color: var(--red); box-shadow: 0 0 0 3px rgba(203, 44, 44, .22); }
  50%      { border-color: #F4A0A0;    box-shadow: 0 0 0 3px rgba(203, 44, 44, 0); }
}
.slot.slot-worst {
  border: 2px solid var(--red);
  animation: slot-worst-blink 1.15s ease-in-out infinite;
}
.slot.slot-worst .slot-stat b { color: var(--red); }
/* Bez migania, gdy system prosi o ograniczenie animacji — sam czerwony kontur. */
@media (prefers-reduced-motion: reduce) {
  .slot.slot-worst { animation: none; box-shadow: 0 0 0 3px rgba(203, 44, 44, .22); }
}
.slot .remove {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; line-height: 1; cursor: pointer; padding: 0;
}
.slot .remove:hover { color: #b91c1c; border-color: #b91c1c; }

/* DATA tables */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 0 rgba(20,20,40,.03); }
.data-table th, .data-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
.data-table th { background: var(--soft); color: var(--text); font-weight: 800; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.data-table td.r, .data-table th.r { text-align: right; white-space: nowrap; }
.data-table th.nowrap, .data-table td.nowrap { white-space: nowrap; }
/* Nagłówki nigdy nie powinny się łamać — zawijanie ucinałoby labelki kolumn */
.data-table thead th { white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { font-variant-numeric: tabular-nums; font-weight: 700; }
.data-table .diff-pos { color: var(--red); }
.data-table .diff-neg { color: var(--green); }
/* Ikony ↑/↓ — nie polegamy wyłącznie na kolorze (a11y) */
.diff-pos::before { content: "↑ "; }
.diff-neg::before { content: "↓ "; }

/* Catalog */
/* F6 audit — Sync pill: czytelny znak + nazwa statusu + kolor semantyczny.
   Zamiast „● W Husky" (mystery-meat) dostawca widzi „✓ Zsynchronizowany" itp. */
.sync-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
.sync-pill-ico { font-size: 12px; line-height: 1; }
.sync-pill.sync-synced          { background: var(--green-bg); color: #0E5E1E; border-color: #B8E0BA; }
.sync-pill.sync-local_only      { background: #FFF3E0; color: #B25C00; border-color: #FFD7A0; }
.sync-pill.sync-error           { background: var(--red-bg); color: var(--red); border-color: #F5B5B5; }
.sync-pill.sync-exists_in_if    { background: #FFF3E0; color: #B25C00; border-color: #FFD7A0; }
.sync-pill.sync-in_if_external  { background: var(--soft); color: #5C5C7A; border-color: var(--line); }
.sync-pill.sync-deleted_in_if   { background: var(--red-bg); color: var(--red); border-color: #F5B5B5; text-decoration: line-through; }

/* F6 audit — EAN oryginalny input: nie ucinaj wielokropkiem, pełny kod widoczny */
.catalog-table input.ean-input {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 12.5px;
  letter-spacing: 0.2px;
}
.catalog-table .cat-td-ean input.ean-input { min-width: 145px; }

/* F6 audit — #catalogMeta: pojedyncze liczby jako „stat-chipy" (visual separacja) */
.meta-pill { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; }
.meta-pill .meta-stat {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--soft); padding: 3px 10px; border-radius: 999px;
  font-size: 12px; color: var(--muted-strong); font-weight: 600;
  border: 0; font-family: inherit;
}
.meta-pill .meta-stat b { color: var(--text); font-weight: 800; }
/* Klikalny chip (button[data-filter]) — hover + active state. */
.meta-pill button.meta-stat { cursor: pointer; transition: background 0.12s, color 0.12s; }
.meta-pill button.meta-stat:hover { background: #e8e6f0; }
.meta-pill button.meta-stat.active {
  background: var(--navy); color: #fff;
}
.meta-pill button.meta-stat.active b { color: var(--orange); }
.meta-pill button.meta-stat.meta-total { background: var(--navy); color: #fff; }
.meta-pill button.meta-stat.meta-total b { color: var(--orange); }
.meta-pill button.meta-stat.meta-total:hover { background: #2b2e57; }
/* Info-only chip (Widoczne) — bez klikalności */
.meta-pill .meta-stat.meta-info { cursor: default; }
/* „Więcej" — chip z ikoną filtra, po prawej stronie listy */
.meta-pill button.meta-stat.meta-more {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: auto;
  background: #fff; border: 1px solid var(--line);
  color: var(--muted-strong);
}
.meta-pill button.meta-stat.meta-more:hover {
  background: var(--soft); border-color: var(--orange); color: var(--orange);
}
/* Aktywny chip z zaawansowanego filtra (marża, ewentualnie kolejne) — z „✕" */
.meta-pill button.meta-stat.meta-adv-clear {
  background: rgba(255, 177, 66, 0.18);
  color: var(--text); border: 1px solid var(--orange);
}
.meta-pill button.meta-stat.meta-adv-clear b { color: var(--text); }
.meta-pill button.meta-stat.meta-adv-clear:hover {
  background: rgba(255, 177, 66, 0.28); border-color: #e69f2b;
}
/* Popover „Więcej" z inputami min/max marży */
.cat-adv-filters-popover {
  position: absolute; z-index: 100;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(31, 34, 65, 0.18);
  padding: 14px 16px; width: 320px;
  font-family: inherit;
}
.cat-adv-head {
  font-size: 11px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted-strong);
  margin-bottom: 10px;
}
.cat-adv-section { margin-bottom: 12px; }
.cat-adv-label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--text);
}
.cat-adv-row-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px;
}
/* Pill toggle PLN / % — segmented control style */
.cat-adv-mode {
  display: inline-flex;
  background: var(--soft); border-radius: 999px;
  padding: 3px; gap: 2px;
}
.cat-adv-mode-btn {
  background: transparent; border: 0;
  padding: 4px 12px; border-radius: 999px;
  font: inherit; font-size: 11px; font-weight: 700;
  color: var(--muted-strong); cursor: pointer;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.cat-adv-mode-btn:hover:not(.active) { color: var(--text); }
.cat-adv-mode-btn.active {
  background: #fff; color: var(--orange);
  box-shadow: 0 1px 3px rgba(31, 34, 65, 0.14);
}
.cat-adv-range {
  display: flex; align-items: center; gap: 8px;
}
.cat-adv-range input {
  width: 100px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 6px;
  font: inherit; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.cat-adv-range input:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 177, 66, 0.15);
}
.cat-adv-dash { color: var(--muted); font-weight: 600; }
.cat-adv-unit { font-size: 12px; color: var(--muted-strong); font-weight: 600; }
.cat-adv-hint {
  font-size: 11px; margin-top: 6px; line-height: 1.4;
}
.cat-adv-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line);
}
.cat-adv-actions .btn { padding: 6px 14px; font-size: 13px; }

/* F4 audit — klikalne nagłówki sortujące. Cykl klik: asc → desc → off. Strzałka
   po prawej pokazuje aktualny kierunek. */
.catalog-table thead th[data-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 20px;
  transition: background .12s;
}
.catalog-table thead th[data-sort]:hover { background: var(--soft); }
.catalog-table thead th[data-sort]::after {
  content: "↕";
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--muted); opacity: 0.5;
}
.catalog-table thead th.sorted-asc::after { content: "↑"; color: var(--orange); opacity: 1; }
.catalog-table thead th.sorted-desc::after { content: "↓"; color: var(--orange); opacity: 1; }

/* F1 audit — wrapper przewijalny wokół .catalog-table. Bez tego tabela przy
   ~1370px szeroko wychodzi za panel treści (~1300px) i przycisk „Zapisz" +
   kolumna Sync uciekają za prawą krawędź. Owinięcie = przewija się TYLKO tabela,
   toolbar i #catalogMeta zostają na miejscu. */
.catalog-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;  /* iOS momentum */
}
.catalog-scroll .catalog-table { margin: 0; min-width: 780px; }

/* F3 audit — kolumna „Produkt" łączy miniaturę + nazwę + brand + EAN SL kod
   w jednej celi. Wcześniej: 3 osobne kolumny (Obrazek | Produkt | EAN SL).
   Zmniejsza szerokość tabeli i usuwa redundancję (EAN SL widoczny dopiero po
   pełnym skanie 3 kolumn). */
.cat-product-cell {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  min-width: 240px;
}
.cat-product-cell .cat-img-col { padding: 0; }
.cat-product-info { min-width: 0; }
.cat-ean-line { margin-top: 2px; font-size: 11px; }

/* F3 — rozwijany wiersz szczegółów pod głównym. Klik chevron „▾" toggle.
   Zawiera to co wcześniej było w tabeli (atrybuty SL, cena sprzedaży) ale
   nie jest już zaśmiecony w kolumnach na widoku podstawowym. */
.cat-details-toggle {
  appearance: none; background: transparent; border: 1px solid var(--line);
  width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; font-size: 13px; line-height: 1;
  color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0 4px;
  transition: transform .12s, background .12s;
}
.cat-details-toggle:hover { background: var(--soft); border-color: var(--orange); }
.cat-details-toggle[aria-expanded="true"] { transform: rotate(180deg); background: var(--soft); }
.cat-details-row[hidden] { display: none; }
.cat-details-row > td {
  padding: 0 !important;
  background: #fbfaff;
  border-bottom: 1px solid var(--line);
}
.cat-details-body { padding: 16px 20px; }
/* Layout: wszystkie panele w jednej linii obok siebie (Ceny · Identyfikatory
   · Klasyfikacja · Atrybuty EAN SL na prawo). */
.cat-details-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.cat-details-panel {
  background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px;
  min-width: 0;
}
/* Wąskie ekrany — zawijamy do 2 kolumn, na mobile 1. */
@media (max-width: 1100px) {
  .cat-details-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .cat-details-grid { grid-template-columns: 1fr; }
}
.cat-details-panel-head {
  font-size: 10px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted-strong, #5C5C7A);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.cat-details-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 12px;
  margin: 0; font-size: 13px;
}
.cat-details-dl dt {
  font-size: 11px; font-weight: 700; color: var(--muted-strong);
  align-self: baseline;
  white-space: nowrap;
}
.cat-details-dl dd {
  margin: 0; color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 0; word-break: break-word;
}
.cat-details-dl dd code {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px; padding: 1px 5px;
  background: var(--soft); border-radius: 4px;
}
.cat-details-dl dd.cat-details-margin--pos { color: #16a34a; font-weight: 700; }
.cat-details-dl dd.cat-details-margin--neg { color: #dc2626; font-weight: 700; }
.cat-details-dl dd.cat-details-margin--muted { color: var(--muted); }
.cat-details-if-id { font-size: 11px !important; }
/* Sync panel — pill inline + meta pod spodem */
.cat-details-sync-cell { margin-bottom: 6px; }
.cat-details-sync-meta { font-size: 11px; margin-top: 6px; }
.cat-details-sync-error {
  font-size: 11px; color: #dc2626;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px;
  padding: 6px 8px; margin-top: 6px;
  cursor: help;
}
/* Atrybuty EAN SL — pełna szerokość */
.cat-details-panel-wide .attr-pills { margin-top: 0; }

/* F8 audit — empty state gdy filtr wyfiltruje wszystko. Wcześniej: pusta tabela. */
.cat-empty-state {
  padding: 48px 20px; text-align: center; color: var(--muted);
}
.cat-empty-ico { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.cat-empty-state h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.cat-empty-state p { margin: 0 0 16px; font-size: 13px; }

.catalog-table .cat-name { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.25; }
/* F5 audit — kod EAN + meta w 11px używają --muted-strong (5.4:1, AA), waga
   500 dla lepszej czytelności małego tekstu. */
.catalog-table .cat-code { font-size: 11.5px; color: var(--muted-strong); font-weight: 500; font-family: ui-monospace, "SF Mono", monospace; }
.catalog-table .cat-code.sl-ean { color: #B25C00; font-weight: 700; }  /* Pomarańczowy ciemniejszy dla AA */
.catalog-table .cat-meta { font-size: 11.5px; color: var(--muted-strong); margin-top: 2px; }
.catalog-table .num.muted { color: var(--muted-strong); }
.catalog-table input.cat-input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; font-family: inherit; outline: none; }
.catalog-table input.cat-input.r { text-align: right; min-width: 78px; max-width: 110px; }
.pp-input-wrap {
  display: inline-flex; align-items: center; gap: 4px;
  width: 100%; justify-content: flex-end;
}
.pp-input-wrap .pp-input { flex: 1 1 auto; }
.pp-history-btn {
  appearance: none; border: 1px solid var(--line); background: #fff;
  width: 26px; height: 26px; border-radius: 6px; flex: 0 0 auto;
  cursor: pointer; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.pp-history-btn:hover { background: var(--soft); border-color: var(--orange); }

/* Ikona kosza w wierszu katalogu — admin only delete (lokalnie + Husky IF) */
.cat-del-btn {
  appearance: none; border: 1px solid var(--line); background: #fff;
  width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; margin-left: 4px;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.cat-del-btn:hover { background: #ffeaea; border-color: #d32f2f; }
.cat-del-btn:active { transform: scale(0.93); }
.cat-del-btn:disabled { cursor: wait; }
.catalog-table input.cat-input:focus { border-color: var(--orange); }
.catalog-table input.cat-input.err { border-color: var(--red); background: var(--red-bg); }

/* F7 audit — widoczny stan „niezapisane" per pole + kropka na wierszu. Wcześniej
   user zmieniał wartość i nie było sygnału że musi kliknąć Zapisz. */
.catalog-table input.cat-input.cat-input-dirty {
  border-color: var(--orange);
  background: #FFF6E5;
}
.catalog-table tr.cat-main-row.cat-row-dirty .cat-save {
  background: var(--orange);
  color: var(--navy);
  font-weight: 800;
}
.catalog-table tr.cat-main-row.cat-row-dirty .cat-save::before {
  content: "●";
  margin-right: 6px;
  color: var(--navy);
  font-size: 11px;
  vertical-align: middle;
}
.catalog-table .btn.ghost { background: var(--soft); color: var(--text); border: 0; padding: 6px 12px; }
.catalog-table tr.saved-flash { background: var(--green-bg); transition: background .6s; }
.catalog-table th, .catalog-table td { vertical-align: middle; }
.catalog-table th.r, .catalog-table td.r { white-space: nowrap; }
/* min-widths dla kolumn (4-column layout: Produkt · Ceny · Marża · Akcje) */
.catalog-table th.cat-h-prices, .catalog-table td.cat-td-prices { min-width: 280px; }
.catalog-table th.cat-h-margin, .catalog-table td.cat-td-margin { min-width: 110px; text-align: right; }
.catalog-table th.cat-h-actions, .catalog-table td.cat-td-actions { min-width: 170px; text-align: right; }

/* Ceny (Zakup + Sprzedaż side-by-side) — grid z FIXED szerokościami kolumn,
   żeby wartości pod sobą siedziały w jednej pionowej linii między wierszami. */
.cat-price-group {
  display: grid;
  grid-template-columns: 120px 120px;
  gap: 12px;
  align-items: end;
}
.cat-price-cell {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 700; color: var(--muted-strong, #5C5C7A);
  min-width: 0;
}
.cat-price-lbl { line-height: 1; }
.cat-price-readonly {
  padding: 6px 10px;
  font-size: 14px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums; text-transform: none;
  background: var(--soft); border-radius: 6px;
  width: 100%; box-sizing: border-box; text-align: center;
}
/* Brak ceny zakupu → jasnożółte tło + pomarańczowa krawędź, od razu widać do uzupełnienia. */
.cat-price-readonly--missing {
  background: #FFF8EC;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--orange);
}

/* Marża — duża wartość + procent, semantyczne kolory */
.cat-td-margin { font-variant-numeric: tabular-nums; }
.cat-margin-val {
  font-size: 16px; font-weight: 700; line-height: 1.1;
}
.cat-margin-pct { font-size: 12px; opacity: 0.75; margin-top: 2px; }
.cat-margin--pos .cat-margin-val, .cat-margin--pos .cat-margin-pct { color: #16a34a; }
.cat-margin--neg .cat-margin-val, .cat-margin--neg .cat-margin-pct { color: #dc2626; }
.cat-margin--none .cat-margin-val { color: var(--muted); }

/* Akcje — Zapisz (primary) + ▾ + 🗑 (icon buttons) */
.cat-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.cat-actions .btn.primary { padding: 6px 14px; font-size: 13px; }
.btn-icon {
  background: transparent; border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 9px;
  cursor: pointer; font-size: 14px; line-height: 1;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}
.btn-icon:hover { background: var(--soft); border-color: var(--muted); }
.btn-icon--danger:hover { background: #fee2e2; border-color: #fecaca; color: #dc2626; }
/* „Edytuj" — biały button z pomarańczową obwódką i pomarańczowym tekstem. */
.cat-edit-btn {
  background: #fff; border: 1.5px solid var(--orange); border-radius: 6px;
  color: var(--orange); font: inherit; font-size: 13px; font-weight: 700;
  padding: 6px 14px; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.cat-edit-btn:hover { background: var(--orange); color: #fff; }

.tab-actions input[type="search"], .tab-actions select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-family: inherit; font-size: 13px; background: #fff; }

/* F2 audit — mobile (<700px): tabela zamienia się w listę kart. Każdy tr w
   .cat-main-row to karta z pełną informacją. Rezygnujemy z tabelarnego układu —
   kolumny na 375px są nieużywalne (audit F2). Details-row (atrybuty SL) na
   mobile niewidoczna — użytkownik nie potrzebuje jej podczas pracy. */
@media (max-width: 700px) {
  /* Ukryj thead + wyłącz overflow (karty flow-owo, nie w tabeli) */
  .catalog-table thead { display: none; }
  .catalog-table, .catalog-table tbody, .catalog-table tr, .catalog-table td { display: block; }
  .catalog-scroll { overflow-x: visible; }
  .catalog-scroll .catalog-table { min-width: 0; }

  /* Wiersz główny → karta */
  .catalog-table tbody tr.cat-main-row {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
  }
  .catalog-table tbody tr.cat-main-row.saved-flash { background: var(--green-bg); }

  /* Kolumna Produkt (col 1) — miniatura + nazwa + EAN SL już wewnątrz .cat-product-cell */
  .catalog-table td.cat-td-product {
    padding: 0 0 8px 0;
  }
  .cat-product-cell {
    grid-template-columns: 56px 1fr;
    min-width: 0;
  }
  .cat-product-cell .cat-img-wrap,
  .cat-product-cell .cat-img-none {
    width: 56px; height: 56px; border-radius: 10px;
  }
  .cat-product-cell .cat-img-none svg { width: 28px; height: 28px; }
  .catalog-table .cat-name {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 15px; line-height: 1.3;
  }

  /* Pozostałe kolumny (Ceny, Marża) — jako label:wartość */
  .catalog-table td.cat-td-prices,
  .catalog-table td.cat-td-margin {
    padding: 8px 0 0 0;
    border-top: 1px solid var(--line);
    margin-top: 8px;
    position: relative;
    text-align: left;
  }
  .catalog-table td[data-label]:not(.cat-td-product):not(.cat-td-actions)::before {
    content: attr(data-label);
    display: block;
    font-size: 11px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .06em;
    margin-bottom: 6px;
  }
  /* Ceny na mobile: te same fixed kolumny (120px 120px) co desktop — spójny wygląd,
     wartości pod sobą wyrównane pomiędzy wierszami. */
  .catalog-table td.cat-td-prices .cat-price-readonly {
    white-space: nowrap;
  }

  /* Marża jako prominent stat na całą szerokość — łatwiej skanować */
  .catalog-table td.cat-td-margin::before { text-align: center; margin-bottom: 8px; }
  .catalog-table td.cat-td-margin { text-align: center; }
  .catalog-table td.cat-td-margin .cat-margin-val { font-size: 20px; }

  /* Akcje — Zapisz full-width, chevron + delete inline */
  .catalog-table td.cat-td-actions {
    padding: 12px 0 0 0;
    border-top: 1px solid var(--line);
    margin-top: 8px;
    text-align: left;
  }
  .catalog-table td.cat-td-actions .cat-actions {
    display: grid; grid-template-columns: 1fr auto auto; gap: 8px;
    justify-content: stretch;
  }
  .catalog-table td.cat-td-actions .cat-save { padding: 10px 12px; font-size: 14px; }
  .catalog-table td.cat-td-actions .btn-icon { padding: 8px 12px; font-size: 16px; }

  /* Details row ukryta na mobile (atrybuty SL nie są operacyjne dla dostawcy) */
  .cat-details-row { display: none !important; }

  /* Toolbar — pełna szerokość */
  .tab[data-tab="catalog"] .tab-actions {
    flex-wrap: wrap; gap: 8px;
  }
  .tab[data-tab="catalog"] .tab-actions input[type="search"],
  .tab[data-tab="catalog"] .tab-actions select {
    flex: 1 1 100%; min-width: 0;
  }
}

/* Sortowalne nagłówki */
.sales-table th.sortable,
.sales-table th.stale-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.sales-table th.sortable:hover,
.sales-table th.stale-sortable:hover { color: var(--orange); }
.sales-table th.sort-active { color: var(--orange); }

/* Marża — kolor bez mylących strzałek (dodatnia = zysk = zielony) */
.sales-table .mrg-pos, .sales-table .sales-subtable .mrg-pos { color: var(--green); }
.sales-table .mrg-neg, .sales-table .sales-subtable .mrg-neg { color: var(--red); }

/* Pasek narzędzi Sprzedaż */
.sales-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sales-presets { display: inline-flex; gap: 2px; background: var(--soft); padding: 3px; border-radius: 10px; flex-wrap: wrap; }
.sp-preset {
  border: 0; background: transparent; padding: 7px 13px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted-strong); white-space: nowrap;
}
.sp-preset:hover { color: var(--text); }
.sp-preset.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(20,20,40,.1); }
.sales-toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.sales-updated { font-size: 12px; color: var(--muted); }
/* Przyciski na jasnym tle (bazowy .btn.ghost jest pod ciemny topbar → biały tekst) */
.sales-toolbar-right .btn.ghost, .ph-filters .btn.ghost {
  background: #fff; color: var(--text); border: 1px solid var(--line);
}
.sales-toolbar-right .btn.ghost:hover, .ph-filters .btn.ghost:hover { background: var(--soft); }
.sales-custom-range {
  display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
  background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
/* [hidden] musi wygrać z display:flex/grid (specyficzność klasy > atrybutu) */
.sales-custom-range[hidden], .kpi-grid[hidden] { display: none; }
.sales-custom-range .meta {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  font-size: 12px; color: var(--muted-strong); font-weight: 600;
}
.sales-custom-range input[type="date"] {
  font-family: inherit; font-size: 13px; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.sales-custom-range input[type="date"]:hover { border-color: var(--muted); }
.sales-custom-range input[type="date"]:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; border-color: var(--orange); }

/* KPI delta */
.kpi-card .kpi-pct { font-size: 14px; color: var(--muted-strong); font-weight: 700; }
.kpi-delta { font-size: 12px; font-weight: 700; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.kpi-delta .muted { font-weight: 500; }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }
.kpi-delta.neutral { color: var(--muted); font-weight: 500; }

/* Sticky nagłówek tabeli sprzedaży */
.sales-table thead th { position: sticky; top: 0; background: #fff; z-index: 2; box-shadow: inset 0 -1px 0 var(--line); }

/* Empty / skeleton */
.sales-empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.sales-empty-icon { font-size: 34px; }
.sales-empty-title { font-size: 16px; font-weight: 700; color: var(--text); margin-top: 8px; }
.sales-empty-sub { font-size: 13px; margin-top: 4px; }
.sales-skeleton { margin-top: 8px; }
.sk-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.kpi-card.sk { pointer-events: none; }
.sk-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #eee 25%, #f5f5f5 37%, #eee 63%); background-size: 400% 100%; animation: sk-shimmer 1.4s ease infinite; }
.sk-line.sk-sm { width: 40%; }
.sk-line.sk-lg { width: 70%; height: 22px; margin: 8px 0; }
@keyframes sk-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .sk-line { animation: none; } }

.stale-capital {
  font-size: 12px; font-weight: 700; color: var(--red); background: var(--red-bg);
  padding: 3px 9px; border-radius: 999px;
}

/* Lista transakcji — filtry */
.ph-filters { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; }
.ph-qty { color: var(--text); font-weight: 800; }

/* Link „Klient" → Redash (tylko ref z U-) */
.client-redash-link { text-decoration: none; }
.client-redash-link code {
  color: var(--blue); background: var(--blue-bg); cursor: pointer;
  transition: background .12s;
}
.client-redash-link:hover code { background: #dce8fb; text-decoration: underline; }
.ph-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.ph-sortable:hover { color: var(--orange); }
.ph-sortable.sort-active { color: var(--orange); }

/* Toggle „tylko promocje" (custom switch) */
.ph-toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.ph-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.ph-toggle-track {
  position: relative; width: 40px; height: 22px; border-radius: 999px;
  background: #d7d5e3; transition: background .15s; flex-shrink: 0;
}
.ph-toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(20,20,40,.3); transition: transform .15s;
}
.ph-toggle input:checked + .ph-toggle-track { background: var(--orange); }
.ph-toggle input:checked + .ph-toggle-track .ph-toggle-thumb { transform: translateX(18px); }
.ph-toggle input:focus-visible + .ph-toggle-track { outline: 2px solid var(--orange); outline-offset: 2px; }
.ph-toggle-label { font-size: 13px; font-weight: 600; color: var(--text); }

/* Select „Widok" (custom chevron) */
.ph-select-wrap { display: inline-flex; align-items: center; gap: 8px; }
.ph-select-cap { font-size: 13px; color: var(--muted-strong); font-weight: 600; }
.ph-select { position: relative; display: inline-block; }
.ph-select::after {
  content: "▾"; position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--muted); font-size: 11px;
}
.ph-select select {
  appearance: none; -webkit-appearance: none; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 30px 8px 12px; cursor: pointer;
}
.ph-select select:hover { border-color: var(--muted); }
.ph-select select:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; border-color: var(--orange); }

/* Sekcja Zalegające (dead stock) */
.stale-section { margin-top: 22px; border-top: 2px solid var(--line); padding-top: 8px; }
.stale-head { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.stale-toggle {
  border: 0; background: var(--soft); width: 26px; height: 26px; border-radius: 6px;
  cursor: pointer; color: var(--muted); font-size: 12px; flex-shrink: 0;
}
.stale-toggle:hover { background: #e7e5ee; color: var(--text); }
.stale-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.stale-count { color: var(--orange); }
.stale-threshold { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stale-threshold input {
  width: 64px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px;
}
.stale-body { margin-top: 8px; }
.stale-table .stale-expiry-soon { color: var(--red); font-weight: 700; }

/* Expandable sales rows */
.sales-table .sales-row.expandable { cursor: pointer; }
.sales-table .sales-row.expandable:hover { background: var(--soft); }
.sales-table .sales-row.open { background: var(--soft); }
.sales-table .sales-toggle { width: 32px; padding-left: 12px; padding-right: 0; }
.sales-table .sales-chev {
  appearance: none; background: transparent; border: 0; cursor: pointer;
  color: var(--muted); padding: 0;
  width: 26px; height: 26px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
/* Chevron rysowany borderem (ostry w każdym zoomie) — obraca się przy rozwinięciu */
.sales-table .sales-chev::before {
  content: ""; width: 6px; height: 6px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  border-radius: 1px;
  transform: rotate(-45deg); margin-left: -2px;
  transition: transform .18s ease;
}
.sales-table .sales-chev:hover { background: var(--soft); color: var(--text); }
.sales-table .sales-row.open .sales-chev { color: var(--orange); }
.sales-table .sales-row.open .sales-chev::before { transform: rotate(45deg); margin-left: 0; margin-top: -2px; }
.sales-table tr.sales-detail > td { background: #fbfaff; padding: 0 0 0 32px; border-bottom: 1px solid var(--line); }
.sales-table .sales-subtable {
  width: 100%; border-collapse: collapse;
  background: transparent;
  margin: 8px 14px 12px 0;
}
.sales-table .sales-subtable th, .sales-table .sales-subtable td {
  padding: 7px 10px; font-size: 12px; border-bottom: 1px dashed var(--line); text-align: left;
}
.sales-table .sales-subtable tr:last-child td { border-bottom: 0; }
.sales-table .sales-subtable th {
  background: transparent; color: var(--muted); font-weight: 700;
  text-transform: uppercase; font-size: 10px; letter-spacing: .06em;
}
.sales-table .sales-subtable td.r, .sales-table .sales-subtable th.r { text-align: right; }
.sales-table .sales-subtable .num { font-variant-numeric: tabular-nums; font-weight: 700; }
.sales-table .sales-subtable .diff-pos { color: var(--red); }
.sales-table .sales-subtable .diff-neg { color: var(--green); }

/* Zero-stock row (in Expiring) */
.data-table tr.row-zero td { opacity: .55; }
.data-table tr.row-zero .num { color: var(--muted); }

/* Sales monthly blocks */
.month-block { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-top: 12px; }
.month-block .month-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.month-block .month-head .muted { color: var(--muted); }
.month-block table { margin-top: 6px; }

/* Expiry badges */
.exp-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.exp-badge.exp-bad  { background: var(--red-bg);   color: var(--red); }
.exp-badge.exp-warn { background: #FFE9CC;          color: #B25C00; }
.exp-badge.exp-soon { background: #FFF4D6;          color: #8A5B00; }
.exp-badge.exp-ok   { background: var(--green-bg); color: var(--green); }

/* Cards grid (restock needs/surplus) */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.r-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px;
  display: flex; gap: 12px; align-items: center;
}
.r-card .thumb {
  width: 56px; height: 56px;
  background: var(--soft) center/contain no-repeat;
  border-radius: 10px; flex: none;
}
.r-card .info { flex: 1; min-width: 0; }
.r-card .name { font-weight: 700; font-size: 13px; line-height: 1.25; max-height: 2.5em; overflow: hidden; }
.r-card .code { font-size: 11px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.r-card .stats { display: flex; gap: 10px; margin-top: 6px; align-items: baseline; }
.r-card .diff-pos { color: var(--red); font-weight: 800; }
.r-card .diff-neg { color: var(--green); font-weight: 800; }

/* Collapsible "W normie" — zbalansowane półki domyślnie zwinięte */
.r-shelf-collapsed { background: transparent; border: 1px solid var(--line); border-radius: 12px; }
.r-shelf-collapsed summary {
  cursor: pointer;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}
.r-shelf-collapsed summary::-webkit-details-marker { display: none; }
.r-shelf-collapsed summary::before {
  content: "▸";
  margin-right: 6px;
  display: inline-block;
  transition: transform 0.2s;
}
.r-shelf-collapsed[open] summary::before { transform: rotate(90deg); }
.r-shelf-collapsed > .r-card { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; margin: 0; }

/* Cena w sekcji "Do wymiany" — kluczowa info, nie muted (kontrast) */
.r-price-sub { color: var(--text); font-weight: 600; }

/* Delivery table — hover state dla wierszy (czytelność tabeli) */
.delivery-table tbody tr:hover { background: var(--soft); }

/* Version banner (planogram) */
.version-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; border-radius: 12px; margin: 0 0 14px;
  font-size: 13px;
}
.version-banner.live { background: var(--green-bg); color: var(--green); border: 1px solid #c3e3cd; }
.version-banner.future { background: #FFF4D6; color: #8A5B00; border: 1px solid #f1d98a; }
.version-banner.past { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.version-banner b { color: inherit; }
.version-banner .pill-mini { background: rgba(255,255,255,.6); padding: 2px 8px; border-radius: 999px; font-weight: 700; }

.tab-actions select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-family: inherit; font-size: 13px; background: #fff; }

/* Tabs mini (inside modals) */
.tabs-mini { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; }
.tab-mini {
  appearance: none; border: 0; background: transparent;
  padding: 8px 14px; font-weight: 700; color: var(--muted);
  cursor: pointer; font-family: inherit; font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tab-mini.active { color: var(--text); border-bottom-color: var(--orange); }
.tab-mini:hover { color: var(--text); }

/* Clone modal lists */
.clone-panel { padding: 4px 0; }
.clone-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; margin: 8px 0 14px; }
.clone-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.clone-row:hover { border-color: var(--orange); }
.clone-row.selected { border-color: var(--orange); background: #fff8e6; }
.clone-row .main { font-weight: 700; font-size: 13px; }
.clone-row .meta { font-size: 11px; color: var(--muted); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.form-row .meta { display: flex; flex-direction: column; gap: 4px; align-items: stretch; color: var(--muted); font-size: 12px; }
.form-row .meta.full { grid-column: 1 / -1; }
.form-row input[type="text"], .form-row input[type="date"], .form-row textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  font-family: inherit; font-size: 13px; color: var(--text); outline: none; background: #fff;
}
.form-row input:focus, .form-row textarea:focus { border-color: var(--orange); }

/* Versions list (in versions modal) */
#versionsList { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.version-row {
  display: block;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  margin-bottom: 10px;
}
/* Layout wiersza wersji: info + akcje obok siebie gdy mieszczą się w jednej linii,
   inaczej akcje pod info (przez flex-wrap). Bez tego sekcja Historyczne (węższy
   kontener przez padding `.versions-past-section`) wciska daty znak-po-znaku
   między ścianę buttonów. */
.version-row-view {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  flex-wrap: wrap;
}
.version-row.is-active { border-color: var(--green); background: var(--green-bg); }
.version-row.is-future { border-color: #f1d98a; background: #FFF4D6; }
.version-row.is-override {
  border-color: var(--orange);
  background: linear-gradient(135deg, #FFF6E5 0%, #FFEACC 100%);
  border-width: 2px;
}
.version-row.is-active.is-override { background: linear-gradient(135deg, var(--green-bg) 0%, #FFEACC 100%); }
/* `flex: 1 1 240px` = info ma minimum 240px szerokości; jeśli akcje obok się nie mieszczą,
   `flex-wrap` na rodzicu przerzuca akcje pod info (zamiast wciskać info w 50px ścianę). */
.vrow-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 240px; }
.vrow-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.version-row .v-date { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--text); white-space: nowrap; }
.version-row .v-label { color: var(--muted); font-size: 12.5px; }
.version-row .v-tag { padding: 3px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 800; background: var(--soft); color: var(--text); text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }
.version-row .v-tag.active { background: var(--green); color: #fff; }
.version-row .v-tag.future { background: #FFB142; color: #fff; }
.version-row .v-tag.override { background: var(--orange); color: var(--navy); border: 1px solid var(--navy); }

/* Akcje wiersza — czytelne kolorowe przyciski z border i ikoną */
.vrow-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.btn-icon-edit, .btn-icon-clone, .btn-icon-archive, .btn-icon-restore, .btn-icon-delete,
.btn-icon-edit-slots {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; font-weight: 700; font-size: 12.5px;
  cursor: pointer; border: 2px solid; transition: all 0.12s; line-height: 1;
  background: #fff;
}
/* "Edytuj sloty" — primary action (pomarańczowy) bo to najczęstsza akcja edycji starej wersji */
.btn-icon-edit-slots { color: var(--orange); border-color: var(--orange); }
.btn-icon-edit-slots:hover { background: var(--orange); color: #fff; transform: translateY(-1px); }
.btn-icon-edit { color: var(--navy); border-color: var(--navy); }
.btn-icon-edit:hover { background: var(--navy); color: #fff; transform: translateY(-1px); }
.btn-icon-clone { color: var(--green); border-color: var(--green); }
.btn-icon-clone:hover { background: var(--green); color: #fff; transform: translateY(-1px); }
.btn-icon-archive { color: #B07A1F; border-color: #FFB142; }  /* żółto-pomarańczowy = soft archive */
.btn-icon-archive:hover { background: #FFB142; color: var(--navy); transform: translateY(-1px); }
.btn-icon-restore { color: var(--green); border-color: var(--green); background: var(--green-bg); }
.btn-icon-restore:hover { background: var(--green); color: #fff; transform: translateY(-1px); }
.btn-icon-delete { color: var(--red); border-color: var(--red); }
.btn-icon-delete:hover { background: var(--red); color: #fff; transform: translateY(-1px); }
.btn-icon-edit .ico, .btn-icon-clone .ico, .btn-icon-archive .ico,
.btn-icon-restore .ico, .btn-icon-delete .ico, .btn-icon-edit-slots .ico { font-size: 13px; }

/* Nagłówki sekcji w modal Wersje */
.vsection-head {
  font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 4px 0 6px; margin-top: 4px;
}
.vsection-head.muted { color: var(--muted); text-transform: none; font-weight: 600; font-size: 13px; padding: 12px 0; }

/* Sekcja historyczne — collapsed default */
.versions-past-section {
  margin-top: 14px; padding: 10px 14px; background: var(--soft);
  border: 1px solid var(--line); border-radius: 10px;
}
.versions-past-section > summary {
  cursor: pointer; font-weight: 700; font-size: 12.5px; color: var(--muted);
  padding: 4px 0; user-select: none;
}
.versions-past-section > summary:hover { color: var(--text); }
.versions-past-section .version-row {
  background: rgba(255, 255, 255, 0.7); margin-top: 8px; margin-bottom: 0;
  opacity: 0.85;
}

/* Sekcja archived na dole modal Wersje */
.versions-archived-section {
  margin-top: 18px; padding: 12px 14px; background: var(--soft);
  border: 1px solid var(--line); border-radius: 10px;
}
.versions-archived-section > summary {
  cursor: pointer; font-weight: 700; font-size: 13px; color: var(--muted);
  padding: 4px 0; user-select: none;
}
.versions-archived-section > summary:hover { color: var(--text); }
.versions-archived-section .version-row {
  background: rgba(255, 255, 255, 0.6); margin-top: 8px; margin-bottom: 0;
  opacity: 0.85;
}
.version-row.is-archived { border-style: dashed; }

/* Day-action: "Nowy planogram" — default styling (spójność z resztą) */

/* Inline editor pod wierszem */
.version-row-edit, .version-row-clone {
  margin-top: 14px; padding: 16px; background: #fff; border-radius: 10px;
  border: 2px dashed var(--orange);
}
.version-row-clone { border-color: var(--green); }
.version-row.is-override .version-row-edit { background: #FFFBF3; }
.vrow-edit-head { font-weight: 800; font-size: 13px; color: var(--text); margin-bottom: 10px; }
.version-row-edit[hidden], .version-row-clone[hidden] { display: none; }
.version-row-edit .form-row, .version-row-clone .form-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 10px; }
.version-row-edit .form-row .meta, .version-row-clone .form-row .meta { font-size: 12px; font-weight: 700; color: var(--text); }
.version-row-edit .form-row .meta input[type="date"],
.version-row-edit .form-row .meta input[type="text"],
.version-row-clone .form-row .meta input[type="date"],
.version-row-clone .form-row .meta input[type="text"] {
  display: block; margin-top: 4px; padding: 7px 10px;
  border: 1.5px solid var(--line); border-radius: 8px; font-size: 13px;
  background: #fff;
}
.version-row-edit .form-row .meta input:focus,
.version-row-clone .form-row .meta input:focus { outline: none; border-color: var(--orange); }
.version-row-edit-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.version-row-edit-actions .btn { padding: 8px 16px; font-size: 13px; font-weight: 700; }
.version-row-edit-status { margin-top: 10px; }
.version-row-edit-status .notice { margin: 0; padding: 8px 12px; font-size: 12.5px; }

/* Override tag na sticky barze */
.psb-override-tag {
  display: inline-block; margin-left: 8px;
  padding: 3px 8px; border-radius: 6px;
  background: var(--orange); color: var(--navy);
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.4px;
  border: 1px solid var(--navy);
  vertical-align: middle;
}
/* "Nakładka nad: ..." pod nazwą override planogramu — pomaga zorientować się
   z którym głównym jest powiązany override aktualnie edytowany. */
.psb-overlay-info {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.psb-overlay-info b { color: var(--navy); font-weight: 700; }

/* Override event w kalendarzu — wyraźna ramka żeby wyróżnić warstwę */
.fc-event.planogram-event.is-override {
  border: 2px solid var(--navy) !important;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6), 0 2px 6px rgba(31, 34, 65, 0.25);
  font-style: italic;
}

/* Day-action: wszystkie opcje używają default styling (.day-action-btn) — spójność.
   Override i Nowy pusty zachowują tylko ikonkę jako akcent. */

/* Quick range buttons */
.quick-ranges { display: inline-flex; gap: 4px; }
.quick-ranges .btn.ghost { padding: 6px 12px; font-size: 12px; }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px;
}
.kpi-card .kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.kpi-card .kpi-value { font-size: 22px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-card .kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi-card.accent { background: linear-gradient(135deg, #fff8e6, #fff); border-color: #ffd996; }
.kpi-card.accent .kpi-value { color: var(--orange); }

/* Chart grid */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 8px;
}
.chart-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px;
}
.chart-card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 800; }
.chart-card.chart-span2 { grid-column: span 2; }
.chart-wrap { position: relative; height: 240px; }
.chart-wrap.chart-tall { height: 360px; }
@media (max-width: 1100px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card.chart-span2 { grid-column: span 1; }
}

/* SL EAN highlighting in catalog */
.catalog-table code.sl-ean {
  color: var(--orange);
  font-weight: 800;
  background: rgba(255, 177, 66, 0.12);
}
.catalog-table tr.row-local-only {
  background: rgba(255, 248, 230, 0.5);
}
.catalog-table tr.row-local-only td:first-child::before {
  content: "● ";
  color: var(--orange);
  margin-right: 4px;
}

/* Attribute pills (in catalog 'Atrybuty SL' column) */
.attr-pills {
  display: flex; flex-wrap: wrap; gap: 3px;
  max-width: 240px;
}
.attr-pill {
  display: inline-block;
  background: var(--soft); color: var(--text);
  padding: 1px 6px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
  white-space: nowrap;
  cursor: help;
}
.attr-empty {
  font-size: 11px; color: var(--muted); font-style: italic;
}

.sync-cell {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
}

.sync-icon {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  cursor: help;
}
.sync-icon::before {
  content: ""; display: inline-block;
  width: 10px; height: 10px; border-radius: 50%;
}
.sync-icon.synced       { background: var(--green-bg); color: var(--green); }
.sync-icon.synced::before { background: var(--green); }
.sync-icon.local_only   { background: var(--soft); color: var(--muted); }
.sync-icon.local_only::before { background: var(--muted); }
.sync-icon.error        { background: var(--red-bg); color: var(--red); }
.sync-icon.error::before { background: var(--red); }
.sync-icon.exists_in_if { background: #EAF1FA; color: var(--blue); }
.sync-icon.exists_in_if::before { background: var(--blue); }
.sync-icon.in_if_external { background: var(--soft); color: var(--text); opacity: .8; }
.sync-icon.in_if_external::before { background: var(--muted); }
.sync-icon.deleted_in_if { background: var(--red-bg); color: var(--red); text-decoration: line-through; }
.sync-icon.deleted_in_if::before { background: var(--red); }

.sync-retry-btn {
  appearance: none; border: 0; background: var(--soft); color: var(--text);
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; cursor: pointer; margin-left: 4px;
}
.sync-retry-btn:hover { background: #e7e5ee; }
.sync-retry-btn.danger { background: var(--red-bg); color: var(--red); }
.sync-retry-btn.danger:hover { background: #f7d6d6; }

/* SL form */
.sl-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  margin-bottom: 14px;
}
.sl-form-grid .meta { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.sl-form-grid .meta.full { grid-column: 1 / -1; }
.sl-form-grid input, .sl-form-grid select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  font-family: inherit; font-size: 13px; color: var(--text); outline: none; background: #fff;
}
.sl-form-grid input:focus, .sl-form-grid select:focus { border-color: var(--orange); }
#slAttrFields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 14px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}
#slAttrFields .meta { display: flex; flex-direction: column; gap: 4px; }

.ean-preview {
  margin-top: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fff8e6 0%, #fff 100%);
  border: 1px solid #ffd996;
  border-radius: 12px;
}
.ean-preview-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ean-preview-value {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 22px; font-weight: 800; color: var(--navy);
  letter-spacing: .04em;
}
.ean-breakdown {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px;
}
.ean-chip {
  display: inline-flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 8px; min-width: 38px;
}
.ean-chip .d { font-family: ui-monospace, Menlo, monospace; font-weight: 800; font-size: 14px; color: var(--navy); }
.ean-chip .l { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.ean-chip.counter { background: rgba(255, 177, 66, .15); border-color: #ffd996; }
.ean-chip.counter .d { color: var(--orange); }
.ean-chip.checksum { background: rgba(31, 34, 65, .08); }

.sync-banner {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
}
.sync-banner.ok    { background: var(--green-bg); color: var(--green); border: 1px solid #c3e3cd; }
.sync-banner.err   { background: var(--red-bg); color: var(--red); border: 1px solid #f7c8c8; }
.sync-banner.warn  { background: #FFF4D6; color: #8A5B00; border: 1px solid #f1d98a; }
.sync-banner.info  { background: var(--soft); color: var(--text); border: 1px solid var(--line); }

/* Toast stack — prawy górny róg, ZAWSZE widoczny (fixed). Newest pojawia się na dole
   (column, append-na-końcu), żeby user mógł czytać top→bottom w kolejności. */
.toast-stack {
  position: fixed; top: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1000; pointer-events: none;
}
.toast {
  background: var(--navy); color: #fff;
  padding: 12px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(20,20,40,.25);
  max-width: 360px; min-width: 240px;
  pointer-events: auto;
  animation: toast-in .25s ease-out;
}
.toast.ok    { background: var(--green); }
.toast.err   { background: var(--red); }
.toast.warn  { background: #B25C00; }
.toast .toast-sub { font-weight: 500; font-size: 12px; opacity: .85; margin-top: 4px; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Shelves layout (zakładka „Półki") */
.shelves-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
  min-height: 500px;
}
.shelves-sidebar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  height: fit-content;
  position: sticky;
  top: 80px;
}
.shelf-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background .12s;
}
.shelf-item:hover { background: var(--soft); }
.shelf-item.active { background: var(--navy); color: #fff; }
.shelf-item .shelf-name { font-weight: 700; }
.shelf-item .shelf-count {
  font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,.06); color: inherit;
  padding: 2px 8px; border-radius: 999px;
}
.shelf-item.active .shelf-count { background: rgba(255,255,255,.18); }

.shelves-main { min-width: 0; }
.shelves-bulkbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 12px;
  background: #fff8e6; border: 1px solid #ffd996;
  border-radius: 10px;
  flex-wrap: wrap;
}
.shelves-bulkbar select {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; font-family: inherit; font-size: 13px;
}
.shelves-bulkbar .btn { padding: 6px 14px; font-size: 13px; }
.shelves-bulkbar #bulkSelectedCount { color: var(--orange); }

#shelvesTable tbody tr.selected { background: #fff8e6; }
#shelvesTable input[type="checkbox"] { cursor: pointer; width: 16px; height: 16px; }

/* MODAL */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(15,20,40,.55);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  padding: 32px;
}
.modal-bg.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  width: 720px; max-width: 100%;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 64px);
  box-shadow: 0 30px 80px rgba(20,20,40,.45);
}
.modal.large { width: 960px; }
.modal.modal-wide { width: 1100px; }

/* Bulk import preview */
.import-preview-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.import-preview-actions { display: flex; gap: 6px; }
.import-preview-actions .btn { padding: 4px 10px; font-size: 12px; }
#importPreviewCounts { display: flex; gap: 6px; flex-wrap: wrap; }
.ip-chip {
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  background: var(--soft); color: var(--text);
}
.ip-chip b { font-weight: 800; }
.ip-chip.create    { background: #e6f6ea; color: #1b6b32; }
.ip-chip.update    { background: #fff3e0; color: #7a4a00; }
.ip-chip.unchanged { background: #eef1f5; color: #5b6478; }
.ip-chip.skip      { background: #fbe6e6; color: #8a2020; }

.ip-group { margin-bottom: 18px; }
.ip-group h4 {
  margin: 0 0 8px; font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: #444; border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.ip-group h4 .muted { text-transform: none; letter-spacing: 0; color: #7d7d8b; font-weight: 500; }

.ip-row {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 8px; background: #fff;
}
.ip-row-update    { border-left: 4px solid #f5a300; }
.ip-row-create    { border-left: 4px solid #2e9a4a; }
.ip-row-skip      { border-left: 4px solid #c94a4a; background: #fdf3f3; }
.ip-row-head { display: flex; align-items: flex-start; gap: 12px; }
.ip-check-wrap { display: flex; align-items: center; padding-top: 2px; }
.ip-check { width: 16px; height: 16px; cursor: pointer; }
.ip-check-off { color: #b3b3bb; font-size: 14px; padding-top: 2px; }
.ip-row-title { flex: 1; min-width: 0; }
.ip-row-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ip-row-meta { font-size: 11px; margin-top: 2px; }
.ip-code {
  font-family: ui-monospace, Menlo, monospace; font-size: 11px;
  background: #f3f3f7; padding: 2px 6px; border-radius: 4px; color: #666;
}
.ip-newmark {
  background: #2e9a4a; color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: .05em; padding: 2px 7px; border-radius: 4px;
}
.ip-match-badge {
  background: #ffe4b3; color: #7a4a00; font-size: 10px; font-weight: 700;
  letter-spacing: .04em; padding: 2px 6px; border-radius: 4px; cursor: help;
}
.ip-match-badge.muted { background: #eef1f5; color: #5b6478; }

/* Import: toggle Plik / Arkusz Google */
.import-source-toggle {
  display: flex; gap: 4px; margin-bottom: 14px;
  background: var(--soft); padding: 4px; border-radius: 8px; width: fit-content;
}
.ist-btn {
  background: transparent; border: 0; padding: 6px 14px; border-radius: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: #5b6478;
}
.ist-btn.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.ist-btn:disabled { cursor: not-allowed; opacity: .5; }
.import-src-panel { margin-bottom: 10px; }

/* Settings: Google Sheets */
.gsheets-cfg { display: flex; flex-direction: column; gap: 10px; max-width: 800px; }
.gsheets-status-row { display: flex; align-items: center; gap: 10px; }
.gsheets-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.gsheets-url-label { flex: 1; min-width: 400px; display: flex; flex-direction: column; gap: 4px; }
.gsheets-url-label input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px;
}
.gsheets-hint { font-size: 12px; padding: 8px 12px; background: var(--soft); border-radius: 6px; }
.gsheets-hint code {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
  background: transparent; padding: 0; color: var(--text); font-weight: 600;
}
.exp-badge.exp-warn { background: #fff3e0; color: #7a4a00; }
.ip-skip-reason {
  margin-top: 6px; padding-left: 28px; font-size: 12px; color: #8a2020;
}
.ip-diff {
  margin-top: 6px; padding: 8px 12px 8px 28px; background: #fafbfc;
  border-radius: 6px; font-size: 12px;
}
.ip-diff-row { padding: 2px 0; line-height: 1.5; }
.ip-diff-label { font-weight: 600; color: #444; margin-right: 4px; }
.ip-diff-before { color: #a34e4e; text-decoration: line-through; text-decoration-thickness: 1px; }
.ip-diff-after { color: #1b6b32; font-weight: 600; }
.modal-head { padding: 20px 24px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-x {
  appearance: none; border: 0; background: var(--soft); color: var(--text);
  width: 36px; height: 36px; border-radius: 50%; font-size: 20px; cursor: pointer; line-height: 1;
}
.modal-x:hover { background: #e7e5ee; }
.modal-filters { padding: 12px 24px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.modal-filters input, .modal-filters select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; font-family: inherit;
  outline: none;
}
.modal-filters input:focus, .modal-filters select:focus { border-color: var(--orange); }
.modal-body { flex: 1; overflow-y: auto; padding: 14px 24px; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.modal-foot .btn.ghost { background: var(--soft); color: var(--text); border: 0; }
.modal-foot .btn.ghost:hover { background: #e7e5ee; }
.qty-input { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-right: auto; }
.qty-input input { width: 64px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-family: inherit; font-size: 14px; text-align: center; }

/* Category picker grid */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.cat-item {
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  padding: 14px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  min-height: 140px;
  transition: border-color .12s, transform .08s, background .12s;
}
.cat-item:hover { border-color: var(--orange); background: #fffbf2; }
.cat-item.selected { border-color: var(--orange); background: #fff8e6; }
.cat-item:active { transform: scale(.98); }
.cat-item .cat-icon { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.cat-item .cat-name { font-size: 14px; font-weight: 800; color: var(--text); }
.cat-item .cat-meta { font-size: 10px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

/* Emoji kategorii w tabelach (z marginesem żeby nie kleiło się do tekstu) */
.cat-emoji { display: inline-block; margin-right: 6px; font-size: 18px; vertical-align: -2px; }

/* Slot z kategorią */
.slot { overflow: hidden; }
.slot .cat-icon { font-size: 32px; line-height: 1; margin-bottom: 4px; flex: none; }
.slot.has-product { border-color: var(--orange); background: linear-gradient(180deg, #fff8e6 0%, #fff 60%); border-style: solid; }
.slot.has-product .pname {
  font-size: 12px; font-weight: 800; color: var(--text);
  -webkit-line-clamp: 2;
}
.slot .cat-sub { font-size: 10px; color: var(--muted); margin-top: 2px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; flex: none; }
.slot.any-product { border-style: dashed; }
.slot.any-product .pname { font-size: 13px; font-weight: 800; }

/* Compact badge zamienników w slocie + tooltip popup z pełną listą */
.slot .slot-subs-badge {
  position: relative;
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(255, 177, 66, 0.15);
  color: #8a5a00;
  border: 1px dashed rgba(255, 177, 66, 0.5);
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  /* overflow MUSI być visible — tooltip wystaje poza bounds badge.
     Tekst "🔄 N zamienników" i tak jest krótki, ellipsis niepotrzebny. */
  overflow: visible;
  max-width: 100%;
}
.slot .slot-subs-badge > * {
  pointer-events: none; /* tooltip wewnątrz — klik przechodzi do badge */
}
.slot .slot-subs-badge:hover {
  background: rgba(255, 177, 66, 0.3);
  border-color: var(--orange);
  border-style: solid;
}
.slot .slot-subs-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 260px;
  max-width: 440px;
  background: #1f2241;
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 100;
  white-space: normal;
}
.slot .slot-subs-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1f2241;
}
.slot .slot-subs-badge:hover .slot-subs-tooltip,
.slot .slot-subs-badge:focus-visible .slot-subs-tooltip,
/* Na telefonie nie ma hovera — restocker rozwija listę dotknięciem (klasa z JS). */
.slot .slot-subs-badge.tip-open .slot-subs-tooltip { opacity: 1; pointer-events: auto; }
.slot-subs-tt-h { font-size: 11px; margin-bottom: 6px; color: #c8cee5; }
.slot-subs-tt-h b { color: #ffd089; }
.slot-subs-tt-list { margin: 0; padding-left: 18px; }
.slot-subs-tt-list li { margin: 2px 0; }
.slot-subs-tt-foot { font-size: 10px; margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.1); color: #8b91ab; }
/* Slot z zamiennikami może urosnąć — zezwól na auto-wysokość */
.slot.has-product { min-height: 0; height: auto; overflow: visible; }

/* Przycisk zarządzania zamiennikami — w slocie z productCode */
.slot .subs-btn {
  margin-top: 6px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 177, 66, 0.15);
  color: #8a5a00;
  border: 1px dashed rgba(255, 177, 66, 0.5);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.slot .subs-btn:hover {
  background: rgba(255, 177, 66, 0.3);
  border-color: var(--orange);
  border-style: solid;
}
.slot .subs-btn:active { transform: scale(0.96); }

/* Modal zamienników */
.subs-target-cat { font-size: 11px; margin-top: 2px; font-weight: 600; }
.subs-section { margin-bottom: 18px; }
.subs-section:last-child { margin-bottom: 0; }
.subs-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 800;
  color: var(--muted);
  margin: 0 0 8px;
}
.subs-section p.small { font-size: 11px; margin: -4px 0 8px; }

.subs-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
  padding: 8px;
  background: var(--soft, #f7f7f9);
  border-radius: 8px;
  border: 1px solid var(--line);
}
.subs-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px 6px 10px;
  background: #fff;
  border: 1px solid var(--orange);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.subs-chip-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subs-chip-x {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.subs-chip-x:hover { background: #d32f2f; color: #fff; }

/* Filtry w modalu zamienników: dropdown kategorii + search obok siebie */
.subs-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 700px) {
  .subs-filters { grid-template-columns: 1fr; }
}
.subs-cat-label {
  display: flex; flex-direction: column; gap: 4px;
}
.subs-cat-sel {
  padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-family: inherit;
  background: #fff;
  cursor: pointer;
}
.subs-cat-sel:focus {
  border-color: var(--orange); outline: none;
  box-shadow: 0 0 0 3px rgba(255,171,0,0.13);
}
.subs-search-input { margin: 0; align-self: end; }

/* Restock — inline zamienniki pod preferred product */
.pref-block { display: block; margin-bottom: 4px; }
.pref-block:last-child { margin-bottom: 0; }
.pref-subs {
  margin-left: 28px;
  margin-top: 2px;
  padding: 4px 0 6px 8px;
  border-left: 2px solid rgba(255, 177, 66, 0.4);
}
.pref-subs-h {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
  padding-left: 4px;
}
.pref-subs .cat-prod-row {
  padding-top: 4px;
  padding-bottom: 4px;
  opacity: 0.95;
}
.pref-subs .cat-prod-row .name { font-size: 12px; font-weight: 600; }
.pref-subs .cat-prod-row .thumb-sm { width: 28px; height: 28px; }
.cat-prod-row.substitute-of { background: rgba(255, 177, 66, 0.04); border-radius: 6px; }

/* Restock card */
.cat-card { padding: 0; display: block; }
.cat-card-head {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.cat-card .cat-icon-lg { font-size: 32px; line-height: 1; flex: none; }
.cat-card .cat-card-head .info { flex: 1; min-width: 0; }
.cat-card .cat-card-head .name { font-weight: 800; font-size: 14px; }
.cat-card .cat-card-head .stats { display: flex; gap: 8px; align-items: baseline; margin-top: 4px; font-size: 12px; }
.cat-section { padding: 8px 14px; border-bottom: 1px dashed var(--line); border-left: 3px solid transparent; }
.cat-section:last-child { border-bottom: 0; }
.cat-section-h { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.cat-section-h.muted { color: var(--muted); font-weight: 700; }
.cat-section-h .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.cat-section-h .dot-red { background: var(--red); }
.cat-section-h .dot-green { background: var(--green); }
.cat-section-h .dot-orange { background: var(--orange); }
.cat-section-h .dot-blue { background: var(--blue); }

.cat-section.sec-missing { border-left-color: var(--red); background: rgba(192, 57, 43, .03); }
.cat-section.sec-proposed { border-left-color: var(--blue); background: rgba(41, 92, 225, .03); }
.cat-section.sec-proposed > summary { cursor: pointer; padding: 6px 0; user-select: none; list-style: none; }
.cat-section.sec-proposed > summary::-webkit-details-marker { display: none; }
.cat-section.sec-proposed > summary::before { content: "▸"; color: var(--muted); margin-right: 6px; transition: transform .12s; display: inline-block; }
.cat-section.sec-proposed[open] > summary::before { transform: rotate(90deg); }
.sec-proposed-body { padding-top: 4px; }
.cat-section.sec-ok { background: transparent; }
.cat-section.sec-subs { border-left-color: var(--orange); background: rgba(255, 177, 66, .04); }

/* Mini-stat w nagłówku karty — wyjaśnia paradoks diff vs braki */
.cat-breakdown { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; font-size: 11px; }
.cat-breakdown .bd-miss { color: var(--red); }
.cat-breakdown .bd-subs { color: var(--orange); }
.cat-breakdown b { font-weight: 800; }

.cat-prod-row .ok-check { color: var(--green); }
.cat-prod-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px; align-items: center;
  padding: 4px 0;
}
.cat-prod-row .thumb-sm {
  width: 32px; height: 32px;
  background: var(--soft) center/contain no-repeat;
  border-radius: 6px;
}
.cat-prod-row .info { min-width: 0; }
.cat-prod-row .name { font-size: 12px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-prod-row .muted { font-size: 10px; }
.cat-prod-row .counts { display: flex; flex-direction: column; align-items: flex-end; font-size: 11px; font-weight: 700; gap: 1px; }
.cat-prod-row.preferred.ok { opacity: .8; }
.cat-prod-row.substitute { opacity: .9; }
.cat-prod-row.has-tooltip { position: relative; cursor: help; }
.cat-prod-row.has-tooltip:hover,
.cat-prod-row.has-tooltip:focus-within,
.cat-prod-row.has-tooltip:focus-visible {
  background: rgba(0, 0, 0, .035);
  /* Hover-owany wiersz wchodzi nad sąsiadów — inaczej kolejne wiersze
     (też position:relative) paintują się nad naszym tooltipem. */
  z-index: 60;
}
.cat-prod-row.has-tooltip:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; border-radius: 4px; }

/* Globalny focus-visible outline — 3px dla lepszej widoczności keyboard nav (a11y).
   Specyficzne reguły niżej w pliku (np. .cat-prod-row, .hc-param) nadpisują własne 2px. */
*:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

/* Tooltip — pokazywany na hover (i focus dla klawiatury / dotyku) */
.prod-tooltip {
  position: absolute;
  z-index: 50;
  top: 100%; left: 0;
  margin-top: 4px;
  min-width: 240px; max-width: 320px;
  background: #1c1f24;
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .12s, transform .12s;
}
.cat-prod-row.has-tooltip:hover .prod-tooltip,
.cat-prod-row.has-tooltip:focus-within .prod-tooltip,
.cat-prod-row.has-tooltip:focus-visible .prod-tooltip {
  opacity: 1;
  transform: translateY(0);
}
.prod-tooltip .tt-name { font-weight: 700; font-size: 13px; white-space: normal; word-break: break-word; }
.prod-tooltip .tt-ean { margin-top: 2px; color: rgba(255,255,255,.6); }
.prod-tooltip .tt-ean code { font-family: ui-monospace, monospace; font-size: 11px; }
.prod-tooltip .tt-kv { margin-top: 8px; display: grid; gap: 3px; }
.prod-tooltip .tt-kv .muted { color: rgba(255,255,255,.55); min-width: 78px; display: inline-block; }
.prod-tooltip .tt-pos { color: #57d27e; }
.prod-tooltip .tt-neg { color: #ff7676; }

/* 2-step picker */
.picker-breadcrumb {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
  font-size: 13px;
}
.picker-back {
  appearance: none; border: 0; background: var(--soft); color: var(--text);
  padding: 6px 12px; border-radius: 999px; font-weight: 700; cursor: pointer;
  font-family: inherit; font-size: 12px;
}
.picker-back:hover { background: #e7e5ee; }
.picker-cat-tag {
  background: var(--orange); color: #fff;
  padding: 4px 12px; border-radius: 999px;
  font-weight: 800; font-size: 13px;
}
.picker-any-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px; align-items: center;
  padding: 8px 12px;
  width: 100%;
  appearance: none; font-family: inherit; text-align: left;
  /* Drugorzędne wizualnie — szare tło bez gradientu, dyskretne; główna uwaga
     to lista produktów i banner "Aktualnie w slocie". */
  background: var(--soft);
  border: 1.5px dashed var(--line); border-radius: 8px;
  cursor: pointer; margin-bottom: 10px;
}
/* `display: grid` nadpisuje default [hidden]{display:none} — dodajemy explicit. */
.picker-any-row[hidden] { display: none; }
.picker-any-row:hover { background: #ECEBF4; border-color: var(--muted); }
.picker-any-icon { font-size: 20px; line-height: 1; text-align: center; opacity: 0.7; }
.picker-any-row .info .name { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.picker-any-row .info .muted { font-size: 10.5px; margin-top: 1px; }
.picker-any-row .pick-action { font-size: 11px; font-weight: 700; color: var(--muted); }
.picker-search {
  width: 100%;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  font-family: inherit; font-size: 13px;
  margin-bottom: 12px;
}
.picker-search:focus { border-color: var(--orange); outline: none; }
/* Wymagane pole — gwiazdka w label + dyskretny hint pod inputem. */
.required-mark { color: var(--red); font-weight: 800; margin-left: 2px; cursor: help; }
.meta-hint { font-size: 11px; margin-top: 2px; display: inline-block; }
/* Highlight pola gdy backend zwróci 422 z polem `field` — pulsuje przez 4s. */
.input-error { border-color: var(--red) !important; outline: 2px solid rgba(220, 53, 69, 0.25); }

/* Picker step 2: head (filters) + body (scrollable products list).
   Jeden scroll w środku zamiast wcześniejszych dwóch (modal-body i picker-products).
   Scope tylko do modala picker-a (#modalBg) żeby nie zaburzać innych modali. */
#modalBg .modal-body { display: flex; flex-direction: column; overflow: hidden; }
#modalBg #pickerStep2 { display: flex; flex-direction: column; min-height: 0; flex: 1; }
#modalBg #pickerStep1 { overflow-y: auto; }  /* step 1 = grid kategorii: jeden scroll w body */
/* `#modalBg #pickerStep2 { display: flex }` powyżej nadpisuje native `[hidden]{display:none}`
   (specyficzność ID > atrybut). Bez tego override `pickerStep2.hidden = true` z JS nie ukrywa
   sekcji — i krok 2 z poprzedniego pickera (np. Snickers + zamienniki) pozostaje widoczny
   gdy user otwiera picker na pustym slocie. */
#modalBg #pickerStep1[hidden],
#modalBg #pickerStep2[hidden] { display: none; }
.picker-step2-head { flex-shrink: 0; }
.picker-step2-body { flex: 1; overflow-y: auto; min-height: 0; padding: 0 0 8px 0; }
.picker-step2-body .picker-products { max-height: none; overflow: visible; }
/* Pozostałe .picker-products (np. w substitutes modal) wciąż mają własny scroll. */
.picker-products { max-height: calc(70vh - 80px); overflow-y: auto; }
.picker-product-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px; align-items: center;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.picker-product-row:hover { background: var(--soft); border-color: var(--line); }
.picker-product-row.selected { background: #fff8e6; border-color: var(--orange); }
.picker-product-row .thumb {
  width: 48px; height: 48px;
  background: var(--soft) center/contain no-repeat;
  border-radius: 8px;
}
.picker-product-row .thumb.empty {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--muted); opacity: .5;
}
.picker-product-row .info { min-width: 0; }
.picker-product-row .name { font-size: 13px; font-weight: 700; line-height: 1.25; }
.picker-product-row .code { font-size: 11px; font-family: ui-monospace, Menlo, monospace; }
.picker-product-row .pick-action { font-size: 11px; font-weight: 800; color: var(--orange); white-space: nowrap; }

/* ---------- Toggle widoków (np. Sprzedaż: Per produkt / Lista transakcji) ---------- */
.view-toggle {
  display: inline-flex;
  background: var(--soft);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.view-toggle .vt-btn {
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.view-toggle .vt-btn:hover { color: var(--text); }
.view-toggle .vt-btn.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(20, 20, 40, .12);
}

/* ---------- Lista transakcji: grupowanie po kliencie ---------- */
.data-table tr.ph-client-head td {
  background: var(--soft);
  font-size: 11px;
  font-weight: 800;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.data-table tr.ph-client-head code {
  font-family: ui-monospace, Menlo, monospace;
  background: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

/* ---------- Health monitoring ---------- */
/* Screen-reader-only — content niewidoczny wizualnie ale obecny w accessibility tree.
   Używamy dla `<thead>` w health-check-table (kolumny Status/Sprawdzenie/Wartość).
   Visual users widzą tylko emoji-ikony, screen reader announces full kontekst. */
.sr-only {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important; border: 0 !important;
}

.health-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 14px;
}
.health-code { font-size: 11px; color: var(--muted); margin-left: 4px; font-weight: 500; }
.health-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 14px; flex-wrap: wrap;
}
.health-title { font-size: 15px; font-weight: 700; }
.health-title code { background: var(--soft); padding: 2px 8px; border-radius: 6px; font-family: ui-monospace, monospace; }
.health-stats { font-size: 12px; }
.health-check-table { font-size: 13px; }
.health-check-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); }
.health-check-table tr:last-child td { border-bottom: 0; }
.health-check-table td.health-value { text-align: right; font-weight: 600; white-space: nowrap; }

/* Sekcja w Settings — health checks */
#healthChecksTable td.hc-params-cell { white-space: nowrap; }
#healthChecksTable select { padding: 4px 8px; font-size: 12px; }
.hc-param-label {
  display: inline-flex; align-items: center; gap: 4px;
  margin-right: 14px;
  font-size: 12px;
}
.hc-param {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  text-align: right;
}
.hc-param:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
.hc-param-suffix { font-size: 11px; }

/* Health card — lodówka testowa (alerty pomijane) — wyciszone */
.health-card.is-test {
  opacity: 0.7;
  background: var(--soft);
}
.health-card.is-test .health-title code {
  background: #fff;
}

/* Fridge flags table */
#fridgeFlagsTable input[type="text"] {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

/* ===== Zakładka Etykiety — krokowy layout ===== */
.lbl-step {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 14px;
  overflow: hidden;
}
.lbl-step-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}
.lbl-step-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.lbl-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--navy); color: #fff;
  border-radius: 50%;
  font-weight: 800; font-size: 13px;
}
.lbl-step-num-ready { background: var(--green); }
.lbl-step-body { padding: 18px; }
.lbl-step-body[hidden] { display: none; }

/* Step 1 — produkt */
#lblProductSearch {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 10px;
  font-family: inherit;
}
#lblProductSearch:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
#lblProductList {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.lbl-product-item {
  display: flex; flex-direction: column; align-items: flex-start;
  width: 100%;
  padding: 8px 12px;
  border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  gap: 2px;
  transition: background .08s;
}
.lbl-product-item:last-child { border-bottom: 0; }
.lbl-product-item:hover { background: var(--soft); }
.lbl-product-item:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.lbl-product-item .lbl-product-name { font-weight: 700; line-height: 1.25; }
.lbl-product-item .lbl-product-meta { font-size: 11px; }
.lbl-product-empty, .lbl-product-overflow {
  padding: 10px 12px;
  font-size: 12px;
  text-align: center;
}
.lbl-product-overflow { border-top: 1px dashed var(--line); }

/* Step 1 — chosen product card */
.lbl-chosen-card {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(0deg, #fff8e6 0%, #fff 100%);
  border: 2px solid var(--orange);
  padding: 14px 18px;
  border-radius: 12px;
  gap: 14px;
}
.lbl-chosen-info { min-width: 0; flex: 1; }
.lbl-chosen-name { font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.lbl-chosen-meta { color: var(--muted); font-size: 12px; }
.lbl-chosen-meta code { background: var(--soft); padding: 1px 6px; border-radius: 4px; font-size: 11px; }

/* Change product button — wyraźny na pomarańczowej karcie */
.lbl-change-btn {
  display: inline-flex; align-items: center; gap: 8px;
  appearance: none;
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--orange);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .12s;
}
.lbl-change-btn:hover {
  background: var(--orange);
  color: #fff;
}
.lbl-change-btn svg { flex-shrink: 0; }
.lbl-change-btn:hover svg { transform: rotate(30deg); transition: transform .15s; }

/* Step 2 — data ważności */
.lbl-expiry-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.lbl-expiry-row input[type="date"] {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  min-width: 170px;
}
.lbl-expiry-row input[type="date"]:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
.lbl-day-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.lbl-chip {
  appearance: none;
  background: #fff;
  border: 1.5px solid var(--line);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700; font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.lbl-chip:hover {
  border-color: var(--orange);
  background: #fff8e6;
  color: var(--orange);
}
.lbl-hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text);
  padding: 8px 12px;
  background: var(--soft);
  border-radius: 8px;
  border-left: 3px solid var(--orange);
}

/* Symulator wydruku */
.lbl-preview-wrap {
  margin-top: 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.lbl-preview-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}
.lbl-preview {
  display: flex; flex-direction: column; gap: 8px;
}
.lbl-prev-svg {
  width: 100%;
  max-width: 340px;
  height: auto;
  display: block;
  background: #fff;
  border: 2px dashed var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(20, 20, 40, .08);
}
.lbl-prev-bg { fill: #fff; }
.lbl-prev-carrier { fill: #f0eef5; }
.lbl-prev-shapelabel {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.1px;
  fill: rgba(0,0,0,.25);
  font-weight: 600;
}
.lbl-prev-text {
  /* Roboto Condensed = najbliższy free webfont do CG Triumvirate Bold Condensed (font drukarki ^A0) */
  font-family: "Roboto Condensed", "Arial Narrow", "Liberation Sans Narrow", sans-serif;
  font-weight: 700;
  font-stretch: condensed;
  fill: #1a1a1a;
}
.lbl-prev-outline {
  fill: none;
  stroke: rgba(255, 177, 66, .35);
  stroke-width: 0.15;
  stroke-dasharray: 0.5 0.4;
}
/* Pionowa kreska pokazująca granicę faktycznej print area (`previewClipWidthMm`) */
.lbl-prev-clipline {
  stroke: rgba(200, 0, 0, .8);
  stroke-width: 0.2;
  stroke-dasharray: 0.8 0.4;
}

/* WYSIWYG drag boxes nakładane na pola etykiety */
.lbl-drag-box {
  fill: transparent;
  stroke: rgba(255, 177, 66, .55);
  stroke-width: 0.25;
  cursor: move;
}
.lbl-drag-group:hover .lbl-drag-box {
  fill: rgba(255, 177, 66, .12);
  stroke: rgba(255, 145, 0, .9);
}
.lbl-drag-label {
  font-size: 1.2px;
  fill: rgba(255, 145, 0, .85);
  font-weight: 700;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 0.03px;
}
.lbl-drag-handle {
  fill: rgba(255, 145, 0, .95);
  stroke: #fff;
  stroke-width: 0.1;
  cursor: se-resize;
}
.lbl-preview.lbl-dragging { user-select: none; }
.lbl-preview.lbl-dragging * { cursor: grabbing !important; }

/* Layout editor (collapse w zakładce Etykiety) */
.lbl-layout-editor {
  background: #FFFBF0;
  border: 1px solid #F0DCA0;
  border-radius: 12px;
  margin: 12px 0 22px;
  overflow: hidden;
}
.lbl-layout-editor > summary {
  cursor: pointer;
  padding: 14px 18px;
  background: #FFF3CD;
  font-size: 14px;
  user-select: none;
  list-style: none;
}
.lbl-layout-editor > summary::-webkit-details-marker { display: none; }
.lbl-layout-editor > summary::after {
  content: "▾"; float: right; opacity: .5;
}
.lbl-layout-editor[open] > summary::after { content: "▴"; }
.lbl-layout-editor[open] > summary { border-bottom: 1px solid #F0DCA0; }
.lbl-layout-body { padding: 18px; overflow-x: auto; }

/* Tabela layoutu — wymuszone wąskie kolumny żeby mieściła się w containerze */
#lblLayoutTable { table-layout: fixed; width: 100%; min-width: 720px; }
#lblLayoutTable thead th { padding: 6px 4px; font-size: 11px; }
#lblLayoutTable tbody td { padding: 6px 4px; vertical-align: middle; }
#lblLayoutTable tbody td:first-child { padding-left: 10px; }
#lblLayoutTable input[type="number"] { width: 56px; padding: 4px 6px; text-align: right; font-size: 12px; }
#lblLayoutTable input[type="checkbox"] { transform: scale(1.1); }
#lblLayoutTable select { width: 60px; padding: 4px 4px; font-size: 12px; }
/* Kolumny — proporcje */
#lblLayoutTable colgroup, /* fallback */
#lblLayoutTable th:nth-child(1) { width: 160px; }       /* Pole */
#lblLayoutTable th:nth-child(2) { width: 60px; }        /* Aktywne */
#lblLayoutTable th:nth-child(3),
#lblLayoutTable th:nth-child(4),
#lblLayoutTable th:nth-child(5),
#lblLayoutTable th:nth-child(6) { width: 72px; }        /* X/Y/W/H */
#lblLayoutTable th:nth-child(7) { width: 80px; }        /* Font mm */
#lblLayoutTable th:nth-child(8) { width: 70px; }        /* Align */
.lbl-prev-ruler line {
  stroke: rgba(0, 0, 0, .25);
  stroke-width: 0.1;
}
.lbl-prev-info {
  font-size: 12px;
  color: var(--text);
  padding: 8px 12px;
  background: var(--soft);
  border-radius: 8px;
  border-left: 3px solid var(--orange);
}

/* Step 3 — qty + akcja */
.lbl-qty-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.lbl-qty-control {
  display: inline-flex; align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.lbl-qty-btn {
  appearance: none; border: 0;
  background: var(--soft);
  width: 38px; height: 38px;
  font-size: 18px; font-weight: 800;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.lbl-qty-btn:hover { background: var(--orange); color: #fff; }
#lblQty {
  width: 70px;
  text-align: center;
  border: 0;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  height: 38px;
  -moz-appearance: textfield;
}
#lblQty::-webkit-outer-spin-button,
#lblQty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.lbl-generate-btn {
  font-size: 14px;
  padding: 10px 20px;
}

/* Step 4 — wygenerowane tagi + drukowanie */
.lbl-print-bar {
  display: flex; align-items: center; gap: 14px;
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--soft);
  border-radius: 10px;
}
.lbl-print-info { flex: 1; font-size: 14px; }
.lbl-print-big {
  font-size: 14px;
  padding: 12px 24px;
}

/* EPC w tabeli wygenerowanych */
.lbl-epc {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--soft);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: .02em;
}

/* Secondary button — widoczny ghost z border (nie znika na białym tle) */
.btn.lbl-secondary-btn {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--line);
}
.btn.lbl-secondary-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
}

/* Historia — collapse */
.lbl-history-details {
  margin-top: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
}
.lbl-history-details summary {
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}
.lbl-history-details[open] summary { margin-bottom: 10px; }

/* ---------- Printer config row (Settings) ---------- */
.printer-cfg-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.printer-cfg-row input[type="text"],
.printer-cfg-row input[type="number"] {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

/* ---------- Dish staging (Katalog) ---------- */
.stg-box {
  background: #FFFAEC;
  border: 1px solid #E8C97A;
  border-radius: 12px;
  margin-bottom: 22px;
  /* Pozwól boxowi rosnąć do natural width tabeli, ale NIE szerszemu niż
     viewport minus sidebar (~250px) + margines. Jeśli treść większa —
     scroll horyzontalny w .stg-body. */
  width: max-content;
  max-width: calc(100vw - 280px);
  min-width: 100%;
}
.stg-box.collapsed .stg-body { display: none; }
.stg-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 14px 18px; background: #FFEFC2;
  border-bottom: 1px solid #E8C97A;
}
.stg-head > div { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stg-pill {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  background: #fff; border: 1px solid #E8C97A;
  font-size: 13px; font-weight: 600; color: #5C4612;
}
.stg-pill.warn { background: #FFE9B0; border-color: #E8C97A; }
.stg-pill.err  { background: #FBEDED; border-color: #E5A8A8; color: var(--red); }
.stg-bulk { display: flex; gap: 8px; align-items: center; }
/* W całym stg-box (pasek + tabela) .btn.ghost ma transparent bg + jasny color,
   przez co na białym/żółtym tle jest niewidoczny. Wymuszamy kontrast. */
.stg-box .btn { background: #fff !important; color: #4A3909 !important; border: 1px solid #B8923B !important; }
.stg-box .btn:hover { background: #FFE9B0 !important; }
.stg-box .btn.primary { background: var(--orange) !important; color: #fff !important; border-color: transparent !important; }
.stg-box .btn.primary:hover { filter: brightness(.95) !important; background: var(--orange) !important; }
.stg-box .btn.ghost { background: #fff !important; opacity: 1 !important; }
#stgToggleCollapse {
  font-size: 16px !important; padding: 4px 14px !important;
  line-height: 1; min-width: 36px;
}

/* Tabela — pozwalamy wystawać poza .content, ale w przypadku gdy
   stg-box jest cappowany max-width-em → wewnątrz scroll horyzontalny. */
.stg-body { padding: 14px 18px 18px; overflow-x: auto; }
.stg-table {
  width: auto; font-size: 13.5px; border-collapse: separate; border-spacing: 0;
  /* width: auto + min-widths kolumn → tabela rośnie do natural rozmiaru,
     stg-box ją okala bo ma width: max-content. */
}
.stg-table thead th {
  background: transparent; padding: 8px 10px;
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; border-bottom: 1px solid #E8C97A;
}
.stg-table tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid #F0E2BB;
  vertical-align: top;
}
.stg-table tbody tr:last-child td { border-bottom: 0; }
.stg-table .stg-row.duplicate { opacity: .82; background: #FBEDED30; }
.stg-table .stg-row:hover { background: #FFF0BD80; }

/* Kolumny — zwężone żeby tabela mieściła się bez horyzontalnego scrolla
   w typowym oknie (~1000-1100px szerokości). */
.stg-c-check   { width: 28px; }
.stg-c-name    { min-width: 160px; max-width: 220px; }
.stg-c-prop    { min-width: 320px; }
.stg-c-ean     { width: 135px; }
.stg-c-price   { width: 80px; white-space: nowrap; }
.stg-c-status  { width: 95px; }
.stg-c-actions {
  width: 100px; text-align: right;
  white-space: normal;
}
.stg-c-actions .btn.small { display: block; width: 100%; margin: 0 0 6px; }
.stg-c-actions .btn.small:last-child { margin-bottom: 0; }

.stg-name { font-weight: 700; color: var(--text); line-height: 1.25; }
.stg-dishtype-inline {
  display: inline-block; margin-top: 4px;
  padding: 2px 8px; border-radius: 999px; background: var(--soft);
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.stg-prop { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; width: 100%; }
.stg-prop-grid {
  display: grid;
  /* 4 kolumny: [klucz1 | wartość1 | klucz2 | wartość2] — 4 wiersze zamiast 8 */
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 3px;
  font-size: 12px;
  line-height: 1.35;
  width: 100%;
}
.stg-prop-grid .stg-prop-k {
  color: var(--muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  white-space: nowrap;
}
.stg-prop-grid b {
  color: var(--text); font-weight: 600;
  overflow-wrap: anywhere;
}
/* Dodatkowa separacja między dwiema grupami atrybutów (3. kolumna = key2) */
.stg-prop-grid > :nth-child(4n+3) { padding-left: 14px; border-left: 1px dashed #E0CFA8; }
/* Przycisk "Zmień" — wysoki kontrast, nadpisuje .btn.ghost */
.stg-change-btn.stg-change-btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1.5px solid #B8923B !important;
  background: #FFFFFF !important;
  color: #4A3909 !important;
  padding: 4px 14px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  border-radius: 999px !important;
  cursor: pointer;
}
.stg-change-btn.stg-change-btn:hover {
  background: #FFE9B0 !important;
  border-color: #8B6E1F !important;
}
.stg-change-btn::before { content: "✏️"; font-size: 10px; }
.stg-dup {
  display: inline-block; padding: 4px 10px;
  background: var(--red-bg); color: var(--red); border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
}
.stg-status-pending {
  display: inline-block; padding: 4px 10px;
  background: #E0F4E1; color: #2A6F3A; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
}
.stg-ean-inp {
  width: 100%; max-width: 160px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  font-family: ui-monospace, monospace; font-size: 12px;
}
.stg-ean-inp:focus { border-color: var(--orange); outline: none; }
.btn.small { padding: 6px 12px; font-size: 11.5px; font-weight: 700; }


/* ── CTA picker ───────────────────────────────────────────────────────── */
.cta-input-row {
  display: flex; gap: 6px; align-items: stretch;
}
.cta-input-row input[type="text"] { flex: 1; min-width: 0; }
.cta-random-btn, .cta-toggle-btn {
  border: 1px solid var(--line);
  background: #fff; border-radius: 8px;
  padding: 0 10px; cursor: pointer;
  font-size: 13px; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  white-space: nowrap; height: 38px; min-width: 38px;
}
.cta-random-btn { font-size: 16px; }
.cta-random-btn:hover, .cta-toggle-btn:hover {
  background: #fafafa; border-color: var(--orange);
}
.cta-toggle-arrow { transition: transform 0.2s; font-size: 12px; opacity: 0.6; }
.cta-toggle-btn[aria-expanded="true"] .cta-toggle-arrow { transform: rotate(180deg); }

/* ── CTA popover (kompaktowy dropdown z search) ─────────────────────── */
/* Anchor TYLKO na CTA label — nie globalnie .meta (psułoby inne dropdowny) */
.cta-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  max-height: 380px;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: cta-popover-in 0.12s ease-out;
}
/* WAŻNE: `display: flex` powyżej nadpisuje native `[hidden] { display: none }`.
   Explicitne override żeby `box.hidden = true` w JS faktycznie ukrywał popover. */
.cta-popover[hidden] { display: none; }
@keyframes cta-popover-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.cta-popover-search {
  padding: 10px 12px;
  border: none; border-bottom: 1px solid var(--line);
  font-size: 13px; outline: none;
  background: #fafbfd; flex-shrink: 0;
}
.cta-popover-search:focus { background: #fff; }
.cta-popover-list {
  flex: 1; overflow-y: auto;
  padding: 10px 12px;
  display: grid; gap: 12px;
}
.cta-popover-list .cta-cat-empty {
  text-align: center; color: #9aa0ad;
  font-size: 12px; font-style: italic;
  padding: 16px 8px;
}
.cta-cat {
  display: flex; flex-direction: column; gap: 6px;
}
.cta-cat-header {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  color: #6b7180; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cta-cat-emoji { font-size: 14px; }
.cta-cat-count {
  margin-left: auto;
  font-size: 10px; font-weight: 500;
  color: #9aa0ad; letter-spacing: 0;
  text-transform: none;
}
.cta-chips {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.cta-chip {
  border: 1px solid var(--line);
  background: #fff; border-radius: 999px;
  padding: 4px 11px; cursor: pointer;
  font-size: 11.5px; color: var(--ink);
  font-weight: 500; letter-spacing: 0.01em;
  transition: all 0.12s;
}
.cta-chip:hover {
  background: var(--orange); border-color: var(--orange);
  color: #fff; transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(255, 171, 0, 0.25);
}
.cta-chip:active { transform: translateY(0); }


/* ── Automatyzacje: grid + form ──────────────────────────────────────── */

.form-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  background: linear-gradient(180deg, #fff5e0 0%, #ffe2b0 100%);
  border-radius: 7px; font-size: 14px;
}


  /* pozwala input <= grid cell */


.quick-window {
  border: 1px solid var(--line); background: #fff;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  font-size: 12px; font-weight: 500; color: #4a4f5a;
  transition: all 0.12s;
}
.quick-window:hover {
  background: var(--orange); border-color: var(--orange);
  color: #fff; transform: translateY(-1px);
}

.aut-fridges-selected-badge {
  background: #e8eaf5; color: #4d56a8;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  letter-spacing: 0;
}
.aut-fridges-selected-badge.has-some { background: #ffe9b5; color: #6b4500; }
.fridge-picker-toolbar .spacer { flex: 1; }

/* ── Fridge picker (multi-checkbox) ──────────────────────────────────── */
.fridge-picker-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 6px; font-size: 12px;
}
.fridge-picker-mode {
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 400; color: #4a4f5a;
  text-transform: none; letter-spacing: 0;
  margin-right: 6px;
}
.fridge-picker-list {
  max-height: 200px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px; background: #fafbfd;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
}
.fridge-picker-list.disabled {
  opacity: 0.4; pointer-events: none;
}
.fridge-picker-row {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; padding: 2px 4px; border-radius: 4px;
  cursor: pointer; transition: background 0.1s;
}
.fridge-picker-row:hover { background: rgba(255,171,0,0.08); }
.fridge-picker-row input[type="checkbox"] { margin: 0; }

/* ── Lista automatyzacji ────────────────────────────────────────────── */

.aut-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px; border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 12px;
  background: linear-gradient(180deg, #fafbfd 0%, #f5f6fa 100%);
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}
.aut-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.aut-card.status-scheduled {
  background: linear-gradient(180deg, #f0f2fa 0%, #e6e9f5 100%);
  border-color: #c8cee5;
}
.aut-card.status-active {
  background: linear-gradient(180deg, #fff7d6 0%, #ffeeb0 100%);
  border-color: #ffce69;
  box-shadow: 0 0 0 3px rgba(255,171,0,0.1);
}
.aut-card.status-done {
  opacity: 0.7; background: #f8f9fb;
}
.aut-card.status-error {
  background: linear-gradient(180deg, #fdf0f0 0%, #f7dede 100%);
  border-color: #f5b7b7;
}
.aut-card.status-cancelled { opacity: 0.55; background: #f5f5f5; }

.aut-card-thumb {
  width: 64px; height: 114px; object-fit: cover;
  border-radius: 8px; flex-shrink: 0;
  background: #eee;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.aut-card-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; opacity: 0.3;
}
.aut-card-body { flex: 1; min-width: 0; }
.aut-card-title {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.aut-card-name { font-weight: 600; font-size: 15px; color: var(--ink); }

.aut-status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; letter-spacing: 0.01em;
}
.aut-status-pill .aut-status-icon { font-size: 11px; }
.aut-status-pill.scheduled { background: #e0e5f7; color: #3d479f; }
.aut-status-pill.active {
  background: #fff; color: #b87100;
  box-shadow: 0 0 0 2px #ffce69;
  animation: aut-pulse 2s ease-in-out infinite;
}
.aut-status-pill.done { background: #d6dbe5; color: #4a4f5a; }
.aut-status-pill.error { background: #ffcfcf; color: #8a1f1f; }
.aut-status-pill.cancelled { background: #e0e0e0; color: #7a7a7a; }
@keyframes aut-pulse {
  0%, 100% { box-shadow: 0 0 0 2px #ffce69; }
  50% { box-shadow: 0 0 0 2px rgba(255,171,0,0.4); }
}

.aut-time-row {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px; margin-bottom: 3px;
}
.aut-time-label {
  width: 50px; flex-shrink: 0;
  font-size: 10px; font-weight: 600; color: #6b7180;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.aut-time-rel { font-weight: 600; color: var(--ink); }
.aut-time-rel.future { color: #3d479f; }
.aut-time-rel.highlight { color: #b87100; font-weight: 700; }
.aut-time-abs { font-size: 11px; color: #6b7180; }

.aut-progress {
  height: 5px; background: rgba(0,0,0,0.06); border-radius: 999px;
  overflow: hidden; margin-top: 6px;
}
.aut-progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--orange) 0%, #ff7a00 100%);
  transition: width 0.5s ease;
}

.aut-card-fridges {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: #4a4f5a;
  margin-top: 8px;
  background: rgba(255,255,255,0.6); padding: 4px 10px;
  border-radius: 999px; max-width: 100%; overflow: hidden;
}
.aut-fridges-icon { font-size: 13px; opacity: 0.7; }
.aut-fridges-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.aut-fridges-count {
  background: #d6dbe5; color: #4a4f5a;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px;
  margin-left: auto; flex-shrink: 0;
}

.aut-error-line {
  color: #c4302b; font-size: 11px; margin-top: 6px;
  background: rgba(255,255,255,0.5); padding: 4px 8px; border-radius: 6px;
}

.aut-card-actions {
  display: flex; gap: 6px; align-items: flex-start; flex-shrink: 0;
}
.aut-card-btn-label { display: inline; }
@media (max-width: 1300px) {
  .aut-card-btn-label { display: none; }
  .aut-card-btn { padding: 7px 9px; }
}
.aut-card-btn {
  border: 1px solid var(--line); background: #fff;
  padding: 6px 12px; border-radius: 7px; cursor: pointer;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  transition: all 0.12s;
}
.aut-card-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.aut-card-btn:active { transform: translateY(0); }
.aut-card-btn.aut-btn-cancel {
  color: #b87100; border-color: #ffd591;
  background: linear-gradient(180deg, #fff9eb 0%, #fff2d3 100%);
}
.aut-card-btn.aut-btn-cancel:hover {
  background: #ffe9b5; border-color: #ffab00;
}
.aut-card-btn.aut-btn-stop {
  color: #fff; border-color: #d76e00;
  background: linear-gradient(180deg, #ff9526 0%, #e07f0a 100%);
  font-weight: 600;
}
.aut-card-btn.aut-btn-stop:hover {
  background: linear-gradient(180deg, #ff8a14 0%, #c66f08 100%);
}
.aut-card-btn.aut-btn-delete {
  color: #6b7180; border-color: var(--line);
}
.aut-card-btn.aut-btn-delete:hover {
  color: #c4302b; border-color: #f5b7b7; background: #fdf0f0;
}
.aut-status-badge {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; letter-spacing: 0.04em;
}
.aut-status-badge.scheduled { background: #e8eaf5; color: #4d56a8; }
.aut-status-badge.active { background: #ffce69; color: #6b4500; }
.aut-status-badge.done { background: #d6dbe5; color: #4a4f5a; }
.aut-status-badge.error { background: #ffcfcf; color: #8a1f1f; }
.aut-status-badge.cancelled { background: #e0e0e0; color: #7a7a7a; }
.aut-card-empty {
  text-align: center; padding: 40px 12px;
  color: #9aa0ad; font-size: 13px; font-style: italic;
}
.aut-empty {
  text-align: center; padding: 40px 16px;
  background: linear-gradient(180deg, #fafbfd 0%, #f5f6fa 100%);
  border: 1px dashed var(--line); border-radius: 12px;
}
.aut-empty-icon {
  font-size: 48px; margin-bottom: 12px;
  filter: grayscale(0.3); opacity: 0.6;
}
.aut-empty-title {
  font-size: 15px; font-weight: 600; color: #4a4f5a;
  margin-bottom: 6px;
}
.aut-empty-sub {
  font-size: 13px; color: #6b7180; max-width: 340px;
  margin: 0 auto; line-height: 1.5;
}
.aut-empty-sub b { color: var(--orange); }

/* ── Stan rzeczywisty na lodówkach ────────────────────────────────────── */

.aut-state-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-top: 16px;
}

.aut-fridge-card {
  background: linear-gradient(180deg, #ffffff 0%, #fafbfd 100%);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.aut-fridge-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.06); }
.aut-fridge-card.has-images { border-color: #d4dcef; }
.aut-fridge-card.has-error {
  background: linear-gradient(180deg, #fdf0f0 0%, #f9e2e2 100%);
  border-color: #f5b7b7;
}
.aut-fridge-card.empty { opacity: 0.7; }

.aut-fridge-card-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.aut-fridge-card-icon {
  font-size: 20px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #e6ecfa 0%, #d4dcef 100%);
  border-radius: 9px;
}
.aut-fridge-card-titles { flex: 1; min-width: 0; }
.aut-fridge-card-code {
  font-weight: 700; font-size: 14px; color: var(--ink);
  font-family: ui-monospace, SF Mono, monospace;
}
.aut-fridge-card-name {
  font-size: 11px; color: #6b7180;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aut-fridge-card-count {
  background: #fff; color: #4d56a8;
  font-size: 12px; font-weight: 700;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid #d4dcef;
  flex-shrink: 0; min-width: 28px; text-align: center;
}
.has-images .aut-fridge-card-count {
  background: linear-gradient(180deg, #ffce69 0%, #ffab00 100%);
  color: #6b4500; border-color: #ffab00;
}
.has-error .aut-fridge-card-count {
  background: #ffcfcf; color: #8a1f1f; border-color: #f5b7b7;
}

.aut-fridge-card-error {
  font-size: 11px; color: #c4302b;
  padding: 6px 8px; background: rgba(255,255,255,0.5); border-radius: 6px;
}
.aut-fridge-card-empty {
  font-size: 11px; color: #9aa0ad; font-style: italic;
  padding: 12px; text-align: center;
  background: rgba(0,0,0,0.02); border-radius: 8px;
}
.aut-fridge-card-images {
  display: flex; gap: 8px; flex-wrap: wrap;
}



.ap-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 8px; background: #fff;
  font-size: 12px;
}
.ap-card.status-generated { background: #f1faf4; border-color: #b6dec5; }
.ap-card.status-waiting_for_image { background: #fffaeb; border-color: #ffe1a0; }
.ap-card.status-error { background: #fdf0f0; border-color: #f5b7b7; }

.ap-card-thumb {
  width: 48px; height: 86px; flex-shrink: 0;
  border-radius: 6px; background: #eee; object-fit: cover;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.ap-card-thumb-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; opacity: 0.4; background: #f4f4f8;
}
.ap-card-body { flex: 1; min-width: 0; }
.ap-card-name {
  font-weight: 600; font-size: 13px; color: var(--ink);
  margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ap-card-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 11px; color: #6b7180;
}
.ap-card-error {
  font-size: 11px; color: #c4302b; margin-top: 4px;
}
.ap-status-pill {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 999px;
  letter-spacing: 0.04em;
}
.ap-status-pill.generated { background: #d6f5e1; color: #1f7a3d; }
.ap-status-pill.waiting_for_image { background: #ffe9b5; color: #6b4500; }
.ap-status-pill.error { background: #ffcfcf; color: #8a1f1f; }
.ap-status-pill.processing {
  background: linear-gradient(90deg, #e8eaf5 0%, #d4d9f0 50%, #e8eaf5 100%);
  background-size: 200% 100%; color: #3d479f;
  animation: ap-shimmer 1.6s linear infinite;
}
@keyframes ap-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.ap-card.status-processing {
  background: linear-gradient(180deg, #f0f3fb 0%, #e6ebf7 100%);
  border-color: #c8cee5;
}
.ap-progress-line {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; padding: 6px 10px;
  background: rgba(255,255,255,0.7);
  border-radius: 6px;
  font-size: 11px; color: #3d479f; font-weight: 500;
}
.ap-progress-spinner {
  width: 12px; height: 12px;
  border: 2px solid #c8cee5;
  border-top-color: #3d479f;
  border-radius: 50%;
  animation: ap-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes ap-spin {
  to { transform: rotate(360deg); }
}

/* ── Modal Nowy produkt SL — pełen redesign ─────────────────────────── */
.sl-modal {
  max-width: 1100px; width: 95vw;
  max-height: 92vh;
  padding: 0;
  display: flex; flex-direction: column;
  background: #fff;
}

.sl-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 26px;
  background: linear-gradient(180deg, #fff 0%, #fafbfd 100%);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.sl-modal-head-actions { display: inline-flex; align-items: center; gap: 12px; }
/* „Usuń produkt" — czerwony ghost button, widoczny tylko w edit mode. */
.sl-modal-delete {
  background: #fff; border: 1.5px solid #dc2626; border-radius: 6px;
  color: #dc2626; font: inherit; font-size: 13px; font-weight: 700;
  padding: 6px 14px; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sl-modal-delete:hover { background: #dc2626; color: #fff; }
.sl-modal-delete:disabled { opacity: 0.5; cursor: wait; }
.sl-modal-title {
  display: flex; align-items: center; gap: 14px;
}
.sl-modal-icon {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px;
  line-height: 1;
  background: linear-gradient(135deg, #ffd991 0%, #ff9526 100%);
  border-radius: 11px;
  box-shadow: 0 2px 8px rgba(255, 149, 38, 0.32);
  color: #fff;
}
.sl-modal-title h3 { margin: 0; font-size: 18px; font-weight: 700; }
.sl-modal-sub {
  font-size: 12px; color: #6b7180; margin-top: 2px;
}

.sl-modal-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  flex: 1; overflow: hidden;
  min-height: 0;
}
@media (max-width: 900px) {
  .sl-modal-body { grid-template-columns: 1fr; }
}

.sl-modal-form {
  padding: 22px 26px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
}
.sl-modal-side {
  padding: 22px 22px 22px 0;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, #fafbfd 0%, #f1f3f8 100%);
  overflow-y: auto;
}
@media (max-width: 900px) {
  .sl-modal-side { border-left: none; border-top: 1px solid var(--line); padding: 22px 26px; }
}

/* Sekcje formularza */
.sl-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  /* Parent .sl-modal-form to flex column z overflow:auto. Bez flex-shrink:0
     collapsed <details> sekcje są ściskane do ~2px (flexbox ucina nawet
     widoczność summary) — i header znika. Wymuszamy żeby summary + body
     zawsze zajmowały swój content-height; scroll obsługuje parent. */
  flex-shrink: 0;
}
/* Tylko zamknięte mogą crop'ować arrow (border-radius); otwarte muszą pokazać body bez wycinania. */
.sl-section-collapsible:not([open]) { overflow: hidden; }
.sl-section-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #fff 0%, #fafbfd 100%);
  border-bottom: 1px solid var(--line);
}
.sl-section-head h4 { margin: 0; font-size: 14px; font-weight: 600; }
.sl-section-icon {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  background: #f1f3f8;
  border-radius: 8px;
}
.sl-section-badge {
  margin-left: auto;
  font-size: 11px; font-weight: 600; color: #6b7180;
  background: #f1f3f8;
  padding: 3px 9px; border-radius: 999px;
}
.sl-section-badge.complete {
  background: #d6f5e1; color: #1f7a3d;
}
.sl-section-opt {
  margin-left: auto;
  font-size: 10px; color: #9aa0ad;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.sl-section-arrow {
  font-size: 11px; opacity: 0.5;
  transition: transform 0.2s;
  margin-left: 6px;
}
.sl-section-collapsible[open] .sl-section-arrow { transform: rotate(180deg); }
.sl-section-collapsible > summary { list-style: none; cursor: pointer; user-select: none; }
.sl-section-collapsible > summary::-webkit-details-marker { display: none; }
.sl-section-collapsible > summary:hover { background: linear-gradient(180deg, #fafbfd 0%, #f1f3f8 100%); }

.sl-section-body {
  padding: 16px;
}

/* Pola */
.sl-modal-form .meta { display: flex; flex-direction: column; gap: 5px; margin: 0; }
.sl-modal-form .meta > span {
  font-size: 11px; font-weight: 600; color: #4a4f5a;
  display: flex; align-items: center; gap: 5px;
}
.sl-modal-form input[type="text"],
.sl-modal-form input[type="number"],
.sl-modal-form select,
.sl-modal-form textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-family: inherit;
  background: #fff;
  width: 100%; box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sl-modal-form input:focus, .sl-modal-form select:focus, .sl-modal-form textarea:focus {
  border-color: var(--orange); outline: none;
  box-shadow: 0 0 0 3px rgba(255,171,0,0.13);
}
.sl-row-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px;
}
.sl-modal-form textarea { resize: vertical; min-height: 60px; }

/* Atrybuty EAN grid */
.sl-attr-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (max-width: 600px) { .sl-attr-grid { grid-template-columns: 1fr; } }
.sl-attr-grid .meta > span {
  text-transform: uppercase; letter-spacing: 0.03em;
}

/* Nutri */
.sl-nutri-mode {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px; padding-bottom: 14px;
  border-bottom: 1px dashed var(--line);
}
.sl-radio { display: inline-flex; align-items: center; cursor: pointer; }
.sl-radio input { display: none; }
.sl-radio-pill {
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff;
  font-size: 13px; font-weight: 500; color: #4a4f5a;
  transition: all 0.12s;
}
.sl-radio:hover .sl-radio-pill { border-color: var(--orange); }
.sl-radio input:checked + .sl-radio-pill {
  background: linear-gradient(180deg, #ff9526 0%, #e07f0a 100%);
  color: #fff; border-color: #d76e00;
  font-weight: 600;
}
.sl-serving-input {
  flex-direction: row; align-items: center; gap: 8px;
  margin-left: auto !important;
}
.sl-serving-input > span { white-space: nowrap; }
.sl-serving-input input { width: 80px; padding: 6px 10px; }

.sl-nutri-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.sl-input-suffix {
  display: flex; align-items: center;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.sl-input-suffix:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255,171,0,0.13);
}
.sl-input-suffix input {
  border: none !important; padding: 8px 11px !important;
  flex: 1; box-shadow: none !important;
}
.sl-input-suffix input:focus { box-shadow: none !important; }
.sl-input-suffix > span {
  padding: 0 10px; font-size: 11px; color: #6b7180;
  background: #f1f3f8; align-self: stretch;
  display: flex; align-items: center;
  border-left: 1px solid var(--line);
}

/* Chips alergenów / badges */
.sl-rich-label {
  font-size: 11px; font-weight: 600; color: #4a4f5a;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.sl-chip-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.sl-chip {
  cursor: pointer; user-select: none;
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff;
  font-size: 12px; color: #4a4f5a;
  transition: all 0.12s;
}
.sl-chip:hover { border-color: var(--orange); color: var(--ink); }
.sl-chip input[type="checkbox"] { display: none; }
.sl-chip.checked {
  background: linear-gradient(180deg, #ff9526 0%, #e07f0a 100%);
  border-color: #d76e00;
  color: #fff; font-weight: 600;
  box-shadow: 0 2px 6px rgba(224, 127, 10, 0.25);
}

/* ── Global full-screen loader ─────────────────────────────────────── */
.page-loader {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(20, 25, 56, 0.32);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  animation: pl-fade-in 0.15s ease-out;
}
.page-loader[hidden] { display: none !important; }
@keyframes pl-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.page-loader-box {
  background: #fff;
  border-radius: 14px;
  padding: 22px 28px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.08);
}
.page-loader-spinner {
  width: 28px; height: 28px;
  border: 3px solid #f1f3f8;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: pl-spin 0.8s linear infinite;
}
@keyframes pl-spin { to { transform: rotate(360deg); } }
.page-loader-label {
  font-size: 14px; font-weight: 500; color: var(--ink);
}

/* Uploader zdjęcia produktu (side panel, nad EAN preview) */
.sl-image-card {
  background: #fff;
  border: 1px solid var(--line); border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.sl-image-card .sl-ean-card-head { margin-bottom: 10px; }

/* Slot na zdjęcie — jeden kwadrat: placeholder gdy brak, img gdy jest.
   Hover na zdjęciu ujawnia półprzezroczysty overlay z ołówkiem = klik podmienia. */
.sl-image-slot {
  position: relative;
  width: 100%; aspect-ratio: 1;
  background: linear-gradient(135deg, #fafbfd 0%, #f1f3f8 100%);
  border: 2px dashed #c8cee5; border-radius: 12px;
  cursor: pointer; overflow: hidden;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  font-family: inherit;
  padding: 0;
}
.sl-image-slot:hover {
  border-color: var(--orange);
  box-shadow: 0 4px 12px rgba(255, 171, 0, 0.18);
}
/* Placeholder — widoczny tylko gdy brak zdjęcia (slot bez .has-image) */
.sl-image-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: #6b7180;
}
.sl-image-plus {
  font-size: 48px; line-height: 1; font-weight: 300; color: #b0b6c4;
  transition: color 0.15s, transform 0.2s;
}
.sl-image-slot:hover .sl-image-plus {
  color: var(--orange);
  transform: scale(1.1) rotate(90deg);
}
.sl-image-hint {
  font-size: 13px; font-weight: 500; text-align: center; line-height: 1.4;
}
.sl-image-hint .muted { font-size: 11px; opacity: 0.7; }
/* Zdjęcie — widoczne tylko gdy slot.has-image */
.sl-image-img {
  width: 100%; height: 100%; object-fit: contain;
  display: block; background: #fff;
}
.sl-image-slot.has-image { border-style: solid; border-color: var(--line); background: #fff; }
/* Overlay z ołówkiem — pojawia się na hover gdy jest zdjęcie */
.sl-image-edit-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  background: rgba(31, 34, 65, 0.55);
  color: #fff;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
.sl-image-edit-overlay svg { width: 32px; height: 32px; }
.sl-image-edit-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sl-image-slot.has-image:hover .sl-image-edit-overlay { opacity: 1; }
.sl-image-slot:not(.has-image) .sl-image-edit-overlay { display: none; }

.sl-image-name {
  font-size: 11px; color: #6b7180;
  padding: 6px 4px 0; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sl-image-name:empty { display: none; }

/* Sticky EAN preview po prawej */
.sl-ean-card {
  background: #fff;
  border: 1px solid var(--line); border-radius: 14px;
  padding: 20px;
  position: sticky; top: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.sl-ean-card-head {
  font-size: 10px; font-weight: 700; color: #6b7180;
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.sl-ean-value {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 26px; font-weight: 700;
  letter-spacing: 0.05em;
  color: #c8cee5;
  margin-bottom: 14px;
  text-align: center;
  padding: 14px;
  background: #fafbfd;
  border-radius: 10px;
  border: 2px dashed var(--line);
  transition: all 0.2s;
}
.sl-ean-value.ready {
  color: #fff;
  background: linear-gradient(135deg, #ff9526 0%, #e07f0a 50%, #ff7a00 100%);
  border-style: solid; border-color: #d76e00;
  box-shadow: 0 4px 14px rgba(224, 127, 10, 0.3);
}

/* Karta EAN oryginalny — pod generated EAN, nie-sticky, takie same border/padding */
.sl-ean-orig-card {
  position: static;
  margin-top: 14px;
}
.sl-ean-card-opt {
  font-size: 9px; font-weight: 600; color: #9aa0ad;
  letter-spacing: 0.04em; margin-left: 6px;
  text-transform: lowercase;
}
.sl-ean-orig-input {
  width: 100%; box-sizing: border-box;
  padding: 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 18px; font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
  border: 2px dashed var(--line); border-radius: 10px;
  background: #fafbfd; color: #2a2d36;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.sl-ean-orig-input::placeholder {
  color: #c8cee5; font-weight: 600;
}
.sl-ean-orig-input:focus {
  border-color: var(--orange); border-style: solid;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255,171,0,0.13);
}
.sl-ean-orig-input.has-value {
  border-style: solid; border-color: #d76e00;
  color: #c95e00; background: #fff8eb;
}
.sl-ean-breakdown {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 12px;
  justify-content: center;
}
.sl-ean-breakdown:empty { display: none; }
.sl-ean-breakdown .ean-chip {
  min-width: 32px; padding: 3px 5px;
}
.sl-ean-breakdown .ean-chip .d { font-size: 13px; }
.sl-ean-breakdown .ean-chip .l { font-size: 8px; }
.sl-ean-status {
  font-size: 12px; color: #9aa0ad;
  padding: 8px 10px;
  background: #f1f3f8; border-radius: 7px;
  text-align: center;
}
.sl-ean-status.ready {
  background: #d6f5e1; color: #1f7a3d; font-weight: 600;
}

/* Footer */
.sl-modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px;
  border-top: 1px solid var(--line);
  background: #fafbfd;
  flex-shrink: 0;
  gap: 16px;
}
.sl-foot-actions { display: flex; gap: 8px; }
.sl-foot-actions .btn.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: #4a4f5a;
}
.sl-foot-actions .btn.ghost:hover {
  background: #fafafa; border-color: #b3b8c5;
}
.sl-foot-actions .btn.primary {
  padding: 10px 18px;
  background: linear-gradient(180deg, #ff9526 0%, #e07f0a 100%);
  border: 1px solid #d76e00;
  color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(224, 127, 10, 0.22);
}
.sl-foot-actions .btn.primary:disabled {
  background: #e0e0e0;
  border-color: #ccc;
  color: #999;
  box-shadow: none;
  cursor: not-allowed;
}
.sl-foot-actions .btn.primary:not(:disabled):hover {
  background: linear-gradient(180deg, #ff8a14 0%, #c66f08 100%);
  transform: translateY(-1px);
}
.sl-push-note { font-size: 12px; letter-spacing: 0.01em; }

/* WIP placeholder — zakładki jeszcze nieotworzone (np. Restock w budowie). */
.wip-placeholder {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted-strong, #5C5C7A);
}
.wip-placeholder .wip-icon {
  font-size: 56px; line-height: 1;
  margin-bottom: 16px;
}
.wip-placeholder h3 {
  font-size: 20px; font-weight: 700;
  color: var(--text); margin: 0 0 8px;
}
.wip-placeholder p { font-size: 14px; margin: 0; }

.sl-banner { margin: 0 26px; }

/* ── Kolumna "Obrazek" w tabeli Katalog (upload z dysku) ─────────────── */
.catalog-table th.cat-img-col,
.catalog-table td.cat-img-col {
  width: 56px; padding: 6px 8px; text-align: center;
}
.cat-img-wrap {
  width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden;
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.cat-img-wrap img {
  width: 100%; height: 100%; object-fit: contain;
}
.cat-img-wrap.cat-img-broken {
  background: #fafbfd; color: #b00; font-size: 14px;
}
.cat-img-wrap.cat-img-broken::after {
  content: "⚠"; display: block;
}
/* Brak zdjęcia — przekreślony aparat (SVG). Statyczny placeholder, nie klikalny. */
.cat-img-none {
  width: 40px; height: 40px;
  border: 1px dashed var(--line); background: #fafbfd;
  border-radius: 6px;
  color: #9aa0ad;
  display: inline-flex; align-items: center; justify-content: center;
}
.cat-img-none svg { width: 22px; height: 22px; }

/* ── Sekcja "Obrazki produktów (Frisco)" w Katalogu ──────────────────── */
.prodimg-section {
  background: linear-gradient(180deg, #fafbfd 0%, #f5f6fa 100%);
  border: 1px solid var(--line); border-radius: 12px;
  margin: 14px 0;
  overflow: hidden;
}
.prodimg-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; cursor: pointer; user-select: none;
  list-style: none; outline: none;
}
.prodimg-summary::-webkit-details-marker { display: none; }
.prodimg-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #fff5e0 0%, #ffe2b0 100%);
  border-radius: 8px; font-size: 16px;
}
.prodimg-title { font-weight: 600; font-size: 14px; }
.prodimg-counts {
  margin-left: auto;
  font-size: 12px; font-weight: 500; color: #6b7180;
  background: #fff; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line);
}
.prodimg-arrow { font-size: 10px; opacity: 0.5; transition: transform 0.2s; }
.prodimg-section[open] .prodimg-arrow { transform: rotate(180deg); }

.prodimg-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.prodimg-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid #eef0f3;
  margin-bottom: 14px;
}
.prodimg-toolbar .spacer { flex: 1; }
.prodimg-toolbar select {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 13px; background: #fff;
}

.prodimg-empty {
  text-align: center; padding: 30px 12px;
  color: #9aa0ad; font-size: 13px; font-style: italic;
}

.prodimg-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; margin-bottom: 12px;
  transition: box-shadow 0.15s;
}
.prodimg-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.prodimg-card.status-ok { background: linear-gradient(180deg, #f1faf4 0%, #e6f5ed 100%); border-color: #b6dec5; }
.prodimg-card.status-empty { opacity: 0.6; }

.prodimg-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px; gap: 12px;
}
.prodimg-card-code {
  font-family: ui-monospace, SF Mono, monospace;
  font-size: 11px; color: #6b7180; font-weight: 600;
  letter-spacing: 0.02em;
}
.prodimg-card-name {
  font-size: 14px; font-weight: 500; color: var(--ink);
  margin-top: 2px;
}
.prodimg-card-actions {
  display: flex; gap: 6px; align-items: flex-start; flex-shrink: 0;
}
.prodimg-card-empty {
  font-size: 12px; color: #9aa0ad; font-style: italic;
  margin-top: 6px;
}
.prodimg-card-accepted-img {
  width: 80px; height: 80px; object-fit: cover;
  border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  margin-right: 14px; float: left;
}
.prodimg-card-source {
  font-size: 11px; color: #6b7180;
  word-break: break-all; margin-top: 4px;
}

.prodimg-tiles {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.prodimg-tile {
  background: #fafbfd; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
  transition: all 0.12s;
}
.prodimg-tile:hover { background: #fff; border-color: var(--orange); }
.prodimg-tile-thumb {
  width: 100%; aspect-ratio: 1;
  background: #fff; border-radius: 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.prodimg-tile-thumb img {
  width: 100%; height: 100%; object-fit: contain;
}
.prodimg-tile-name {
  font-size: 12px; font-weight: 500; color: var(--ink);
  line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.prodimg-tile-meta {
  font-size: 10px; color: #6b7180;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.prodimg-tile .btn.small { padding: 5px 10px; font-size: 11px; }
.aut-state-img {
  position: relative;
  width: 88px; height: 156px;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #f4f4f8;
  display: flex; flex-direction: column;
}
.aut-state-img img {
  width: 100%; height: 100%; object-fit: cover;
}
.aut-state-img-tag {
  position: absolute; top: 4px; left: 4px;
  background: rgba(0,0,0,0.7); color: #fff;
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; letter-spacing: 0.04em;
}
.aut-state-img-tag.known { background: #2c7a3d; }
.aut-state-img-tag.foreign { background: #b87100; }
.aut-state-img-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(255,255,255,0.95); color: #c4302b;
  border: none; border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1; font-weight: 700;
  display: none;
  align-items: center; justify-content: center;
}
.aut-state-img:hover .aut-state-img-remove { display: flex; }
.aut-state-img-remove:hover { background: #c4302b; color: #fff; }

/* ============= Planogram — Sticky pasek (nazwa + daty + akcje) — PRZYKLEJONY DO GÓRY ============= */
.planogram-sticky-bar {
  position: sticky;
  /* Od wysokości topbaru (JS: syncTopbarHeight), bo na telefonie ma on dwa rzędy
     i sztywne 80px wjeżdżało na selektor lodówki. Fallback = desktop. */
  top: calc(var(--topbar-h, 66px) + 14px);
  z-index: 60;
  background: var(--card);
  border: 2px solid var(--orange);
  border-radius: 14px;
  padding: 12px 18px;
  margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  /* Pomarańczowa poświata + cień głębi = wyróżnia się od reszty */
  box-shadow: 0 4px 14px rgba(31, 34, 65, 0.10),
              0 0 0 1px rgba(255, 177, 66, 0.18),
              0 4px 18px rgba(255, 177, 66, 0.18);
}
.psb-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.psb-line1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* Uppercase label „Planogram:" / „Okres obowiązywania:" — subtelne, semantycznie
   grupuje sekcje sticky bar. Kontrast --muted-strong = WCAG AA dla małego tekstu. */
.psb-label {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted-strong);
  flex-shrink: 0;
}
.psb-plan-name { font-size: 18px; font-weight: 800; color: var(--text); }
.psb-sep { color: var(--line); }
.psb-status-badge {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 3px 8px; border-radius: 6px;
}
.psb-status-badge.active { background: var(--green-bg); color: var(--green); }
.psb-status-badge.future { background: var(--blue-bg); color: var(--blue); }
.psb-status-badge.past { background: var(--soft); color: var(--muted); }
.psb-line2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted-strong); }
.psb-dates { font-weight: 700; color: var(--text); }
.psb-meta { color: var(--muted-strong); }
.psb-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

/* Inline pencil-button do edycji nazwy / okresu — mały, dyskretny, wyraźnie
   klikalny (hover → pomarańczowa ramka + ikona). Aria-label opisuje pełny scope. */
.psb-edit-btn {
  appearance: none; background: transparent; border: 1px solid var(--line);
  width: 26px; height: 26px; border-radius: 6px;
  cursor: pointer; padding: 0; line-height: 1;
  font-size: 13px; color: var(--muted-strong); font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.06s;
}
.psb-edit-btn:hover {
  background: #fff; border-color: var(--orange); color: var(--orange);
}
.psb-edit-btn:active { transform: scale(0.94); }
.psb-edit-btn:focus-visible {
  outline: 2px solid var(--orange); outline-offset: 2px;
}

/* Inline edit nazwy — span zamieniany na input po klik ✎. Wyświetla się dokładnie
   w miejscu nazwy, żeby user od razu edytował bez przeskoku wzroku. */
.psb-plan-name-input {
  font-size: 18px; font-weight: 800; color: var(--text);
  font-family: inherit;
  padding: 3px 8px;
  border: 2px solid var(--orange);
  border-radius: 6px;
  background: #fff;
  outline: none;
  min-width: 220px; max-width: 100%;
  box-shadow: 0 0 0 3px rgba(255, 177, 66, 0.18);
}
.psb-plan-name-input:focus { border-color: var(--orange); }

/* Popover edycji okresu — pod pencilem, absolute, poza flow tabeli. */
.psb-period-popover {
  position: absolute; z-index: 210;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(31, 34, 65, 0.18),
              0 0 0 1px rgba(255, 177, 66, 0.15);
  padding: 14px 16px;
  /* 340px min — native date input z ikoną kalendarza (📅) wymaga ~150px, 2 obok
     siebie z gap+padding daje minimum 340 żeby DO nie było ucinane. */
  width: 340px;
  animation: psb-pop-in 0.14s ease-out;
}
@keyframes psb-pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.psb-pop-head {
  font-size: 11px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted-strong);
  margin-bottom: 10px;
}
.psb-pop-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.psb-pop-field { display: flex; flex-direction: column; gap: 4px; }
.psb-pop-field > span {
  font-size: 10.5px; font-weight: 700; color: var(--muted-strong);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.psb-pop-field input[type="date"] {
  font-family: inherit; font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
.psb-pop-field input[type="date"]:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 177, 66, 0.18);
}
/* .btn.ghost default styling (biały tekst na navy topbar) — w popoverze na białym
   tle byłby niewidoczny. Override dla dark-on-light. */
.psb-period-popover .btn.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
.psb-period-popover .btn.ghost:hover {
  background: var(--soft);
  border-color: var(--orange);
}
.psb-pop-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 10px; }
.psb-pop-actions .btn { padding: 6px 14px; font-size: 13px; }
#psbPopStatus:empty { display: none; }
#psbPopStatus .notice { padding: 6px 10px; font-size: 12px; margin: 6px 0; border-radius: 6px; }
@media (max-width: 480px) {
  .psb-period-popover {
    width: auto !important;
    left: 8px !important;
    right: 8px !important;
    max-width: calc(100vw - 16px);
  }
  .psb-pop-fields { grid-template-columns: 1fr 1fr; gap: 8px; }
  .psb-pop-field input[type="date"] { width: 100%; box-sizing: border-box; }
  .psb-pop-actions .btn { flex: 1; }
}

/* Tryb read-only (tab `restock-planogram` — Planogram (restock)) używa tego samego DOM
   co edytor planogramu, ale wyłącza wszystkie kontrole modyfikacji. */
/* `.is-readonly` to standardowy tryb planogram (Edytuj button widoczny). `.is-strict-readonly`
   to tab restock-planogram — wszystko ukryte (Edytuj też). Slot controls schowane w obu. */
.tab.is-strict-readonly .psb-actions { display: none !important; }
.tab.is-readonly .slot .remove,
.tab.is-readonly .slot .plus,
.tab.is-readonly .empty-label,
.tab.is-readonly .slot-add,
.tab.is-readonly .subs-btn { display: none !important; }
/* slot-subs-badge zostaje widoczny — restocker MUSI widzieć listę zamienników (hover
   tooltip jest pasywny info, nie edycja). Klik na badge jest blokowany w planogram.click. */
/* Plakietka zamienników jest jedyną klikalną rzeczą u restockera — otwiera panel
   z listą, więc kursor ma to zapowiadać (hover-tooltip w karcie jest wyłączony). */
.tab.is-readonly .slot-subs-badge { cursor: pointer; }
.tab.is-readonly .slot { cursor: default; }
.tab.is-readonly .slot[draggable="true"] { -webkit-user-drag: none; }
.tab.is-readonly #browsePlanogramsBtn::before {
  content: "👁 ";  /* podpowiedź wizualna że to tylko podgląd */
}
/* Sticky bar ma białe tło — .btn.ghost (default biały tekst dla navy topbar)
   wymaga override żeby był czytelny. Inaczej biały tekst na białym tle = invisible. */
.planogram-sticky-bar .btn.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
.planogram-sticky-bar .btn.ghost:hover {
  background: var(--soft);
  border-color: var(--orange);
}

/* ============= Planogram + Kalendarz (FullCalendar 6) ============= */
.planogram-layout {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 18px;
  margin-top: 14px;
  align-items: stretch;
}
.planogram-cal-pane {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  position: sticky;
  top: 168px;  /* pod sticky topbar (80) + sticky planogram bar (~74px + 14px margin) */
  z-index: 50;
  box-shadow: 0 4px 14px rgba(31, 34, 65, 0.07);
  /* align-self: start — kalendarz nie rozciąga się do wysokości editor-pane (rodzic
     ma align-items: stretch dla empty state). Bez tego stretched element ma identyczną
     wysokość co viewport scrollu i sticky nie ma czego trzymać. */
  align-self: start;
}
.planogram-editor-pane { min-width: 0; order: 1; display: flex; flex-direction: column; }
.planogram-editor-pane > .planogram { flex: 1; display: flex; flex-direction: column; }
.planogram-cal-pane { order: 2; }
.planogram-cal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.planogram-cal-head .section-h { margin: 0; font-size: 15px; font-weight: 800; color: var(--text); }
#planogramCalHint { font-size: 11px; color: var(--muted); }
.planogram-calendar { width: 100%; }
/* Container pod kalendarzem — teraz zawiera tylko pojedynczy button
   "📋 Przeglądaj planogramy" (zastąpił kartę z nazwą/datami, które są w sticky barze). */
.planogram-selected-info { margin-top: 12px; }
.planogram-selected-info #browsePlanogramsBtn {
  width: 100%; padding: 10px 14px; font-size: 13px;
  background: var(--navy); color: #fff; border: none; border-radius: 8px;
  font-weight: 700; cursor: pointer; transition: filter 0.12s;
}
.planogram-selected-info #browsePlanogramsBtn:hover { filter: brightness(1.15); }

/* FullCalendar override — pasuj do palety aplikacji */
.fc { font-family: inherit; font-size: 11px; }
.fc .fc-toolbar { gap: 4px; margin-bottom: 6px !important; flex-wrap: wrap; }
.fc .fc-toolbar-title { font-size: 13.5px !important; font-weight: 800; color: var(--text); }
.fc .fc-button {
  background: var(--soft) !important; border: 1px solid var(--line) !important;
  color: var(--text) !important; font-weight: 600 !important;
  padding: 3px 8px !important; border-radius: 7px !important; box-shadow: none !important;
  text-transform: none !important; font-size: 11px !important;
}
.fc .fc-button:hover { background: #ECEBF4 !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { background: var(--navy) !important; color: #fff !important; border-color: var(--navy) !important; }
.fc .fc-button-primary:disabled { opacity: 0.5; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--line); }
.fc-theme-standard .fc-scrollgrid { border-color: var(--line); border-radius: 10px; overflow: hidden; }
.fc .fc-col-header-cell { background: var(--soft); }
.fc .fc-col-header-cell-cushion { color: var(--muted); font-weight: 700; padding: 4px 2px; text-decoration: none; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.3px; }
.fc .fc-daygrid-day { background: #fff; cursor: pointer; transition: background 0.12s; }
.fc .fc-daygrid-day:hover { background: var(--soft); }
.fc .fc-daygrid-day.fc-day-today { background: #FFF6E5; }
/* Klik w pasek event → JS dodaje klasę .day-clicked do TD → pomarańczowa ramka.
   Używamy `outline` (rysowany POZA pudełkiem, ponad eventami) zamiast inset shadow,
   bo paski wydarzeń nakładają się na środek TD i zakrywałyby inner ring. */
.fc .fc-day.day-clicked,
.fc [data-date].day-clicked {
  background: rgba(255, 177, 66, 0.18) !important;
  outline: 3px solid var(--orange);
  outline-offset: -3px;
  position: relative;
  z-index: 3;
}
.fc .fc-daygrid-day-number { color: var(--text); padding: 2px 4px; text-decoration: none; font-weight: 600; font-size: 11px; }
.fc .fc-daygrid-day.fc-day-other .fc-daygrid-day-number { color: #C9C8D6; }
.fc .fc-daygrid-day.fc-day-other { background: #FAFAFC; }
/* Plusik w kółku na pustych dniach — delikatna podpowiedź że można utworzyć planogram.
   Pojawia się tylko w bieżącym miesiącu (.fc-day-other ukrywa), wzmocniony hover. */
.fc .fc-daygrid-day.empty-day .fc-daygrid-day-frame { position: relative; }
.fc .fc-daygrid-day.empty-day .fc-daygrid-day-frame::after {
  content: "+";
  position: absolute;
  right: 4px; bottom: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid #D9D7E3;
  color: #B0AEC2;
  font-size: 11px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.55;
  transition: opacity .12s, background .12s, border-color .12s, color .12s;
  pointer-events: none;
}
.fc .fc-daygrid-day.empty-day:hover .fc-daygrid-day-frame::after {
  opacity: 1; background: var(--orange); border-color: var(--orange); color: #fff;
}
.fc .fc-daygrid-day.empty-day.fc-day-other .fc-daygrid-day-frame::after { display: none; }
/* W trybie restockera nie ma czego dodawać — plusik na pustych dniach i podpowiedź
   o tworzeniu planogramu prowadziły w martwy punkt (dateClick wychodzi od razu). */
.tab.is-strict-readonly .fc .fc-daygrid-day.empty-day .fc-daygrid-day-frame::after { display: none; }
.tab.is-strict-readonly .fc .fc-daygrid-day { cursor: default; }
.tab.is-strict-readonly #planogramCalHint { display: none; }
/* Ikonki edycji nazwy i okresu — restocker niczego nie edytuje. */
.tab.is-strict-readonly .psb-edit-btn { display: none !important; }
/* Rodzaj slotu: u restockera sama ikonka. Pasek z napisem („ŚWIEŻY",
   „WARIANTOWY") zajmował całą szerokość kafla i zjadał miejsce na nazwę. */
.tab.is-strict-readonly .slot-kind-badge .skb-txt { display: none; }
/* U restockera listę pokazuje panel w warstwie body (patrz openSubsPanel) —
   tooltip w karcie chowałby się pod nagłówkiem półki, bo półka przewija się
   w poziomie i przycina dzieci. */
.tab.is-strict-readonly .slot .slot-subs-tooltip { display: none; }
.tab.is-strict-readonly .slot-subs-badge.tip-open {
  background: rgba(255, 177, 66, 0.35); border-style: solid; border-color: var(--orange);
}

/* Panel zamienników — poza półką, więc nic go nie przycina. */
.subs-panel {
  position: fixed; z-index: 200;
  max-width: min(320px, 88vw);
  background: #1F2241; color: #fff;
  border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .32);
  font-size: 13px; line-height: 1.4;
}
.subs-panel[hidden] { display: none; }
.subs-panel-h {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 11.5px; color: #C8CEE5; margin-bottom: 6px;
  padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.12);
}
.subs-panel-h b { color: #FFD089; }
.subs-panel-x {
  margin-left: auto; flex: none;
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(255,255,255,.1); border: none; color: #fff;
  font-size: 16px; line-height: 1; cursor: pointer; font-family: inherit;
}
.subs-panel-list { margin: 0; padding-left: 20px; }
.subs-panel-list li { margin: 3px 0; }
.tab.is-strict-readonly .slot-kind-badge { padding: 3px 5px; font-size: 12px; line-height: 1; }

/* ── Planogram (restock): półka = jeden rząd ──────────────────────────────────
   Fizyczna półka to jeden szereg produktów od lewej do prawej. Grid auto-fill
   zawijał ją na wąskim ekranie w 2–3 rzędy i restocker tracił odwzorowanie
   tego, co widzi w lodówce. Kolumny w jednym rzędzie + przewijanie w poziomie. */
.tab.is-strict-readonly .shelf-slots {
  grid-auto-flow: column;
  grid-template-columns: none;
  /* Górny limit, nie 1fr: przy 1fr kolumny rozjeżdżały się do szerokości treści
     (długie nazwy produktów) i ostatni kafel wychodził za krawędź półki, jakby
     był ucięty. Stała szerokość daje też jednakowe kafle na każdej półce —
     dwa produkty nie puchną do pół ekranu. */
  grid-auto-columns: minmax(148px, 200px);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  /* Snapport domyślnie startuje na krawędzi obramowania, więc `scroll-snap-align:
     start` dociągał pierwszy kafel PONAD padding — przyklejał się do krawędzi
     półki. scroll-padding odsuwa punkt zaczepienia o tyle, ile ma padding. */
  scroll-padding-left: 14px;
  scrollbar-width: thin;
}
.tab.is-strict-readonly .shelf-slots > .slot { scroll-snap-align: start; }
/* Widoczny, cienki pasek przewijania — bez niego rząd, który nie mieści się
   w kolumnie, wyglądał na ucięty zamiast przewijalnego. Przeglądarka rysuje go
   tylko wtedy, gdy jest co przewijać. */
.tab.is-strict-readonly .shelf-slots::-webkit-scrollbar { height: 6px; }
.tab.is-strict-readonly .shelf-slots::-webkit-scrollbar-track { background: transparent; }
.tab.is-strict-readonly .shelf-slots::-webkit-scrollbar-thumb { background: #C9C6D6; border-radius: 999px; }

/* ── Kalendarz restockera na telefonie (pasek u dołu, rozwijany do góry) ───── */
.rpg-cal { display: none; }
.rpg-cal-bar {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 16px; border: none; border-top: 1px solid rgba(255,255,255,.12);
  background: var(--navy); color: #fff;
  font-family: inherit; font-size: 15px; font-weight: 800;
  cursor: pointer; text-align: left;
}
.rpg-cal-ico { font-size: 17px; }
.rpg-cal-now { margin-left: auto; font-weight: 600; font-size: 13px; color: rgba(255,255,255,.72); }
.rpg-cal-chev {
  width: 9px; height: 9px; flex: none;
  border-left: 2px solid rgba(255,255,255,.75); border-top: 2px solid rgba(255,255,255,.75);
  transform: rotate(45deg);            /* strzałka do góry = rozwinie się w górę */
  transition: transform .18s;
}
.rpg-cal.open .rpg-cal-chev { transform: rotate(225deg); }
.rpg-cal-sheet {
  background: var(--card); border-top: 1px solid var(--line);
  padding: 12px 12px 14px;
  box-shadow: 0 -10px 28px rgba(20, 20, 40, .18);
}
.rpg-wk-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.rpg-wk-label {
  flex: 1; text-align: center; font-weight: 800; font-size: 14px; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rpg-wk-arrow {
  width: 44px; height: 44px; flex: none;      /* pełny cel dotyku */
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--text);
  font-size: 22px; line-height: 1; font-family: inherit; cursor: pointer;
}
.rpg-wk-arrow:active { background: var(--soft); }
.rpg-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.rpg-day {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 7px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--text);
  font-family: inherit; cursor: pointer;
  min-height: 62px;                            /* palec, nie kursor */
}
.rpg-day-dow { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .06em; }
.rpg-day-num { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rpg-day-dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.rpg-day.has .rpg-day-dot { background: var(--orange); }
.rpg-day.empty { color: var(--muted-strong); cursor: default; background: var(--soft); }
.rpg-day.today { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.rpg-day.on {
  background: var(--navy); border-color: var(--navy); color: #fff;
}
.rpg-day.on .rpg-day-dow { color: rgba(255,255,255,.7); }
/* Kropka = „tu jest planogram". Na wskazanym dniu bez planogramu jej nie ma,
   inaczej sam wybór dnia wyglądał jak pokrycie. */
.rpg-day.on.has .rpg-day-dot { background: var(--orange); }

@media (max-width: 768px) {
  /* Kalendarz miesięczny w kolumnie obok planogramu nie ma na telefonie sensu:
     ściśnięty do ~150 px gubił czytelność. Zastępuje go pasek u dołu. */
  .tab.is-strict-readonly .planogram-layout { grid-template-columns: 1fr; gap: 12px; }
  .tab.is-strict-readonly .planogram-cal-pane { display: none; }
  .tab.is-strict-readonly .rpg-cal:not([hidden]) {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
  }
  /* Miejsce pod paskiem, żeby ostatnia półka nie chowała się za nim. */
  .tab.is-strict-readonly .planogram-layout { padding-bottom: 62px; }

  /* Skala widoku pod telefon: mniejsze kafle, węższe paddingi, krótsze nagłówki. */
  .tab.is-strict-readonly .planogram { gap: 12px; }
  .tab.is-strict-readonly .shelf { border-radius: 12px; }
  .tab.is-strict-readonly .shelf-head { padding: 8px 12px; font-size: 11px; letter-spacing: .1em; }
  .tab.is-strict-readonly .shelf-head .shelf-meta { font-size: 10px; }
  .tab.is-strict-readonly .shelf-slots { gap: 8px; padding: 10px; grid-auto-columns: minmax(112px, 132px); scroll-padding-left: 10px; }
  .tab.is-strict-readonly .slot { min-height: 128px; padding: 8px 6px; border-radius: 10px; }
  .tab.is-strict-readonly .slot .thumb { width: 44px; height: 44px; margin-bottom: 4px; }
  .tab.is-strict-readonly .slot .cat-icon { font-size: 22px; }
  .tab.is-strict-readonly .slot .pname { font-size: 11px; -webkit-line-clamp: 2; margin-bottom: 3px; }
  .tab.is-strict-readonly .slot .cat-sub { font-size: 9.5px; }
  .tab.is-strict-readonly .slot .qty-badge { margin-top: 4px; font-size: 11px; padding: 1px 8px; }

  /* Sticky bar: dwie linie etykiet zjadały pół ekranu. */
  .tab.is-strict-readonly .planogram-sticky-bar { padding: 8px 12px; gap: 4px; }
  .tab.is-strict-readonly .psb-label { display: none; }
  .tab.is-strict-readonly .psb-plan-name { font-size: 15px; }
  .tab.is-strict-readonly .psb-line2 { font-size: 12px; }
  /* Separator wisiał sam na końcu wiersza z datami — meta jest już w osobnej linii. */
  .tab.is-strict-readonly .psb-sep { display: none; }
  /* Tooltip zamienników jest centrowany na plakietce — przy kaflu 112 px wychodził
     poza lewą krawędź ekranu. Na telefonie przyklejamy go do lewej strony kafla. */
  .tab.is-strict-readonly .slot .slot-subs-tooltip {
    left: 0; transform: none; min-width: 0; width: max-content; max-width: 72vw;
  }
  .tab.is-strict-readonly .slot .slot-subs-tooltip::after { left: 18px; transform: none; }
}
.fc-event { border: none !important; border-radius: 4px !important; padding: 1px 4px !important; font-weight: 700; cursor: pointer; box-shadow: 0 1px 3px rgba(31,34,65,0.12); font-size: 10px !important; }
.fc-event.planogram-event.active { background: var(--orange) !important; color: var(--navy) !important; border-color: var(--orange) !important; }
.fc-event-title { overflow: hidden; text-overflow: ellipsis; }

/* Tooltip nad eventem (custom — czysty CSS) */
.fc-event-tooltip {
  position: fixed; z-index: 9999; pointer-events: none;
  background: var(--navy); color: #fff; padding: 8px 10px; border-radius: 8px;
  font-size: 12px; max-width: 240px; box-shadow: 0 8px 22px rgba(31,34,65,0.35);
  transform: translate(-50%, -100%); margin-top: -8px;
}
.fc-event-tooltip strong { display: block; font-size: 12.5px; margin-bottom: 2px; }
.fc-event-tooltip .ftt-dates { color: var(--orange-2); font-weight: 600; }

/* Notice — warn variant (brak planogramu) */
.notice.warn {
  background: #FFF4D9; border-color: #FFD37A; color: #7A5500;
}

/* Modal: niezapisane zmiany */
.dirty-modal-bg.open { display: flex; }
.dirty-modal {
  max-width: 480px;
  text-align: center;
  padding: 32px 32px 28px;
  border-top: 4px solid var(--orange);
}
.dirty-modal-icon { font-size: 48px; line-height: 1; margin-bottom: 6px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); }
.dirty-modal-title { margin: 6px 0 10px; font-size: 20px; font-weight: 800; color: var(--text); }
.dirty-modal-msg { margin: 0 0 26px; color: var(--muted); font-size: 14px; line-height: 1.5; }

.dirty-modal-actions {
  display: flex; flex-direction: column; gap: 10px;
}
.dirty-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 18px; border-radius: 12px;
  border: 2px solid transparent; cursor: pointer; font-weight: 700;
  font-size: 14px; text-align: left;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.dirty-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(31,34,65,0.10); }
.dirty-btn:active { transform: translateY(0); }
.dirty-btn-ico { font-size: 20px; flex-shrink: 0; }
.dirty-btn-label { flex: 1; }

.dirty-btn-save {
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-2) 100%);
  color: var(--navy); border-color: var(--orange);
}
.dirty-btn-save:hover { background: linear-gradient(135deg, var(--orange-2) 0%, var(--orange) 100%); }

.dirty-btn-discard {
  background: #fff; color: var(--red); border-color: var(--red);
}
.dirty-btn-discard:hover { background: var(--red); color: #fff; }

.dirty-btn-stay {
  background: var(--soft); color: var(--text); border-color: var(--line);
}
.dirty-btn-stay:hover { background: #fff; border-color: var(--text); }

.btn.danger {
  background: var(--red); color: #fff; border: 1px solid var(--red);
}
.btn.danger:hover { background: #9F2E22; border-color: #9F2E22; }
/* Pulsacja ramki — przyciąga wzrok */
@keyframes dirty-pulse {
  0%, 100% { box-shadow: 0 8px 28px rgba(31,34,65,0.20), 0 0 0 0 rgba(255,177,66,0.45); }
  50%      { box-shadow: 0 8px 28px rgba(31,34,65,0.20), 0 0 0 8px rgba(255,177,66,0); }
}
.dirty-modal-bg.open .dirty-modal { animation: dirty-pulse 1.4s ease-in-out infinite; }

/* Save button gdy są niezapisane zmiany — mocna pulsacja przyciągająca wzrok */
@keyframes save-dirty-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 177, 66, 0.6), 0 0 0 0 rgba(192, 57, 43, 0.0);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(255, 177, 66, 0), 0 6px 22px rgba(255, 177, 66, 0.55);
    transform: scale(1.06);
  }
}
@keyframes save-dirty-bounce {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}
#saveBtn.is-dirty {
  animation: save-dirty-pulse 1.4s ease-in-out infinite;
  background: linear-gradient(135deg, var(--orange) 0%, #FF9421 100%) !important;
  font-weight: 800 !important;
  border: 2px solid #FF8800 !important;
}

/* Picker — banner aktualnego stanu (gdy edytujemy istniejący slot) */
.picker-current-banner {
  background: linear-gradient(135deg, #FFF7EA 0%, #FFEBD0 100%);
  border: 2px solid var(--orange);
  border-radius: 12px; padding: 12px 16px;
  margin-bottom: 14px; display: flex; align-items: center; gap: 12px;
}
/* `display: flex` powyżej nadpisuje native `[hidden]{display:none}` — banner zostawałby
   widoczny po `banner.hidden = true` z JS (np. otwarcie pickera na pustym slocie po
   wcześniejszej edycji wypełnionego). */
.picker-current-banner[hidden] { display: none; }
.picker-current-banner .pcb-ico { font-size: 28px; flex-shrink: 0; }
.picker-current-banner .pcb-text { flex: 1; min-width: 0; }
.picker-current-banner .pcb-label { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px; }
.picker-current-banner .pcb-value { font-size: 14px; font-weight: 700; color: var(--navy); }
.picker-current-banner .pcb-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Picker — wiersz produktu ma 2 stany: default (Wstaw button) i expanded (qty + Potwierdź) */
.row-action-area {
  display: flex; align-items: center; flex-shrink: 0;
}
.row-insert-btn {
  background: var(--orange); color: var(--navy); border: 2px solid var(--orange);
  border-radius: 8px; padding: 8px 16px; cursor: pointer;
  font-weight: 800; font-size: 13px; line-height: 1;
  white-space: nowrap;
  transition: all 0.12s;
  min-width: 80px;
}
.row-insert-btn:hover { background: var(--orange-2); border-color: var(--orange-2); transform: translateY(-1px); }
.row-insert-btn:active { transform: translateY(0); }

.row-sub-toggle {
  background: #fff; color: var(--green); border: 2px solid var(--green);
  border-radius: 8px; padding: 7px 12px; cursor: pointer;
  font-weight: 700; font-size: 12px; line-height: 1; white-space: nowrap;
  margin-left: 6px; transition: all 0.12s;
}
.row-sub-toggle:hover { background: var(--green); color: #fff; }
.picker-product-row.is-substitute { background: #EAF7F0; box-shadow: inset 0 0 0 2px var(--green); border-radius: 8px; }
.picker-product-row.is-substitute .row-sub-toggle { background: var(--green); color: #fff; }

.row-qty-confirm {
  display: flex; align-items: center; gap: 6px;
}
.row-qty-confirm[hidden] { display: none; }
.row-qty-btn {
  width: 30px; height: 30px; border-radius: 7px;
  background: #fff; border: 2px solid var(--line); cursor: pointer;
  font-size: 16px; font-weight: 800; color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s; padding: 0; line-height: 1;
}
.row-qty-btn:hover { background: var(--orange); color: #fff; border-color: var(--orange); }
.row-qty-btn:active { transform: scale(0.92); }
.row-qty-input {
  width: 44px; height: 30px; border: 2px solid var(--line); border-radius: 7px;
  text-align: center; font-size: 14px; font-weight: 800; color: var(--navy); background: #fff;
  padding: 0;
}
.row-qty-input:focus { outline: none; border-color: var(--orange); }
.row-qty-input::-webkit-inner-spin-button,
.row-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.row-confirm-btn {
  background: var(--green); color: #fff; border: 2px solid var(--green);
  border-radius: 7px; padding: 6px 12px; cursor: pointer;
  font-weight: 800; font-size: 13px; line-height: 1; white-space: nowrap;
  transition: all 0.12s;
}
.row-confirm-btn:hover { background: #3DA868; border-color: #3DA868; transform: translateY(-1px); }
.picker-product-row.is-expanded,
.picker-any-row.is-expanded,
.picker-product-row.selected,
.picker-any-row.selected {
  background: #FFF6E5;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px var(--orange);
}

/* Slot — wyraźne badge "Konkretny / Dowolny" w lewym górnym rogu.
   Tag ma swój pasek — slot dostaje padding-top żeby ikona kategorii pod
   spodem nie nachodziła na tag. */
.slot.filled { padding-top: 28px; }

/* Drag&drop — wizualne wskaźniki zamiany miejscami */
.slot[draggable="true"] { cursor: grab; }
.slot[draggable="true"]:active { cursor: grabbing; }
.slot.dragging { opacity: 0.35; transform: scale(0.96); }
.slot.drag-over {
  box-shadow: inset 0 0 0 3px var(--orange), 0 6px 18px rgba(255, 177, 66, 0.35);
  transform: scale(1.02);
  transition: transform 0.12s, box-shadow 0.12s;
}
.slot.filled .slot-type-tag {
  position: absolute; top: 6px; left: 6px;
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 2px 6px; border-radius: 4px;
}
.slot.filled.has-product .slot-type-tag {
  background: var(--green-bg); color: var(--green);
}
.slot.filled.any-product .slot-type-tag {
  background: var(--blue-bg); color: var(--blue);
}

/* Picker lodówki gdy są niezapisane zmiany — wyszarzony + kursor not-allowed */
#fridgeSelect:disabled {
  opacity: 0.55; cursor: not-allowed; background: var(--soft);
}
.fridge-picker[data-locked="true"] { cursor: not-allowed; }
.fridge-picker[data-locked="true"]::after {
  content: "🔒"; margin-left: 8px; font-size: 13px;
}
/* Nav items zablokowane gdy są niezapisane zmiany */
.nav-item.is-locked {
  opacity: 0.55; cursor: not-allowed;
  position: relative;
}
.nav-item.is-locked:hover::after {
  content: "Najpierw zapisz lub odrzuć zmiany w planogramie";
  position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  background: var(--navy); color: #fff; padding: 6px 10px; border-radius: 8px;
  font-size: 11px; font-weight: 500; white-space: nowrap; z-index: 1000;
  box-shadow: 0 6px 18px rgba(31,34,65,0.25);
}

/* Modal: day-action */
.day-action-options {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px; margin: 14px 0;
}
.day-action-btn {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--soft); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; text-align: left; transition: all 0.15s;
}
.day-action-btn:hover { background: #fff; border-color: var(--orange); box-shadow: 0 2px 8px rgba(31,34,65,0.06); }
.day-action-btn.selected { background: #fff; border-color: var(--navy); box-shadow: 0 2px 10px rgba(31,34,65,0.12); }
.day-action-ico { font-size: 22px; line-height: 1; flex-shrink: 0; }
.day-action-text { flex: 1; min-width: 0; }
.day-action-title { font-weight: 800; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.day-action-sub { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

.day-action-subpanel {
  margin-top: 14px; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--soft);
}
/* Checkbox "Dodaj jako nakładkę (override)" — pokazywany tylko dla mode=copy-version,
   żeby user mógł świadomie wybrać czy klon ma być main czy override. Bez override = wymóg
   confirm replace gdy ef koliduje, z override = nowa warstwa (priority=1). */
.day-action-override-toggle {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  background: #FFF6E5; border: 1px solid var(--orange);
  font-size: 13px; line-height: 1.4; cursor: pointer;
  color: var(--text);
}
.day-action-override-toggle input[type="checkbox"] {
  width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; cursor: pointer;
}
.day-action-override-toggle b { color: var(--navy); }
.day-action-override-toggle[hidden] { display: none; }
.day-action-subpanel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.day-action-subpanel-head .btn { padding: 6px 12px; font-size: 12px; }
/* Wstecz button — widoczny kontur na białym tle subpanela */
.day-action-subpanel-head .btn.ghost {
  background: #fff; color: var(--navy); border: 1.5px solid var(--navy); font-weight: 700;
}
.day-action-subpanel-head .btn.ghost:hover { background: var(--navy); color: #fff; }
#dayActionStatus { margin-top: 10px; }
#dayActionStatus .notice { margin: 0; }

/* === Zakładka: Dostawa === */
.delivery-toolbar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin: 4px 0 14px;
}
.delivery-toolbar .meta { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.delivery-toolbar input[type="date"],
.delivery-toolbar select {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  font-family: inherit; font-size: 13px; background: #fff; color: var(--text);
}

/* Pill switch — tryb Pojedyncza/Zbiorczo */
.delivery-mode-toggle {
  display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px;
  border: 1px solid var(--line);
}
.delivery-mode-toggle .dmt-btn {
  appearance: none; border: 0; background: transparent;
  padding: 7px 18px; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700; color: var(--muted);
  transition: background .15s, color .15s, box-shadow .15s;
}
.delivery-mode-toggle .dmt-btn:hover { color: var(--text); }
.delivery-mode-toggle .dmt-btn.active {
  background: var(--orange); color: #fff;
  box-shadow: 0 2px 6px rgba(255,177,66,.35);
}

/* Najbliższy dzień dostawy — banner w nagłówku zakładki Dostawa. Cutoff 9:00 PL. */
.delivery-next-day {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; border-radius: 12px; margin: 0 0 12px;
  background: linear-gradient(135deg, #1F2241 0%, #2A2D52 100%); color: #fff;
  border: 1px solid var(--navy); box-shadow: 0 2px 8px rgba(31,34,65,.12);
}
.delivery-next-day .dnd-ico { font-size: 26px; line-height: 1; }
.delivery-next-day .dnd-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.delivery-next-day .dnd-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em;
  color: rgba(255,255,255,.7);
}
.delivery-next-day .dnd-date {
  font-size: 18px; font-weight: 800; color: var(--orange);
}
.delivery-next-day .dnd-meta { font-size: 12px; color: rgba(255,255,255,.7); }
.delivery-next-day .dnd-meta .muted { color: inherit; }
@media (max-width: 480px) {
  .delivery-next-day { padding: 10px 14px; gap: 10px; }
  .delivery-next-day .dnd-ico { font-size: 22px; }
  .delivery-next-day .dnd-date { font-size: 15px; }
  .delivery-next-day .dnd-meta { display: none; }
}

/* Context bar — duży banner pokazujący kontekst (lodówka / liczba lodówek) */
.delivery-context-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 20px; border-radius: 12px; margin: 0 0 16px;
  font-size: 15px;
}
.delivery-context-bar:empty { display: none; }
.delivery-context-bar .dcb-mode {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em;
  padding: 4px 10px; border-radius: 999px;
}
.delivery-context-bar .dcb-value { font-weight: 800; font-size: 20px; }
.delivery-context-bar.mode-single {
  background: var(--navy); color: #fff; border: 1px solid var(--navy);
}
.delivery-context-bar.mode-single .dcb-mode { background: rgba(255,255,255,.14); color: rgba(255,255,255,.85); }
.delivery-context-bar.mode-single b { color: var(--orange); }
.delivery-context-bar.mode-aggregate {
  background: #FFF4D6; color: var(--navy);
  border: 2px solid var(--orange);
  box-shadow: 0 2px 10px rgba(255,177,66,.18);
}
.delivery-context-bar.mode-aggregate .dcb-mode { background: var(--orange); color: #fff; }
.delivery-context-bar.mode-aggregate .dcb-value { font-size: 22px; color: var(--text); }

/* Grid kart kategorii — responsive 1-3 kolumny */
.delivery-cat-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.delivery-cat-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow .15s, border-color .15s;
}
.delivery-cat-card:hover {
  border-color: #d8d4e3;
  box-shadow: 0 4px 14px rgba(31,34,65,.06);
}

.delivery-cat-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); padding-bottom: 10px;
}
.delivery-cat-emoji { font-size: 24px; line-height: 1; }
.delivery-cat-title { margin: 0; font-size: 16px; font-weight: 800; color: var(--text); flex: 1; min-width: 0; }
.delivery-cat-badge {
  display: inline-block; background: var(--blue-bg); color: var(--blue);
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}

/* 3 liczby per kategoria */
.delivery-cat-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.delivery-cat-stat {
  background: var(--soft); border-radius: 10px; padding: 10px 8px;
  text-align: center;
}
.delivery-cat-num {
  font-size: 26px; font-weight: 800; color: var(--text); line-height: 1.1;
}
.delivery-cat-num.to-order { color: var(--orange); font-size: 30px; }
.delivery-cat-lbl {
  font-size: 11px; color: var(--muted); margin-top: 4px;
  text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
}

.delivery-any-hint { font-size: 12px; padding-top: 2px; }

/* Rozwijana lista wariantów */
.delivery-variants { margin-top: 4px; }
.delivery-variants > summary {
  cursor: pointer; padding: 8px 12px; background: var(--soft);
  border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--navy);
  list-style: none;
}
.delivery-variants > summary::-webkit-details-marker { display: none; }
.delivery-variants > summary::before {
  content: "▸"; display: inline-block; margin-right: 8px;
  transition: transform .15s; color: var(--muted);
}
.delivery-variants[open] > summary::before { transform: rotate(90deg); }
.delivery-variants > summary:hover { background: #ECE9F3; }

/* Rozwinięta karta z listą wariantów: rozciąga się na pełną szerokość gridu
   żeby tabela się mieściła czytelnie (7 kolumn × thumb+badge+nazwa+4 liczby).
   `order: -1` przesuwa rozwiniętą kartę na pierwsze miejsce w siatce, dzięki
   czemu pozostałe kafelki zwijają się pod spodem bez dziury w layoucie.
   :has() supported od Chrome 105 / Safari 15.4 / Firefox 121 (>2024). */
.delivery-cat-card:has(> .delivery-variants[open]) {
  grid-column: 1 / -1;
  /* `width: 100%` + `justify-self: stretch` wymusza zajęcie pełnej szerokości
     trackiów (oba `max-width` + `margin:auto` powodowały że Snack jako pierwszy
     w gridzie był zwężony o 41px i przesunięty o 20px — quirk grid+:has(). */
  width: 100%;
  justify-self: stretch;
  box-shadow: 0 6px 22px rgba(31, 34, 65, 0.08);
  border-color: var(--orange);
}

.delivery-variants-table {
  margin-top: 10px; font-size: 13px;
  width: 100%; border-collapse: collapse; table-layout: auto;
}
.delivery-variants-table th,
.delivery-variants-table td { padding: 8px 10px; vertical-align: middle; }
.delivery-variants-table thead th {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); text-align: left;
  border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.delivery-variants-table tbody tr {
  border-bottom: 1px solid var(--line);
}
.delivery-variants-table tbody tr:last-child { border-bottom: 0; }
.delivery-variants-table td.dv-img { width: 44px; padding: 6px 4px 6px 6px; }
.delivery-variants-table .dv-thumb {
  display: block; width: 36px; height: 36px; border-radius: 6px;
  background-color: var(--soft); background-size: cover; background-position: center;
  border: 1px solid var(--line);
}
.delivery-variants-table .dv-thumb-empty { background-image: none; }
.delivery-variants-table .dv-name {
  font-weight: 700; color: var(--text);
  /* Długie nazwy mogą się zawijać — daj miejsce */
  white-space: normal; line-height: 1.3;
}
.delivery-variants-table .dv-code { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); }
.delivery-variants-table td.num {
  text-align: right; font-variant-numeric: tabular-nums;
  min-width: 70px; white-space: nowrap;
}
.delivery-variants-table td.num.to-order { color: var(--orange); font-weight: 800; }
.delivery-variants-table td.dv-kind { width: 130px; padding-right: 4px; }
.delivery-variants-table td.dv-kind .slot-kind-badge { white-space: nowrap; }

/* Fallback: jeśli karta z jakichkolwiek powodów (np. width: 280px na mobile)
   nie ma miejsca na siedmiocollumnową tabelę → scroll horyzontalny zamiast obciętej tabeli. */
.delivery-variants[open] {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.delivery-variants[open] > .delivery-variants-table { min-width: 720px; }

/* ============= Slot kind picker + badges (PR-175, Marta) ============= */

/* Pill picker (4 typy slotów) — w step 2 modal pickera, nad listą produktów */
.slot-kind-picker {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 8px;
}
.slot-kind-picker .skp-btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--navy);
  font-family: inherit; font-size: 13px; font-weight: 600;
  transition: border-color .12s, background .12s, color .12s, box-shadow .12s, transform .08s;
}
.slot-kind-picker .skp-btn:hover {
  border-color: var(--orange);
  color: var(--text);
}
.slot-kind-picker .skp-btn:active { transform: scale(0.97); }
.slot-kind-picker .skp-btn.active {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--navy);
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(255,177,66,.35);
}
.slot-kind-picker .skp-ico { font-size: 14px; line-height: 1; }
.slot-kind-picker .skp-txt { line-height: 1; }

/* Hint pod pillami — krótki opis typu i wymagań */
.slot-kind-hint {
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--soft);
  border-left: 3px solid var(--orange);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}

/* Badge typu slotu — używany w slot card (planogram) i delivery variants */
.slot-kind-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  line-height: 1.5;
}
.slot-kind-fresh    { background: #DCF3DC; color: #0E5E1E; }
.slot-kind-fixed    { background: var(--navy); color: #fff; }
.slot-kind-rotating { background: var(--orange); color: var(--navy); }
.slot-kind-limited  { background: #7C3AED; color: #fff; }

/* W slot card badge zastępuje stary slot-type-tag — pozycjonowany top-left.
   Stary .slot-type-tag może istnieć w starych slotach (no-op gdyby został). */
.slot.filled .slot-kind-badge {
  position: absolute; top: 6px; left: 6px;
  z-index: 1;
}


/* === Dostawa: płaska lista produktów (refactor produkt-first) === */
.delivery-filter-bar {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 10px;
  position: sticky; top: 80px; z-index: 30;
}
.dfilter-chip {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 6px 12px; border-radius: 999px; font-family: inherit; font-size: 13px;
  cursor: pointer; transition: all .12s; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.dfilter-chip:hover { border-color: var(--orange); }
.dfilter-chip.active {
  background: var(--navy); color: #fff; border-color: var(--navy);
}
.dfilter-chip .dfilter-count {
  background: rgba(255,177,66,.25); color: var(--navy);
  padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 800;
  min-width: 18px; text-align: center;
}
.dfilter-chip.active .dfilter-count { background: var(--orange); color: var(--navy); }

.delivery-list { display: flex; flex-direction: column; gap: 8px; }
.dp-row {
  display: grid;
  grid-template-columns: 36px 88px 1fr;
  gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; align-items: center;
  transition: box-shadow .12s, border-color .12s;
}
.dp-row.need { border-left: 4px solid var(--orange); }
.dp-row.done { opacity: 0.65; border-left: 4px solid #DCF3DC; }
.dp-row:hover { box-shadow: 0 2px 8px rgba(31,34,65,.06); }

.dp-qty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 4px;
}
.dp-qty-num {
  font-size: 44px; font-weight: 900; line-height: 1; color: var(--orange);
  font-variant-numeric: tabular-nums; letter-spacing: -1px;
}
.dp-row.done .dp-qty-num { color: var(--muted); font-size: 28px; }
.dp-qty-lbl { font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin-top: 2px; }

.dp-main {
  display: grid; grid-template-columns: 48px 1fr auto;
  grid-template-areas: "thumb info tags";
  gap: 10px; align-items: center;
  min-width: 0;
}
.dp-thumb { grid-area: thumb; }
.dp-info { grid-area: info; }
.dp-tags { grid-area: tags; }
.dp-thumb {
  width: 48px; height: 48px; border-radius: 8px;
  background-size: cover; background-position: center;
  background-color: var(--soft); border: 1px solid var(--line);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.dp-thumb-empty { color: var(--muted); }

.dp-info { min-width: 0; }
.dp-name { font-weight: 800; font-size: 15px; line-height: 1.25; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-sub { font-size: 12px; margin-top: 2px; }
/* Zamienniki — flat lista pod główną pozycją, zawsze widoczne (do 3, reszta pod
   expanderem „Pokaż wszystkie (N)"). Każdy wiersz: ikona statusu + nazwa + count.
   Pełna szerokość karty wiersza (grid-column 1/-1) — nie wciśnięte w kolumnę info. */
.dp-subs-list {
  grid-column: 1 / -1;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.dp-subs-list[data-collapsed="1"] .dp-subs-hidden { display: none; }
.dp-subs-hidden { display: flex; flex-direction: column; gap: 2px; }
.dp-subs-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted-strong, #5C5C7A);
  margin-bottom: 2px;
}
.dp-sub-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 8px;
  padding: 4px 8px 4px 18px;
  border-left: 2px solid var(--line);
  margin-left: 4px;
  font-size: 12.5px; color: var(--text);
  align-items: center;
  border-radius: 0 4px 4px 0;
  background: rgba(0,0,0,0.015);
}
.dp-sub-row:hover { background: var(--soft); }
.dp-sub-icon {
  font-weight: 900; font-size: 13px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.dp-sub-icon-in-fridge { color: var(--green); }
.dp-sub-icon-not-in-fridge { color: var(--muted); }
.dp-sub-name {
  font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dp-sub-count {
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.dp-sub-count.in-fridge { color: var(--green); }
.dp-sub-count.not-in-fridge { color: var(--muted); }
.dp-subs-more {
  appearance: none; background: transparent; border: 0;
  color: var(--navy); font-family: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; padding: 4px 8px 4px 18px;
  text-align: left; margin-left: 4px;
  border-left: 2px solid transparent;
}
.dp-subs-more:hover { text-decoration: underline; }
/* Strikethrough cascade gdy główny wiersz odhaczony */
.dp-row.is-checked .dp-sub-name,
.dp-row.is-checked .dp-sub-count { text-decoration: line-through; opacity: 0.7; }

.dp-cat {
  background: var(--soft); color: var(--muted); padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
/* Tag typu slotu (TC-D07, UX-D03): świeże/zamienne/konkretne/limitowane — pierwsza
   linia, mocniejsze tło żeby dostawca od razu widział co to za rodzaj produktu. */
.dp-tags { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.dp-kind {
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap;
  border: 1.5px solid transparent;
}
.dp-kind-fresh          { background: #C8E6C9; color: #1B5E20; border-color: #81C784; }
.dp-kind-fixed_variants { background: #FFE0B2; color: #BF6900; border-color: #FFB74D; }
.dp-kind-rotating       { background: #BBDEFB; color: #0D47A1; border-color: #64B5F6; }
.dp-kind-limited        { background: #F8BBD0; color: #880E4F; border-color: #F06292; }
.dp-expired-note { color: var(--red); font-weight: 700; }
.dp-expired-text { color: var(--red); font-weight: 700; }

/* F7 — checkbox „dostarczone" po prawej każdego wiersza. State w localStorage,
   po zaznaczeniu nazwa + sub-line są przekreślone, opacity ~ done. */
.dp-check {
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 4px; user-select: none;
}
.dp-check-input {
  position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0;
}
.dp-check-mark {
  width: 28px; height: 28px; border-radius: 6px;
  border: 2px solid var(--line); background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.dp-check:hover .dp-check-mark { border-color: var(--orange); }
.dp-check-input:focus-visible + .dp-check-mark { outline: 2px solid var(--orange); outline-offset: 2px; }
.dp-check-input:checked + .dp-check-mark {
  background: var(--green); border-color: var(--green); color: #fff;
}
.dp-row.is-checked { background: var(--soft); opacity: 0.55; }
.dp-row.is-checked .dp-name,
.dp-row.is-checked .dp-sub { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.dp-row.is-checked .dp-qty-num { color: var(--muted); }
.dp-row.is-checked .dp-subs-toggle { opacity: 0.5; }

/* F6 — timestamp ostatniego odświeżenia w toolbarze (małe, dyskretne). */
.delivery-last-loaded { font-size: 12px; color: var(--muted); margin-right: 8px; }

/* F9 — daty obok nazwy planogramu w context bar (single mode). */
.delivery-context-bar.mode-single .dcb-plan-dates {
  font-size: 13px; color: rgba(255,255,255,.7); margin-left: 4px;
}
/* Override-badge w context bar (mode-single): wyraźny pomarańczowy chip. */
.delivery-context-bar.mode-single .dcb-override-badge {
  display: inline-block; margin-left: 10px;
  background: var(--orange); color: var(--navy);
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 800;
}
.delivery-context-bar.mode-single .dcb-override { font-size: 14px; }

/* Kontenery niżej mają display: flex/grid, co bije regułę UA dla [hidden] —
   a w tej zakładce chowamy ich sporo (kroki kreatora, przełączniki, inspektor,
   strzałki podglądu). Jedna reguła na sekcję zamiast łatania każdego osobno. */
section[data-tab="marketing"] [hidden],
.mkt-lightbox[hidden], .mkt-lightbox [hidden] { display: none !important; }

/* ── Marketing — grafiki na ekranach lodówek ──────────────────────────────── */
.mkt-scope {
  display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px;
  border: 1px solid var(--line);
}
.mkt-scope-btn {
  appearance: none; border: 0; background: transparent;
  padding: 7px 18px; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700; color: var(--muted);
  transition: background .15s, color .15s, box-shadow .15s;
}
.mkt-scope-btn:hover { color: var(--text); }
.mkt-scope-btn.active {
  background: var(--orange); color: #fff;
  box-shadow: 0 2px 6px rgba(255,177,66,.35);
}

/* Nagłówek per lodówka + licznik zajętości karuzeli (IF wyświetla 5 slotów). */
.mkt-fridge-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
/* Pusty ekran / błąd — jedna linijka, nie pudło (w widoku wszystkich lodówek
   pustych bywa większość). */
.mkt-empty-line { font-size: 13px; margin-bottom: 18px; }
.mkt-meter { display: inline-flex; align-items: center; gap: 3px; }
.mkt-meter-seg { width: 14px; height: 6px; border-radius: 3px; background: var(--line); }
.mkt-meter-seg.on { background: var(--orange); }
.mkt-meter-txt { margin-left: 4px; font-size: 11px; font-weight: 800; color: var(--muted); }
.mkt-meter-txt.full { color: var(--red); }

/* Pasek miniaturek — celowo małe, to widok pomocniczy. Grafikę oglądamy
   w podglądzie, nie w siatce. */
.mkt-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.mkt-tile {
  position: relative; flex: none; width: 92px; aspect-ratio: 9/16;
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: var(--soft);
}
.mkt-tile img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
/* Kodowanie źródła: przerywana złota = spoza automatyzacji (ręczna w Husky albo
   po starym Marketingu, do zdjęcia), ciągła pomarańczowa = z harmonogramu
   (pilnuje jej watchdog, stąd nie ma krzyżyka). */
.mkt-tile.ext { border-style: dashed; border-color: #d9b96a; }
.mkt-tile.blocked { border-color: var(--orange); }
.mkt-tile-x {
  position: absolute; top: 4px; right: 4px; width: 19px; height: 19px;
  appearance: none; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(16,18,32,.7); color: #fff; font-size: 10px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.mkt-tile-x:hover { background: var(--red); }
.mkt-tile-confirm {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 6px;
  align-items: center; justify-content: center; padding: 6px; text-align: center;
  background: rgba(16,18,32,.88); color: #fff; font-size: 11px; font-weight: 700;
}
.mkt-tile-confirm-btns { display: flex; gap: 4px; }
.mkt-btn-xs { padding: 3px 9px; font-size: 11px; }

/* Ghost buttony na jasnym tle treści (globalny .btn.ghost jest pod ciemny topbar). */
section[data-tab="marketing"] .btn.ghost {
  background: #fff; color: var(--text); border: 1px solid var(--line);
}
section[data-tab="marketing"] .btn.ghost:hover { background: var(--soft); }
section[data-tab="marketing"] .btn.ghost:disabled { opacity: .5; cursor: not-allowed; }

/* Tooltip (content z data-tip) — wzór jak .dp-qty-extra w Dostawie. */
section[data-tab="marketing"] [data-tip] { position: relative; }
section[data-tab="marketing"] [data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; right: 0; bottom: calc(100% + 6px);
  background: var(--navy); color: #fff;
  padding: 7px 11px; border-radius: 8px;
  font-size: 11.5px; font-weight: 600; line-height: 1.45;
  white-space: normal; width: max-content; max-width: 240px; text-align: left;
  box-shadow: 0 6px 20px rgba(20,20,40,.28);
  z-index: 130; pointer-events: none;
}

/* ── Studio szablonów ─────────────────────────────────────────────────────── */
.mkt-tpl-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px; margin-top: 4px;
}
.mkt-tpl {
  appearance: none; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); padding: 10px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.mkt-tpl:hover { border-color: var(--orange); box-shadow: 0 4px 16px rgba(20,20,40,.1); transform: translateY(-2px); }
.mkt-tpl.soon { opacity: .55; cursor: not-allowed; }
.mkt-tpl.soon:hover { border-color: var(--line); box-shadow: none; transform: none; }
.mkt-tpl-img { width: 100%; aspect-ratio: 9/16; object-fit: cover; border-radius: 8px; background: var(--soft); display: block; }
.mkt-tpl-name { font-size: 13px; font-weight: 700; color: var(--text); }

/* Widok „Zaplanowane" — wpisy czekające na okno i te w oknie */
.mkt-plan {
  display: flex; align-items: flex-start; gap: 14px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  margin-bottom: 8px;
}
.mkt-plan-img {
  flex: none; width: 54px; aspect-ratio: 9/16; object-fit: cover;
  border-radius: 7px; background: var(--soft); display: block;
}
.mkt-plan-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mkt-plan-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mkt-plan-name { font-weight: 700; font-size: 14px; }
.mkt-plan-meta { font-size: 12px; line-height: 1.5; }
.mkt-plan-err {
  font-size: 12px; color: var(--red); font-weight: 600; margin-top: 2px;
  word-break: break-word;
}
.mkt-plan-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Wskaźnik kroku kreatora */
.mkt-steps {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  list-style: none; margin: 0 0 14px; padding: 0;
}
.mkt-step {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px 6px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.mkt-step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--line); color: var(--card); font-size: 11px; font-weight: 800;
}
.mkt-step.now { border-color: var(--orange); background: #fff8e6; color: var(--text); }
.mkt-step.now .mkt-step-n { background: var(--orange); color: #fff; }
.mkt-step.done { color: var(--muted-strong); }
.mkt-step.done .mkt-step-n { background: var(--navy); color: #fff; }

/* Krok 2 — lodówki */
.mkt-fr-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.mkt-fr-count { font-size: 13px; font-weight: 700; }
.mkt-fr-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px;
}
.mkt-fr {
  display: flex; align-items: center; gap: 10px; padding: 10px 13px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  cursor: pointer; font-size: 14px;
}
.mkt-fr:hover { border-color: var(--orange); }
.mkt-fr.on { background: #fff8e6; border-color: var(--orange); }
.mkt-fr input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--orange); }
.mkt-fr-name { flex: 1; font-weight: 700; }

/* Krok 3 — termin */
.mkt-sched {
  display: flex; flex-direction: column; gap: 14px; max-width: 620px;
  padding: 16px 18px; background: var(--soft); border-radius: 12px;
}
.mkt-sched-fields { display: flex; gap: 14px; flex-wrap: wrap; }
.mkt-sched-f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted-strong); }
.mkt-sched-f input {
  font: inherit; font-size: 14px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text);
}
.mkt-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.mkt-preset {
  appearance: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700;
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.mkt-preset:hover { border-color: var(--orange); }
.mkt-preset.active { background: var(--orange); border-color: var(--orange); color: #fff; }

.mkt-summary {
  max-width: 620px; margin-top: 16px; display: flex; flex-direction: column; gap: 6px;
  padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
.mkt-sum-row { display: flex; align-items: baseline; gap: 10px; font-size: 14px; flex-wrap: wrap; }
.mkt-sum-l { flex: 0 0 78px; font-size: 12px; font-weight: 700; color: var(--muted-strong); }
.mkt-sum-warn { margin-top: 10px; border-color: var(--red); color: var(--red); }

.mkt-studio-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.mkt-studio-name { font-size: 16px; font-weight: 800; margin-right: auto; }
.mkt-studio-body { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }

/* Podgląd = iframe z ramką 1080×1920 przeskalowaną transformem. Renderuje ten
   sam HTML, który serwer zapieka Chrome'em, więc podgląd nie może się rozjechać
   z wynikiem. --k to współczynnik pomniejszenia. */
.mkt-canvas-wrap {
  --k: .34; flex: none; position: relative; overflow: hidden;
  width: calc(1080px * var(--k)); height: calc(1920px * var(--k));
  border: 1px solid var(--line); border-radius: 12px; background: var(--soft);
}
#mktCanvas {
  width: 1080px; height: 1920px; border: 0; display: block;
  transform: scale(var(--k)); transform-origin: top left;
}

.mkt-studio-panel { flex: 1 1 280px; min-width: 260px; display: flex; flex-direction: column; gap: 14px; }
.mkt-field { display: flex; flex-direction: column; gap: 5px; }
.mkt-field-label { font-size: 13px; font-weight: 700; color: var(--muted-strong); }
.mkt-field textarea {
  font: inherit; font-size: 14px; padding: 9px 12px; resize: vertical;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text);
}
.mkt-field textarea:focus { outline: none; border-color: var(--orange); }
#mktFields { display: flex; flex-direction: column; gap: 12px; }
/* Pole formatowane: edycja w panelu (na ramce w skali 0,34x tekst jest
   nieczytelny), efekt widać obok na podglądzie. */
.mkt-rich {
  font: inherit; font-size: 14px; padding: 9px 12px; min-height: 62px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  color: var(--text); white-space: pre-wrap; word-break: break-word;
  line-height: 1.45; outline: none;
}
.mkt-rich:focus { border-color: var(--orange); }
/* Rozmiar w px jest projektowy (np. 104) — w panelu rozsadziłby pole, więc go
   tu neutralizujemy. Kolor i grubość zostają, bo czytają się w skali UI;
   rozmiar widać na ramce obok. */
.mkt-rich span { font-size: inherit !important; }

/* Wybór produktów z lodówki */
.mkt-prod-btn { align-self: flex-start; }
.mkt-prod-search {
  width: 100%; font: inherit; font-size: 14px; padding: 9px 12px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text);
}
.mkt-photo-modes { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.mkt-photo-modes[hidden] { display: none; }
.mkt-photo-modes .mkt-scope-btn:disabled { opacity: .45; cursor: not-allowed; }
.mkt-photo-hint { font-size: 12px; }

.mkt-prod-list { max-height: 52vh; overflow-y: auto; }
.mkt-prod-cat {
  font-size: 12px; font-weight: 800; color: var(--muted-strong);
  text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 4px;
}
.mkt-prod-cat:first-child { margin-top: 0; }
.mkt-prod {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--card);
  cursor: pointer; font-size: 14px; margin-bottom: 4px;
}
.mkt-prod:hover { border-color: var(--orange); }
.mkt-prod.on { background: #fff8e6; border-color: var(--orange); }
.mkt-prod input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--orange); flex: none; }
.mkt-prod-name { flex: 1; min-width: 0; }
.mkt-prod-price { font-weight: 800; font-variant-numeric: tabular-nums; }
.mkt-prod-was {
  font-size: 12px; color: var(--muted); text-decoration: line-through;
  font-variant-numeric: tabular-nums;
}
.mkt-prod-cnt { font-size: 12px; flex: none; min-width: 68px; text-align: right; }
.mkt-prod-info { margin-right: auto; font-size: 13px; }

/* Pływający pasek formatowania — wyskakuje nad zaznaczonym fragmentem. */
.mkt-fmtbar {
  position: fixed; z-index: 210; display: flex; align-items: center; gap: 5px;
  padding: 5px 6px; border-radius: 9px;
  background: var(--navy); box-shadow: 0 8px 26px rgba(20,20,40,.35);
}
.mkt-fmtbar[hidden] { display: none; }
.mkt-fmt {
  appearance: none; cursor: pointer; font: inherit; font-size: 12px; line-height: 1;
  padding: 6px 10px; border: 0; border-radius: 6px;
  background: rgba(255,255,255,.14); color: #fff;
}
.mkt-fmt:hover { background: rgba(255,255,255,.28); }
.mkt-fmt-color {
  width: 30px; height: 26px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; cursor: pointer;
}
.mkt-fmt-size {
  width: 56px; font: inherit; font-size: 12px; padding: 5px 7px;
  border: 0; border-radius: 6px; background: rgba(255,255,255,.14); color: #fff;
}
.mkt-fmt-size::placeholder { color: rgba(255,255,255,.5); }

.mkt-panel-h { font-size: 13px; font-weight: 800; color: var(--muted-strong); }
.mkt-panel-h + .mkt-layers { margin-top: -6px; }
.mkt-layers { display: flex; flex-direction: column; gap: 2px; }
.mkt-layer {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px;
  border-radius: 8px; font-size: 13px; cursor: pointer;
  border: 1px solid transparent;
}
.mkt-layer:hover { background: var(--soft); }
.mkt-layer.sel { background: #fff8e6; border-color: var(--orange); }
.mkt-layer.off .mkt-layer-name { text-decoration: line-through; color: var(--muted); }
.mkt-layer-name { flex: 1; font-weight: 600; }
.mkt-layer-pos { font-size: 12px; font-variant-numeric: tabular-nums; }
.mkt-eye {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-size: 12px; line-height: 1; padding: 2px 3px; border-radius: 5px;
  filter: grayscale(1); opacity: .65;
}
.mkt-eye:hover { opacity: 1; background: var(--card); }
.mkt-layer.off .mkt-eye { opacity: .9; filter: none; color: var(--red); }

/* Inspektor zaznaczonej warstwy */
.mkt-insp {
  display: flex; flex-direction: column; gap: 7px;
  padding: 11px 12px; border: 1px solid var(--orange); border-radius: 10px;
  background: #fffdf7;
}
.mkt-insp-h { font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 1px; }
.mkt-insp-row { display: flex; align-items: center; gap: 7px; }
.mkt-insp-l { flex: 0 0 74px; font-size: 12px; font-weight: 700; color: var(--muted-strong); }
.mkt-insp-u { font-size: 11px; }
.mkt-insp input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--orange); }
.mkt-insp .mkt-num {
  width: 62px; font: inherit; font-size: 13px; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.mkt-insp select {
  flex: 1; font: inherit; font-size: 13px; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text);
}
.mkt-insp .mkt-color {
  width: 44px; height: 26px; padding: 0; border: 1px solid var(--line);
  border-radius: 6px; background: var(--card); cursor: pointer;
}
.mkt-align {
  appearance: none; cursor: pointer; font-size: 13px; line-height: 1;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--text);
}
.mkt-align.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.mkt-insp-rst { align-self: flex-start; margin-top: 2px; }

/* Podgląd grafiki (klik w miniaturę). Strzałki ← → przełączają po wszystkich
   grafikach z aktualnego widoku, Esc zamyka. */
.mkt-lightbox {
  position: fixed; inset: 0; z-index: 200; display: flex;
  align-items: center; justify-content: center; gap: 10px;
  background: rgba(10,12,24,.85); padding: 30px 20px; cursor: zoom-out;
}
.mkt-lb-center {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  min-width: 0; max-height: 100%; cursor: default;
}
#mktLbImg {
  max-height: calc(100vh - 110px); max-width: min(80vw, 440px);
  border-radius: 12px; object-fit: contain; background: #16182e;
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
}
.mkt-lb-cap { color: #fff; font-size: 13px; font-weight: 600; text-align: center; }
.mkt-lb-count { margin-left: 8px; color: rgba(255,255,255,.6); font-weight: 700; }
.mkt-lb-nav {
  appearance: none; border: 0; cursor: pointer; flex: none;
  background: rgba(255,255,255,.14); color: #fff;
  width: 44px; height: 44px; border-radius: 50%; font-size: 26px; line-height: 1;
}
.mkt-lb-nav:hover { background: rgba(255,255,255,.28); }
.mkt-lb-close {
  position: absolute; top: 18px; right: 22px; appearance: none; border: 0;
  background: rgba(255,255,255,.14); color: #fff;
  width: 38px; height: 38px; border-radius: 50%; font-size: 17px; cursor: pointer;
}
.mkt-lb-close:hover { background: rgba(255,255,255,.26); }

@media (max-width: 768px) {
  /* Przełącznik + Odśwież w jednym rzędzie nagłówka nie mieszczą się na 375px —
     pozwalamy im się zawinąć, przełącznik bierze wolną szerokość. */
  section[data-tab="marketing"] .tab-actions { flex-wrap: wrap; }
  .mkt-scope { flex: 1; }
  .mkt-scope-btn { flex: 1; }
  .mkt-lightbox { padding: 20px 6px; gap: 4px; }
  .mkt-lb-nav { width: 36px; height: 36px; font-size: 22px; }
}

/* Estymacja dostawy (sprzedaż po cutoffie) */
.delivery-est-banner {
  margin-bottom: 12px; padding: 8px 14px; border-radius: 10px;
  background: #fff7e8; border: 1px solid #f4dbae; color: #7a4a00; font-size: 13px;
}
.delivery-est-banner.unavailable { background: var(--soft); border-color: var(--line); color: var(--muted); }
.dp-qty-extra {
  /* Blok POD cyfrą (nie inline obok) — inline wystawał poza 88px kolumnę
     i nachodząca komórka grida zjadała hover (tooltip nie działał). */
  display: block; margin-top: 1px; line-height: 1.2;
  font-size: 12px; font-weight: 800; color: var(--orange);
  white-space: nowrap; cursor: help;
  position: relative;
}
.dp-row.done .dp-qty-extra { color: var(--orange); }
/* Własny tooltip (content z data-tip) — natywny title bywał zawodny
   (1s opóźnienia, kaprysy przeglądarek). Pokazuje się od razu na hover/focus. */
.dp-qty-extra:hover::after,
.dp-qty-extra:focus-visible::after,
.dp-qty-extra:focus::after,
.dp-qty-extra.tip-open::after {
  content: attr(data-tip);
  position: absolute; left: 0; bottom: calc(100% + 6px);
  background: var(--navy); color: #fff;
  padding: 7px 11px; border-radius: 8px;
  font-size: 11.5px; font-weight: 600; line-height: 1.45;
  white-space: normal; width: max-content; max-width: 250px; text-align: left;
  box-shadow: 0 6px 20px rgba(20,20,40,.28);
  z-index: 60; pointer-events: none;
}
.dp-qty-extra:focus { outline: none; }

.delivery-stocked {
  margin-top: 16px; background: var(--soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px;
}
.delivery-stocked > summary {
  cursor: pointer; padding: 4px; font-weight: 700; font-size: 13px; color: var(--muted);
  list-style: none;
}
.delivery-stocked > summary::-webkit-details-marker { display: none; }
.delivery-stocked > summary::before { content: "▸ "; transition: transform .15s; }
.delivery-stocked[open] > summary::before { content: "▾ "; }
.delivery-stocked .delivery-list { margin-top: 8px; }

.delivery-any-slots {
  margin-top: 16px; padding: 14px 16px; background: #DCF3DC; border-radius: 12px;
  border: 1px solid #B8E0BA;
}
.das-head { font-size: 13px; font-weight: 700; color: #0E5E1E; margin-bottom: 8px; }
.das-list { display: flex; flex-wrap: wrap; gap: 8px; }
.das-chip {
  background: #fff; border: 1px solid #B8E0BA; border-radius: 999px;
  padding: 4px 12px; font-size: 13px; color: var(--text);
}

/* === Hamburger sidebar + responsive layout (mobile-first dla Dostawy + nav) === */
.topbar-burger {
  display: none;  /* widoczny tylko na mobile via media query niżej */
  appearance: none; border: 0; background: transparent; padding: 6px 8px;
  cursor: pointer; margin-right: 4px;
}
.topbar-burger span {
  display: block; width: 22px; height: 2.5px; background: #fff; border-radius: 2px;
  margin: 4px 0; transition: transform .2s, opacity .2s;
}
body.sidebar-open .topbar-burger span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
body.sidebar-open .topbar-burger span:nth-child(2) { opacity: 0; }
body.sidebar-open .topbar-burger span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(31,34,65,.4); z-index: 80;
  display: none; touch-action: none;
}

@media (max-width: 900px) {
  .topbar-burger { display: inline-block; }
  /* Topbar: override grid → flex (grid z fixed 220+360+1fr wyciekał poza viewport).
     Layout: rząd 1 = burger + brand + top-actions; rząd 2 = fridge-picker full-width. */
  .topbar {
    display: flex; flex-wrap: wrap; align-items: center;
    padding: 8px 12px; gap: 8px;
  }
  .brand { font-size: 13px; flex: 1; min-width: 0; order: 1; }
  /* Dopisek „automation" nie mieści się obok chipa usera — przy 375 px nachodził
     na „smart / Wyloguj". Logo wystarcza do rozpoznania panelu. */
  .brand-app { display: none; }
  .top-actions { order: 2; margin-left: auto; }
  .fridge-picker {
    order: 3; width: 100%; margin: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    padding: 8px 12px;
  }
  .fridge-picker label { font-size: 11px; color: rgba(255,255,255,.7); }
  .fridge-picker select {
    width: 100%; font-size: 13px;
    padding: 6px 24px 6px 10px;
    text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
  }
  /* User chip — kompakt: ukryj rolę (admin/restocker — przy 1 koncie na osobę oczywiste),
     skróć nazwę z ellipsis żeby topbar się nie rozjeżdżał. */
  .user-chip { padding: 4px 4px 4px 8px; gap: 6px; }
  .user-chip .user-name { font-size: 12px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-chip .user-role { display: none; }
  /* Layout: grid 220+1fr → flex/block na mobile, bo sidebar jest absolute. */
  .layout { display: block; }
  /* Sidebar wjeżdża z lewej */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px;
    padding-top: 16px;  /* topbar mobile wieloliniowy — padding wewnętrzny zamiast top offset */
    transform: translateX(-100%); transition: transform .25s ease-out;
    z-index: 90; overflow-y: auto; box-shadow: 4px 0 20px rgba(0,0,0,.25);
    background: #fff;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  /* Main content na pełną szerokość */
  .content { padding: 12px; max-width: none; }
  .content.content-wide { padding: 12px; }
  /* Tab head — pionowo, mniejszy */
  .tab-head { flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 10px; }
  .tab-head h2 { font-size: 18px; margin: 0; }
  .tab-head .sub { font-size: 12px; line-height: 1.3; }
  .tab-actions { width: 100%; }
  /* Delivery toolbar — pionowo na wąskich */
  .delivery-toolbar { flex-direction: column; align-items: stretch; gap: 10px; padding: 10px 12px; }
  .delivery-mode-toggle { width: 100%; justify-content: center; }
  .delivery-mode-toggle .dmt-btn { flex: 1; }
  /* Context bar — kompakt na mobile, ukryta meta "LODÓWKA" chip (oczywista). */
  .delivery-context-bar { padding: 8px 12px; font-size: 12px; gap: 8px; margin: 0 0 10px; border-radius: 10px; }
  .delivery-context-bar .dcb-mode { display: none; }
  .delivery-context-bar .dcb-value { font-size: 14px; }
  .delivery-context-bar.mode-aggregate .dcb-value { font-size: 15px; }
  /* Filter bar — sticky pod topbarem mobile, skrócone chipy żeby się mieściły 2-3/wiersz */
  .delivery-filter-bar { position: sticky; top: 0; padding: 6px 6px; margin-bottom: 8px; gap: 4px; z-index: 20; }
  .dfilter-chip { padding: 4px 8px; font-size: 11.5px; gap: 4px; font-weight: 700; }
  .dfilter-chip .dfilter-count { padding: 0 5px; font-size: 10.5px; min-width: 14px; }
  /* Produkt row — checkbox po lewej + qty + main (thumb+name w 1 linii, kategoria pod) */
  .dp-row { grid-template-columns: 28px 60px 1fr; gap: 8px; padding: 10px 10px; align-items: flex-start; }
  .dp-qty { padding: 2px; }
  .dp-qty-num { font-size: 32px; }
  .dp-qty-lbl { font-size: 9px; }
  /* dp-main na mobile: thumb + info w 1 linii, tags pod, subs na full szerokości */
  .dp-main {
    grid-template-columns: 36px 1fr;
    grid-template-areas: "thumb info" "tags tags";
    gap: 8px;
    align-items: center;
  }
  .dp-thumb { width: 36px; height: 36px; grid-area: thumb; font-size: 16px; }
  .dp-info { grid-area: info; min-width: 0; }
  .dp-tags {
    grid-area: tags; justify-self: start; margin-top: 2px;
    flex-direction: row; flex-wrap: wrap; gap: 4px;
  }
  .dp-cat, .dp-kind { padding: 3px 8px; font-size: 10.5px; }
  .dp-check-mark { width: 24px; height: 24px; font-size: 15px; }
  .dp-name { font-size: 13.5px; white-space: normal; line-height: 1.25; }
  .dp-sub { font-size: 11.5px; }
  /* Substytuty: toggle + chips na mobile mniejsze fonty */
  .dp-subs-toggle { font-size: 11.5px; padding: 4px 8px; }
  .dp-subs-chips { padding: 5px 8px; }
  .dp-sub-chip { padding: 2px 8px; font-size: 11px; }
  /* Any-slots — mniejsze chipy */
  .delivery-any-slots { padding: 10px 12px; }
  .das-head { font-size: 12px; }
  .das-chip { padding: 3px 10px; font-size: 12px; }
  /* Sticky bar planogramu — mniejszy padding, akcje w drugim wierszu jeśli brak miejsca */
  .planogram-sticky-bar { padding: 10px 12px; flex-wrap: wrap; }
  .psb-label { display: none; }  /* na mobile skróć — semantyka utrzymuje aria-label na buttonach */
  .psb-plan-name { font-size: 16px; }
  .psb-line2 { font-size: 12px; }
  .psb-edit-btn { width: 30px; height: 30px; font-size: 14px; }  /* większy touch target */
  .psb-actions { width: 100%; margin-top: 4px; }
  .psb-actions .btn { flex: 1; padding: 8px 10px; font-size: 13px; }
  .psb-actions .btn#saveBtn { flex: 1 1 100%; }  /* Zapisz — cała szerokość gdy visible */
  /* Popover zamiennika — pełna szerokość minus padding */
  .dp-sub-popover { max-width: calc(100vw - 24px); }
  /* Substytuty na mobile — stack: ikona + nazwa na górze (z text-wrap), count pod
     spodem. Nazwy produktów są długie (CORNY Baton zbożowy z mleczną czekoladą)
     i 3-column grid na 380px viewport obcina je do "CORNY ...". */
  .dp-sub-row {
    grid-template-columns: 14px 1fr;
    grid-template-rows: auto auto;
    column-gap: 6px;
    row-gap: 0;
    padding: 5px 8px 5px 12px;
    align-items: start;
  }
  .dp-sub-icon {
    grid-column: 1; grid-row: 1 / span 2;
    align-self: center;
  }
  .dp-sub-name {
    grid-column: 2; grid-row: 1;
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
    font-size: 13px;
  }
  .dp-sub-count {
    grid-column: 2; grid-row: 2;
    font-size: 11px;
    margin-top: 1px;
  }
  .dp-subs-more {
    padding: 6px 8px 4px 12px;
    text-align: center;
    width: 100%;
  }
}
