/**
 * 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 .source-sellasist { background: rgba(37,99,235,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 ── */
.page-container { padding: 20px; max-width: 1400px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.page-header-extras { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; cursor: pointer;
    border: none; transition: all var(--transition);
    white-space: nowrap; text-decoration: none;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.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); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-xs { padding: 3px 8px; font-size: 10px; border-radius: 6px; }

/* ── 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 ── */
.data-table, .bl-product-table { border-collapse: collapse; font-size: 13px; }
.data-table th, .bl-product-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, .bl-product-table th:hover { color: var(--text-secondary); }
.data-table th .sort-arrow, .bl-product-table th .sort-arrow { margin-left: 4px; opacity: 0.4; }
.data-table th.sorted .sort-arrow, .bl-product-table th.sorted .sort-arrow { opacity: 1; color: var(--accent); }
.data-table td, .bl-product-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); }
.data-table tr:hover td, .bl-product-table tr:hover td { background: var(--bg-hover); }
.data-table tr.clickable { cursor: pointer; }
.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; }

/* ── 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-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-sellasist { background: rgba(59,130,246,0.2); color: #60a5fa; }
.source-manual { background: rgba(113,113,122,0.2); color: var(--color-text-secondary); }

/* ── Inputs ── */
.input {
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-primary); font-size: 13px; padding: 8px 12px;
    border-radius: var(--radius-sm); outline: none; transition: border-color var(--transition);
    width: 100%;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }
.select {
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-primary); font-size: 13px; padding: 8px 12px;
    border-radius: var(--radius-sm); outline: none; cursor: pointer;
    transition: border-color var(--transition);
}
.select:focus { border-color: var(--accent); }

/* ── 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;
}
.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);
    }
}

/* 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; }
.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; }
}

/* 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-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 */
    .page-container { padding: 12px; }

    /* 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; }
/* 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: linear-gradient(90deg, #7c3aed, #a78bfa);
    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; }
    .bl-product-table { min-width: 720px; width: 100%; }

    /* 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; }
}

/* ── Pływający pasek akcji listy produktów (mobile) — pokazywany z JS ── */
.bl-fab { display: none; }
@media (max-width: 768px) {
    .bl-fab {
        position: fixed; left: 50%; transform: translateX(-50%);
        bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 12px));
        z-index: 95; 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 */
    .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: 60vh; overflow-y: auto;
        z-index: 96;
    }
    .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ść ── */
    #cms-content .page-container { padding: 10px; }
    #cms-content { overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .page-header { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 10px; }
    .page-header h1 { font-size: 17px; }
    .page-header > div { width: 100%; flex-wrap: wrap; gap: 6px; }
    .page-header .btn { min-height: 34px; }

    /* ── Toolbar: zawijanie + dotykowe przyciski (dropdowny bez scroll-clip) ── */
    .bl-toolbar { flex-wrap: wrap; row-gap: 6px; }
    .bl-toolbar .btn, .bl-toolbar .select { min-height: 32px; }
    .bl-toolbar-group { flex-wrap: wrap; }

    /* ── Pasek statusów zamówień: poziomy scroll (brak dropdownów) ── */
    .orders-status-bar {
        overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch; scrollbar-width: none;
    }
    .orders-status-bar::-webkit-scrollbar { display: none; }
    .orders-status-tab { flex-shrink: 0; min-height: 30px; }

    /* ── Tabs stron (Produkty/Zestawy/Operacje): poziomy scroll ── */
    .bl-page-tabs {
        overflow-x: auto; flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch; scrollbar-width: none;
    }
    .bl-page-tabs::-webkit-scrollbar { display: none; }
    .bl-page-tab { flex-shrink: 0; min-height: 34px; }

    /* ── Filtry: 1 kolumna, większe pola dotykowe ── */
    .bl-filters-grid { grid-template-columns: 1fr !important; gap: 6px; }
    .bl-filters-panel { padding: 10px; }
    .bl-field label { font-size: 11px; }
    .bl-field input, .bl-field select { height: 36px; font-size: 14px; }
    .bl-filters-panel .btn { min-height: 34px; }

    /* ── Tabele: przewijane poziomo (min-width trzyma kolumny) ── */
    .bl-product-table { min-width: 760px; }
    .table-wrap { -webkit-overflow-scrolling: touch; }

    /* ── Footer pasków (paginacja): układ kolumnowy ── */
    .bl-footer-bar { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 12px; }
    .bl-footer-left, .bl-footer-right { flex-wrap: wrap; gap: 6px; }
    .bl-footer-right { justify-content: flex-start; }
    .bl-pager { flex-wrap: wrap; }

    /* ── Bulk bar ── */
    .bl-bulk-bar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }

    /* ── 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 ── */
    .bl-dropdown-menu, .bl-row-menu { max-width: calc(100vw - 20px); }
    .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: 1 kolumna ── */
    .pd-form-grid, .pd-form-grid-3, .pd-form-grid-5 { grid-template-columns: 1fr !important; }
    .pd-modal-container { width: 100vw; max-width: 100vw; max-height: 100vh; border-radius: 0; }
    .pd-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .pd-tab { white-space: nowrap; flex-shrink: 0; }

    /* ── 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: w normalnym przepływie (pływający pasek akcji jest osobno) ── */
    .bl-footer-bar {
        flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 12px;
    }

    /* ── 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 { 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ń ═══ */
.bl-footer-bar { padding: 10px 18px; }

/* Telefon: lista zamówień — bez produktów i ceny, nr zamówienia na pierwszym planie,
   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(6), #orders-table td:nth-child(6) { display: none; }
    #orders-table th, #orders-table td { padding: 5px 6px; font-size: 11px; }
    #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; }
    #orders-table td:nth-child(4) > div:last-child { font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 92px; }
    #orders-table td:nth-child(5) { font-size: 10px; max-width: 86px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #orders-table td:nth-child(7) { padding: 5px 4px; }
    #orders-table td:nth-child(8), #orders-table td:nth-child(9) { font-size: 10px; white-space: nowrap; }
    .bl-footer-bar { padding: 8px 10px; font-size: 11px; gap: 4px; }
}
@media (max-width: 480px) {
    /* Najwęższy telefon: bez daty — status i ikonki muszą być widoczne */
    #orders-table th:nth-child(9), #orders-table td:nth-child(9) { display: none; }
    #orders-table td:nth-child(7) { padding: 5px 2px; }
    #orders-table td:nth-child(7) [style*="width:20px"] { width: 16px !important; height: 16px !important; font-size: 9px !important; }
}
