/* Widok mobilny (telefony od 360 px). Plik ladowany TYLKO przez
   <link media="(max-width: 768px)"> - na komputerze przegladarka w ogole go nie stosuje,
   wiec nic tutaj nie moze zmienic widoku desktopowego. Kolory wylacznie ze zmiennych
   motywu (style.css), zeby jasny/ciemny dzialal tak samo jak na komputerze. */

/* ---------- Szkielet: wysokosc ekranu i przewijanie ---------- */
/* 100dvh zamiast 100vh - na telefonie 100vh liczy sie bez paska adresu i dol panelu
   chowal sie pod nim */
.layout, .content { height: 100dvh; }
main { padding: 1rem 0.75rem calc(1.5rem + env(safe-area-inset-bottom)); overflow-x: hidden; }
h1 { font-size: 1.2rem; }
.subtitle { margin-bottom: 1rem; }

/* ---------- Menu boczne: wysuwane spod przycisku ☰ ---------- */
.sidebar,
.sidebar.collapsed {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 1000;
  width: min(82vw, 300px); height: 100dvh; padding: 1rem 0.75rem calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-100%); transition: transform 0.22s ease;
  box-shadow: none;
}
body.mobile-menu-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, 0.45); }
/* Tryb "zwiniety" z komputera (zapamietany w localStorage) nie ma sensu w wysuwanym menu */
.sidebar.collapsed .logo-text, .sidebar.collapsed .nav-label, .sidebar.collapsed .nav-group-arrow { display: revert; }
.sidebar.collapsed .sidebar-header { flex-direction: row; padding: 0.5rem 0.6rem 1rem; }
.sidebar.collapsed .nav-item, .sidebar.collapsed .nav-group-header { justify-content: flex-start; padding: 0.6rem 0.75rem; gap: 0.7rem; }
.mobile-menu-backdrop {
  display: block; position: fixed; inset: 0; z-index: 999;
  background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.22s ease;
}
body.mobile-menu-open .mobile-menu-backdrop { opacity: 1; pointer-events: auto; }
/* Pozycje menu wygodne do klikniecia palcem */
.nav-item, .nav-subitem { min-height: 44px; display: flex; align-items: center; font-size: 0.95rem; }

/* ---------- Gorny pasek ---------- */
.topbar { height: auto; grid-template-columns: auto 1fr auto; gap: 0.5rem; padding: 0.5rem 0.75rem; padding-top: calc(0.5rem + env(safe-area-inset-top)); }
#topbarSidebarToggle { display: none; }
.mobile-menu-btn { display: flex; width: 44px; height: 44px; font-size: 1.35rem; border-radius: 4px; }
.topbar-icon-btn { width: 40px; height: 40px; }
.topbar-right { gap: 0.35rem; }
.topbar-right > .topbar-icon-btn:disabled { display: none; } /* "?" - placeholder bez akcji */
#userMenuName, .user-menu-btn .status-group-arrow { display: none; }
.user-menu-btn { padding: 0.2rem; min-height: 44px; }
.topbar-search-input-wrap { padding: 0.35rem 0.35rem 0.35rem 0.75rem; }
.topbar-search-input-wrap .search-icon { display: none; }
#globalSearchSubmit { width: 34px; height: 34px; }
.status-flyout { max-width: calc(100vw - 1.5rem); }
.user-menu-flyout { right: 0; }
#globalSearchFlyout.global-search-flyout { position: fixed; left: 0.75rem; right: 0.75rem; width: auto; max-width: none; }
.global-search-flyout-cols { grid-template-columns: 1fr; gap: 0.5rem; }
.global-search-flyout-cols > div + div { border-left: 0; border-top: 1px solid var(--border); padding-top: 0.5rem; }

/* ---------- Palec zamiast myszy: pola i przyciski ---------- */
/* 16px - mniejsza czcionka w polu sprawia, ze iPhone przybliza strone przy wpisywaniu */
input, select, textarea { font-size: 16px; min-height: 44px; }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 20px; height: 20px; }
button, .btn { min-height: 44px; }
/* Male okragle przyciski-ikonki zostaja okragle (wieksze, ale bez rozciagania w owal) */
.nav-section-add { min-height: 0; width: 34px; height: 34px; }

/* Zadnej tabeli/karty szerszej niz ekran - w ostatecznosci przewijana wewnatrz siebie */
.panel-card { max-width: 100% !important; padding: 1rem; }
table { max-width: 100%; }
img, svg, canvas { max-width: 100%; }

/* ---------- Logowanie ---------- */
body.login-page { height: 100dvh; padding: 1rem; }
body.login-page .card { width: 100%; max-width: 400px; padding: 2rem 1.25rem; }
body.login-page button { min-height: 48px; font-size: 1rem; }

/* ---------- Pulpit (Strona glowna) ---------- */
/* Liczniki obok siebie zamiast dwoch kafli na pol ekranu; wykres pod nimi na cala szerokosc */
.dh-top { grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 0.6rem; }
.dh-chart { grid-column: 1 / -1; height: 190px; padding: 0.6rem; }
.dh-card { padding: 0.9rem 1rem; }
.dh-num { min-height: 96px; }
.dh-big { font-size: 2.4rem; }
.dh-numlabel { font-size: 0.85rem; text-align: center; }
/* "Wymaga uwagi" - kazda pozycja to wygodny cel dla palca */
.dh-att { min-height: 56px; padding: 0.7rem 0.1rem; gap: 0.7rem; }
.dh-att-count { min-width: 2.2rem; font-size: 0.9rem; }
.dh-att-label { font-size: 0.95rem; min-width: 0; }

/* ---------- Lista zamowien ---------- */
.mobile-only { display: inline-flex; align-items: center; justify-content: center; }

/* Listy statusow (Zamowienia, Zwroty): panel wysuwany od dolu zamiast kolumny obok tabeli.
   Otwierany przyciskiem [data-mobile-sheet] - patrz closeMobileSheets w dashboard.js */
.orders-shell.active { display: block; }
.orders-status-panel, .rt-status-panel {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 950;
  width: auto !important; min-height: 0; max-height: 75dvh; margin: 0; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform 0.22s ease; visibility: hidden;
}
.mobile-sheet-open { transform: none; visibility: visible; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45); }
/* Przyciemnione tlo pod panelem od dolu - prawdziwa warstwa (nie cien), zeby dotkniecie obok
   panelu tylko go zamykalo, a nie klikalo tez w link/przycisk pod spodem */
body.mobile-sheet-active::after,
body:has(#statusDetailFlyout.open)::after {
  content: ''; position: fixed; inset: 0; z-index: 930; background: rgba(0, 0, 0, 0.5);
}
.orders-status-panel .order-status-item, .orders-status-panel .status-group-header,
.rt-status-panel .order-status-item, .rt-status-panel .status-group-header { min-height: 44px; font-size: 0.95rem; }

/* Naglowek listy: tytul w pierwszym wierszu, Statusy + Filtrowanie pod nim */
#view-orders > h1, #view-orders > .subtitle { display: none; }
.orders-list-card { padding: 0.75rem; border: none; background: transparent; }
.orders-list-head { flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem !important; }
.orders-list-head > div:first-child { flex: 1 1 100%; }
.orders-list-head h2 { font-size: 1.15rem; }
.orders-list-head > button { flex: 1 1 auto; white-space: nowrap; padding-left: 0.75rem; padding-right: 0.75rem; }
#mobileStatusBtn { flex: 0 0 auto; }

/* Filtry w jednej kolumnie */
.orders-filter-grid { grid-template-columns: minmax(0, 1fr) !important; }
/* zakresy od-do maja na komputerze "span 2" - przy jednej kolumnie tworzylyby niewidoczna druga */
.orders-filter-grid > * { grid-column: 1 / -1 !important; }
.pl-range label { min-width: 0; }
.orders-filter-panel .pl-range input { width: 100%; min-width: 0; }
.orders-filter-panel { padding: 0.75rem; }
.orders-filter-panel > div:last-child { flex-wrap: wrap; }
.orders-filter-panel > div:last-child > button { flex: 1 1 0; }
.or-filter-builder { grid-template-columns: 1fr; gap: 0.75rem; }
.or-filter-row { flex-wrap: wrap; }
.or-filter-row .or-filter-field, .or-filter-row .or-filter-operator { flex: 1 1 45%; }
.or-filter-value-wrap { flex: 1 1 100%; }

/* Pasek narzedzi: bez placeholderow "Wkrotce", przyciski wieksze i zawijane */
.orders-toolbar { flex-wrap: wrap; gap: 0.4rem; }
.orders-toolbar > .toolbar-icon-btn:disabled { display: none; }
.orders-toolbar .toolbar-icon-btn, .orders-toolbar .toolbar-split-btn { min-width: 44px; height: 44px; }
.orders-toolbar .toolbar-flyout-anchor { position: static; }
.orders-toolbar { position: relative; }
.orders-toolbar .select-menu, .orders-toolbar .status-flyout { left: 0; right: 0; min-width: 0; max-height: 60dvh; overflow-y: auto; }
.select-menu button { min-height: 44px; }

/* Wiersze tabeli jako karty */
.orders-list-card table, .orders-list-card tbody { display: block; }
.orders-list-card thead { display: none; }
.orders-list-card tbody tr {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.35rem 0.6rem; align-items: start;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.75rem; margin-bottom: 0.6rem;
}
.orders-list-card tbody td { display: block; padding: 0; border: none; min-width: 0; font-size: 0.9rem; }
/* 1 checkbox | 2 numer | 6 kwota  -> pierwszy wiersz karty */
.orders-list-card tbody td:nth-child(1) { grid-column: 1; grid-row: 1; align-self: center; }
.orders-list-card tbody td:nth-child(2) { grid-column: 2; grid-row: 1; align-self: center; }
.orders-list-card tbody td:nth-child(6) { grid-column: 3; grid-row: 1; align-self: center; font-weight: 700; font-size: 1rem; white-space: nowrap; }
/* reszta na cala szerokosc karty */
.orders-list-card tbody td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; }
.orders-list-card tbody td:nth-child(7) { grid-column: 1 / -1; grid-row: 3; }
.orders-list-card tbody td:nth-child(4) { grid-column: 1 / -1; grid-row: 4; padding-top: 0.4rem; border-top: 1px solid var(--border); }
.orders-list-card tbody td:nth-child(5) { grid-column: 1 / -1; grid-row: 5; font-size: 0.85rem; color: var(--text-muted); }
.orders-list-card tbody td:nth-child(5)::before { content: 'Uwagi kupującego: '; font-weight: 600; }
.orders-list-card tbody td.order-note-cell.is-empty { display: none; }
.orders-list-card tbody td:nth-child(8) { grid-column: 1 / -1; grid-row: 6; display: flex; flex-wrap: wrap; gap: 0 0.8rem; }
.orders-list-card tbody td:nth-child(8) .status-changed-date::before { content: 'w statusie: '; }
.orders-list-card .order-checkbox { width: 24px; height: 24px; }
.orders-list-card .order-num-cell { display: flex; align-items: center; gap: 0.3rem; }
.orders-list-card .order-star { min-height: 0; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; }
/* Numer zamowienia = glowne wejscie w szczegoly: duzy cel dla palca */
.orders-list-card .order-number-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.4rem; font-size: 1.05rem; font-weight: 700; }
.orders-list-card .order-row-item { gap: 0.6rem; }
.orders-list-card .order-row-item + .order-row-item { margin-top: 0.4rem; }
.orders-list-card .order-meta-line { overflow-wrap: anywhere; }
.orders-pagination { flex-wrap: wrap; gap: 0.6rem; justify-content: center; }
.orders-pagination > div { flex: 1 1 100%; }
.orders-pagination button { flex: 1; }

/* ---------- Szczegoly zamowienia ---------- */
/* Kolejnosc na telefonie: naglowek -> STATUS (najczestsza akcja w terenie) -> informacje ->
   przedmioty -> adresy -> reszta. Na komputerze uklad zostaje z dashboard.html. */
#view-order-detail.active { display: flex; flex-direction: column; }
#view-order-detail > * { order: 10; }
#view-order-detail > .od-head { order: 0; }
#view-order-detail > .subtitle { order: 2; }
#view-order-detail > .od-archive-banner { order: 1; }
#view-order-detail > .od-main-card { order: 3; }
#view-order-detail > .od-items-actions { order: 4; }
#view-order-detail > .od-items-card { order: 4; margin-top: 0.75rem; }
#view-order-detail > #oiEditPanel { order: 5; }
#view-order-detail > .detail-grid-3 { order: 6; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 0.25rem; font-size: 0.95rem; }
#orderTitle { font-size: 1.1rem; overflow-wrap: anywhere; }
#orderDetailStarBtn { min-height: 0; width: 36px; height: 36px; justify-content: center; align-items: center; }
#view-order-detail .panel-card { margin-top: 0.75rem !important; }
#view-order-detail h2 { font-size: 1.05rem; }

.detail-grid, .detail-grid-3 { display: flex; flex-direction: column; gap: 0; margin-top: 0; }
.detail-grid > .od-status-card { order: -1; }

/* Wiersze "etykieta: wartosc" - wezsza etykieta, wartosc na reszte szerokosci */
.field-row { gap: 0.5rem; margin-bottom: 0.35rem; flex-wrap: wrap; }
.field-row label { width: 104px; font-size: 0.8rem; }
.field-row > :not(label) { min-width: 0; }
.field-row input[type="text"], .field-row textarea, .field-row select { flex: 1 1 0; min-width: 0; }
.icon-btn-edit { min-height: 0; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; }
#paidView, #paidEdit { flex-wrap: wrap; }

/* Status: przycisk wyboru i "Przenies" na cala szerokosc */
.od-status-row label { width: 100%; }
.od-status-controls { flex: 1 1 100%; flex-direction: column; align-items: stretch !important; }
.od-status-controls .toolbar-flyout-anchor { position: static; }
.status-current-btn { width: 100%; min-height: 48px; font-size: 1rem; }
#confirmStatusBtn { width: 100%; min-height: 48px; font-size: 1rem; background: var(--accent); color: var(--accent-text); }
/* Lista statusow jako panel od dolu ekranu */
#statusDetailFlyout {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 960;
  width: auto !important; max-width: none; max-height: 70dvh; margin: 0;
  border-radius: 16px 16px 0 0; padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45);
}
#statusDetailFlyout .order-status-item, #statusDetailFlyout .status-group-header { min-height: 44px; font-size: 0.95rem; }

/* Przedmioty jako karty: miniatura | nazwa | menu, pod spodem ilosc/cena/VAT/waga/ID */
.od-items-card table, .od-items-card tbody { display: block; }
.od-items-card thead { display: none; }
.od-items-card tbody tr {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.3rem 0.8rem;
  padding: 0.7rem 0; border-bottom: 1px solid var(--border);
}
.od-items-card tbody td { display: block; padding: 0; border: none; font-size: 0.85rem; }
.od-items-card tbody td[colspan] { flex: 1 1 100%; }
.od-items-card tbody td:nth-child(1) { flex: 0 0 44px; }
.od-items-card tbody td:nth-child(3) { flex: 1 1 calc(100% - 44px - 44px - 1.6rem); order: 1; font-size: 0.92rem; overflow-wrap: anywhere; }
.od-items-card tbody td:nth-child(8) { display: none; } /* Data - na telefonie pomijana */
.od-items-card tbody td:nth-child(9) { flex: 0 0 auto; order: 2; }
.od-items-card tbody td:nth-child(2) { order: 7; color: var(--text-muted); }
.od-items-card tbody td:nth-child(4) { order: 3; padding-left: calc(44px + 0.8rem); font-weight: 700; }
.od-items-card tbody td:nth-child(4)::after { content: ' szt.'; font-weight: 400; }
.od-items-card tbody td:nth-child(5) { order: 4; font-weight: 700; }
.od-items-card tbody td:nth-child(6) { order: 5; color: var(--text-muted); }
.od-items-card tbody td:nth-child(6)::before { content: 'VAT '; }
.od-items-card tbody td:nth-child(7) { order: 6; color: var(--text-muted); }
.od-items-card tbody td:nth-child(7)::before { content: 'waga '; }
.od-items-card .pset-dots { width: 40px; height: 40px; min-height: 0; }
#oiAddBtn { width: 100%; }

/* Panel edycji pozycji - pola na szerokosc ekranu zamiast stalych szerokosci w px */
#oiEditPanel > div { gap: 0.75rem !important; }
#oiEditPanel > div > div { flex: 1 1 calc(50% - 0.75rem); min-width: 0 !important; }
#oiEditPanel input, #oiEditPanel select { width: 100% !important; }
#oiEditPanel > div:last-child > button { flex: 1; }
.tile-actions > button { flex: 1; }

/* ---------- Lista produktow (Produkty -> lista) ---------- */
#view-products .panel-card { padding: 0; }
.pl-topbar { padding: 0.75rem; }
.pl-topbar > .pl-field { flex: 1 1 100%; }
.pl-topbar-right { margin-left: 0; flex: 1 1 100%; flex-wrap: wrap; }
.pl-topbar-right > .pl-pill { flex: 1 1 auto; min-height: 44px; justify-content: center; }
.pl-icon-btn { min-width: 44px; min-height: 44px; }
.pl-filters { padding: 0.75rem !important; }
.pl-filter-grid { grid-template-columns: minmax(0, 1fr) !important; }
.pl-filter-grid > * { grid-column: 1 / -1 !important; }
.pl-filter-actions { flex-wrap: wrap; }
.pl-filter-actions > .pl-pill:disabled { display: none; }
.pl-filter-actions > .pl-pill { flex: 1 1 auto; min-height: 44px; }
.pl-toolbar { padding: 0.6rem 0.75rem; gap: 0.6rem; }
.pl-toolbar-left { flex-wrap: wrap; flex: 1 1 100%; }
.pl-toolbar-right { margin-left: 0; flex: 1 1 100%; justify-content: space-between; flex-wrap: wrap; }
.pl-tbtn { min-height: 44px; min-width: 44px; justify-content: center; }
.pl-ops { position: static; }
.pl-toolbar { position: relative; }
.pl-ops-menu { left: 0.5rem !important; right: 0.5rem !important; min-width: 0 !important; max-height: 60dvh; overflow-y: auto; }
.pl-ops-menu button { min-height: 44px; }
.pl-pager { margin: 0; }
.pl-pager button { min-width: 40px; }

/* Produkt jako karta: miniatura | nazwa + menu / stan + cena; pod spodem warianty i integracje */
#plTable, #plTable tbody { display: block; }
#plTable thead { display: none; }
#plTable tbody tr {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 0.3rem 0.7rem; align-items: center;
  padding: 0.75rem; border-bottom: 1px solid var(--border);
}
#plTable tbody td { display: block; padding: 0 !important; border: none; width: auto; min-width: 0; }
#plTable tbody td.pl-thumb { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
#plTable tbody td:nth-child(3) { grid-column: 2; grid-row: 1; overflow-wrap: anywhere; }
#plTable tbody td:nth-child(8) { grid-column: 3; grid-row: 1; align-self: start; }
#plTable tbody td:nth-child(5) { grid-column: 2; grid-row: 2; text-align: left; }
#plTable tbody td:nth-child(6) { grid-column: 3; grid-row: 2; font-weight: 700; }
#plTable tbody td.pl-check { grid-column: 1; grid-row: 3; display: flex; align-items: center; gap: 0.2rem; }
#plTable tbody td:nth-child(4) { grid-column: 2 / -1; grid-row: 3; }
#plTable tbody td:nth-child(7) { grid-column: 1 / -1; grid-row: 4; }
#plTable tbody td:nth-child(7):not(:has(*:not(:empty))) { display: none; }
#plTable .pl-thumb img, #plTable .pl-noimg { width: 64px; height: 64px; }
#plTable .pl-name { font-size: 0.95rem; }
#plTable .pl-cb { width: 22px; height: 22px; margin-right: 0.2rem; }
#plTable .pl-star { min-height: 0; width: 36px; height: 36px; }
#plTable .pset-dots { width: 40px; height: 40px; min-height: 0; }
#plTable .pl-variant-row { background: rgba(var(--overlay-rgb), 0.03); padding-left: 1.5rem; }

/* ---------- Zwroty ---------- */
#view-returns > h1, #view-returns > .subtitle, #view-customers > h1, #view-customers > .subtitle { display: none; }
.cu-list-card { padding: 0.75rem; border: none; background: transparent; }
.rt-layout { display: block !important; }
.rt-list-card { padding: 0.75rem; border: none; background: transparent; }
.rt-list-head > h2 { flex: 1 1 100%; font-size: 1.15rem; }
.rt-list-head > button { flex: 0 0 auto; }
#rtSearch, #cuSearch { flex: 1 1 0; min-width: 0; }
#view-returns .ao-tabs { margin-bottom: 0.5rem; }
#view-returns .ao-tabs button { padding: 0.7rem 1rem; min-height: 44px; }
/* Zwrot jako karta - te same zasady co karta zamowienia */
.rt-list-card table, .rt-list-card tbody { display: block; }
.rt-list-card thead { display: none; }
.rt-list-card tbody tr {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 0.35rem 0.5rem; align-items: center;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0.75rem; margin-bottom: 0.6rem;
}
.rt-list-card tbody td { display: block; padding: 0 !important; border: none; min-width: 0; font-size: 0.9rem; }
.rt-list-card tbody td:nth-child(1) { grid-column: 1; grid-row: 1; }
.rt-list-card tbody td:nth-child(2) { grid-column: 2; grid-row: 1; }
.rt-list-card tbody td:nth-child(3) { grid-column: 3; grid-row: 1; overflow-wrap: anywhere; }
.rt-list-card tbody td:nth-child(6) { grid-column: 4; grid-row: 1; font-weight: 700; white-space: nowrap; }
.rt-list-card tbody td:nth-child(4) { grid-column: 1 / -1; grid-row: 2; }
.rt-list-card tbody td:nth-child(7) { grid-column: 1 / -1; grid-row: 3; }
.rt-list-card tbody td:nth-child(5) { grid-column: 1 / -1; grid-row: 4; padding-top: 0.4rem !important; border-top: 1px solid var(--border); }
.rt-list-card tbody td:nth-child(8) { grid-column: 1 / -1; grid-row: 5; color: var(--text-muted); font-size: 0.82rem; }
.rt-list-card .return-checkbox { width: 24px; height: 24px; }
.rt-list-card .order-star { min-height: 0; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; }
.rt-list-card td:nth-child(3) > .order-number-link { display: inline-flex; align-items: center; min-height: 40px; font-weight: 700; font-size: 1rem; }

/* ---------- Zabezpieczenie dla widokow jeszcze nieprzerobionych na karty ---------- */
/* Szeroka tabela przewija sie w bok WEWNATRZ siebie, a nie cala strona. Widoki z kartami
   (zamowienia, szczegoly, produkty, zwroty) maja juz wlasny uklad i sa wylaczone. */
main table:not(#plTable):not(.orders-list-card table):not(.od-items-card table):not(.rt-list-card table):not(.od-ship-table):not(.rd-items) {
  display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
}

/* Ustawienia produktow: menu nad trescia, kolumna moze sie zwezic do szerokosci ekranu */
.pset-layout { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }

/* ---------- Pociagnij w dol, aby odswiezyc (dashboard.js: initPullToRefresh) ---------- */
.pull-refresh {
  display: flex; align-items: center; gap: 0.5rem;
  position: fixed; left: 50%; top: 60px; z-index: 900;
  transform: translate(-50%, -56px); opacity: 0; pointer-events: none;
  padding: 0.5rem 0.9rem; border-radius: 999px;
  background: var(--card-bg); border: 1px solid var(--border); color: var(--text-muted);
  font-size: 0.85rem; white-space: nowrap; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.pull-refresh.pulling { transition: none; }
.pull-refresh-icon { display: inline-block; font-size: 1rem; transition: transform 0.2s ease; }
.pull-refresh.ready { color: var(--accent); border-color: var(--accent); }
.pull-refresh.ready .pull-refresh-icon { transform: rotate(180deg); }
.pull-refresh.refreshing { opacity: 1; color: var(--accent); }
.pull-refresh.refreshing .pull-refresh-icon { animation: pull-refresh-spin 0.8s linear infinite; }
@keyframes pull-refresh-spin { to { transform: rotate(360deg); } }

/* Karta zamowienia -> Wymiana wiadomosci: panel "Napisz wiadomosc" - etykiety nad polami */
.omc-panel { margin: 1rem -1rem -1rem; padding: 1rem; }
.omc-row, .omc-row-line + .omc-row-line { flex-direction: column; align-items: stretch; gap: 0.35rem; padding-left: 0; }
.omc-row > label, .omc-row-line + .omc-row-line > label { width: auto; }
.omc-radios label { width: auto; margin-right: 2rem; }
.omc-dd-menu { position: fixed; left: 8px; right: 8px; top: auto; flex-wrap: wrap; justify-content: center; }
.omc-editor .ql-toolbar.ql-snow .ql-formats { height: 36px; }
.omc-editor .ql-toolbar.ql-snow button { min-height: 0; width: 34px; height: 34px; }
.omc-editor .ql-toolbar.ql-snow .omc-swatch { width: 26px; height: 26px; }
#omcToolbar .ql-picker { height: 34px; }
.omc-source { font-size: 16px; min-height: 0; }

/* Szablony E-mail/SMS -> Konta e-mail */
.ea-table thead { display: none; }
.ea-table, .ea-table tbody { display: block; width: 100%; }
.ea-table td:nth-child(2), .ea-table td:nth-child(3) { min-width: 0; overflow-wrap: anywhere; }
.ea-table tr { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto auto auto; grid-template-areas: "drag email edit copy del" "drag name edit copy del" "drag test test test test"; gap: 0.2rem 0.4rem; padding: 0.75rem 0.5rem; border-bottom: 1px solid var(--border); }
.ea-table td { padding: 0 !important; border: none; }
.ea-table td:nth-child(1) { grid-area: drag; } .ea-table td:nth-child(2) { grid-area: email; font-weight: 600; }
.ea-table td:nth-child(3) { grid-area: name; } .ea-table td:nth-child(4) { grid-area: test; text-align: left !important; margin-top: 0.4rem; }
.ea-table td:nth-child(5) { grid-area: edit; } .ea-table td:nth-child(6) { grid-area: copy; } .ea-table td:nth-child(7) { grid-area: del; }
.ea-icon-btn { width: 38px; height: 38px; min-height: 0; }
.ea-table .ea-col-icon { width: auto; }
.ea-row-result { margin-left: 0; text-align: left; }
.ea-settings { padding: 1rem; }
.ea-form-row { grid-template-columns: 1fr; gap: 0.35rem; }
.ea-form-row > label { text-align: left; padding-top: 0; }
.ea-actions { justify-content: stretch; } .ea-add-btn { width: 100%; justify-content: center; }
.ea-google-btn { width: 100%; justify-content: center; }
.ov-mail-menu { min-width: 0; width: min(92vw, 340px); }
.oda-bar { margin: 0 0 0.75rem; }
.oda-menu { min-width: 0; width: min(92vw, 320px); }
.oda-li-form { width: 100%; }
.oda-li-form button { flex: 1; }
.xf-row-pencil { left: calc(104px - 0.55rem); }

/* ---------- Zamowienia jak w BaseLinkerze na telefonie ----------
   Dodaj zamowienie na cala szerokosc, pod nim "Statusy / Rozwin statusy" - lista statusow
   rozwija sie W MIEJSCU (nie jako panel od dolu), grupy i statusy ulozone obok siebie.
   Tylko na liscie zamowien - w szczegolach zamowienia panel jest ukryty. */
#ordersStatusPanel {
  position: static; transform: none; visibility: visible; max-height: none; overflow: visible;
  border: none; border-radius: 0; background: transparent; box-shadow: none; padding: 0.75rem 0.75rem 0.25rem;
}
.orders-shell:not(:has(#view-orders.active)) #ordersStatusPanel { display: none; }
#mobileStatusBtn { display: none; }
#ordersStatusPanel .add-order-btn { width: 100%; justify-content: center; border-radius: 999px; min-height: 48px; font-size: 1.05rem; margin: 0; }
.mo-st-head { display: flex; justify-content: space-between; align-items: center; padding: 0.9rem 0.1rem 0.4rem; }
.mo-st-head > span { font-size: 1.15rem; font-weight: 600; color: var(--text-muted); }
#moStToggle { display: inline-flex; align-items: center; gap: 0.5rem; background: none; border: none; padding: 0.3rem 0; min-height: 40px; color: var(--text-muted); font-size: 0.98rem; font-weight: 500; }
.mo-st-chev { width: 38px; height: 38px; border-radius: 50%; background: var(--card-bg); display: inline-flex; align-items: center; justify-content: center; transition: transform 0.15s; }
.mo-st-chev svg { width: 18px; height: 18px; }
#ordersStatusPanel.mo-st-open .mo-st-chev { transform: rotate(180deg); }
#ordersStatusPanel:not(.mo-st-open) #orderStatusList { display: none; }
/* Uklad w linii: grupa (naglowek + jej statusy) w jednym ciagu tekstu, kazda grupa od nowej linii
   (::after "\A" po statusach grupy) - statusy zawijaja sie jak slowa */
#orderStatusList { display: block; padding: 0.2rem 0.1rem 0.6rem; line-height: 1; }
#orderStatusList .status-group-items { display: inline; }
#orderStatusList .status-group-items::after { content: '\A'; white-space: pre; }
#orderStatusList .status-group-items.collapsed > * { display: none; }
#orderStatusList .status-group-header { display: inline-flex; vertical-align: middle; margin: 0 0.7rem 0 0; padding: 0.35rem 0; min-height: 40px; font-size: 0.98rem; font-weight: 600; border: none; background: none; color: var(--text); }
#orderStatusList .status-group-header .status-group-right { display: inline-flex; flex-direction: row-reverse; align-items: center; gap: 0.2rem; margin-left: 0.3rem; }
#orderStatusList .status-group-header .status-group-arrow { display: inline-flex; }
#orderStatusList .status-group-header .status-group-arrow svg { width: 14px; height: 14px; }
#orderStatusList .order-status-item { display: inline-flex; vertical-align: middle; align-items: center; margin-right: 0.5rem !important; min-height: 40px; padding: 0.3rem 0.45rem; margin: 0; width: auto; border-radius: 4px; font-size: 0.98rem; background: none; border: none; }
#orderStatusList .order-status-item.active { background: var(--border); }
#orderStatusList .ov-st-all { display: flex; }
#orderStatusList .order-archive-item { display: inline-flex; }
#orderStatusList .order-archive-item { border: none; padding-top: 0.3rem; }

/* Naglowek listy: kwadrat statusu + nazwa, po prawej okragly przycisk filtrowania */
.orders-list-card { background: var(--card-bg); border-radius: 4px 4px 0 0; padding: 0.75rem 0.6rem; }
.orders-list-head { flex-wrap: nowrap; }
.orders-list-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.orders-list-head h2 { font-size: 1.2rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#toggleFiltersBtn { flex: 0 0 auto; width: 46px; height: 46px; padding: 0; border-radius: 50%; background: none; border: 1px solid var(--border); }
#toggleFiltersBtn .ofb-ico { display: block; width: 22px; height: 22px; }
#toggleFiltersBtn .ofb-txt, #toggleFiltersBtn .pl-caret { display: none; }

/* Stronicowanie: "1-4 z 4 pozycji" + strzalki w jednym wierszu (jak w BL) */
.orders-pagination { flex-wrap: nowrap; justify-content: flex-end; align-items: center; gap: 0.8rem; }
.orders-pagination > div { flex: 0 0 auto; gap: 0 !important; }
.orders-pagination #paginationInfo { color: var(--text-muted); }
.orders-pagination button { flex: 0 0 auto; width: 46px; height: 40px; padding: 0; border-radius: 0; }
.orders-pagination button:first-child { border-radius: 999px 0 0 999px; }
.orders-pagination button:last-child { border-radius: 0 999px 999px 0; border-left: none; }
.orders-pagination .pg-txt { display: none; }
.orders-pagination .pg-ico { width: 20px; height: 20px; }

/* Wiersze zamowien gesciej: bez osobnych kart, oddzielone linia */
.orders-list-card tbody tr { border: none; border-bottom: 1px solid var(--border); border-radius: 0; margin: 0; padding: 0.6rem 0.15rem; gap: 0.25rem 0.5rem; background: transparent; }
.orders-list-card tbody tr:first-child { border-top: 1px solid var(--border); }
.orders-list-card .order-number-link { min-height: 36px; padding: 0 0.2rem; }
.orders-list-card .order-star { width: 30px; height: 30px; }
.orders-toolbar .toolbar-icon-btn, .orders-toolbar .toolbar-split-btn { min-width: 42px; height: 42px; }
#orderStatusList .order-status-item, #orderStatusList .status-group-items .order-status-item { font-size: 0.95rem; padding-left: 0.45rem; }
#orderStatusList .ov-cnt { min-width: 1.5rem; height: 1.3rem; font-size: 0.8rem; border-radius: 3px; }
#orderStatusList .ov-st-all { width: fit-content; }
/* zebra (ustawienia listy) na calym wierszu-karcie, nie na pojedynczych komorkach */
body.os-list-zebra #ordersBody > tr:nth-child(even) > td { background: transparent; }
body.os-list-zebra #ordersBody > tr:nth-child(even) { background: rgba(var(--overlay-rgb), 0.035); }
.orders-pagination button { border: 1px solid var(--border); background: var(--card-bg); }
.orders-toolbar .orders-pagination { flex: 1 1 100%; margin-top: 0.2rem; }

/* Karta zamowienia (uklad jak w BL): naglowek zawijany, przyciski pod przedmiotami na cala szerokosc */
.od-head { flex-wrap: wrap; }
.od-head-buyer { display: block; margin: 0; font-size: 0.9rem; flex-basis: 100%; }
#orderTitle { flex-wrap: wrap; }
.od-head-right { width: 100%; }
.od-head-right .od-back-pill { flex: 1; justify-content: center; }
.od-items-actions { flex-wrap: wrap; margin: 0.6rem 0; }
.od-items-actions > * { flex: 1 1 100%; }
.od-items-actions #oiAddBtn { width: 100%; justify-content: center; }
.od-main-head { flex-wrap: wrap; }
.od-main-card [data-tile="info"] > div:first-child { position: static !important; margin-bottom: 0.4rem !important; }
.field-row.od-multi { flex-wrap: wrap; }

/* Karta zamowienia: pasek "Klient prosi o fakture" bez wychodzenia poza karte */
.od-inv-request { margin: 0 0 0.8rem; border: 1px solid #f3d9b8; border-radius: 4px; padding: 0.6rem 0.8rem; }

/* ---------- Karta zamowienia i zwrotu jak w BL na telefonie (zrzuty 16.11.2026) ----------
   gesto: etykieta ~42% szerokosci, wartosc obok, wiersze ~24 px (pola tylko do odczytu bez wysokosci
   "pod palec"); status + maly "Przenies" pod nim; kafelki adresow na cala szerokosc; przesylki jako bloki */
#view-order-detail .detail-grid-3 > .panel-card { width: 100%; max-width: none !important; align-self: stretch; }
#view-order-detail .detail-grid-3 .field-row,
.od-main-card .field-row { min-height: 24px; margin: 0; gap: 0.5rem; flex-wrap: nowrap; align-items: flex-start; }
#view-order-detail .detail-grid-3 .field-row label,
#view-order-detail .detail-grid-3 .field-row input,
#view-order-detail .detail-grid-3 .field-row select,
#view-order-detail .detail-grid-3 .field-row textarea,
#view-order-detail .detail-grid-3 .field-row > div,
.od-main-card .field-row label, .od-main-card .field-row input, .od-main-card .field-row select, .od-main-card .field-row textarea, .od-main-card .field-row > div {
  font-size: 0.92rem; line-height: 24px; color: var(--text);
}
#view-order-detail .detail-grid-3 .field-row label, .od-main-card .field-row label { width: 42%; flex: 0 0 42%; margin: 0; }
#view-order-detail .detail-grid-3 .field-row > :not(label), .od-main-card .field-row > :not(label) { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
#view-order-detail .detail-grid-3 .field-row input:read-only, #view-order-detail .detail-grid-3 .field-row select:disabled,
.od-main-card .field-row input:read-only, .od-main-card .field-row select:disabled { min-height: 0; height: 24px; padding-top: 0; padding-bottom: 0; }
.od-main-card .field-row textarea:read-only { min-height: 0; padding-top: 0; padding-bottom: 0; }
.od-main-card .field-group-divider { margin-top: 0.6rem; padding-top: 0.6rem; }
#view-order-detail .detail-grid-3 .icon-btn-edit, .od-main-card [data-tile="info"] > div:first-child .icon-btn-edit {
  width: 40px; height: 34px; border-radius: 4px; background: var(--card-bg); border: 1px solid var(--border);
}
/* Status: lista na szerokosc wartosci, "Przenies" maly pod nia (jak w BL), nie niebieski na cala szerokosc */
.od-status-row label { width: 42%; }
.od-status-controls { flex: 1 1 0 !important; flex-direction: column; align-items: flex-start !important; gap: 0.4rem !important; }
.od-status-controls .toolbar-flyout-anchor { width: 100%; }
.od-main-card .status-current-btn { width: 100%; min-height: 40px; font-size: 0.92rem; }
.od-main-card #confirmStatusBtn { width: auto; min-height: 0; height: 36px; padding: 0 0.8rem; font-size: 0.85rem; font-weight: 500; background: var(--card-bg); color: var(--text); border: 1px solid var(--border); border-radius: 3px; }
.od-main-card .od-status-row { margin-bottom: 0.5rem; }
#odReceiptArea, #odInvoiceArea { flex-direction: column; align-items: flex-start !important; }
.od-main-card .btn-pill, .od-main-card #odInvoiceArea button, .od-main-card #odReceiptArea button { min-height: 0; height: 34px; font-size: 0.8rem; }

/* Przesylki: kazda paczka jako blok - data + przewoznik, konto, numer, status, przyciski (jak w BL) */
.od-ship-table, .od-ship-table tbody { display: block; width: 100%; }
.od-ship-table thead { display: none; }
.od-ship-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; padding: 0.8rem 0.4rem; border-bottom: 1px solid var(--border); }
.od-ship-table td { display: block; padding: 0 !important; border: none !important; font-size: 0.92rem; }
.od-ship-table td:nth-child(1) { order: 1; color: var(--text-muted); }
.od-ship-table td:nth-child(2) { order: 2; flex: 1 1 auto; }
.od-ship-table td:nth-child(3) { order: 3; flex: 1 1 100%; }
.od-ship-table td:nth-child(3):empty { display: none; }
.od-ship-table td:nth-child(4) { order: 4; flex: 1 1 100%; overflow-wrap: anywhere; }
.od-ship-table td:nth-child(5) { order: 5; flex: 1 1 100%; }
.od-ship-table td:nth-child(6) { order: 6; flex: 1 1 100%; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.od-ship-table td:nth-child(6):empty { display: none; }
.od-ship-table .od-ship-btn, .od-ship-table .od-ship-dots { min-height: 0; height: 36px; }
.od-ship-table .od-ship-dots { width: 40px; border-radius: 50%; }
.od-ship-carriers button { min-height: 0; height: 38px; font-size: 0.95rem; }

/* Karta zwrotu: jedna kolumna, te same gestosci */
.rd-top { flex-direction: column; align-items: stretch; }
#returnTitle { flex-wrap: wrap; font-size: 1.1rem; }
.rd-title-name { margin-left: 0; flex-basis: 100%; font-size: 0.95rem; }
.rd-top-nav .rd-back-btn { flex: 1; justify-content: center; }
.rd-nav-btn { min-height: 0; }
.rd-info-cols { grid-template-columns: minmax(0, 1fr); gap: 0.8rem; }
.rd-info, .rd-frow { grid-template-columns: 42% minmax(0, 1fr); font-size: 0.92rem; }
.rd-frow > div { min-width: 0; overflow-wrap: anywhere; }
.rd-addr { grid-template-columns: 42% minmax(0, 1fr); padding: 0.2rem 0; font-size: 0.92rem; }
.rd-card-head { flex-wrap: wrap; }
.rd-head-btns { flex-wrap: wrap; }
.rd-head-btn, .rd-split > button, .rd-real-btns button, .rd-move-btn { min-height: 0; }
.rd-refund { flex-wrap: wrap; }
.rd-msg-head { grid-template-columns: 1fr auto; gap: 0.3rem 0.6rem; }
.rd-msg-head > em { grid-column: 1; }
.rd-tx-btn, .rd-acc-head { min-height: 0; }
.rd-hrow { grid-template-columns: minmax(0, 1fr); }
.modal-card.rd-am-card .rd-am-form { grid-template-columns: minmax(0, 1fr); }
.od-main-card .field-row > .badge { flex: 0 0 auto; }
.od-items-card tbody td:nth-child(3) { flex: 1 1 calc(100% - 44px - 56px - 1.6rem); min-width: 0; }
.od-items-card tbody td:nth-child(9) { margin-left: auto; flex: 0 0 40px !important; width: 40px; }
/* Karta zwrotu: pozycje jako bloki (miniatura | nazwa | menu, pod spodem status pozycji, ilosc, cena, magazyn) */
.rd-items, .rd-items tbody { display: block; width: 100%; }
.rd-items thead { display: none; }
.rd-items tr { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.4rem 0.7rem; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.rd-items td { display: block; padding: 0 !important; border: none !important; font-size: 0.88rem; }
.rd-items td[colspan] { flex: 1 1 100%; }
.rd-items td:nth-child(1) { order: 1; width: auto; flex: 0 0 58px; }
.rd-items td:nth-child(3) { order: 2; flex: 1 1 calc(100% - 58px - 56px - 1.4rem); min-width: 0; overflow-wrap: anywhere; }
.rd-items td:nth-child(8) { order: 3; width: auto; flex: 0 0 auto; margin-left: auto; }
.rd-items td:nth-child(4) { order: 4; flex: 1 1 100%; }
.rd-items td:nth-child(2) { order: 5; }
.rd-items td:nth-child(2)::before { content: 'ID '; color: var(--text-muted); }
.rd-items td:nth-child(5) { order: 6; font-weight: 700; }
.rd-items td:nth-child(5)::after { content: ' szt.'; font-weight: 400; color: var(--text); }
.rd-items td:nth-child(6) { order: 7; font-weight: 700; }
.rd-items td:nth-child(7) { order: 8; color: var(--text-muted); }
.rd-items .rd-ist { min-width: 0; }
.rd-items .rd-dots { min-height: 0; width: 40px; height: 40px; }
/* Status zwrotu: lista na szerokosc wartosci, "Przenies" pod nia */
.rd-info-right > .rd-frow:first-child > div { flex-direction: column; align-items: flex-start !important; min-width: 0; }
#rdStatusAnchor, #rdStatusCurrentBtn { width: 100%; }
#rdStatusCurrentBtn { min-height: 40px; font-size: 0.92rem; }
.rd-move-btn { height: 36px; }
