/**
 * BeeOS CMS — Core CMS styles + responsive
 * Split from cms.css monolith
 */
/* ═══════════════════════════════════════════════════════════════
   BeeOS CMS/WMS — Complete Stylesheet (Proof of Concept)
   Premium dark theme + full responsive breakpoints
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
    --bg-root: var(--color-bg);
    --bg-sidebar: var(--color-bg-sidebar);
    --bg-topbar: var(--color-bg-topbar);
    --bg-card: var(--color-card);
    --bg-card-hover: var(--color-card-hover);
    --bg-hover: var(--color-card-hover);
    --bg-active: var(--color-card-hover);
    --bg-input: var(--color-input);
    --bg-surface: #28282d;
    --bg-panel: #222226;
    --border: var(--color-border);
    --border-light: var(--color-border-light);
    --border-subtle: var(--color-border-light);
    --text-primary: var(--color-text);
    --text-secondary: var(--color-text-secondary);
    --text-muted: var(--color-text-muted);
    --text-inverse: #ffffff;
    --accent: var(--color-accent);
    --accent-hover: var(--color-accent-hover);
    --accent-text: #161618;
    --blue: #60a5fa;
    --green: var(--color-success);
    --red: var(--color-error);
    --purple: #8b5cf6;
    /* Akcent podświetleń (użycia var(--primary) w cms.js) */
    --primary: #8b5cf6;
    --primary-hover: #a78bfa;
    --primary-soft: rgba(139,92,246,0.12);
    --radius: 10px;
    --radius-sm: 8px;
    --transition: 0.15s ease;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
    --shadow-md: 0 6px 20px rgba(0,0,0,0.45);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);
}

/* ── Light Theme ── */
body.light {
    --bg-root: #f3f4f6;
    --bg-sidebar: #ffffff;
    --bg-topbar: rgba(255,255,255,0.95);
    --bg-card: #ffffff;
    --bg-card-hover: #f6f7f9;
    --bg-hover: #f1f2f5;
    --bg-active: #e9ebef;
    --bg-input: #ffffff;
    --bg-surface: #f6f7f9;
    --bg-panel: #ffffff;
    --border: #c8cdd6;
    --border-light: #e3e6eb;
    --border-subtle: #eef0f3;
    --text-primary: #1a1d23;
    --text-secondary: #4a5462;
    --text-muted: #6b7482;
    --text-inverse: #ffffff;
    --accent: #3d4754;
    --accent-hover: #252c36;
    --accent-text: #ffffff;
    --blue: #2563eb;
    --green: #15803d;
    --red: #dc2626;
    --purple: #7c3aed;
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-soft: rgba(124,58,237,0.10);
    --shadow-sm: 0 1px 2px rgba(16,24,40,0.06);
    --shadow-md: 0 6px 20px rgba(16,24,40,0.12);
    --shadow-lg: 0 12px 40px rgba(16,24,40,0.18);
}
body.light .cms-topbar {
    background: var(--bg-topbar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
body.light .cms-sidebar {
    border-right-color: var(--border-light);
}
body.light .nav-item:hover { background: var(--bg-hover); }
body.light .nav-item.active { background: var(--bg-active); }
body.light .data-table tr:hover td { background: var(--bg-hover); }
body.light .kanban-card { background: #f6f7f9; }
body.light .modal-overlay { background: rgba(15,23,42,0.4); }
body.light .pick-item { background: #f6f7f9; }
body.light .wh-zone { background: var(--bg-card); }
body.light .cms-topbar .topbar-btn:hover { background: var(--bg-hover); }
body.light .filter-bar { background: var(--bg-card); }
body.light .input, body.light .select { background: var(--bg-input); border-color: var(--border); }
body.light .source-allegro { background: rgba(124,58,237,0.12); }
body.light ::-webkit-scrollbar-thumb { background: #c8cdd6; }
body.light .modal,
body.light .pp-dialog .modal,
body.light .mod-dialog,
body.light .bee-modal,
body.light .toast,
body.light #notif-dropdown,
body.light #help-popover {
    box-shadow: var(--shadow-md);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-root);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-border); }

/* ── Layout ── */
.cms-layout { display: flex; height: 100vh; width: 100%; overflow: hidden; }

/* ── Sidebar ── */
.cms-sidebar {
    width: 240px; min-width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex; flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease, opacity 0.2s ease;
    z-index: 50; overflow: hidden;
}
.cms-sidebar.collapsed {
    width: 0 !important; min-width: 0 !important; opacity: 0; border: none;
}
.cms-sidebar-logo {
    padding: 12px 16px; border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; gap: 8px;
}
.cms-sidebar-logo .logo-icon {
    width: 28px; height: 28px; background: var(--purple);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0; color: #fff;
}
.cms-sidebar-logo .logo-text { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.cms-sidebar-logo .logo-text span { color: var(--purple); }
.sidebar-collapse-btn {
    margin-left: auto; background: none; border: none;
    color: var(--text-muted); cursor: pointer; padding: 4px 6px;
    border-radius: 5px; font-size: 10px; transition: all 0.15s;
    display: flex; align-items: center;
}
.sidebar-collapse-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.cms-sidebar.collapsed .sidebar-collapse-btn { display: none; }
.sidebar-footer-link {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; color: var(--text-muted); text-decoration: none;
    padding: 6px 8px; border-radius: 6px; transition: all 0.15s;
}
.sidebar-footer-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.cms-sidebar-nav {
    flex: 1; padding: 8px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 1px;
}
.cms-sidebar-footer {
    border-top: 1px solid var(--border-light);
    padding: 10px 12px;
}

/* ── Nav Items ── */
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px; border-radius: var(--radius-sm);
    font-size: 13px; font-family: Arial, 'Helvetica Neue', sans-serif;
    color: var(--text-secondary);
    transition: all var(--transition); cursor: pointer;
    width: 100%; text-align: left; background: none; border: none;
    text-decoration: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--bg-active); color: var(--text-primary); font-weight: 500; }
.nav-item .nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.65; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-item .nav-icon svg { display: block; }
.nav-item .nav-badge {
    margin-left: auto; background: var(--red); color: #fff;
    font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 10px;
    min-width: 20px; text-align: center;
}
.nav-divider { border-top: 1px solid var(--border-light); margin: 4px 0; }
.nav-section { font-size: 10px; color: var(--text-muted); padding: 8px 14px 4px; }

/* ── Main Content ── */
textarea { resize: none !important; }
.cms-main {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    background: var(--bg-root); min-width: 0;
}

/* ── Top Bar ── */
.cms-topbar {
    position: sticky; top: 0; z-index: 30;
    background: var(--bg-topbar); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    padding: 10px 20px;
    display: flex; align-items: center; gap: 16px;
}
.cms-topbar .menu-toggle {
    display: none; background: none; border: none; color: var(--text-secondary);
    padding: 6px; border-radius: 6px; cursor: pointer; font-size: 20px;
}
.cms-topbar .menu-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.cms-topbar .page-title { font-size: 16px; font-weight: 600; color: var(--text-primary); flex: 1; }
.cms-topbar .topbar-actions { display: flex; align-items: center; gap: 8px; }
.cms-topbar .topbar-btn {
    background: none; border: none; color: var(--text-secondary);
    padding: 8px; border-radius: 8px; cursor: pointer; font-size: 16px;
    transition: all var(--transition); position: relative;
}
.cms-topbar .topbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.cms-topbar .topbar-btn .dot {
    position: absolute; top: 6px; right: 6px;
    width: 6px; height: 6px; background: var(--red); border-radius: 50%;
}

/* ── Page Container — STANDARD SEKCJI ŚRODKOWEJ (kont. 53au) ──
   Margines zewnętrzny treści = 12px (góra/dół) × 16px (boki) — dokładnie
   jak .section-content wzorca „Statusy zamówień”. Desktop i mobile
   IDENTYCZNIE (bez max-width i bez osobnej reguły mobilnej).
   Ramka treści = .page-panel (patrz niżej). */
.page-container { padding: 12px 16px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header .ph-title { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.page-header-extras { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Section page & poziome zakładki (wspólny klocek CMS) ── */
.section-page { display: flex; flex-direction: column; height: 100%; }
.section-tabs {
    display: flex; gap: 0; align-items: stretch;
    padding: 0 16px;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border);
    /* Desktop: zakładki zawijają się do kolejnych linii — wszystkie
       widoczne i klikalne (brak ukrytego przewijania). Mobile ≤720px:
       jeden rząd przewijany poziomo (media query niżej). */
    flex-wrap: wrap; overflow-x: hidden; flex-shrink: 0;
    /* Rezerwa wysokości: podświetlenie aktywnej zakładki (border akcent)
       i zawijanie wierszy nie mogą wywoływać pionowego suwaka na pasku
       (overflow-x:hidden wymusza overflow-y:auto — jawnie wyłączamy). */
    overflow-y: hidden;
    min-height: 41px;
    scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar { display: none; }
.section-tab {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 14px;
    font-size: 12px; font-weight: 500;
    color: var(--text-muted);
    background: none; border: none; border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.section-tab:hover { color: var(--text-primary); border-bottom-color: var(--border); }
.section-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.section-tab svg { flex-shrink: 0; }
/* Treść sekcji — ten sam margines standardowy co .page-container */
.section-content { flex: 1; overflow-y: auto; padding: 12px 16px; }

/* ── Panele stron (ramka „kolor szary na czarnym” — wzorzec: Statusy
   zamówień; standard ramki dla treści sekcji środkowej, kont. 53au) ── */
.page-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
}
.panel-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
@media (max-width: 480px) {
    .panel-header { padding: 10px 12px; }
    .panel-header .btn { flex: 1 1 auto; }
}

/* ── Buttons (klocek: jeden właściciel, scalony z cms.html) ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 6px;
    font-size: 12px; font-weight: 500;
    border: 1px solid transparent; cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    white-space: nowrap; text-decoration: none;
}
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-active); color: var(--text-primary); }
.btn-secondary:hover { background: var(--border-light); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: rgba(239,68,68,0.15); color: #f87171; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
/* Sukces = zielona OBWÓDKA (kont. 53au — jednolite szare przyciski akcji
   zyskały kolor przez obramowanie, nie wypełnienie) */
.btn-success { background: rgba(34,197,94,0.10); color: #4ade80; border: 1px solid rgba(34,197,94,0.45); font-weight: 600; }
.btn-success:hover { background: rgba(34,197,94,0.22); }
body.light .btn-success { color: #047857; }
.btn-sm { padding: 4px 8px; font-size: 11px; }
.btn-xs { padding: 2px 6px; font-size: 10px; border-radius: 6px; }
.btn-group { display: flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 6px 0 0 6px; }
.btn-group .btn:last-child { border-radius: 0 6px 6px 0; }
.btn-group .btn.active { background: var(--bg-active); color: var(--text-primary); }

/* ── Przycisk druku + strzałka ▾ = PRZYLEGŁE (kont. 53au, standard UI) ── */
.bp-btns { display: inline-flex; gap: 0 !important; align-items: center; }
.bp-btns .bp-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.bp-btns .bp-arrow { border-top-left-radius: 0; border-bottom-left-radius: 0;
    margin-left: -1px; }

/* ── Orzełek KSeF (PNG): ciemny na jasnym motywie, biały na czerwonym ── */
.ksef-eagle { display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 5px; cursor: pointer; flex-shrink: 0; }
.ksef-eagle img { width: 15px; height: 15px; }
.ksef-eagle.ksef-unset { background: transparent; }
body.light .ksef-eagle.ksef-unset img { filter: invert(1); } /* czarny na jasnym */
.ksef-eagle.ksef-sent { background: #dc2626; }
.ksef-eagle.ksef-sent img { filter: brightness(0) invert(1); } /* biały na czerwonym */

/* ── Cards ── */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* ── Stat Cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; cursor: pointer;
    transition: all var(--transition);
}
.stat-card:hover { border-color: var(--text-muted); transform: translateY(-1px); }
.stat-card .stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.stat-card .stat-change { font-size: 11px; margin-top: 4px; }
.stat-card .stat-change.up { color: var(--green); }
.stat-card .stat-change.down { color: var(--red); }
/* Statystyki zaawansowane (moduł cms-analytics.js) */
.stat-card .stat-card-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-card-value { font-size: 26px; font-weight: 700; color: var(--text-primary); margin-top: 6px; line-height: 1; }
.stat-card .stat-card-delta { font-size: 11px; margin-top: 4px; }

/* ── Table (uniwersalna .data-table; .bl-product-table = cms-products.css) ── */
.data-table { border-collapse: collapse; font-size: 13px; width: 100%; table-layout: fixed; }
.data-table th {
    text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 500;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-light); cursor: pointer; user-select: none;
    white-space: nowrap;
}
.data-table th:hover { color: var(--text-secondary); }
/* Strzałki sortowania — JEDEN klocek dla wszystkich tabel (kont. 53au):
   ↕ = niesortowana, ↑/↓ = kierunek aktywnego sortowania. */
.sort-arrow { margin-left: 4px; opacity: 0.4; font-size: 9px; }
th.sorted .sort-arrow, .bl-sort-ctrl.sorted .sort-arrow { opacity: 1; color: var(--accent); }
/* Rozdzielone kontrolki sortowania nagłówka (Nazwa/ID/SKU/EAN) — klocek
   .bl-sort-ctrl: generyczne reguły bazowe (single-owner w cms-core.css;
   cms-products.css doprecyzowuje szerokości dla .bl-product-table). */
.bl-sort-ctrl { cursor: pointer; margin-right: 10px; white-space: nowrap; }
.bl-sort-ctrl:last-child { margin-right: 0; }
.bl-sort-ctrl:hover { color: var(--accent); }
.bl-sort-ctrl.sorted { color: var(--accent); }
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr.clickable { cursor: pointer; }

/* Menu prawego przycisku wiersza zamówienia (nowa karta / kopiuj link) */
.od-row-ctx { position: fixed; z-index: 10100; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 8px; padding: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35); display: flex;
    flex-direction: column; min-width: 190px; }
.od-row-ctx .btn { justify-content: flex-start; text-align: left; width: 100%; }
.data-table .cell-id { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; color: var(--accent); }
.data-table .cell-primary { color: var(--text-primary); font-weight: 500; }

/* ── Tabela podglądu/mapowania CSV (uiKit.csvImportModal #24) ── */
.csv-preview-table { border-collapse: collapse; width: 100%; }
.csv-preview-table th,
.csv-preview-table td { border: 1px solid var(--border); }
.csv-preview-table th:not(.csv-num-col),
.csv-preview-table td:not(.csv-num-col) { min-width: 170px; max-width: 240px; padding: 8px 10px; }
.csv-preview-table th:not(.csv-num-col) { vertical-align: top; }
.csv-preview-table td:not(.csv-num-col) {
    font-size: 11px; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; color: var(--text-secondary);
}
.csv-preview-table th.csv-num-col,
.csv-preview-table td.csv-num-col {
    width: 38px; min-width: 38px; max-width: 38px;
    text-align: center; color: var(--text-muted);
    background: rgba(255,255,255,0.02); font-weight: 600;
}
.csv-row-skipped td { opacity: 0.42; background: rgba(255,255,255,0.02); color: var(--text-muted); }
.csv-row-skipped .csv-num-col { text-decoration: line-through; }
.csv-col-skipped { opacity: 0.42; background: rgba(0,0,0,0.18); }
.csv-preview-table th.csv-col-mapped { border-top: 2px solid var(--accent); }

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge-new { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-progress { background: rgba(139,92,246,0.16); color: #a78bfa; }
.badge-ready { background: rgba(139,92,246,0.15); color: #a78bfa; }
.badge-shipped { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-delivered { background: rgba(34,197,94,0.08); color: var(--color-success); }
.badge-cancelled { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-danger { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-returned { background: rgba(239,68,68,0.08); color: var(--color-error); }
.badge-paid { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-unpaid { background: rgba(239,68,68,0.15); color: #f87171; }

/* ── Source Badges ── */
.source-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.source-allegro { background: rgba(139,92,246,0.14); color: var(--color-warning); }
.source-manual { background: rgba(113,113,122,0.2); color: var(--color-text-secondary); }

/* ── Inputs (klocek: scalony z cms.html — jeden właściciel) ── */
.input {
    background: var(--bg-input); border: 1px solid var(--border-light);
    color: var(--text-primary); border-radius: 6px; padding: 4px 8px;
    font-size: 12px; outline: none; transition: border-color var(--transition);
    width: 100%;
}
.input:focus { border-color: var(--primary); }
.input::placeholder { color: var(--text-muted); }

/* ── Pole wyboru pliku — spójny wygląd systemu (przycisk zamiast natywnego) ── */
input[type="file"].input, input[type="file"] {
    color: var(--text-muted);
    font-size: 11px;
    padding: 3px 4px;
}
input[type="file"]::file-selector-button {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    margin-right: 8px;
    transition: background var(--transition);
}
input[type="file"]::file-selector-button:hover { background: var(--bg-hover); }

/* ── Obszar tabel pozycji z paginacją (dostawy / dokumenty magazynowe):
      spora część ekranu, ale bez rozciągania — wysokość ograniczona ── */
.wh-pg-scroll { max-height: 60vh; overflow-y: auto; border-radius: 8px; }

/* ── Pola number: ukryte strzałki systemowe; klocek num-stepper (cms.js)
      renderuje przyciski +/− z ikonami SVG systemu ── */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.num-stepper { position: relative; display: inline-flex; align-items: center; width: 100%; height: 28px; }
.num-stepper > input { width: 100%; height: 28px; padding-right: 20px; }
.num-stepper .ns-btn {
    position: absolute; right: 3px; width: 13px; height: 12px; padding: 0;
    border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 3px;
}
.num-stepper .ns-btn svg { width: 10px; height: 10px; }
.num-stepper .ns-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.num-stepper .ns-up { top: 4px; }
.num-stepper .ns-down { bottom: 4px; }
.select {
    background: var(--bg-input); border: 1px solid var(--border-light);
    color: var(--text-primary); border-radius: 6px; padding: 4px 8px;
    font-size: 12px; outline: none; cursor: pointer;
    transition: border-color var(--transition);
}
.select:focus { border-color: var(--primary); }

/* ── Filter Bar ── */
.filter-bar {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    padding: 12px 16px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px;
}
.filter-bar .filter-group { display: flex; align-items: center; gap: 6px; }
.filter-bar .filter-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.filter-bar input, .filter-bar select { min-width: 120px; }

/* ── Kanban Board ── */
.kanban-board {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px; overflow-x: auto; padding-bottom: 8px;
}
.kanban-column {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px; min-height: 300px;
}
.kanban-column h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.kanban-column h3 .count { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.kanban-card {
    background: var(--bg-root); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px;
    cursor: pointer; transition: all var(--transition);
}
.kanban-card:hover { border-color: var(--border); }
.kanban-card .kc-id { font-size: 11px; color: var(--text-muted); }
.kanban-card .kc-customer { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.kanban-card .kc-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 8px; }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    z-index: 10040; display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.15s ease;
}
/* Dialogi systemowe (potwierdzenia/prompt) muszą być NAD innymi modalami
   (np. kreatorem zwrotu z z-index 10060) — inaczej nie da się ich zaakceptować. */
.modal-overlay.pp-dialog { z-index: 11000; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); width: 90%; max-width: 700px;
    max-height: 85vh; overflow-y: auto;
    animation: slideUp 0.2s ease;
}
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Rozmiary modali — jeden spójny system */
.modal-sm { max-width: 400px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1150px; }
.modal-footer {
    padding: 14px 20px; border-top: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    position: sticky; bottom: 0; background: var(--bg-card);
}

/* ── Panel boczny Agenta AI ── */
@keyframes ap-bounce {
    0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}
#agent-panel { overflow: hidden; }
/* Pole wiadomości panelu Agenta (wzór: pełna strona Agenta) */
#agent-panel-input-shell {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-input);
    overflow: hidden;
    transition: border-color 0.15s ease;
}
#agent-panel-input-shell:focus-within { border-color: var(--primary); }
#agent-panel-input-shell textarea {
    width: 100%;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.5;
    min-height: 44px;
    max-height: 160px;
    padding: 10px 12px;
    font-family: inherit;
}
#agent-panel-input-shell textarea::placeholder { color: var(--text-muted); }
.agent-panel-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 6px;
    border-top: 1px solid var(--border-light);
    min-height: 34px;
}
#agent-panel-file-chips { flex: 1; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
#agent-panel-file-chips .ap-chip {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10px; color: var(--text-secondary);
    background: var(--bg-hover); border: 1px solid var(--border-light);
    border-radius: 6px; padding: 2px 6px; max-width: 130px;
}
#agent-panel-file-chips .ap-chip img { width: 16px; height: 16px; border-radius: 3px; object-fit: cover; }
#agent-panel-file-chips .ap-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#agent-panel-file-chips .ap-chip button {
    border: none; background: none; cursor: pointer; padding: 0;
    color: var(--text-muted); display: inline-flex; flex-shrink: 0;
}
#agent-panel-file-chips .ap-chip button:hover { color: var(--red); }
#agent-panel-attach-btn, #agent-panel-send-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 8px;
    border: 1px solid transparent; cursor: pointer; flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
#agent-panel-attach-btn { background: transparent; color: var(--text-muted); }
#agent-panel-attach-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
#agent-panel-send-btn { background: var(--primary); color: #fff; }
#agent-panel-send-btn:hover { filter: brightness(1.1); }
#agent-panel-send-btn:active { transform: scale(0.95); }
@media (max-width: 768px) {
    #agent-panel {
        position: fixed; top: 0; right: 0; bottom: 0;
        width: min(400px, 92vw) !important;
        min-width: 0 !important;
        z-index: 10001;
        box-shadow: -8px 0 28px rgba(0,0,0,0.35);
    }
}

/* ── Wskaźnik pracy Agenta (trzy kropeczki + status kroku) ── */
.agent-typing {
    align-self: flex-start; max-width: 92%;
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 10px 10px 10px 2px;
    background: var(--bg-surface); border: 1px solid var(--border-light);
    font-size: 11px; color: var(--text-secondary);
}
.agent-typing-dots { display: inline-flex; gap: 3px; align-items: center; flex-shrink: 0; }
.agent-typing-dots span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--primary); animation: ap-bounce 1s infinite;
}
.agent-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.agent-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* Przycisk wysyłania — spinner + blokada podczas pracy Agenta */
#agent-panel-send-btn:disabled { opacity: 0.55; }
#agent-panel-send-btn.ap-sending::before {
    content: ''; width: 12px; height: 12px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff; border-radius: 50%;
    animation: ap-spin 0.7s linear infinite;
}
@keyframes ap-spin { to { transform: rotate(360deg); } }

/* ── Kompaktowe karty produktu w czacie (zamiast 6-kolumnowych tabel) ──
   Lekcja Z3: KONIEC z pół-ramkami (border-left) — cały bąbelek ma jednolity,
   delikatny odcień: zielony (sukces) / czerwony (błąd) / neutralny. ── */
.agent-prod-card {
    border: 1px solid var(--border-light);
    border-radius: 10px; background: var(--bg-surface);
    padding: 8px 10px; margin: 6px 0; overflow: hidden;
}
.agent-prod-card-success {
    background: rgba(34, 197, 94, 0.10);
    border: 1px solid rgba(34, 197, 94, 0.28);
}
.agent-prod-card-error {
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.28);
}
.agent-prod-card-head { font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.agent-prod-card-rows { display: flex; flex-direction: column; gap: 2px; }
.agent-prod-card-rows > div {
    display: flex; gap: 8px; font-size: 11px; line-height: 1.5;
    color: var(--text-secondary); word-break: break-word;
}
.agent-prod-card-rows span { color: var(--text-muted); flex-shrink: 0; min-width: 92px; }
.agent-prod-card-rows b { color: var(--text-primary); font-weight: 600; }
.agent-prod-card-rows a { color: var(--accent); word-break: break-all; }
.agent-prod-note { font-size: 11px; color: var(--text-muted); font-style: italic; margin-top: 6px; }

/* ── Karty .bee-card w panelu czatu: spójny ciemny motyw (koniec z
      jasnokremowym tłem nagłówków — styles.css targetuje [data-theme=dark],
      a CMS używa body.light/domyślnego ciemnego) ── */
#agent-panel .bee-card { background: var(--bg-surface); border-color: var(--border-light); }
#agent-panel .bee-card-warning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: var(--text-primary);
}
#agent-panel .bee-card-warning .bee-card-header,
#agent-panel .bee-card-warning .bee-card-body { background: transparent; }
#agent-panel .bee-card-warning .bee-card-header { color: #fcd34d; }
#agent-panel .bee-card-success {
    background: rgba(34, 197, 94, 0.10); border-color: rgba(34, 197, 94, 0.35);
}
#agent-panel .bee-card-success .bee-card-header,
#agent-panel .bee-card-success .bee-card-body { background: transparent; }
#agent-panel .bee-card-success .bee-card-header { color: #4ade80; }
#agent-panel .bee-card-error {
    background: rgba(239, 68, 68, 0.10); border-color: rgba(239, 68, 68, 0.35);
}
#agent-panel .bee-card-error .bee-card-header,
#agent-panel .bee-card-error .bee-card-body { background: transparent; }
#agent-panel .bee-card-error .bee-card-header { color: #f87171; }
#agent-panel .bee-card-info {
    background: rgba(59, 130, 246, 0.10); border-color: rgba(59, 130, 246, 0.35);
}
#agent-panel .bee-card-info .bee-card-header,
#agent-panel .bee-card-info .bee-card-body { background: transparent; }
#agent-panel .bee-card-info .bee-card-header { color: #93c5fd; }
#agent-panel .bee-confirm-params { background: var(--bg-hover); }

/* Ikony SVG — jednolity system (bez emoji) */.icon {
    width: 14px; height: 14px; flex-shrink: 0;
    display: inline-block; vertical-align: middle;
    color: inherit;
}
.icon-xs { width: 11px; height: 11px; }
.icon-md { width: 18px; height: 18px; }
/* Ikony nigdy nie nachodzą na tekst w przyciskach/badge'ach */
.btn svg, .badge svg, .nav-item svg, .tab svg, .section-tab svg,
.od-doc-chip svg, .sf-chip svg, .toast svg { flex-shrink: 0; }
.btn .icon, .badge .icon, .section-tab .icon { width: 13px; height: 13px; }

/* Dialogi systemowe (zastępują window.prompt/confirm) */
.pp-dialog .modal { max-width: 460px; }
/* Popup rezerwacji produktu = tabela 860px — modal-xl NIE dziedziczy
   limitu 460px z .pp-dialog (kont. 53au: tabela uciekała poza popup). */
.pp-dialog .modal-xl { max-width: 1150px; }
.pp-dialog-title { font-size: 15px; font-weight: 600; }
.pp-dialog-msg { font-size: 13px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.pp-dialog .input { margin-top: 10px; }
.od-menu-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 7px 10px; border-radius: 6px; font-size: 12px;
    color: var(--text-secondary); background: none; border: none;
    cursor: pointer; text-align: left; transition: background 0.1s, color 0.1s;
}
.od-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.od-menu-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.pp-choice-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    cursor: pointer; margin-top: 6px; font-size: 13px;
    transition: all var(--transition-fast);
}
.pp-choice-item:hover { border-color: var(--border); background: var(--bg-hover); }

/* ══════════ PRZEŁĄCZNIK (switch) — ustawienia zamiast checkboxów ══════════ */
input[type="checkbox"].switch {
    appearance: none;
    -webkit-appearance: none;
    width: 34px; height: 18px;
    background: #3f3f46;
    border: 1px solid #52525b;
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    margin: 0;
    vertical-align: middle;
}
input[type="checkbox"].switch::after {
    content: '';
    position: absolute;
    top: 1px; left: 1px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #d4d4d8;
    transition: left var(--transition-fast), background var(--transition-fast);
}
/* WŁĄCZONY — wyraźny fiolet, biała gałka (kontrast ON/OFF) */
input[type="checkbox"].switch:checked {
    background: #8b5cf6;
    border-color: #a78bfa;
    box-shadow: 0 0 0 1px #8b5cf6;
}
input[type="checkbox"].switch:checked::after {
    left: 17px;
    background: #ffffff;
}
input[type="checkbox"].switch:focus-visible {
    outline: 2px solid #a78bfa;
    outline-offset: 2px;
}

/* ══════════ FORMY INTEGRACJI — gridy 2-kolumnowe → 1 na mobile ══════════ */
.ship-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ship-form-grid .input, .ship-form-grid .select { width: 100%; box-sizing: border-box; }
@media (max-width: 720px) {
    .ship-form-grid { grid-template-columns: 1fr; gap: 10px; }
}

/* ══════════ KLOCEK: pole formularza (etykieta nad kontrolką) ══════════
   Etykieta, która OWIJA kontrolkę (input/select/textarea), to kolumna flex:
   tekst nad kontrolką, kontrolka pełna szerokość, a kontrolki w wierszu
   wyrównane do dołu (żeby opis dwuliniowy nie "podnosił" pola względem
   sąsiada). Checkboxy/switch mają osobne style — tu ich nie ruszamy. */
.ship-form-grid > label:has(> .input),
.ship-form-grid > label:has(> .select),
.ship-form-grid > label:has(> textarea) {
    display: flex; flex-direction: column; gap: 6px; justify-content: flex-end;
    font-size: 11px; color: var(--text-secondary); min-width: 0;
}
.ship-form-grid > label > .input,
.ship-form-grid > label > .select,
.ship-form-grid > label > textarea {
    width: 100%; box-sizing: border-box; min-width: 0;
}

/* Selecty w modalach nie rozpychają kolumn (pełna szerokość — jak .input). */
.modal-body .select { width: 100%; box-sizing: border-box; min-width: 0; }

/* Pole formularza .bl-field (wspólny klocek: etykieta + kontrolka). */
.bl-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.bl-field > label { font-size: 11px; color: var(--text-secondary); }
.bl-field > .input, .bl-field > .select, .bl-field > textarea {
    width: 100%; box-sizing: border-box; min-width: 0;
}

/* Automatyczne akcje — karty reguł i edytor */
.aa-rule-row {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 8px;
    transition: border-color var(--transition-fast);
}
.aa-rule-row:hover { border-color: var(--border); }
.aa-rule-off { opacity: 0.6; }
.aa-rule-name { font-size: 13px; font-weight: 600; }
.aa-rule-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.aa-rule-title svg { color: var(--primary); }
.aa-rule-id {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
}
.aa-rule-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.aa-rule-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.aa-rule-summary {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.aa-rule-summary b { color: var(--text-secondary); font-weight: 600; }
.aa-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 12px 2px 6px;
    margin-top: 4px;
    border-bottom: 1px solid var(--border-light);
}
.aa-editor-row {
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-bottom: 6px;
}

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 1px solid var(--border-light); margin-bottom: 16px; gap: 0; }
.tab {
    padding: 10px 16px; font-size: 13px; color: var(--text-muted);
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: all var(--transition); background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }

/* ── Timeline ── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before {
    content: ''; position: absolute; left: -20px; top: 4px;
    width: 8px; height: 8px; border-radius: 50%; background: var(--border);
    border: 2px solid var(--bg-card);
}
.timeline-item .tl-time { font-size: 10px; color: var(--text-muted); }
.timeline-item .tl-text { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ── Warehouse Grid ── */
.warehouse-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.wh-zone {
    background: var(--bg-card); border: 2px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px; cursor: pointer;
    transition: all var(--transition); text-align: center; min-height: 80px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.wh-zone:hover { border-color: var(--text-muted); }
.wh-zone.active { border-color: var(--primary); background: var(--primary-soft); }
.wh-zone .wh-code { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.wh-zone .wh-label { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.wh-zone .wh-count { font-size: 11px; color: var(--accent); margin-top: 2px; }
.wh-zone.zone-A { border-left: 3px solid #3b82f6; }
.wh-zone.zone-B { border-left: 3px solid var(--color-warning); }
.wh-zone.zone-C { border-left: 3px solid var(--color-success); }
.wh-zone.zone-D { border-left: 3px solid #a855f7; }
.wh-zone.zone-E { border-left: 3px solid var(--color-error); }

/* ── Pick & Pack ── */
.pick-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pick-scanner {
    background: var(--bg-card); border: 2px dashed var(--border);
    border-radius: var(--radius); padding: 40px 20px; text-align: center;
}
.pick-scanner.active { border-color: var(--accent); }
.pick-scanner .scan-input {
    width: 100%; max-width: 300px; font-size: 18px; text-align: center;
    padding: 12px; background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-primary); border-radius: var(--radius-sm); outline: none;
    letter-spacing: 2px;
}
.pick-scanner .scan-input:focus { border-color: var(--accent); }
.pick-item {
    display: flex; align-items: center; gap: 10px; padding: 10px;
    border-radius: var(--radius-sm); margin-bottom: 4px;
    background: var(--bg-root); border: 1px solid var(--border-light);
}
.pick-item.picked { opacity: 0.5; text-decoration: line-through; }
.pick-item .pick-loc { font-size: 11px; color: var(--text-muted); min-width: 50px; }

/* ── Chart Containers ── */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap canvas { width: 100% !important; }

/* ── Grid System ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-pulse { animation: pulse 2s infinite; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 10080; display: flex; flex-direction: column; gap: 8px; }
/* Pasek wdrożeń: tryb zmian (amber) / nowa wersja (blue) */
.build-banner {
    position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
    z-index: 10090; display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; border-radius: 10px;
    background: rgba(245,158,11,0.14); border: 1px solid rgba(245,158,11,0.55);
    color: #f59e0b; font-size: 12px; font-weight: 600;
    box-shadow: 0 6px 24px rgba(0,0,0,0.35); backdrop-filter: blur(6px);
}
.build-banner-refresh {
    background: rgba(59,130,246,0.14); border-color: rgba(59,130,246,0.55); color: #60a5fa;
}
.toast {
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 12px 18px; border-radius: var(--radius-sm);
    font-size: 13px; animation: slideUp 0.2s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    display: flex; align-items: center; gap: 8px;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--blue); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════ */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .cms-sidebar { width: 200px; min-width: 200px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .pick-layout { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .kanban-board { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
    /* Sidebar becomes overlay */
    .cms-sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        width: 260px; min-width: 260px; z-index: 60;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }
    .cms-sidebar.open { transform: translateX(0); }

    /* Sidebar overlay backdrop */
    .sidebar-backdrop {
        display: none; position: fixed; inset: 0;
        background: rgba(0,0,0,0.5); z-index: 55;
    }
    .sidebar-backdrop.show { display: block; }

    /* Show menu toggle */
    .cms-topbar .menu-toggle { display: flex; }

    /* Full-width main — marginesy boczne o połowę mniejsze (kont. 53au) */
    .page-container { padding: 6px; }

    /* Tabs przewijane poziomo (nie łamią się na telefonie) */
    .section-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .section-tabs .section-tab { white-space: nowrap; flex-shrink: 0; }

    /* Modale produktu/zamówienia pełna szerokość */
    .modal.pp-modal { width: 100vw; max-width: 100vw; border-radius: 0; }

    /* Karta zamówienia na telefonie: od góry ekranu, pełna wysokość —
       górne menu nie zasłania widoku tabeli */
    #order-modal { align-items: flex-start; }
    #order-modal .pp-modal { max-height: 100vh; width: 100vw; max-width: 100vw; border-radius: 0; }
}

/* Statystyki paska zarządzania karty zamówienia */
.od-stat {
    display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 14px; border-radius: 8px; background: var(--bg-hover);
    border: 1px solid var(--border-light); min-width: 72px;
}
.od-stat b { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.od-stat span { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
/* Tabela produktów karty zamówienia: zdjęcie zawsze widoczne (sticky),
   reszta przewijana w poziomie bez widocznego paska */
.od-items-wrap { overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.od-items-wrap::-webkit-scrollbar { display: none; }
.od-item-thumb-cell {
    position: sticky; left: 0; z-index: 1; width: 52px; padding: 4px 4px !important;
    background: var(--bg-card);
    border-right: 1px solid var(--border-light);
    box-shadow: 6px 0 10px -8px rgba(0,0,0,0.55);
}
.od-item-thumb {
    width: 44px; height: 44px; border-radius: 6px; object-fit: cover; display: block;
    background: var(--bg-surface, #f6f7f9);
}
.od-item-thumb-ph {
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 16px;
}
@media (max-width: 720px) {
    .od-items-table { min-width: 640px; }
    /* Menu Dokumentów na mobile: dolna zakładka FIXED — absolutnie
       pozycjonowane menu w scrollowalnym modalu inaczej rozpycha
       tabelę produktów (przesuwa ją poza ekran). */
    .od-doc-menu {
        position: fixed !important;
        left: 8px !important;
        right: 8px;
        top: auto !important;
        bottom: 12px;
        min-width: 0 !important;
        width: auto !important;
        max-width: none !important;
        max-height: 55vh;
    }
}
/* Pola edytowalne klienta/płatności na karcie zamówienia */
.od-kv { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.od-kv > label { width: 105px; flex: none; font-size: 10px; color: var(--text-muted); }
.od-kv .input, .od-kv .select { min-width: 0; }
/* Karta zamówienia jako PEŁNA STRONA (szkielet nowego UI — #order/ID).
   Ten sam render co modal, bez ograniczeń modala (pełna szerokość strony). */
.od-page-card {
    font-size: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.od-page-card .od-items-wrap { background: var(--bg-card); }
/* Chip wystawionego dokumentu (faktura/paragon) na pasku funkcji */
.od-doc-chip {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 3px 6px 3px 10px; border-radius: 8px; font-size: 11px;
    background: rgba(59,130,246,0.12); border: 1px solid rgba(59,130,246,0.4);
    white-space: nowrap; max-width: 100%;
}
.od-doc-chip > div { margin-left: auto; }  /* przyciski od prawej krawędzi */
.od-fn-bar .od-doc-chip { flex: 0 0 auto; }  /* chip dokumentu w jednej linijce */
.od-fn-bar .od-doc-chip > * { flex-shrink: 0; }
.od-fn-bar .od-pp-actions { margin-left: auto; justify-content: flex-end; }  /* akcje PP od prawej krawędzi */
.od-doc-chip a { white-space: nowrap; }
.od-doc-chip a { color: var(--primary); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.od-doc-chip a:hover { text-decoration: underline; }
.od-doc-chip button {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 3px; border-radius: 5px; border: none; background: transparent;
    color: var(--text-secondary); cursor: pointer; font-size: 11px;
}
.od-doc-chip button:hover { background: var(--bg-active); color: var(--text-primary); }
/* Szybki dostęp na dashboardzie — 6 małych kafelków (styl stat-card) */
.dash-quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dash-quick-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 7px; padding: 12px 6px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: all var(--transition);
}
.dash-quick-tile:hover { border-color: var(--primary); background: var(--bg-hover); }
.dash-quick-ico {
    width: 32px; height: 32px; border-radius: 8px; background: var(--bg-hover);
    display: flex; align-items: center; justify-content: center; color: var(--primary);
}
.dash-quick-ico svg { width: 17px; height: 17px; }
.dash-quick-lbl { font-size: 10px; color: var(--text-secondary); text-align: center; line-height: 1.2; }

/* Pasek statusu przesyłki (graficzny, BaseLinker-style) */
.od-track-bar { height: 10px; background: var(--bg-hover); border-radius: 6px;
    overflow: hidden; border: 1px solid var(--border); }
.od-track-fill { height: 100%;
    background: var(--accent);
    border-radius: 5px; transition: width 0.4s ease; }

/* Karta zamówienia — Logi obok Klient i płatność (desktop), pod spodem (mobile) */
.od-main-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: 12px; align-items: start; margin-bottom: 12px; }
.od-main-grid .card { margin-bottom: 0 !important; min-width: 0; overflow: hidden; }
.od-main-grid .od-log-group { min-width: 0; }

/* Karta zamówienia — responsywność na telefonie */
@media (max-width: 880px) {
    .od-main-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .od-3col { grid-template-columns: 1fr !important; }
    .od-mgmt > div { grid-template-columns: 1fr !important; }
}

@media (max-width: 720px) {
    /* Tables - allow horizontal scroll */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 640px; width: 100%; table-layout: auto; }
    .data-table th { white-space: nowrap; }
    .data-table td { vertical-align: middle; }

    /* Stats - 2 per row */
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card .stat-value { font-size: 22px; }

    /* Grids - single column */
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

    /* Kanban - single column, horizontal scroll */
    .kanban-board { grid-template-columns: repeat(5, 260px); overflow-x: auto; }
}

/* ═══════════════════════════════════════════════════════════════
   MODULE CATALOG — "Dodaj moduł" modal
   ═══════════════════════════════════════════════════════════════ */

.nav-add-module {
    color: var(--accent) !important;
    font-weight: 500;
    margin-top: 2px;
}
.nav-add-module:hover {
    background: var(--primary-soft) !important;
    color: var(--primary) !important;
}

.mod-overlay {
    position: fixed; inset: 0; z-index: 10040;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.15s ease;
}
.mod-dialog {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); width: 560px; max-width: 90vw;
    max-height: 80vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.mod-dialog-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.mod-dialog-header h2 {
    margin: 0; font-size: 15px; color: var(--text-primary); font-weight: 600;
}
.mod-close-btn {
    background: none; border: none; color: var(--text-muted);
    font-size: 22px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.mod-close-btn:hover { color: var(--text-primary); }
.mod-dialog-body {
    padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
}
.mod-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.mod-card:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.mod-card-disabled {
    opacity: 0.45;
    cursor: default !important;
}
.mod-card-disabled:hover {
    border-color: var(--border);
    background: transparent;
}
.mod-card-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; background: var(--bg-hover);
    color: var(--text-secondary); flex-shrink: 0;
}
.mod-card-info { flex: 1; min-width: 0; }
.mod-card-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.mod-card-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }

/* ══════════ Dropdowny nawigacji topbara (zwinięte menu) ══════════
   Widoczność steruje inline CSS w cms.html (display none/block na :hover).
   Tu tylko wygląd: tokeny → działa w obu motywach, mostek hover bez martwej strefy. */
.nav-dropdown-wrap {
    position: relative;
    display: inline-flex;
    padding-bottom: 8px;
    margin-bottom: -8px;
}
.nav-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    padding: 4px;
    border-radius: 6px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
}
.nav-dropdown-trigger:hover { color: var(--text-primary); }
.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 4px 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 60;
}
.nav-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 5px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
}
.nav-dropdown button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.nav-dropdown-wrap:hover .nav-dropdown,
.nav-dropdown.nav-dd-open { display: block; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}


/* ═══════════════════════════════════════════════════════════════
   Zapisane filtry (saved filters) + budowniczy reguł — cms-filters.js
   ═══════════════════════════════════════════════════════════════ */
.sf-bar { margin: 0 0 8px; }
.sf-bar-inner {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 6px 0; border-bottom: 1px solid var(--border-light);
}
.sf-bar-label { font-size: 11px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }
.sf-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; font-size: 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 999px; color: var(--text-primary);
    cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.sf-chip:hover { border-color: var(--accent); background: var(--bg-hover); }
.sf-chip.active {
    border-color: var(--accent); color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.sf-chip-x {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; padding: 0; border: none; border-radius: 50%;
    background: transparent; color: var(--text-muted); cursor: pointer; font-size: 10px;
}
.sf-chip-x:hover { color: var(--red); background: rgba(255,255,255,0.08); }

.sf-builder-modal { display: flex; flex-direction: column; }
.sf-rule-row {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 6px 8px; background: var(--bg-input);
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
}
.sf-rule-field { min-width: 180px; }
.sf-rule-op { min-width: 140px; }
.sf-rule-value { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 160px; }
.sf-rule-value .input { width: 100%; }
@media (max-width: 720px) {
    .sf-rule-row { flex-direction: column; align-items: stretch; }
    .sf-rule-field, .sf-rule-op { min-width: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   Inline modal (picker składników zestawów) — nad głównym modalem
   ═══════════════════════════════════════════════════════════════ */
.bee-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 10040; display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.15s ease;
}
.bee-modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); width: 90%; max-width: 520px;
    max-height: 85vh; overflow-y: auto;
}
.bee-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border-light);
    font-weight: 600; font-size: 13px;
}
.bee-modal-body { padding: 4px 16px; }
.bee-modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }

/* ═══════════════════════════════════════════════════════════════
   MOBILE UX (< 768px) — przyjazny telefon
   ═══════════════════════════════════════════════════════════════ */

/* ── Wysokość aplikacji: dvh uwzględnia pasek adresu przeglądarki (góra/dół) ── */
body.h-screen { height: 100vh; }
@supports (height: 100dvh) {
    body.h-screen { height: 100dvh; }
}

/* ── Wiersz zamówienia: pogrubiony klient, data w jednym wierszu (desktop) ── */
.ord-cust-name { font-weight: 700; }
.ord-date-cell > div { display: inline; }
.ord-date-cell > div + div { margin-left: 4px; }

/* ── Pływający pasek akcji list (mobile + desktop) — pokazywany z JS ── */
.bl-fab { display: none; }
.bl-fab {
    position: fixed; left: 50%; transform: translateX(-50%);
    /* Fallback dla starszych iOS (brak max()/env()) — bez tego
       bottom jest nieokreślony i pasek znika (kont. 53au: iOS
       Safari/Chrome nie pokazywały przycisku akcji) */
    bottom: 12px;
    bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 12px));
    z-index: 2000; display: flex; gap: 4px; padding: 5px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 999px; box-shadow: 0 10px 32px rgba(0,0,0,0.45);
    max-width: calc(100vw - 12px);
}
.bl-fab-btn {
    display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid transparent; background: transparent;
    color: var(--text-secondary); border-radius: 999px;
    padding: 8px 11px; font-size: 12px; cursor: pointer;
    white-space: nowrap; min-height: 36px;
    transition: background 0.15s ease, color 0.15s ease;
}
.bl-fab-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.bl-fab-btn:disabled { opacity: 0.4; cursor: default; }
.bl-fab-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.bl-fab-page { display: inline-flex; align-items: center; gap: 2px; }
.bl-fab-info { font-size: 11px; color: var(--text-muted); padding: 0 4px; white-space: nowrap; }
.bl-fab-selcount { background: var(--primary); color: #fff; border-radius: 999px;
    font-size: 10px; min-width: 16px; height: 16px; display: inline-flex;
    align-items: center; justify-content: center; padding: 0 4px; }
/* Rozwijane menu nad paskiem (z-index nad paskiem i resztą UI) */
.bl-fab-menu {
    position: absolute; bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 4px; box-shadow: 0 10px 32px rgba(0,0,0,0.45);
    display: none; min-width: 190px; max-height: calc(100vh - 160px);
    overflow-y: auto;
    z-index: 2001;
}
.bl-fab-menu.open { display: block; }
.bl-fab-menu button {
    display: flex; align-items: center; gap: 7px; width: 100%;
    background: none; border: none; color: var(--text-primary);
    font-size: 12px; padding: 9px 10px; border-radius: 8px; cursor: pointer;
    text-align: left;
}
.bl-fab-menu button:hover { background: var(--bg-hover); }
.bl-fab-menu button.active { color: var(--primary); font-weight: 600; }
.bl-fab-menu button svg { width: 14px; height: 14px; flex-shrink: 0; }
.bl-fab-menu .bl-fab-menu-sep { height: 1px; background: var(--border-light); margin: 4px 6px; }

@media (max-width: 768px) {
    /* ── Sidebar: off-canvas drawer (domyślnie schowany, hamburger otwiera) ── */
    #sidebar {
        position: fixed !important;
        left: 0; top: 0; bottom: 0;
        z-index: 90 !important;
        box-shadow: 8px 0 32px rgba(0,0,0,0.55);
    }
    #sidebar:not(.collapsed) { width: 280px !important; min-width: 280px !important; }
    body { overflow-x: hidden !important; }

    /* ── Topbar ── */
    #top-bar { padding: 0 8px; gap: 4px; }
    #page-title { font-size: 12px; }

    /* ── Treść (margines standardowy 12/16 obowiązuje też na mobile) ── */
    #cms-content { overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .page-header { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 10px; }
    .page-header .ph-title { font-size: 17px; }
    .page-header > div { width: 100%; flex-wrap: wrap; gap: 6px; }
    .page-header .btn { min-height: 34px; }

    /* ── Toolbar: klocek w cms-products.css ── */

    /* ── Pasek statusów zamówień: zawija się do kolejnych linii ── */
    .orders-status-bar {
        flex-wrap: wrap; overflow: visible;
        -webkit-overflow-scrolling: touch;
    }
    .orders-status-bar::-webkit-scrollbar { display: none; }
    .orders-status-tab { flex-shrink: 0; min-height: 30px; }

    /* ── Tabs stron (.bl-page-tabs) — klocek w cms-products.css ── */

    /* ── Filtry: klocek w cms-products.css ── */

    /* ── Tabele: klocek .bl-product-table w cms-products.css ── */
    .table-wrap { -webkit-overflow-scrolling: touch; }

    /* ── Footer pasków (paginacja): klocek w cms-products.css ── */

    /* ── Bulk bar: klocek w cms-products.css ── */

    /* ── Modale: pełna szerokość, pełnowymiarowe przyciski ── */
    .modal, .bee-modal {
        width: 100vw; max-width: 100vw;
        border-radius: 0; max-height: 100vh; max-height: 100dvh;
    }
    .modal-lg, .modal-xl { max-width: 100vw; }
    .modal-header, .modal-body, .modal-footer { padding-left: 14px; padding-right: 14px; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .btn { flex: 1; min-height: 42px; white-space: nowrap; }
    .mod-dialog { max-width: 100vw; border-radius: 0; max-height: 100vh; }
    #settings-modal-overlay > div { width: 94vw !important; }

    /* ── Dropdowny / powiadomienia nie wychodzą poza ekran ── */
    .nav-dropdown { max-width: calc(100vw - 16px); overflow-y: auto; max-height: 70vh; }
    #notif-dropdown { width: calc(100vw - 20px) !important; right: 10px !important; left: 10px !important; top: 48px; }

    /* ── Formularze karty produktu: klocek pd-* w cms-products.css ── */

    /* ── Pick & Pack ── */
    .pick-layout { grid-template-columns: 1fr; }

    /* ── Zapisane filtry ── */
    .sf-bar-inner { gap: 5px; }

    /* ── Toast na dole, pełna szerokość, nad belką systemową ── */
    .toast-container { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    .toast { font-size: 13px; }
    .build-banner { max-width: calc(100vw - 24px); }

    /* ── Popup Pick & Pack: stały overlay na pełny ekran (dvh + safe-area) ── */
    #pp-popup-overlay .pp-modal {
        width: 100vw !important; max-width: 100vw !important;
        height: 100vh !important; height: 100dvh !important;
        max-height: 100vh !important; max-height: 100dvh !important;
        border-radius: 0 !important;
    }

    /* ── Stacja robocza: motyw kontrastowy Pick & Pack ── */
    #pp-popup-overlay.pp-contrast .card,
    #pp-popup-overlay.pp-contrast .pp-order-card,
    #pp-popup-overlay.pp-contrast .pp-item-row {
        border-color: var(--text-muted) !important;
        background: var(--bg-surface) !important;
    }
    #pp-popup-overlay.pp-contrast .pp-item-row {
        box-shadow: 0 0 0 1px var(--text-muted) inset;
    }
    #pp-popup-overlay.pp-contrast .pp-qty-btn,
    #pp-popup-overlay.pp-contrast .pp-arm {
        font-weight: 800;
        border-width: 2px;
    }

    /* ── Statystyki / dashboard ── */
    .chart-wrap { height: 220px; }

    /* ══ DOPRACOWANIE MOBILE — nic nie wychodzi poza ekran ══ */
    .card { min-width: 0; }
    .page-container > * { min-width: 0; }
    .btn { max-width: 100%; }
    .btn svg { flex-shrink: 0; }
    select.select, input.input, textarea.input { max-width: 100%; }
    .bl-field input, .bl-field select { width: 100%; }
    .form-grid, .form-grid-2, .ship-form-grid { grid-template-columns: 1fr !important; }
    img { max-width: 100%; height: auto; }

    /* ── Przełączniki w ustawieniach: równe kolumny, kontrolka przy prawej ── */
    .setting-row { align-items: center; gap: 10px; }
    .setting-row > div:first-child { flex: 1; }
    .setting-row .setting-control { min-width: 0 !important; flex-shrink: 0; }
    .setting-row .setting-control input[type="checkbox"].switch { flex-shrink: 0; display: block; }
    .setting-row .setting-control .switch { margin-left: auto; }

    /* ── Zamówienia: tabela przewijana, karta zajmuje cały ekran ── */
    #orders-table { min-width: 720px; }
    #order-modal .od-items-table { min-width: 600px; }

    /* ── Stopki paginacji: klocek w cms-products.css ── */

    /* ── Popup Pick & Pack: odstęp na belkę systemową ── */
    #pp-popup-body { padding-bottom: env(safe-area-inset-bottom, 0px); }

    /* ── Ustawienia statusów zamówień: wiersze zawijane, akcje pod spodem ── */
    .os-status-row { flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px !important; }
    .os-status-row .os-status-actions {
        margin-left: 0 !important; width: 100%;
        display: flex; justify-content: flex-end; gap: 2px;
    }
    .os-status-row .os-status-actions .btn { min-height: 34px; min-width: 36px; }
}

/* ── Backdrop pod szufladą sidebara (mobile) ── */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.55); z-index: 85;
}
.sidebar-backdrop.show { display: block; }

/* ══════════ Mniejsze pola formularzy (ilość, ceny) — widoczne wartości ══════════ */
.input-sm {
    padding: 4px 8px !important;
    height: 28px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    border-radius: 6px !important;
}

/* ══════════ Kontrast elementów w jasnym motywie (badge/switch) ══════════ */
body.light .badge-new { background: #dbeafe; color: #1d4ed8; }
body.light .badge-progress { background: #ede9fe; color: #6d28d9; }
body.light .badge-ready { background: #ede9fe; color: #6d28d9; }
body.light .badge-shipped, body.light .badge-paid { background: #dcfce7; color: #15803d; }
body.light .badge-delivered { background: #dcfce7; color: #15803d; }
body.light .badge-cancelled, body.light .badge-unpaid, body.light .badge-danger { background: #fee2e2; color: #b91c1c; }
body.light .badge-returned { background: #fee2e2; color: #b91c1c; }
body.light .source-badge { color: inherit; }
body.light .source-manual { background: rgba(75,85,99,0.12); color: #4a5462; }
body.light .aa-rule-row { background: var(--bg-card-hover); border-color: var(--border-light); }
body.light .ob-warn { color: #b91c1c; }
body.light .ob-oknote { color: #15803d; }
body.light .ob-ico { background: rgba(124,58,237,0.12); color: #6d28d9; }
body.light .ob-step.done .ob-ico { background: rgba(21,128,61,0.12); color: #15803d; }
body.light .ob-done { color: #15803d; }
body.light .od-item-thumb { background: rgba(0,0,0,0.04); }
body.light .kanban-card { border-color: var(--border-light); }
body.light .btn-danger { color: #b91c1c; }
body.light .od-doc-chip { background: rgba(37,99,235,0.08); border-color: rgba(37,99,235,0.3); }
body.light input[type="checkbox"].switch {
    background: #d3d8df; border-color: #b9c0ca;
}
body.light input[type="checkbox"].switch::after { background: #ffffff; }
body.light .wh-zone.active { background: var(--primary-soft); }
body.light .nav-dropdown { box-shadow: 0 8px 24px rgba(16,24,40,0.14); }
body.light .sf-chip-x:hover { background: rgba(220,38,38,0.1); }
body.light .ob-bar { background: var(--bg-active); }

@media (max-width: 768px) {
    /* Siatki: kolumny mogą się zwężać poniżej min-content (karty z tabelami) */
    .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr) !important; }
    .card { min-width: 0; max-width: 100%; }
    .table-wrap { min-width: 0; max-width: 100%; }
}

/* ── Onboarding / samouczek pierwszego uruchomienia ── */
.ob-intro { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; }
.ob-progress { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.ob-bar { height: 8px; background: var(--bg-input, rgba(255,255,255,0.06)); border-radius: 99px; overflow: hidden; }
.ob-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: 99px; transition: width .4s ease; }
.ob-warn { margin-top: 8px; font-size: 12px; color: #fca5a5; display: flex; align-items: center; gap: 6px; }
.ob-warn svg, .ob-oknote svg { flex-shrink: 0; }
.ob-oknote { margin-top: 8px; font-size: 12px; color: #6ee7b7; display: flex; align-items: center; gap: 6px; }
.ob-steps { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; }
.ob-step { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.ob-step.done { opacity: .72; }
.ob-ico { width: 30px; height: 30px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: rgba(139,92,246,.12); color: #a78bfa; }
.ob-step.done .ob-ico { background: rgba(34,197,94,.12); color: #34d399; }
.ob-main { flex: 1; min-width: 0; }
.ob-title { font-size: 13px; font-weight: 600; color: var(--text); }
.ob-desc { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.45; }
.ob-act { flex-shrink: 0; display: flex; align-items: center; }
.ob-done { color: #34d399; }
@media (max-width: 640px) {
    .ob-act { margin-top: 6px; }
    .ob-step { flex-wrap: wrap; }
}

/* ── Mobile: przeglądarki z dolnym paskiem adresu (dvh zamiast vh) ── */
.cms-layout { height: 100vh; height: 100dvh; }
@media (max-width: 768px) {
    #order-modal .pp-modal, .mod-dialog, .pd-modal-container { max-height: 100vh; max-height: 100dvh; }
}

/* ═══ Wiadomości — mobile (skrzynka centralna) ═══ */
@media (max-width: 900px) {
    #msg-layout { flex-direction: column !important; height: auto !important; }
    #msg-sources { width: 100% !important; min-width: 0 !important;
        max-height: 170px; display: flex; flex-wrap: wrap;
        align-content: flex-start; }
    #msg-sources .msg-source { width: auto !important; flex: 0 0 auto; }
    #msg-content { min-height: 52vh; }
    /* Po otwarciu wątku źródła się zsuwają — pełna szerokość rozmowy */
    #msg-layout.msg-thread-open #msg-sources { display: none; }
    .msg-bubble { max-width: 88% !important; }
}

/* ═══ Tabele i przyciski — nic nie wychodzi poza tabelkę ═══ */
.table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table td .btn, .data-table th .btn { white-space: nowrap; }

/* ═══ Refaktoring UI 2026-09-08: marginesy i mobile zamówień ═══ */
/* (definicja .bl-footer-bar = klocek w cms-products.css) */

/* Telefon: lista zamówień — bez produktów, kropki i kwoty; nr zamówienia na
   pierwszym planie, data+godzina w dwóch wierszach, ciasno, bez przewijania
   w poziomie; reszta danych w menu ⋮ wiersza */
@media (max-width: 768px) {
    #orders-table { min-width: 0; width: 100%; table-layout: auto; }
    #orders-table th:nth-child(2), #orders-table td:nth-child(2),
    #orders-table th:nth-child(3), #orders-table td:nth-child(3),
    #orders-table th:nth-child(7), #orders-table td:nth-child(7) { display: none; }
    #orders-table th, #orders-table td { padding: 5px 6px; font-size: 11px; }
    /* Checkbox — węższa kolumna (kont. 53au TK-21) */
    #orders-table th:nth-child(1), #orders-table td:nth-child(1) {
        padding: 5px 2px; width: 26px; }
    #orders-table td:nth-child(4) .cell-id { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 92px; }
    /* Mobile: JEDEN numer (systemowy) — nr Allegro/ID zewnętrzne ukryte
       (TK-22; !important — działa przy każdej strukturze wiersza) */
    #orders-table .ord-ext-id { display: none !important; }
    /* Klient: pełna nazwa, bez badge źródła (TK-21) — więcej miejsca na nick */
    #orders-table td:nth-child(5) { font-size: 10px; max-width: 130px; white-space: normal; line-height: 1.25; }
    #orders-table .ord-src-badge { display: none !important; }
    /* Karta z tabelą — do brzegów, praktycznie bez obrysu (TK-21) */
    #orders-card { border: none; border-radius: 6px;
        box-shadow: 0 0 0 1px var(--border-light); }
    #orders-table td:nth-child(6) { padding: 5px 4px; }
    /* Data + godzina w dwóch wierszach (TK-22) */
    #orders-table td:nth-child(8) { font-size: 10px; white-space: nowrap; }
    .ord-date-cell > div { display: block; }
    .ord-date-cell > div + div { margin-left: 0; }
    /* Wiadomość od kupującego — czerwona na telefonie (TK-25) */
    #orders-table .ord-msg-chip { background: rgba(239,68,68,0.15) !important; color: #f87171 !important; }
    /* Pływający pasek akcji nie zasłania ostatniego wiersza */
    #orders-table + .bl-footer-bar { margin-bottom: 76px; }
    .bl-footer-bar { flex-wrap: wrap; row-gap: 6px; }
    .bl-footer-bar .bl-pager { flex-wrap: wrap; row-gap: 4px; max-width: 100%; }
    /* .bl-footer-bar (mobile) — klocek w cms-products.css */
}
@media (max-width: 480px) {
    /* Najwęższy telefon: mniejsze ikony statusów */
    #orders-table td:nth-child(6) { padding: 5px 2px; }
    #orders-table td:nth-child(6) [style*="width:20px"] { width: 16px !important; height: 16px !important; font-size: 9px !important; }
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT / SIDEBAR / NAV — przeniesione z <style> w cms.html
   (jedno źródło prawdy; Tailwind CDN niezależny fallback)
   ═══════════════════════════════════════════════════════════════ */
#sidebar {
    width: 224px !important; min-width: 224px !important;
    height: 100% !important; display: flex !important;
    flex-direction: column !important; flex-shrink: 0 !important;
    background: var(--bg-sidebar) !important; color: var(--text-primary) !important;
    border-right: 1px solid var(--border-light) !important;
    overflow: hidden !important;
}
#sidebar.collapsed { width: 0 !important; min-width: 0 !important; padding: 0 !important; border: none !important; overflow: hidden !important; opacity: 0 !important; }
#sidebar + div { flex: 1 1 0% !important; min-width: 0 !important; display: flex !important; flex-direction: column !important; }
body { display: flex !important; }
.nav-item, .nav-section-header, .nav-subitem { display: flex !important; align-items: center !important; width: 100% !important; text-align: left !important; cursor: pointer !important; background: transparent !important; border: none !important; }
.nav-section-body { overflow: hidden !important; max-height: 0 !important; }
.nav-section-body.open { max-height: 600px !important; }
/* KRYTYCZNE: logo MUSI być małe */
.logo-icon { width: 24px !important; height: 24px !important; max-width: 24px !important; max-height: 24px !important; object-fit: contain !important; display: block !important; }
.logo-wrap-icon { width: 32px !important; height: 32px !important; overflow: hidden !important; display: flex !important; align-items: center !important; justify-content: center !important; }
#sidebar img { max-width: 32px !important; max-height: 32px !important; }
/* Dropdown hover — hover na całym wrapperze, nie tylko triggerze */
.nav-dropdown { display: none !important; }
.nav-dropdown-wrap { padding-bottom: 6px; margin-bottom: -6px; }
.nav-dropdown-wrap:hover .nav-dropdown, .nav-dropdown.nav-dd-open { display: block !important; }
/* Collapsed nav — ensure horizontal layout */
#collapsed-nav { display: flex !important; flex-direction: row !important; align-items: center !important; gap: 2px !important; }
#collapsed-nav.hidden { display: none !important; }
.hidden { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
#sidebar { transition: width 0.25s ease, opacity 0.2s, padding 0.25s; }
#sidebar.collapsed { width: 0 !important; padding: 0; border: none; overflow: hidden; opacity: 0; }
@keyframes iconFadeIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: translateX(0); } }

.nav-section-header { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--text-secondary); background: transparent; border: none; cursor: pointer; transition: background 0.15s, color 0.15s; text-align: left; }
.nav-section-header:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-section-header .chevron { margin-left: auto; transition: transform 0.2s; }
.nav-section-header.open .chevron { transform: rotate(180deg); }
.nav-section-body { overflow: hidden; max-height: 0; transition: max-height 0.3s ease; }
.nav-section-body.open { max-height: 600px; }
.nav-subitem { width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 32px; border-radius: 6px; font-size: 12px; font-family: Arial, 'Helvetica Neue', sans-serif; color: var(--text-muted); background: transparent; border: none; cursor: pointer; transition: background 0.12s, color 0.12s; text-align: left; text-decoration: none; }
.nav-subitem:hover { background: var(--bg-hover); color: var(--text-secondary); }
.nav-subitem.active { color: var(--primary); background: var(--primary-soft); font-weight: 500; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; font-size:13px; color: var(--text-secondary); background: transparent; border: none; cursor: pointer; transition: background 0.15s, color 0.15s; text-align: left; }
/* Kategorie główne menu (Dashboard/Statystyki/Agent) — te same wymiary
   i grubość co nagłówki sekcji (kont. 53au: menu jednolite). */
#cms-nav > a.nav-item { padding: 8px 10px; gap: 8px; font-weight: 700; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--bg-active); color: var(--text-primary); font-weight: 600; }
.nav-item svg, .nav-section-header svg { flex-shrink: 0; width: 16px; height: 16px; stroke-width: 1.5; }
.nav-group-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); padding: 8px 10px 4px; }

/* Margines sekcji środkowej zdefiniowany przy .page-container (góra pliku) —
   bez nadpisań desktop/mobile (kont. 53au). */

/* ── Pasek statusów zamówień — karty + grupy (klocek) ── */
.orders-status-tab { background: none; border: none; color: var(--text-secondary); font-size: 12px; padding: 5px 9px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.orders-status-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.orders-status-tab.active { background: var(--primary); color: #fff; }
.orders-group-tab { font-weight: 700; text-transform: uppercase; font-size: 10px; letter-spacing: .4px; margin-left: 6px; border-left: 2px solid var(--border); border-radius: 0 8px 8px 0; }
.orders-group-tab.active { background: transparent; color: var(--primary); }

/* ═══ Hint-dot: ikona „i” w kółku z dymkiem po najechaniu (klocek UI) ═══ */
.hint-dot { position: relative; display: inline-flex; align-items: center;
  justify-content: center; width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid var(--text-muted); color: var(--text-muted);
  font-size: 10px; font-weight: 700; cursor: help; flex: none;
  font-style: normal; line-height: 1; }
.hint-dot .hint-pop { display: none; position: absolute; z-index: 120;
  left: 22px; top: -6px; width: 280px; background: var(--bg-surface);
  color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 10px 12px; font-size: 11px; font-weight: 400; line-height: 1.55;
  white-space: normal; cursor: default; }
.hint-dot:hover .hint-pop, .hint-dot:focus .hint-pop { display: block; }

/* ═══ Edytor tekstu sformatowanego (uiKit.richTextEditor) — klocek UI ═══ */
.rte { display: flex; flex-direction: column; gap: 4px; }
.rte-toolbar { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.rte-btn { padding: 3px 8px; font-size: 11px; line-height: 1.4; }
.rte-btn-b { font-weight: 700; }
.rte-btn-allegro { color: var(--accent, #6366f1); display: inline-flex; align-items: center; gap: 4px; }
.rte-spacer { flex: 1; }
.rte-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
.rte-code { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.5; resize: vertical; }
.rte-preview { width: 100%; background: var(--bg-input, #fff); color: var(--text-primary, #111); border: 1px solid var(--border, #e5e7eb); border-radius: 6px; padding: 8px 10px; font-size: 12px; line-height: 1.6; overflow-y: auto; }
.rte-preview p { margin: 0 0 8px; }
.rte-preview h1 { font-size: 16px; margin: 10px 0 6px; }
.rte-preview h2 { font-size: 14px; margin: 8px 0 6px; }
.rte-preview ul, .rte-preview ol { margin: 4px 0 8px; padding-left: 20px; }
.rte-preview li { margin: 2px 0; }
