/* ==========================================================================
   SYSTEM SPRZEDAZY I ZAKUPOW - system projektowy
   ==========================================================================
   Kierunek: "wieza kontrolna" logistyki. Ciemny sidebar operacyjny,
   jasna, spokojna przestrzen robocza. Liczby i identyfikatory (ceny,
   tracking, ID) zawsze w kroju mono z tabular-nums - to dane, ktore
   trzeba porownywac wzrokiem w kolumnach. Statusy jako "znaczki pocztowe":
   obrys, wersaliki, mono - nawiazanie do stempli na przesylkach, bez
   bycia dosłownym.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* --- Paleta ------------------------------------------------------- */
  --ink:        #171A21;   /* sidebar, tekst podstawowy */
  --ink-soft:   #2A2E38;   /* sidebar - hover/aktywne */
  --paper:      #F6F5F2;   /* tlo robocze */
  --surface:    #FFFFFF;   /* karty, tabele */
  --line:       #E4E1DA;   /* linie podzialu */
  --line-soft:  #EDEBE5;

  --text:       #1D2027;
  --text-muted: #6B6F7A;
  --text-faint: #9A9DA6;

  --amber:      #E8963D;   /* akcent glowny - etykieta spedycyjna */
  --amber-deep: #C97A24;
  --amber-tint: #FBEBD6;

  --teal:       #2F6F6B;   /* sukces / zaplacone / dostarczone */
  --teal-tint:  #E1EFEC;

  --red:        #C0392B;   /* problem / zwrot / przeterminowane */
  --red-tint:   #F8E4E1;

  --blue:       #35618C;   /* informacyjne / w drodze */
  --blue-tint:  #E3EDF5;

  --green:      #3D8B3D;   /* status: otwarte/open */
  --green-tint: #E4F1E4;

  --gray:       #6B6F7A;   /* status: wyslane (jasnoszary/neutralny) */
  --gray-tint:  #EEEEEC;

  --violet:      #6F4E9C;  /* rozroznianie sklepow */
  --violet-tint: #ECE6F4;

  --brown:      #8A5A2E;   /* rozroznianie sklepow */
  --brown-tint: #F1E6DA;

  --pink:       #B14C7B;   /* rozroznianie sklepow */
  --pink-tint:  #F5E3EC;

  /* --- Typografia ----------------------------------------------------- */
  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body:    'Inter', 'Segoe UI', sans-serif;
  --font-mono:    'IBM Plex Mono', 'Consolas', monospace;

  /* --- Layout ----------------------------------------------------------*/
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 60px;
  --quicklinks-h: 34px;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-card: 0 1px 2px rgba(23,26,33,0.06), 0 1px 1px rgba(23,26,33,0.04);
}

/* ==========================================================================
   TRYB NOCNY - nadpisuje TE SAME nazwy zmiennych z :root, wiec caly reszta
   arkusza (komponenty, tabele, formularze) przestraja sie automatycznie,
   bez potrzeby osobnych regul dla kazdego elementu.
   ========================================================================== */
[data-theme="dark"] {
  --paper:      #1B1D22;
  --surface:    #24262C;
  --line:       #35373E;
  --line-soft:  #2B2D33;

  --text:       #E7E6E3;
  --text-muted: #9B9EA6;
  --text-faint: #6B6E76;

  --amber-tint: #3A2E1C;
  --teal-tint:  #16302B;
  --red-tint:   #3A1E1D;
  --blue-tint:  #1A2733;
  --green-tint: #1B2E1D;
  --gray-tint:  #2B2D33;
  --violet-tint:#2A2233;
  --brown-tint: #2E2318;
  --pink-tint:  #331F28;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.25);
}
[data-theme="dark"] body { background: var(--paper); }
[data-theme="dark"] .sidebar { background: #131418; }
[data-theme="dark"] .auth-shell { background: #0F1013; }
[data-theme="dark"] .btn { background: var(--surface); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .btn:hover { background: var(--line-soft); border-color: var(--text-faint); }
[data-theme="dark"] .data-table tbody tr:hover { background: var(--line-soft); }
[data-theme="dark"] .filter-bar { background: var(--line-soft); }
[data-theme="dark"] .field input, [data-theme="dark"] .field select, [data-theme="dark"] .field textarea {
  background: var(--surface); color: var(--text); border-color: var(--line);
}
[data-theme="dark"] .product-suggestions, [data-theme="dark"] .date-cal-popup {
  background: var(--surface); border-color: var(--line);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  padding-top: var(--quicklinks-h);
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* Liczby zawsze rowniej ustawione w kolumnach */
.num, .mono, td.num, th.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px 0;
  color: var(--text);
}
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

/* ==========================================================================
   SZKIELET STRONY
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar ------------------------------------------------------------ */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink);
  color: #C7CAD3;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--quicklinks-h); bottom: 0; left: 0;
  transition: width 0.18s ease;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: relative;
}
.sidebar-collapse-btn-top {
  position: absolute;
  top: 14px;
  right: 12px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  background: transparent;
  color: #8C8FA0;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.sidebar-collapse-btn-top:hover { background: var(--ink-soft); color: #fff; }
[data-sidebar="collapsed"] .sidebar-collapse-btn-top { position: static; margin: 0 auto 10px; display: flex; }
.sidebar-brand .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  background: var(--amber);
  color: var(--ink);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  margin-right: 10px;
  transform: rotate(-3deg);
}
.sidebar-brand .name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  vertical-align: middle;
}
.sidebar-brand .tagline {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7D8090;
}

.nav-group { padding: 14px 12px; }
.nav-group + .nav-group { border-top: 1px solid rgba(255,255,255,0.06); }
.nav-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #62667A;
  padding: 6px 10px 8px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: #C7CAD3;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--ink-soft); color: #fff; }
.nav-link.active { background: var(--ink-soft); color: #fff; }
.nav-link.active .nav-ico { color: var(--amber); }
.nav-ico { width: 16px; text-align: center; opacity: 0.9; font-size: 14px; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12.5px;
}
.sidebar-foot .user { color: #E5E6EA; font-weight: 500; }
.sidebar-foot a { color: #8C8FA0; }
.sidebar-foot a:hover { color: var(--amber); }

/* --- Zwijanie panelu bocznego -------------------------------------------- */

.sidebar-collapse-btn {
  margin: 4px 12px 8px;
  padding: 7px 0;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #8C8FA0;
  cursor: pointer;
  font-size: 13px;
}
.sidebar-collapse-btn:hover { background: var(--ink-soft); color: #fff; }
.collapse-ico-right { display: none; }

[data-sidebar="collapsed"] .sidebar { width: var(--sidebar-w-collapsed); }
[data-sidebar="collapsed"] .main { margin-left: var(--sidebar-w-collapsed); }
[data-sidebar="collapsed"] .sidebar-brand { padding: 22px 0 18px; text-align: center; }
[data-sidebar="collapsed"] .sidebar-brand .name,
[data-sidebar="collapsed"] .sidebar-brand .tagline,
[data-sidebar="collapsed"] .nav-label,
[data-sidebar="collapsed"] .nav-text,
[data-sidebar="collapsed"] .sidebar-foot .user {
  display: none;
}
[data-sidebar="collapsed"] .sidebar-brand .mark { margin-right: 0; }
[data-sidebar="collapsed"] .nav-link { justify-content: center; padding: 10px 0; }
[data-sidebar="collapsed"] .nav-group { padding-left: 8px; padding-right: 8px; }
[data-sidebar="collapsed"] .sidebar-foot { text-align: center; padding: 14px 8px 18px; }
[data-sidebar="collapsed"] .sidebar-foot a { font-size: 15px; }
[data-sidebar="collapsed"] .collapse-ico-left { display: none; }
[data-sidebar="collapsed"] .collapse-ico-right { display: inline; }

/* --- Przelacznik dzien/noc -------------------------------------------------- */

#theme-toggle { padding: 7px 9px; font-size: 14px; line-height: 1; }
.theme-ico-dark { display: none; }
[data-theme="dark"] .theme-ico-light { display: none; }
[data-theme="dark"] .theme-ico-dark { display: inline; }

/* --- Glowna kolumna ------------------------------------------------------ */

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.18s ease;
}

.topbar {
  height: 60px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .crumb { color: var(--text-muted); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.topbar .crumb strong { color: var(--text); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.env-badge {
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
}

.content { padding: 24px 28px 60px; }

/* ==========================================================================
   KOMPONENTY
   ========================================================================== */

/* --- Karty KPI ------------------------------------------------------------ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-grid.kpi-grid-5 {
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.kpi-grid.kpi-grid-5 .kpi-card {
  padding: 12px 14px;
}
.kpi-grid.kpi-grid-5 .kpi-value {
  font-size: 21px;
}
.kpi-grid.kpi-grid-5 .kpi-label {
  font-size: 11px;
}
.kpi-grid.kpi-grid-5 .kpi-sub {
  font-size: 10.5px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--amber);
}
.kpi-card.accent-teal::before { background: var(--teal); }
.kpi-card.accent-red::before  { background: var(--red); }
.kpi-card.accent-blue::before { background: var(--blue); }

.kpi-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-faint);
}

/* --- Karty / panele -------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-body { padding: 4px 0; }
.panel-body.padded { padding: 16px 18px; }

/* Panel miesiaca w Rachunkach uzywa details/summary zamiast zwyklego
   diva, zeby moc zwijac miesiace poza biezacym - usuwamy domyslny
   trojkat przegladarki i dajemy wlasny, obracajacy sie szewron */
.month-panel-details > summary.panel-head {
  cursor: pointer;
  list-style: none;
}
.month-panel-details > summary.panel-head::-webkit-details-marker { display: none; }
.month-panel-details > summary.panel-head::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  font-size: 11px;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}
.month-panel-details[open] > summary.panel-head::before { transform: rotate(90deg); }

/* --- Tabele danych ---------------------------------------------------------- */

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#items-table { table-layout: fixed; }
#items-table td input[type="text"],
#items-table td input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-body);
  font-size: 13px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
#items-table td input:focus {
  outline: 2px solid var(--amber);
  outline-offset: 0;
  border-color: var(--amber);
}
#items-table td input:disabled,
#items-table td input[readonly] {
  background: transparent;
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
  color: var(--text-muted);
  cursor: default;
}
.data-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr:hover { background: #FBFAF8; }
.data-table td.num, .data-table th.num { text-align: right; }
.data-table a.row-link { color: var(--text); font-weight: 600; }
.data-table a.row-link:hover { color: var(--amber-deep); }

.edit-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
}
.edit-icon-link:hover { background: var(--amber-tint); color: var(--amber-deep); }

.quick-edit-input {
  font-size: 11.5px;
  width: 130px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
}
.quick-edit-input:focus {
  outline: 2px solid var(--amber);
  outline-offset: 0;
  border-color: var(--amber);
}

/* Ikonki akcji (edytuj/kopiuj/PDF) - ustawione pionowo, jedna pod drugim,
   zeby zaoszczedzic miejsce w poziomie. WAZNE: flex jest na WEWNETRZNYM
   divie (.actions-stack), NIE na samym <td> - ustawienie display:flex
   bezposrednio na komorce tabeli lamie model wiersza (powodowalo
   przesuniecie o pol wiersza w gore razem z obramowaniem). */
.actions-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }

/* --- Znaczki statusow (pigulki w stylu stempla pocztowego) ------------------ */

.stamp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.stamp::before {
  content: none;
  display: none;
}
.stamp-no-dot::before { display: none; content: none; }
.stamp-amber { color: var(--amber-deep); background: var(--amber-tint); }
.stamp-teal  { color: var(--teal); background: var(--teal-tint); }
.stamp-red   { color: var(--red); background: var(--red-tint); }
.stamp-blue  { color: var(--blue); background: var(--blue-tint); }
.stamp-green { color: var(--green); background: var(--green-tint); }
.stamp-gray  { color: var(--gray); background: var(--gray-tint); }
.stamp-violet{ color: var(--violet); background: var(--violet-tint); }
.stamp-brown { color: var(--brown); background: var(--brown-tint); }
.stamp-pink  { color: var(--pink); background: var(--pink-tint); }
.stamp-neutral { color: var(--text-muted); background: var(--line-soft); }

/* Kolorowany select statusu (edytowalny w miejscu, ale nadal pokazuje kolor) */
.status-select {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  cursor: pointer;
}
.status-select.tone-green  { color: var(--green);  background: var(--green-tint); }
.status-select.tone-gray   { color: var(--gray);   background: var(--gray-tint); }
.status-select.tone-teal   { color: var(--teal);   background: var(--teal-tint); }
.status-select.tone-red    { color: var(--red);    background: var(--red-tint); }
.status-select.tone-amber  { color: var(--amber-deep); background: var(--amber-tint); }
.status-select.tone-blue   { color: var(--blue);   background: var(--blue-tint); }

/* --- Przyciski --------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: #C8C4BA; background: #FBFAF8; }
.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn-primary:hover { background: var(--ink-soft); border-color: var(--ink-soft); }
.btn-accent {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--ink);
}
.btn-accent:hover { background: var(--amber-deep); border-color: var(--amber-deep); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Wymusza IDENTYCZNY rozmiar obu ikonek przy trackingu (kopiuj/sledz) -
   bez tego roznily sie wizualnie, bo glify emoji (⧉ vs 📦) maja rozna
   naturalna wielkosc we wlasnej czcionce, nawet przy tym samym padding.
   Umieszczone PO .btn-sm w pliku, zeby nadpisac jego padding bez
   uciekania sie do !important. */
.icon-btn-square {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
}

.btn-toggle { font-weight: 500; }
.btn-toggle.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* Kolorowe warianty (np. przyciski komentarza Negatywny/Pozytywny) -
   widoczny kolor nawet gdy nieaktywny, wypelnienie kolorem gdy wybrany. */
.btn-toggle-red { border-color: var(--red); color: var(--red); }
.btn-toggle-red:hover { background: var(--red-tint); }
.btn-toggle-red.active { background: var(--red); border-color: var(--red); color: #fff; }

.btn-toggle-green { border-color: var(--green); color: var(--green); }
.btn-toggle-green:hover { background: var(--green-tint); }
.btn-toggle-green.active { background: var(--green); border-color: var(--green); color: #fff; }

/* --- Formularze ---------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 13.5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--amber);
  outline-offset: 0;
  border-color: var(--amber);
}
/* Pola automatyczne (liczone/wypelniane przez system, nie recznie) -
   wygladaja jak zwykly tekst zamiast wyszarzonego, oramkowanego pola.
   Uzyj tego zamiast inline style="background:var(--line-soft)". */
.field input:disabled, .field input[readonly],
.field textarea:disabled, .field textarea[readonly] {
  background: transparent;
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
  color: var(--text-muted);
  cursor: default;
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 18px;
  background: #FBFAF8;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.filter-bar .field { margin-bottom: 0; min-width: 160px; }

/* --- Paginacja ------------------------------------------------------------------ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.pagination .pages { display: flex; gap: 4px; }
.pagination a, .pagination span.current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
}
.pagination a:hover { background: var(--line-soft); }
.pagination span.current { background: var(--ink); color: #fff; font-weight: 600; }

/* --- Empty state ------------------------------------------------------------------ */

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty-state .glyph {
  font-family: var(--font-mono);
  font-size: 28px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

/* --- Logowanie -------------------------------------------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 28px 28px;
}
.auth-card {
  width: 360px;
  background: var(--surface);
  border-radius: 10px;
  padding: 32px 30px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.auth-card .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  background: var(--amber);
  color: var(--ink);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 16px;
  transform: rotate(-3deg);
}
.auth-card h1 { font-size: 19px; margin-bottom: 4px; }
.auth-card p.sub { color: var(--text-muted); font-size: 13px; margin: 0 0 22px; }
.auth-error {
  background: var(--red-tint);
  color: var(--red);
  border: 1px solid rgba(192,57,43,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}
.auth-notice {
  background: var(--teal-tint);
  color: var(--teal);
  border: 1px solid rgba(47,111,107,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* --- Responsywnosc --------------------------------------------------------------- */

@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid.kpi-grid-5 { grid-template-columns: repeat(3, 1fr); }
}

.mobile-sidebar-toggle-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  padding: 2px 4px;
  line-height: 1;
}
.mobile-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}

@media (max-width: 720px) {
  .kpi-grid.kpi-grid-5 { grid-template-columns: repeat(2, 1fr); }
  .mobile-sidebar-toggle-btn { display: inline-flex; align-items: center; }
  .sidebar {
    display: flex;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    top: 0;
  }
  [data-mobile-sidebar="open"] .sidebar { transform: translateX(0); }
  [data-mobile-sidebar="open"] .mobile-sidebar-backdrop { display: block; }
  .main { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
}

/* --- Kalendarz-popup dla pol daty (dd/mm/rrrr) ------------------------------------ */

.date-field-wrap {
  display: flex;
  align-items: stretch;
  gap: 4px;
  position: relative;
}
.date-field-wrap .date-display { flex: 1; min-width: 0; }
.date-cal-toggle {
  flex-shrink: 0;
  width: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.date-cal-toggle:hover { background: #FBFAF8; border-color: #C8C4BA; }

.date-cal-popup {
  position: absolute;
  top: 100%; left: 0;
  z-index: 40;
  margin-top: 4px;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(23,26,33,0.18);
  padding: 10px;
}
.date-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.date-cal-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  text-transform: capitalize;
}
.date-cal-nav {
  width: 24px; height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  border-radius: var(--radius-sm);
}
.date-cal-nav:hover { background: var(--line-soft); color: var(--text); }

.date-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.date-cal-weekdays {
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
}
.date-cal-day {
  border: none;
  background: transparent;
  padding: 6px 0;
  font-size: 12.5px;
  font-family: var(--font-mono);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
}
.date-cal-day:hover { background: var(--amber-tint); }
.date-cal-day.today { font-weight: 700; color: var(--amber-deep); }
.date-cal-day.selected { background: var(--ink); color: #fff; }

.date-cal-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.date-cal-today, .date-cal-clear {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
}
.date-cal-today:hover, .date-cal-clear:hover { background: var(--line-soft); color: var(--text); }

/* --- Podpowiedzi wyszukiwania produktu (formularz nowego zamowienia) -------------- */

.item-product-search, .component-search {
  width: 100%;
  box-sizing: border-box;
}

.product-suggestions {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(23,26,33,0.15);
  max-height: 240px;
  overflow-y: auto;
  margin-top: 2px;
}
.product-suggestion {
  padding: 8px 11px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
}
.product-suggestion:last-child { border-bottom: none; }
.product-suggestion:hover { background: var(--amber-tint); }
.product-suggestion-empty {
  padding: 8px 11px;
  font-size: 13px;
  color: var(--text-faint);
}
.product-suggestion-new {
  color: var(--amber-deep);
  font-weight: 600;
  border-top: 1px solid var(--line-soft);
  background: var(--amber-tint);
}
.product-suggestion-new:hover { background: var(--amber-tint); filter: brightness(0.97); }

/* --- Dostepnosc -------------------------------------------------------------------- */

a:focus-visible, button:focus-visible, .nav-link:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   PASEK SZYBKICH LINKOW (gora strony, widoczny tylko po zalogowaniu) -
   odpowiednik paska z linkami do bankow/kurierow/narzedzi ze starej strony,
   zarzadzany z /settings.php
   ========================================================================== */

.quicklinks-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--quicklinks-h);
  background: #0F1013;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 300;
  display: flex;
  align-items: center;
}
.quicklinks-inner {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 14px;
  height: 100%;
}

.ql-dropdown { position: relative; display: flex; }
.ql-dropdown-toggle {
  background: transparent;
  border: none;
  color: #9CA0AC;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: color 0.12s ease;
}
.ql-caret { font-size: 9px; opacity: 0.6; }
.ql-dropdown-toggle:hover,
.ql-dropdown.open .ql-dropdown-toggle { color: #fff; }
.ql-dropdown.open .ql-dropdown-toggle { background: rgba(255,255,255,0.06); }

.ql-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%; left: 0;
  min-width: 170px;
  background: #1B1D22;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
  padding: 6px;
  z-index: 301;
}
.ql-dropdown.open .ql-dropdown-menu { display: block; }
.ql-dropdown-menu a {
  display: block;
  padding: 7px 10px;
  font-size: 12.5px;
  color: #D5D7DD;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.ql-dropdown-menu a:hover { background: rgba(255,255,255,0.08); color: #fff; }

.ql-settings-link {
  margin-left: auto;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #6B6E78;
  font-size: 13px;
  flex-shrink: 0;
}
.ql-settings-link:hover { color: #fff; }

[data-theme="dark"] .quicklinks-bar { background: #000; border-bottom-color: rgba(255,255,255,0.06); }

/* ==========================================================================
   NOTATNIK (modal, prywatny per uzytkownik, autozapis)
   ========================================================================== */

.notes-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 26, 33, 0.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.notes-modal {
  width: 100%;
  max-width: 560px;
  height: min(70vh, 640px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.notes-modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
}
.notes-modal-head strong { flex-shrink: 0; }
.notes-close-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  padding: 4px;
}
.notes-close-btn:hover { color: var(--text); }
.notes-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  flex-wrap: nowrap;
}
.notes-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.notes-tab:hover { background: var(--line-soft); }
.notes-tab.active {
  color: var(--text);
  background: var(--paper);
  font-weight: 600;
  border: 1px solid var(--line);
  border-bottom-color: var(--paper);
  margin-bottom: -1px;
}
.notes-tab-close {
  opacity: 0.5;
  font-size: 11px;
  padding: 0 2px;
}
.notes-tab-close:hover { opacity: 1; color: var(--red); }
.notes-tab-add {
  flex-shrink: 0;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 14px;
}
.notes-tab-add:hover { color: var(--amber); }
.chat-channel-tabs {
  display: flex;
  gap: 4px;
}
.chat-channel-tab {
  padding: 5px 10px;
  font-size: 12.5px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  position: relative;
}
.chat-channel-tab:hover { background: var(--line-soft); }
.chat-channel-tab.active { background: var(--amber-tint); color: var(--amber-deep); font-weight: 600; }
.chat-tab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  min-width: 14px;
  text-align: center;
}
.order-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px 24px;
}
.order-info-item {
  min-width: 0;
}
.order-info-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
.order-info-value {
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}
.order-info-divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}
.address-block {
  background: var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.address-block-locker {
  background: var(--amber-tint);
}
.supplier-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
}
.purchase-summary-box {
  display: flex;
  gap: 24px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-top: 4px;
}
.purchase-summary-item {
  flex: 1;
}
.online-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
}
.online-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-display);
  border: 2px solid var(--surface);
  margin-left: -6px;
}
.online-dot:first-child { margin-left: 0; }

.chat-unread-badge {
  display: none;
  position: absolute;
  top: 0px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2.5px 5px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface), 0 0 6px rgba(192,57,43,0.5);
  animation: chat-badge-pulse 2.4s ease-in-out infinite;
}
@keyframes chat-badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-unread-badge { animation: none; }
}
#notes-textarea {
  flex: 1;
  border: none;
  outline: none;
  overflow-y: auto;
  padding: 16px;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
}
#notes-textarea:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
}
.notes-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--line-soft);
}
.notes-toolbar-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
}
.notes-toolbar-btn.active,
.notes-toolbar-btn:hover {
  background: var(--amber-tint);
  border-color: var(--amber);
}
.notes-toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 2px;
}
.notes-color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  outline: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
}
.notes-color-swatch:hover {
  outline-color: var(--text-muted);
}

/* ==========================================================================
   OPLATY ALLEGRO - lista wierszy w dwoch kolumnach zamiast siatki kart
   ========================================================================== */

.fee-list-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
@media (max-width: 720px) {
  .fee-list-columns { grid-template-columns: 1fr; }
}
.fee-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.fee-row-shop {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 600;
  font-size: 12.5px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fee-amount-input {
  width: 90px;
  flex-shrink: 0;
  padding: 5px 7px !important;
  font-size: 12.5px;
}
.fee-row-status {
  width: 76px;
  flex-shrink: 0;
  font-size: 11px;
  text-align: center;
}
.fee-row .fee-paid-toggle {
  flex-shrink: 0;
  padding: 4px 8px;
  font-size: 11px;
}

/* ==========================================================================
   CZAT ZESPOLOWY (modal, wspolny kanal, zalaczniki plikow)
   ========================================================================== */

.chat-modal {
  width: 100%;
  max-width: 480px;
  height: min(80vh, 680px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--paper);
}
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 84%;
}
.chat-msg.chat-msg-mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
  flex-shrink: 0;
}
.chat-bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.45;
  min-width: 0;
}
.chat-msg-mine .chat-bubble {
  background: var(--amber);
  color: #fff;
  border-color: var(--amber);
}
.chat-msg-mine .chat-bubble .chat-meta { color: rgba(255,255,255,0.75); }
.chat-read-tick {
  margin-left: auto;
  font-size: 11px;
  color: rgba(255,255,255,0.55);
}
.chat-read-tick[data-read="1"] { color: #6FD8FF; }
.chat-bubble .chat-meta {
  display: flex;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-faint);
  margin-bottom: 3px;
  font-family: var(--font-display);
  font-weight: 600;
}
.chat-bubble-body { white-space: pre-wrap; word-break: break-word; }
.chat-bubble-body a { color: inherit; text-decoration: underline; word-break: break-all; }
.chat-msg-mine .chat-bubble-body a { color: #fff; }
.chat-attachment-link {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 8px;
  font-size: 12px;
  text-decoration: underline;
}
.chat-msg-mine .chat-attachment-link { background: rgba(255,255,255,0.18); }
.chat-day-divider {
  text-align: center;
  font-size: 10.5px;
  color: var(--text-faint);
  margin: 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.chat-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 17px;
  padding: 6px;
  color: var(--text-muted);
  flex-shrink: 0;
  border-radius: 50%;
}
.chat-icon-btn:hover { background: var(--line-soft); }
.chat-send-btn { color: var(--amber); }
#chat-body-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 13.5px;
  max-height: 100px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}
#chat-body-input:focus { border-color: var(--amber); }
.chat-attachment-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  background: var(--amber-tint);
}
.chat-attachment-preview button {
  background: none; border: none; cursor: pointer; color: var(--red); font-size: 13px;
}
.chat-empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.chat-day-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0 10px;
}
.chat-day-separator span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--line-soft);
  padding: 3px 12px;
  border-radius: 999px;
}
