/* =====================================================================
   naszasprzedaz.pl: design system "Rejestr" (MANIK Ogrodzenia)
   Warstwy: 1) tokeny  2) nadpisania Bootstrap 5  3) układ (sidebar, topbar)
            4) komponenty (tabele, filtry, odznaki, formularze, puste stany,
               toasty, modale)  5) moduły (czat, powiadomienia, wyszukiwarka)
            6) responsywność  7) druk
   Opis tokenów i komponentów: CLAUDE.md projektu, sekcja "Design system".
   ===================================================================== */

/* ---------- 1. TOKENY ---------- */
:root {
    /* marka */
    --brand: #D84818;            /* pomarańcz MANIK, tylko akcent i tła przycisków */
    --brand-strong: #C23F13;     /* przycisk główny (kontrast z białym 4,9:1) */
    --brand-ink: #A33410;        /* tekst w kolorze marki na jasnym tle (AA) */
    --brand-bg: #FBEDE6;
    --black: #1A1918;

    /* powierzchnie i linie */
    --bg: #F6F5F2;
    --panel: #FFFFFF;
    --panel-2: #FBFAF8;
    --line: #E4E1DB;
    --line-strong: #CFCBC3;

    /* tekst */
    --ink: #1A1918;
    --ink-2: #4C4945;
    --ink-3: #6F6B64;            /* tekst pomocniczy, 5,3:1 na białym */

    /* znaczenia */
    --ok: #1E7F4F;     --ok-bg: #E6F4EC;
    --warn: #8A5A00;   --warn-bg: #FFF1CF;
    --bad: #B42318;    --bad-bg: #FDEBE9;
    --info: #2458A6;   --info-bg: #E8EFFB;
    --neutral: #5E5A54; --neutral-bg: #ECEAE5;

    /* kształt i rytm */
    --r: 4px;
    --r-lg: 6px;
    --row: 36px;                 /* wysokość wiersza tabeli (desktop) */
    --control: 32px;             /* wysokość pól i przycisków (desktop) */
    --control-sm: 28px;
    --touch: 44px;               /* cel dotykowy (telefon, magazyn) */
    --fs: 13px;
    --fs-sm: 12px;
    --fs-xs: 11px;
    --shadow-pop: 0 8px 24px rgba(26, 25, 24, .14);

    --sidebar-width: 224px;
    --topbar-height: 52px;

    /* Bootstrap: przepięcie zmiennych na tokeny */
    --bs-body-font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: var(--fs);
    --bs-body-line-height: 1.45;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--r);
    --bs-border-radius-sm: 3px;
    --bs-border-radius-lg: var(--r-lg);
    --bs-link-color: var(--brand-ink);
    --bs-link-hover-color: var(--black);
    --bs-primary: var(--brand-strong);
    --bs-primary-rgb: 194, 63, 19;
    --bs-secondary-color: var(--ink-3);
    --bs-emphasis-color: var(--ink);
    --bs-heading-color: var(--ink);
    --bs-focus-ring-color: rgba(26, 25, 24, .22);
}

/* gęstość dotykowa: telefon/tablet albo widoki magazynu */
@media (max-width: 991.98px) {
    :root {
        --row: 44px;
        --control: 40px;
        --control-sm: 36px;
        --fs: 14px;
        --fs-sm: 13px;
    }
}
body.density-touch {
    --row: 48px;
    --control: 44px;
    --control-sm: 40px;
    --fs: 14px;
}

/* ---------- 2. BAZA I NADPISANIA BOOTSTRAP ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--bs-body-font-family);
    font-size: var(--fs);
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { color: var(--black); text-decoration: underline; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--black);
    outline-offset: 2px;
}
h1, h2, h3, h4, h5, h6 { letter-spacing: -.01em; }
small, .small { font-size: var(--fs-sm); }
.text-muted { color: var(--ink-3) !important; }
.text-primary { color: var(--brand-ink) !important; }
.text-danger { color: var(--bad) !important; }
.text-success { color: var(--ok) !important; }
.text-warning { color: var(--warn) !important; }
.text-info { color: var(--info) !important; }
.fw-bold, .fw-semibold, b, strong { font-weight: 600; }
.fs-5 { font-size: 16px !important; }

/* przyciski */
.btn {
    --bs-btn-padding-y: 0;
    --bs-btn-padding-x: 12px;
    --bs-btn-font-size: var(--fs);
    --bs-btn-font-weight: 500;
    --bs-btn-border-radius: var(--r);
    --bs-btn-focus-box-shadow: 0 0 0 3px rgba(26, 25, 24, .18);
    min-height: var(--control);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    line-height: 1.2;
}
.btn .bi { font-size: 1em; line-height: 1; }
.btn-sm, .btn-group-sm > .btn {
    --bs-btn-padding-x: 9px;
    --bs-btn-font-size: var(--fs-sm);
    min-height: var(--control-sm);
}
.btn-lg { --bs-btn-font-size: 15px; min-height: var(--touch); }
.btn-primary, .btn-kowmet, .btn-login {
    --bs-btn-bg: var(--brand-strong);
    --bs-btn-border-color: var(--brand-strong);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: #A33410;
    --bs-btn-hover-border-color: #A33410;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #8E2D0D;
    --bs-btn-active-border-color: #8E2D0D;
    --bs-btn-active-color: #fff;
    --bs-btn-disabled-bg: #E6B8A8;
    --bs-btn-disabled-border-color: #E6B8A8;
    --bs-btn-disabled-color: #fff;
}
.btn-success {
    --bs-btn-bg: var(--ok); --bs-btn-border-color: var(--ok); --bs-btn-color: #fff;
    --bs-btn-hover-bg: #176841; --bs-btn-hover-border-color: #176841; --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #125435; --bs-btn-active-border-color: #125435; --bs-btn-active-color: #fff;
}
.btn-danger {
    --bs-btn-bg: var(--bad); --bs-btn-border-color: var(--bad); --bs-btn-color: #fff;
    --bs-btn-hover-bg: #961C13; --bs-btn-hover-border-color: #961C13; --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #7C170F; --bs-btn-active-border-color: #7C170F; --bs-btn-active-color: #fff;
}
.btn-secondary, .btn-dark {
    --bs-btn-bg: var(--black); --bs-btn-border-color: var(--black); --bs-btn-color: #fff;
    --bs-btn-hover-bg: #333130; --bs-btn-hover-border-color: #333130; --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #000; --bs-btn-active-border-color: #000; --bs-btn-active-color: #fff;
}
/* wszystkie warianty konturowe = jeden spokojny przycisk drugorzędny */
.btn-outline-secondary, .btn-outline-primary, .btn-outline-dark, .btn-outline-info,
.btn-outline-success, .btn-outline-warning, .btn-light, .btn-outline-light, .btn-info, .btn-warning {
    --bs-btn-bg: var(--panel);
    --bs-btn-border-color: var(--line-strong);
    --bs-btn-color: var(--ink);
    --bs-btn-hover-bg: var(--panel-2);
    --bs-btn-hover-border-color: var(--ink-3);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-active-bg: var(--line);
    --bs-btn-active-border-color: var(--ink-3);
    --bs-btn-active-color: var(--ink);
    --bs-btn-disabled-color: var(--ink-3);
    --bs-btn-disabled-border-color: var(--line);
}
.btn-outline-danger {
    --bs-btn-bg: var(--panel);
    --bs-btn-border-color: var(--line-strong);
    --bs-btn-color: var(--bad);
    --bs-btn-hover-bg: var(--bad-bg);
    --bs-btn-hover-border-color: var(--bad);
    --bs-btn-hover-color: var(--bad);
    --bs-btn-active-bg: var(--bad);
    --bs-btn-active-border-color: var(--bad);
    --bs-btn-active-color: #fff;
}
.btn-link { --bs-btn-color: var(--ink-2); --bs-btn-hover-color: var(--ink); text-decoration: none; }
.btn-ghost {
    --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-color: var(--ink-2);
    --bs-btn-hover-bg: var(--line); --bs-btn-hover-border-color: transparent; --bs-btn-hover-color: var(--ink);
    --bs-btn-active-bg: var(--line-strong); --bs-btn-active-border-color: transparent; --bs-btn-active-color: var(--ink);
}
.btn-icon { width: var(--control); padding: 0; }
.btn-sm.btn-icon, .btn-group-sm > .btn-icon { width: var(--control-sm); }
.btn-action { padding: 0 8px; font-size: var(--fs-sm); border-radius: var(--r); }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-top-left-radius: var(--r); border-bottom-left-radius: var(--r); }
.btn-group .btn:last-child, .btn-group form:last-child .btn { border-top-right-radius: var(--r); border-bottom-right-radius: var(--r); }

/* pola formularzy */
.form-label { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
.form-label.small { font-size: var(--fs-sm); }
.form-control, .form-select {
    min-height: var(--control);
    padding: 0 10px;
    font-size: var(--fs);
    color: var(--ink);
    background-color: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    line-height: 1.3;
}
textarea.form-control { min-height: auto; padding: 8px 10px; line-height: 1.45; }
.form-control-sm, .form-select-sm { min-height: var(--control-sm); font-size: var(--fs-sm); padding: 0 8px; }
.form-control:focus, .form-select:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(26, 25, 24, .12);
    outline: 0;
}
.form-control::placeholder { color: #9A958D; }
.form-control[readonly], .form-control:disabled { background: var(--panel-2); color: var(--ink-2); }
.form-select { background-position: right 8px center; padding-right: 28px; }
.form-check-input:checked { background-color: var(--black); border-color: var(--black); }
.form-check-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(26, 25, 24, .12); }
.input-group-text { background: var(--panel-2); border-color: var(--line-strong); color: var(--ink-3); font-size: var(--fs); }
.input-group-sm > .form-control, .input-group-sm > .form-select, .input-group-sm > .btn, .input-group-sm > .input-group-text {
    min-height: var(--control-sm); font-size: var(--fs-sm);
}
.required::after { content: " *"; color: var(--bad); }
.form-text { color: var(--ink-3); font-size: var(--fs-sm); }
.invalid-feedback { color: var(--bad); }

/* karty */
.card {
    --bs-card-border-color: var(--line);
    --bs-card-border-radius: var(--r-lg);
    --bs-card-bg: var(--panel);
    --bs-card-cap-bg: var(--panel);
    --bs-card-spacer-y: 14px;
    --bs-card-spacer-x: 16px;
    border: 1px solid var(--line);
    box-shadow: none;
}
.card-header {
    padding: 10px 16px;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-3);
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}
.card-header .bi { color: var(--ink-3); }
.card-header .btn { text-transform: none; letter-spacing: 0; margin-left: auto; }
.card-header .d-flex, .card-header span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.card-footer { background: var(--panel-2); border-top: 1px solid var(--line); padding: 10px 16px; }
.card-body > .table-responsive:first-child { margin: 0; }

/* alerty: spokojne, lewy pasek znaczenia */
.alert {
    --bs-alert-border-radius: var(--r);
    --bs-alert-padding-y: 10px;
    --bs-alert-padding-x: 14px;
    border: 1px solid var(--line);
    border-left-width: 3px;
    background: var(--panel);
    color: var(--ink);
    font-size: var(--fs);
}
.alert-success { border-left-color: var(--ok); background: var(--ok-bg); }
.alert-danger { border-left-color: var(--bad); background: var(--bad-bg); }
.alert-warning { border-left-color: var(--warn); background: var(--warn-bg); }
.alert-info { border-left-color: var(--info); background: var(--info-bg); }
.alert-secondary { border-left-color: var(--ink-3); background: var(--neutral-bg); }
.alert .btn-close { padding: 12px; }

/* odznaki: Bootstrapowe bg-* przepinamy na miękkie tła (StatusHelper zostaje bez zmian) */
.badge {
    --bs-badge-font-size: var(--fs-xs);
    --bs-badge-font-weight: 600;
    --bs-badge-padding-y: 3px;
    --bs-badge-padding-x: 8px;
    --bs-badge-border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.3;
    white-space: nowrap;
    letter-spacing: 0;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.bg-primary { background: var(--info-bg) !important; color: var(--info) !important; }
.badge.bg-info { background: var(--ok-bg) !important; color: var(--ok) !important; }
.badge.bg-success { background: var(--ok-bg) !important; color: var(--ok) !important; }
.badge.bg-warning { background: var(--warn-bg) !important; color: var(--warn) !important; }
.badge.bg-danger { background: var(--bad-bg) !important; color: var(--bad) !important; }
.badge.bg-secondary, .badge.bg-light { background: var(--neutral-bg) !important; color: var(--neutral) !important; }
.badge.bg-dark { background: var(--black) !important; color: #fff !important; }
.badge.bg-dark::before, .badge.badge-plain::before, .badge.tag::before, .badge[style*="background"]::before { display: none; }
.badge[style*="background-color:#fd7e14"], .badge[style*="background:#fd7e14"] { background: var(--brand-bg) !important; color: var(--brand-ink) !important; }
.badge[style*="background"] { color: #fff; }
/* kody typów dokumentów: WZ / PZ / MM jako prostokątne etykiety */
.tag {
    display: inline-flex; align-items: center;
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em;
    padding: 1px 6px; border-radius: 3px;
    border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--panel);
}
.tag-WZ, .tag-out { color: var(--bad); border-color: #F0C2BC; background: var(--bad-bg); }
.tag-PZ, .tag-PW, .tag-in { color: var(--ok); border-color: #BFE3CE; background: var(--ok-bg); }
.tag-WW, .tag-MM, .tag-move { color: var(--info); border-color: #C3D4F2; background: var(--info-bg); }

/* tabele */
.table {
    --bs-table-bg: var(--panel);
    --bs-table-color: var(--ink);
    --bs-table-border-color: var(--line);
    --bs-table-hover-bg: var(--panel-2);
    --bs-table-striped-bg: var(--panel-2);
    --bs-table-active-bg: var(--panel-2);
    margin-bottom: 0;
    font-size: var(--fs);
}
.table > :not(caption) > * > * { padding: 0 12px; border-bottom-color: var(--line); }
.table thead th, .table > thead > tr > th {
    height: 34px;
    vertical-align: middle;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-3);
    background: var(--panel-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table tbody td { height: var(--row); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-status-color], .table tbody tr[style*="border-left"] { border-left: 0 !important; }
.table td .text-muted, .table td small { color: var(--ink-3); }
.table td a { color: var(--ink); font-weight: 600; }
.table td a:hover { color: var(--brand-ink); }
.table .text-end, .table .num { font-variant-numeric: tabular-nums; }
.table-sm > :not(caption) > * > * { padding: 0 10px; }
.table-sm tbody td { height: calc(var(--row) - 4px); }
.table-light, .table-light > th, .table-light > td, .table-active, .table-active > td { --bs-table-bg: var(--panel-2); background: var(--panel-2); }
.table-secondary, .table-secondary > td { --bs-table-bg: var(--panel); color: var(--ink-3); }
.table-container, .table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.table-container .table, .table-wrap .table { margin: 0; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive .table { border-radius: 0; }
/* akcje w wierszu: wyciszone do najechania lub focusa, zawsze w DOM */
.row-actions, .table td .btn-group, .table td.text-nowrap.text-end {
    display: inline-flex; gap: 2px; align-items: center; justify-content: flex-end;
}
.table td .btn-group .btn, .table td .btn-action {
    border-color: transparent; background: transparent; color: var(--ink-3);
    min-height: var(--control-sm); width: var(--control-sm); padding: 0;
}
.table td .btn-group .btn.btn-outline-danger, .table td .btn-action.btn-outline-danger { color: var(--bad); }
.table td .btn-group .btn:hover, .table td .btn-action:hover,
.table td .btn-group .btn:focus-visible, .table td .btn-action:focus-visible {
    background: var(--line); color: var(--ink); border-color: transparent;
}
.table td .btn-group form { display: inline-flex; }
/* kolumna liczbowa z sumą */
.table .tot, .table tfoot td { font-weight: 600; }
.table tfoot td { background: var(--panel-2); border-top: 1px solid var(--line); }

/* paginacja */
.pagination { --bs-pagination-font-size: var(--fs-sm); --bs-pagination-padding-y: 0; --bs-pagination-padding-x: 0; margin: 0; gap: 4px; }
.page-link {
    min-width: var(--control-sm); height: var(--control-sm);
    display: inline-flex; align-items: center; justify-content: center; padding: 0 8px;
    border: 1px solid var(--line); border-radius: var(--r) !important; color: var(--ink-2); background: var(--panel);
}
.page-link:hover { background: var(--panel-2); color: var(--ink); border-color: var(--line-strong); }
.page-item.active .page-link { background: var(--black); border-color: var(--black); color: #fff; }
.page-item.disabled .page-link { color: #B5B0A8; background: var(--panel); border-color: var(--line); }

/* dropdowny, modale, tooltipy */
.dropdown-menu { border: 1px solid var(--line); box-shadow: var(--shadow-pop); border-radius: var(--r-lg); padding: 4px; font-size: var(--fs); }
.dropdown-item { font-size: var(--fs); padding: 8px 10px; border-radius: var(--r); color: var(--ink); display: flex; gap: 8px; align-items: center; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--panel-2); color: var(--ink); }
.dropdown-item i { width: 18px; color: var(--ink-3); }
.dropdown-item.text-danger i { color: var(--bad); }
.dropdown-divider { border-color: var(--line); margin: 4px 0; }
.modal-content { border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
.modal-header { border-bottom: 1px solid var(--line); padding: 14px 18px; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px; }
.modal-footer { border-top: 1px solid var(--line); padding: 12px 18px; gap: 8px; }
.list-group-item { border-color: var(--line); font-size: var(--fs); }
.list-group-item-action:hover { background: var(--panel-2); }
.tooltip { --bs-tooltip-bg: var(--black); --bs-tooltip-font-size: var(--fs-xs); }
.spinner-border.text-primary { color: var(--brand-ink) !important; }
.progress { height: 6px; background: var(--line); border-radius: 3px; }
.progress-bar { background: var(--ok); }
hr { border-color: var(--line); opacity: 1; }

/* ---------- 3. UKŁAD ---------- */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--panel);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    z-index: 1000;
    display: flex; flex-direction: column;
    transition: transform .22s ease;
}
.sidebar-logo {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px 10px;
    min-height: var(--topbar-height);
}
.sidebar-logo img { height: 34px; width: auto; display: block; }
.sidebar-close { display: none; }
.sidebar-menu { list-style: none; padding: 4px 10px 20px; margin: 0; }
.sidebar-menu li { margin: 0; }
.sidebar-menu li a {
    display: flex; align-items: center; gap: 10px;
    min-height: 34px; padding: 6px 10px;
    border-radius: var(--r);
    color: var(--ink-2); font-size: var(--fs); font-weight: 500;
    position: relative;
    text-decoration: none;
    border-left: 0;
}
.sidebar-menu li a:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }
.sidebar-menu li a.active { background: var(--bg); color: var(--ink); box-shadow: inset 2px 0 0 var(--brand); }
.sidebar-menu li a i { width: 18px; text-align: center; font-size: 15px; color: var(--ink-3); margin: 0; }
.sidebar-menu li a.active i { color: var(--brand-ink); }
.sidebar-menu .menu-header {
    padding: 16px 10px 4px;
    font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
    color: var(--ink-3); font-weight: 600;
}
.sidebar-menu .badge { margin-left: auto; }
#chatSidebarBadge { position: static; transform: none; font-size: 10px; padding: 1px 6px; }
#chatSidebarBadge::before { display: none; }
.sidebar-foot { margin-top: auto; padding: 10px 14px 14px; font-size: var(--fs-xs); color: var(--ink-3); border-top: 1px solid var(--line); }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(26, 25, 24, .45); z-index: 999; }
.sidebar-overlay.active { display: block; }

.topbar {
    position: fixed; top: 0; left: var(--sidebar-width); right: 0;
    height: var(--topbar-height);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 10px;
    padding: 0 20px;
    z-index: 999;
}
.topbar-brand { display: none; }
.topbar-toggle {
    display: none;
    width: var(--touch); height: var(--touch);
    border: 1px solid var(--line); border-radius: var(--r); background: var(--panel);
    font-size: 20px; color: var(--ink); cursor: pointer;
    align-items: center; justify-content: center;
    margin-left: auto; order: 9;
}
.topbar-search { flex: 1; max-width: 460px; position: relative; }
.topbar-search input {
    width: 100%; height: var(--control);
    padding: 0 12px 0 34px;
    border: 1px solid var(--line); border-radius: var(--r);
    font-size: var(--fs); font-family: inherit;
    background: var(--bg); color: var(--ink);
}
.topbar-search input:focus { outline: none; border-color: var(--ink); background: var(--panel); box-shadow: 0 0 0 3px rgba(26, 25, 24, .1); }
.topbar-search input.dropdown-open { border-radius: var(--r) var(--r) 0 0; }
.topbar-search > i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); z-index: 1051; pointer-events: none; font-size: 14px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-user .user-info { text-align: right; font-size: var(--fs-sm); line-height: 1.25; }
.topbar-user .user-name { font-weight: 600; color: var(--ink); }
.topbar-user .user-role { color: var(--ink-3); font-size: var(--fs-xs); }
.topbar-user .btn-link { padding: 4px; color: var(--ink-2); }
.topbar-user .bi-person-circle { font-size: 24px !important; }
.topbar-notifications .btn-link { padding: 4px 8px; color: var(--ink-2); }
.topbar-notifications .bi-bell { font-size: 18px !important; }

.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 20px 20px 48px;
    min-height: calc(100vh - var(--topbar-height));
    min-width: 0;
}

/* nagłówek strony */
.page-header {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 14px;
}
.page-header h1 {
    font-size: 20px; font-weight: 600; margin: 0; color: var(--ink);
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.page-header h1 .bi { color: var(--ink-3); font-size: 18px; }
.page-header h1 .badge { font-size: var(--fs-xs); }
.page-header .page-meta { color: var(--ink-3); font-size: var(--fs); }
.page-header > .btn, .page-header > .d-flex, .page-header .page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.page-header > .text-muted { margin-left: auto; }
.page-header.d-flex.justify-content-between > :last-child { margin-left: auto; }
.page-actions-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.page-actions-bar form { display: inline-flex; }

/* zakładki statusów z licznikami */
.status-tabs {
    display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto;
    border-bottom: 1px solid var(--line); margin-bottom: 10px;
    scrollbar-width: none;
}
.status-tabs::-webkit-scrollbar { display: none; }
.status-tabs a {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 12px; margin-bottom: -1px;
    color: var(--ink-2); font-weight: 500; white-space: nowrap;
    border-bottom: 2px solid transparent;
    text-decoration: none;
}
.status-tabs a:hover { color: var(--ink); border-color: var(--line-strong); text-decoration: none; }
.status-tabs a.active { color: var(--ink); font-weight: 600; border-color: var(--ink); }
.status-tabs .cnt {
    font-size: var(--fs-xs); color: var(--ink-3); font-weight: 500;
    background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 6px; line-height: 16px;
}

/* pasek filtrów */
.filters-bar, .filter-bar {
    display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap;
    background: transparent; padding: 0; margin-bottom: 10px; border: 0; box-shadow: none; border-radius: 0;
}
.filters-bar .form-group { margin: 0; }
.filters-bar label, .filter-bar label { display: block; font-size: var(--fs-xs); color: var(--ink-3); margin-bottom: 3px; font-weight: 500; }
.filters-bar select, .filters-bar input, .filter-bar select, .filter-bar input { min-width: 150px; }
.filter-bar .filter-search { flex: 1 1 220px; min-width: 180px; }
.filter-bar .filter-search input { min-width: 0; width: 100%; }
.filter-bar .filter-actions { display: flex; gap: 6px; }
.filter-bar .btn { min-height: var(--control-sm); }
.filter-bar .form-select, .filter-bar .form-control { min-height: var(--control-sm); font-size: var(--fs-sm); }
.results-info { color: var(--ink-3); font-size: var(--fs-sm); margin-bottom: 8px; }
.results-info strong { color: var(--ink); }
/* stopka tabeli: liczniki i sumy */
.table-foot {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel-2);
    color: var(--ink-3); font-size: var(--fs-sm);
}
.table-foot b, .table-foot strong { color: var(--ink); font-weight: 600; }
.table-foot .pagination, .table-foot > .mt-3 { margin: 0 0 0 auto !important; }

/* pulpit */
.stat-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: 14px 16px; display: flex; align-items: center; gap: 14px; box-shadow: none;
}
.stat-card .stat-icon {
    width: 36px; height: 36px; border-radius: var(--r);
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; color: var(--ink-2) !important; background: var(--bg) !important; border: 1px solid var(--line);
}
.stat-card .stat-value { font-size: 22px; font-weight: 600; color: var(--ink); line-height: 1.1; letter-spacing: -.01em; }
.stat-card .stat-label { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; }

/* widok szczegółów */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0 16px 8px; box-shadow: none; }
.detail-section h5 {
    font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em;
    margin: 0 -16px 6px; padding: 12px 16px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 8px;
}
.detail-row { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--ink-3); font-size: var(--fs); }
.detail-value { font-weight: 500; font-size: var(--fs); color: var(--ink); text-align: right; }
/* tabela klucz-wartość (karty show) */
.kv-table th, .kv-table td, .card-body > .table-sm th, .card-body > .table-sm td { height: auto; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: var(--fs); }
.kv-table th, .card-body > .table-sm th { font-weight: 400; color: var(--ink-3); background: transparent; text-transform: none; letter-spacing: 0; font-size: var(--fs); }
.card-body > .table-sm tr:last-child th, .card-body > .table-sm tr:last-child td { border-bottom: 0; }

/* pozycje dokumentu (edycja) */
.items-table, .items-editor .table { width: 100%; }
.items-editor .table td { height: auto; padding: 4px 6px; }
.items-editor .table td:first-child { padding-left: 12px; min-width: 240px; }
.items-editor .table th { padding: 0 6px; }
.items-editor .table th:first-child { padding-left: 12px; }
.items-editor .form-control, .items-editor .form-select { min-height: var(--control-sm); font-size: var(--fs); padding: 0 8px; }
.items-editor .form-control[type=number] { text-align: right; }
.items-editor .item-net-total, .items-editor .item-gross-total { font-weight: 600; white-space: nowrap; }
.items-editor .input-group .btn { min-height: var(--control-sm); }
.items-editor .product-name-input[readonly] { background: var(--panel) !important; cursor: pointer; }
.items-table th { font-size: var(--fs-sm); padding: 8px; background: var(--panel-2); }
.items-table td { padding: 5px 8px; }
.items-table input, .items-table select { width: 100%; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: var(--r); font-size: var(--fs); }
.items-table .item-total { font-weight: 600; text-align: right; }
.items-table .remove-item { cursor: pointer; color: var(--bad); }
.items-hint { padding: 8px 12px; color: var(--ink-3); font-size: var(--fs-sm); border-top: 1px dashed var(--line); }
/* podsumowanie kwot */
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; min-width: 260px; margin-left: auto; }
.totals .lbl { color: var(--ink-3); }
.totals .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 18px; font-weight: 600; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.totals .grand.lbl { color: var(--ink); }
.card-footer .table-sm td { height: auto; padding: 4px 8px; border: 0; background: transparent; }
.card-footer .table-sm tr.table-active td { border-top: 1px solid var(--line); background: transparent; }
/* pasek akcji formularza przyklejony u dołu */
.form-actions {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    background: var(--panel); border-top: 1px solid var(--line);
    margin: 16px -20px -48px; padding: 10px 20px;
}
.form-actions .form-actions-info { color: var(--ink-3); font-size: var(--fs-sm); }
.form-actions .form-actions-right { margin-left: auto; display: flex; gap: 8px; }

/* stany magazynowe: kolumny i wskaźniki */
.stock-cols th.num, .stock-cols td.num { text-align: right; }
.stock-cols .col-available { font-weight: 600; }
.stock-neg { color: var(--bad); font-weight: 600; }
.stock-low { color: var(--warn); font-weight: 600; }
.stock-ok { color: var(--ok); }
.stock-transit { color: var(--info); }
.meter { display: inline-block; width: 72px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.meter > i { display: block; height: 100%; background: var(--ok); }
.meter > i.warn { background: var(--warn); }
.meter > i.bad { background: var(--bad); }
.stock-info { margin-top: 4px; font-size: var(--fs-sm); line-height: 1.4; }
.stock-info .badge { font-size: var(--fs-xs); padding: 2px 8px; }
.stock-info .btn-sm { font-size: var(--fs-xs); min-height: 24px; padding: 0 8px; }
.stock-other-warehouses { margin-top: 3px; }
.stock-other-warehouses .badge { font-size: 10px; margin-right: 4px; margin-bottom: 2px; }

/* puste stany */
.empty-state {
    text-align: center; padding: 40px 20px; color: var(--ink-3);
}
.empty-state .bi { font-size: 28px; display: block; margin-bottom: 8px; color: var(--line-strong); }
.empty-state .empty-title { color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.empty-state .btn { margin-top: 12px; }
.table td.empty-state { height: auto; }

/* toasty */
.toast-stack {
    position: fixed; top: calc(var(--topbar-height) + 10px); right: 16px; z-index: 1080;
    display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px));
}
.toast-item {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--ink-3);
    border-radius: var(--r-lg); padding: 10px 12px; box-shadow: var(--shadow-pop);
    font-size: var(--fs); color: var(--ink);
    animation: toast-in .18s ease-out;
}
.toast-item.success { border-left-color: var(--ok); }
.toast-item.error { border-left-color: var(--bad); }
.toast-item.warning { border-left-color: var(--warn); }
.toast-item.info { border-left-color: var(--info); }
.toast-item .toast-msg { flex: 1; }
.toast-item .toast-close { background: none; border: 0; color: var(--ink-3); font-size: 16px; line-height: 1; padding: 0 2px; cursor: pointer; }
.toast-item.hide { opacity: 0; transform: translateX(8px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.flash-container { margin-bottom: 14px; }

/* modal potwierdzenia */
.confirm-modal .modal-body { font-size: 14px; }
.confirm-modal .modal-dialog { max-width: 440px; }

/* kafelki akcji na telefonie (dolny pasek) */
.bottom-nav {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0; height: 60px;
    background: var(--panel); border-top: 1px solid var(--line); z-index: 998;
    grid-template-columns: repeat(5, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 10.5px; color: var(--ink-3); text-decoration: none; font-weight: 500;
}
.bottom-nav a .bi { font-size: 20px; }
.bottom-nav a.active { color: var(--brand-ink); }

/* logowanie */
.login-page { background: var(--bg); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 32px 28px; width: 100%; max-width: 400px; box-shadow: none; }
.login-logo { text-align: center; margin-bottom: 18px; }
.login-logo img { max-width: 180px; height: auto; }
.login-title { text-align: center; font-size: 15px; color: var(--ink-2); margin-bottom: 22px; font-weight: 500; }
.login-foot { text-align: center; color: var(--ink-3); font-size: var(--fs-xs); margin-top: 18px; }

/* ---------- 5. MODUŁY ---------- */
/* wyszukiwarka globalna */
.search-dropdown {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--panel); border: 1px solid var(--line); border-top: 0;
    border-radius: 0 0 var(--r-lg) var(--r-lg); box-shadow: var(--shadow-pop);
    z-index: 1050; max-height: 450px; overflow: hidden;
}
.search-dropdown.active { display: flex; }
.search-categories { width: 170px; border-right: 1px solid var(--line); padding: 6px; background: var(--panel-2); flex-shrink: 0; }
.search-cat { padding: 7px 10px; cursor: pointer; font-size: var(--fs-sm); color: var(--ink-2); display: flex; align-items: center; gap: 8px; border-radius: var(--r); }
.search-cat:hover { background: var(--line); }
.search-cat.active { background: var(--black); color: #fff; }
.search-results-panel { flex: 1; overflow-y: auto; max-height: 450px; padding: 6px 0; }
.search-recent-header, .search-result-group-title { padding: 6px 14px 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.search-result-group { padding: 4px 0; }
.search-result-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; text-decoration: none; color: var(--ink); font-size: var(--fs); cursor: pointer; }
.search-result-item:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }
.search-result-item .result-icon { font-size: 15px; color: var(--ink-3); width: 20px; text-align: center; flex-shrink: 0; }
.search-result-item .result-title { flex: 1; white-space: normal; overflow-wrap: anywhere; line-height: 1.3; font-weight: 500; }
.search-result-item .result-type { font-size: var(--fs-xs); color: var(--ink-3); background: var(--bg); border: 1px solid var(--line); padding: 1px 6px; border-radius: 3px; margin-left: auto; flex-shrink: 0; white-space: nowrap; }
.search-no-results, .search-hint { padding: 16px 14px; text-align: center; color: var(--ink-3); font-size: var(--fs-sm); }

/* powiadomienia */
.topbar-notifications { position: relative; }
.notification-badge {
    position: absolute; top: 0; right: 2px;
    background: var(--brand-strong); color: #fff; font-size: 10px; font-weight: 600;
    min-width: 16px; height: 16px; line-height: 16px; text-align: center; border-radius: 8px; padding: 0 4px;
}
.notification-dropdown {
    display: none; position: absolute; top: calc(100% + 6px); right: 0; width: 360px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
    z-index: 1050; max-height: 450px; overflow: hidden;
}
.notification-dropdown.active { display: block; }
.notification-dropdown-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); font-size: var(--fs); }
.notification-dropdown-body { overflow-y: auto; max-height: 380px; }
.notification-item { padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--brand-bg); }
.notification-item:hover, .notification-item-read:hover { background: var(--panel-2); }
.notification-item-read { background: var(--panel); }
.notification-title { font-size: var(--fs); font-weight: 600; color: var(--ink); line-height: 1.3; }
.notification-message { font-size: var(--fs-sm); color: var(--ink-2); margin-top: 2px; line-height: 1.3; }
.notification-time { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 3px; }

/* wybór klienta */
.client-select-display { background: var(--panel); }
.client-select-display:hover { border-color: var(--ink-3); }
.client-select-option:hover { background: var(--panel-2); }
.client-select-wrapper .btn-close-sm { width: .6em; height: .6em; }

/* autouzupełnianie produktu w wierszu */
.item-autocomplete {
    background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg);
    box-shadow: var(--shadow-pop); max-height: 320px; overflow-y: auto; z-index: 2000;
}
.item-autocomplete .ac-item { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.item-autocomplete .ac-item:hover, .item-autocomplete .ac-item.active { background: var(--panel-2); }
.item-autocomplete .ac-name { font-size: var(--fs); font-weight: 500; color: var(--ink); }
.item-autocomplete .ac-meta { font-size: var(--fs-xs); color: var(--ink-3); }
.item-autocomplete .ac-empty { padding: 8px 10px; font-size: var(--fs-sm); color: var(--ink-3); }

/* mapa odległości */
.distance-map-wrapper { display: flex; gap: 16px; min-height: 300px; }
.distance-map-canvas { flex: 1; min-height: 300px; border-radius: var(--r); overflow: hidden; z-index: 1; border: 1px solid var(--line); }
.distance-map-table { width: 280px; flex-shrink: 0; overflow-y: auto; max-height: 350px; }
.distance-map-marker { background: none !important; border: none !important; }

/* czat (strona) */
.chat-container { display: flex; height: calc(100vh - var(--topbar-height) - 40px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.chat-sidebar { width: 280px; min-width: 280px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--panel-2); }
.chat-sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 600; }
.chat-channel-list { flex: 1; overflow-y: auto; }
.chat-channel-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.chat-channel-item:hover { background: var(--line); }
.chat-channel-item.active { background: var(--panel); box-shadow: inset 2px 0 0 var(--brand); }
.chat-channel-name { font-size: var(--fs); font-weight: 600; color: var(--ink); }
.chat-channel-preview { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; }
.chat-unread-badge { font-size: var(--fs-xs); min-width: 20px; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-main-header { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); min-height: 48px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.chat-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; color: var(--ink-3); }
.chat-message { display: flex; flex-direction: column; max-width: 70%; margin-bottom: 4px; }
.chat-message-mine { align-self: flex-end; align-items: flex-end; }
.chat-message-other { align-self: flex-start; align-items: flex-start; }
.chat-msg-author { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; margin-bottom: 2px; padding-left: 12px; }
.chat-msg-bubble { padding: 8px 12px; border-radius: 10px; max-width: 100%; word-wrap: break-word; }
.chat-message-mine .chat-msg-bubble { background: var(--black); color: #fff; border-bottom-right-radius: 3px; }
.chat-message-other .chat-msg-bubble { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.chat-msg-text { font-size: var(--fs); line-height: 1.4; }
.chat-msg-time { font-size: 10px; opacity: .7; text-align: right; margin-top: 2px; }
.chat-message-mine .chat-msg-time { color: rgba(255,255,255,.7); }
.chat-message-other .chat-msg-time { color: var(--ink-3); }
.chat-input-area { padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel); position: relative; }
.chat-input-area .form-control { border-radius: var(--r); }
.chat-input-area .btn { border-radius: var(--r); width: auto; height: auto; padding: 0 12px; }
.chat-mention-dropdown { position: absolute; bottom: 100%; left: 14px; right: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); max-height: 280px; overflow-y: auto; z-index: 100; margin-bottom: 4px; }
.chat-mention-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: var(--fs); border-bottom: 1px solid var(--line); }
.chat-mention-item:last-child { border-bottom: none; }
.chat-mention-item:hover, .chat-mention-item.selected { background: var(--panel-2); }
.chat-mention-item .bi { color: var(--brand-ink); font-size: 15px; min-width: 20px; }
.chat-mention-title { flex: 1; font-weight: 500; color: var(--ink); }
.chat-mention-type { font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; }
.chat-mention-link { display: inline; padding: 1px 4px; border-radius: 3px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.chat-mention-link .bi { font-size: 12px; margin-right: 2px; }
.chat-message-mine .chat-mention-link { background: rgba(255,255,255,.2); color: #fff; }
.chat-message-other .chat-mention-link { background: var(--brand-bg); color: var(--brand-ink); }
.chat-online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; flex-shrink: 0; }
.chat-online-dot.online { background: var(--ok); }
.chat-online-dot.offline { background: var(--line-strong); }
.chat-channel-item .chat-online-dot { margin-top: 4px; }

/* czat (widżet) i asystent: wspólny, stonowany styl */
.chat-widget-bubble, .ai-chatbot-bubble {
    position: fixed; bottom: 18px; right: 18px; width: 48px; height: 48px; border-radius: 50%;
    background: var(--black); color: #fff; border: 1px solid var(--black); cursor: pointer; z-index: 1050;
    display: flex; align-items: center; justify-content: center; font-size: 20px;
    box-shadow: 0 4px 14px rgba(26,25,24,.25); transition: transform .15s;
}
.ai-chatbot-bubble { right: 74px; background: var(--panel); color: var(--ink); border-color: var(--line-strong); }
.chat-widget-bubble:hover, .ai-chatbot-bubble:hover { transform: translateY(-1px); }
.chat-widget-badge { position: absolute; top: -4px; right: -4px; background: var(--brand-strong); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 10px; padding: 0 5px; border: 2px solid var(--panel); }
.chat-widget-panel, .ai-chatbot-panel {
    position: fixed; bottom: 76px; right: 18px; width: 360px; height: 500px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
    flex-direction: column; overflow: hidden; opacity: 0; transform: translateY(12px); transition: opacity .2s ease, transform .2s ease;
}
.chat-widget-panel { z-index: 1049; display: none; }
.ai-chatbot-panel { z-index: 1051; right: 74px; display: flex; }
.chat-widget-panel.open, .ai-chatbot-panel.open { opacity: 1; transform: translateY(0); }
.chat-widget-header, .ai-chatbot-header { background: var(--panel); color: var(--ink); padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; border-bottom: 1px solid var(--line); }
.chat-widget-title, .ai-chatbot-title { font-weight: 600; font-size: 14px; }
.ai-chatbot-header-left { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.chat-widget-header-btns, .ai-chatbot-header-btns { display: flex; gap: 4px; }
.chat-widget-btn, .ai-chatbot-hbtn { background: none; border: none; color: var(--ink-2); cursor: pointer; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: var(--r); font-size: 15px; }
.chat-widget-btn:hover, .ai-chatbot-hbtn:hover { background: var(--line); }
.chat-widget-channels { flex: 1; overflow-y: auto; }
.chat-widget-ch-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.chat-widget-ch-item:hover { background: var(--panel-2); }
.chat-widget-ch-top { display: flex; align-items: center; gap: 6px; }
.chat-widget-ch-name { flex: 1; font-size: var(--fs); font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-widget-ch-badge { background: var(--brand-strong); color: #fff; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 10px; padding: 0 6px; flex-shrink: 0; }
.chat-widget-ch-preview { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-widget-online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.chat-widget-online-dot.online { background: var(--ok); }
.chat-widget-online-dot.offline { background: var(--line-strong); }
.chat-widget-conv, .chat-widget-new-chat { flex: 1; flex-direction: column; overflow: hidden; }
.chat-widget-conv-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); flex-shrink: 0; }
.chat-widget-conv-header .chat-widget-btn { color: var(--ink); width: 28px; height: 28px; font-size: 14px; }
.chat-widget-conv-name { font-weight: 600; font-size: var(--fs); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-widget-messages, .ai-chatbot-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.chat-widget-msg { display: flex; flex-direction: column; max-width: 85%; }
.chat-widget-msg-mine { align-self: flex-end; align-items: flex-end; }
.chat-widget-msg-other { align-self: flex-start; align-items: flex-start; }
.chat-widget-msg-author { font-size: 10px; color: var(--ink-3); font-weight: 600; margin-bottom: 1px; padding-left: 10px; }
.chat-widget-msg-bubble { padding: 6px 10px; border-radius: 10px; max-width: 100%; word-wrap: break-word; }
.chat-widget-msg-mine .chat-widget-msg-bubble { background: var(--black); color: #fff; border-bottom-right-radius: 3px; }
.chat-widget-msg-other .chat-widget-msg-bubble { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.chat-widget-msg-text { font-size: var(--fs); line-height: 1.4; }
.chat-widget-msg-time { font-size: 9px; opacity: .7; text-align: right; margin-top: 1px; }
.chat-widget-msg-mine .chat-widget-msg-time { color: rgba(255,255,255,.7); }
.chat-widget-msg-mine .chat-mention-link { background: rgba(255,255,255,.2); color: #fff; }
.chat-widget-msg-other .chat-mention-link { background: var(--brand-bg); color: var(--brand-ink); }
.chat-widget-input-area, .ai-chatbot-input-area { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel); flex-shrink: 0; }
.chat-widget-input, .ai-chatbot-input { flex: 1; border: 1px solid var(--line-strong); border-radius: var(--r); padding: 0 10px; height: var(--control); font-size: var(--fs); outline: none; font-family: inherit; }
.chat-widget-input:focus, .ai-chatbot-input:focus { border-color: var(--ink); }
.chat-widget-send, .ai-chatbot-send { width: var(--control); height: var(--control); border-radius: var(--r); background: var(--black); color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.chat-widget-send:hover, .ai-chatbot-send:hover { background: #333130; }
.chat-widget-user-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.chat-widget-user-item { padding: 10px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: var(--fs); color: var(--ink); border-bottom: 1px solid var(--line); }
.chat-widget-user-item:hover { background: var(--panel-2); }
.chat-widget-empty, .ai-chatbot-welcome { text-align: center; padding: 30px 16px; color: var(--ink-3); font-size: var(--fs); }
.ai-chatbot-welcome-icon { font-size: 36px; color: var(--line-strong); margin-bottom: 10px; }
.ai-chatbot-welcome-text { font-size: var(--fs); line-height: 1.5; }
.ai-chatbot-msg { display: flex; gap: 8px; max-width: 90%; }
.ai-chatbot-msg-user { align-self: flex-end; flex-direction: row-reverse; }
.ai-chatbot-msg-bot { align-self: flex-start; }
.ai-chatbot-msg-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--line); color: var(--ink-2); display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; margin-top: 2px; }
.ai-chatbot-msg-bubble { padding: 8px 12px; border-radius: 10px; max-width: 100%; word-wrap: break-word; font-size: var(--fs); line-height: 1.5; }
.ai-chatbot-msg-user .ai-chatbot-msg-bubble { background: var(--black); color: #fff; border-bottom-right-radius: 3px; }
.ai-chatbot-msg-bot .ai-chatbot-msg-bubble { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.ai-chatbot-admin-link { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.ai-chatbot-contact-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--black); color: #fff; border-radius: var(--r); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
.ai-chatbot-contact-btn:hover { background: #333130; color: #fff; }
.ai-typing-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.ai-typing-dots span { width: 6px; height: 6px; background: var(--ink-3); border-radius: 50%; animation: aiTypingBounce 1.4s infinite; }
.ai-typing-dots span:nth-child(2) { animation-delay: .2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes aiTypingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ---------- 6. RESPONSYWNOŚĆ ---------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: min(300px, 86vw); border-right: 1px solid var(--line); box-shadow: var(--shadow-pop); }
    .sidebar.active { transform: translateX(0); }
    .sidebar-logo { padding: 10px 14px; }
    .sidebar-close { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); font-size: 18px; }
    .sidebar-menu li a { min-height: var(--touch); }
    .topbar { left: 0; padding: 0 12px; gap: 8px; }
    .topbar-brand { display: flex; align-items: center; order: 0; }
    .topbar-brand img { height: 28px; width: auto; display: block; }
    .topbar-search { order: 1; flex: 1; max-width: none; }
    .topbar-right { order: 2; margin-left: 0; }
    .topbar-toggle { display: inline-flex; }
    .topbar-user .user-info { display: none; }
    .main-content { margin-left: 0; padding: 14px 16px 90px; }
    .page-header h1 { font-size: 18px; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-actions { margin: 16px -16px -90px; padding: 10px 16px; bottom: 60px; }
    .bottom-nav { display: grid; }
    .notification-dropdown { position: fixed; top: var(--topbar-height); left: 8px; right: 8px; width: auto; }
    .search-dropdown { position: fixed; top: var(--topbar-height); left: 0; right: 0; max-height: calc(100vh - var(--topbar-height)); border-radius: 0; }
    .search-categories { width: 130px; }
    .search-cat { font-size: var(--fs-sm); padding: 8px 8px; }
    .distance-map-wrapper { flex-direction: column; }
    .distance-map-canvas { min-height: 250px; }
    .distance-map-table { width: 100%; }
    .chat-widget-bubble, .ai-chatbot-bubble { bottom: 72px; }
    .chat-widget-panel, .ai-chatbot-panel { bottom: 128px; width: calc(100vw - 16px); right: 8px; height: calc(100vh - 200px); }
    .totals { min-width: 0; width: 100%; }
    .filter-bar { gap: 6px; }
    .filter-bar .form-group, .filters-bar .form-group { flex: 1 1 140px; }
    .filters-bar select, .filters-bar input, .filter-bar select, .filter-bar input { min-width: 0; width: 100%; }
}
@media (max-width: 767.98px) {
    .topbar-search input { padding-left: 32px; }
    .page-header > .btn, .page-header .page-actions, .page-header > .d-flex { width: 100%; margin-left: 0; }
    .page-header .page-actions .btn, .page-header > .d-flex .btn { flex: 1 1 auto; }
    .chat-sidebar { width: 100%; min-width: 100%; }
    .chat-main { display: none; }
    .chat-channel-open .chat-sidebar { display: none; }
    .chat-channel-open .chat-main { display: flex; }
    .chat-message { max-width: 85%; }
    /* tabele-karty: nagłówek znika, każdy wiersz staje się kartą z etykietami z data-label */
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
    .table-cards tr:last-child { border-bottom: 0; }
    .table-cards td { height: auto; padding: 3px 0; border: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; white-space: normal; }
    .table-cards td[data-label]::before { content: attr(data-label); color: var(--ink-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; text-align: left; flex-shrink: 0; }
    .table-cards td.card-title-cell { justify-content: flex-start; text-align: left; font-size: 15px; padding-bottom: 6px; }
    .table-cards td.card-title-cell::before { display: none; }
    .table-cards td.card-actions-cell { justify-content: flex-end; padding-top: 8px; }
    .table-cards td.card-actions-cell::before { display: none; }
    .table-cards td.card-actions-cell .btn, .table-cards td.card-actions-cell .btn-group .btn { border-color: var(--line-strong); background: var(--panel); color: var(--ink); width: auto; padding: 0 10px; min-height: var(--control-sm); }
    .table-cards td.empty-state { display: block; text-align: center; }
    .table-cards td.empty-state::before { display: none; }
    .table-cards .table-responsive { overflow: visible; }
}

/* ---------- 7. DRUK ---------- */
@media print {
    .sidebar, .topbar, .no-print, .bottom-nav, .chat-widget-bubble, .ai-chatbot-bubble, .chat-widget-panel, .ai-chatbot-panel, .toast-stack, .form-actions, .status-tabs, .filter-bar, .filters-bar { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    body { background: #fff; }
    .card, .table-container { border-color: #ccc; }
}

/* wiersz pozycji bez wybranego produktu (walidacja) */
.items-editor tr.row-invalid td { background: var(--warn-bg); }

a.stat-card, a.stat-card:hover { color: inherit; text-decoration: none; }
a.stat-card:hover { border-color: var(--line-strong); }

/* poprawki po testach 390/1440 */
.table-responsive { position: relative; }               /* visually-hidden w th nie rozpycha strony */
.table tbody td { white-space: nowrap; }
.table tbody td.text-wrap, .table tbody td .text-wrap { white-space: normal; }
@media (min-width: 992px) {
    .form-actions { padding-right: 150px; }              /* miejsce na przyciski czatu w prawym dolnym rogu */
}
@media (max-width: 767.98px) {
    .table-cards td.text-end { text-align: right; }
}

/* ---------- komponenty dla ekranów etapu 1 (wersje, warianty, stany, kompletacja) ---------- */
/* zakładki wariantów / wersji oferty: ta sama anatomia co .status-tabs */
.variant-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.variant-tabs a, .variant-tabs button {
    background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
    padding: 9px 14px; color: var(--ink-2); font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer; text-decoration: none;
}
.variant-tabs a.active, .variant-tabs button.active { color: var(--ink); font-weight: 600; border-color: var(--brand); }
.variant-tabs .add { color: var(--brand-ink); }
.variant-sum { font-size: var(--fs-sm); color: var(--ink-3); margin-left: 6px; }

/* oś wersji i historia zmian */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: var(--fs); color: var(--ink-2); }
.timeline li:last-child { border-bottom: 0; }
.timeline time, .timeline .ver { color: var(--ink-3); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.timeline .ver { font-weight: 600; color: var(--ink); }
.timeline .who { color: var(--ink); font-weight: 500; }

/* widok dzielony: tabela stanów + panel kartoteki */
.split-view { display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.split-view > .split-detail { border-left: 1px solid var(--line); background: var(--panel-2); padding: 16px; }
.split-detail h3 { font-size: 15px; font-weight: 600; margin: 2px 0 6px; }
.split-detail .kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 10px 0; }
.split-detail .kv span:nth-child(odd) { color: var(--ink-2); }
.split-detail .kv span:nth-child(even) { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.stock-stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line); margin: 8px 0; }
.stock-stack i { display: block; height: 100%; }
.stock-stack .avail { background: var(--ok); }
.stock-stack .res { background: var(--warn); }
.stock-stack .blk { background: var(--bad); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--ink-3); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
@media (max-width: 991.98px) {
    .split-view { grid-template-columns: 1fr; }
    .split-view > .split-detail { border-left: 0; border-top: 1px solid var(--line); }
}

/* lista kompletacyjna: jedna pozycja = jedna karta, duże cele dotykowe */
.pick-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin-bottom: 10px; }
.pick-head .pick-doc { color: var(--ink-3); font-size: var(--fs-sm); }
.pick-head h2 { font-size: 18px; font-weight: 600; margin: 0; width: 100%; }
.pick-segment { display: flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; background: var(--panel); margin-bottom: 12px; }
.pick-segment a, .pick-segment button { flex: 1; text-align: center; padding: 10px 4px; font: inherit; font-weight: 500; color: var(--ink-2); background: none; border: 0; border-right: 1px solid var(--line); text-decoration: none; min-height: var(--touch); }
.pick-segment a:last-child, .pick-segment button:last-child { border-right: 0; }
.pick-segment .active { background: var(--black); color: #fff; }
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name qty" "where qty" "act act";
    gap: 2px 14px; padding: 12px 14px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.pick .pick-name { grid-area: name; font-weight: 600; font-size: 15px; }
.pick .pick-where { grid-area: where; color: var(--ink-3); font-size: var(--fs-sm); }
.pick .pick-qty { grid-area: qty; text-align: right; align-self: center; }
.pick .pick-qty b { display: block; font-size: 24px; font-weight: 600; line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.pick .pick-qty small { color: var(--ink-3); }
.pick .pick-actions { grid-area: act; display: flex; gap: 8px; margin-top: 8px; }
.pick .pick-actions .btn { flex: 1; min-height: var(--touch); font-size: 14px; }
.pick .pick-actions .form-control { max-width: 110px; min-height: var(--touch); text-align: right; font-size: 16px; }
.pick.is-short { border-color: #F0C2BC; background: #FFFBFA; }
.pick.is-short .pick-qty b { color: var(--bad); }
.pick.is-done { opacity: .6; }
.pick.is-done .pick-name { text-decoration: line-through; }
.pick-bar {
    position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
    background: var(--panel); border-top: 1px solid var(--line); margin: 14px -20px -48px; padding: 10px 20px;
}
.pick-bar .btn { min-height: var(--touch); }
.pick-bar .progress { flex: 1; min-width: 80px; }
@media (max-width: 991.98px) { .pick-bar { margin: 14px -16px -90px; padding: 10px 16px; bottom: 60px; } }

/* ---------- oferty: warianty i wersje (karta oferty) ---------- */
.variant-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.variant-row:last-of-type { border-bottom: 0; }
.variant-row .variant-name { min-width: 96px; font-weight: 600; }
.version-pill {
    display: inline-flex; align-items: center; gap: 5px; min-height: var(--control-sm); padding: 0 10px;
    border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel); color: var(--ink-2);
    font-size: var(--fs-sm); font-weight: 500; text-decoration: none;
}
.version-pill:hover { border-color: var(--ink-3); color: var(--ink); text-decoration: none; }
.version-pill.active { background: var(--black); border-color: var(--black); color: #fff; }
.version-pill.st-zaakceptowana { border-color: #BFE3CE; }
.version-pill.st-zastapiona, .version-pill.st-odrzucona { color: var(--ink-3); border-style: dashed; }
.version-pill .bi-check-circle-fill { color: var(--ok); }
.version-pill.active .bi-check-circle-fill { color: #9FE0BC; }
.offer-items-table .item-avail .badge { font-size: var(--fs-xs); }
.offer-items-table .item-code:empty { display: none; }
.items-editor .offer-items-table td { padding: 6px; vertical-align: top; }
.items-editor .offer-items-table .item-date, .items-editor .offer-items-table .item-avnote { min-height: var(--control-sm); font-size: var(--fs-xs); }
.item-autocomplete .ac-item { border-bottom: 1px solid var(--line) !important; cursor: pointer; }
.item-autocomplete .ac-item:hover { background: var(--panel-2); }

/* dokumenty magazynowe: zatwierdzanie i anulowanie korektą, typy dokumentów */
.approve-box { border-left: 3px solid var(--ok); }
.reverse-box { border-left: 3px solid var(--bad); }
.tag-KOR { color: var(--warn); border-color: #EBD39A; background: var(--warn-bg); }
.tag-RW { color: var(--bad); border-color: #F0C2BC; background: var(--bad-bg); }
.tag-BO { color: var(--neutral); border-color: var(--line-strong); background: var(--neutral-bg); }
.form-control-plaintext { font-size: var(--fs); color: var(--ink); min-height: var(--control); display: flex; align-items: center; gap: 6px; }
/* edytor pozycji oferty: minimalne szerokości pól liczbowych, żeby wartości były czytelne */
.offer-items-table .item-qty { min-width: 84px; }
.offer-items-table .item-price { min-width: 104px; }
.offer-items-table .item-disc { min-width: 72px; }
.offer-items-table .item-disc-amt { min-width: 88px; }
.offer-items-table .item-vat { min-width: 64px; }
.offer-items-table .item-unit { min-width: 72px; }
.offer-items-table .item-type { min-width: 110px; }
.offer-items-table .item-gross { white-space: nowrap; }

/* ---------- poprawki po przeglądzie koordynatora (23.10) ---------- */
/* 1. edytor pozycji oferty: dostępność i termin pod nazwą, całość mieści się od 1280 px */
.offer-items-table .item-extra { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 4px; }
.offer-items-table .item-extra .item-avail { flex: 1 1 100%; }
.offer-items-table .item-extra .item-avail:empty { display: none; }
.offer-items-table .item-extra .item-date { width: 136px; min-height: 26px; font-size: var(--fs-xs); margin: 0; }
.offer-items-table .item-extra .item-avnote { flex: 1 1 160px; min-height: 26px; font-size: var(--fs-xs); margin: 0; }
.offer-items-table .item-avail .badge { font-size: 10.5px; padding: 2px 7px; }
.offer-items-table .item-avail .text-muted, .offer-items-table .item-avail .text-primary { font-size: var(--fs-xs); display: inline; margin-left: 6px; }
.items-editor .offer-items-table td { padding: 5px 5px; }
.items-editor .offer-items-table .item-qty { min-width: 72px; }
.items-editor .offer-items-table .item-price { min-width: 92px; }
.items-editor .offer-items-table .item-disc { min-width: 62px; }
.items-editor .offer-items-table .item-disc-amt { min-width: 76px; }
.items-editor .offer-items-table .item-vat { min-width: 56px; }
.items-editor .offer-items-table .item-unit { min-width: 66px; }
.items-editor .offer-items-table .item-type { min-width: 96px; }
.items-editor .offer-items-table .form-control, .items-editor .offer-items-table .form-select { padding-left: 6px; padding-right: 6px; }
.items-editor .offer-items-table .item-type { padding-right: 22px; background-position: right 4px center; }

/* 2. przyciski czatu nie zasłaniają przyklejonego paska akcji */
body:has(.form-actions) .chat-widget-bubble, body:has(.form-actions) .ai-chatbot-bubble,
body:has(.pick-bar) .chat-widget-bubble, body:has(.pick-bar) .ai-chatbot-bubble { bottom: 74px; }
body:has(.form-actions) .chat-widget-panel, body:has(.form-actions) .ai-chatbot-panel { bottom: 132px; }
@media (min-width: 992px) { .form-actions { padding-right: 20px; } }
@media (max-width: 991.98px) {
    body:has(.form-actions) .chat-widget-bubble, body:has(.form-actions) .ai-chatbot-bubble,
    body:has(.pick-bar) .chat-widget-bubble, body:has(.pick-bar) .ai-chatbot-bubble { bottom: 132px; }
    body:has(.form-actions) .chat-widget-panel, body:has(.form-actions) .ai-chatbot-panel { bottom: 190px; height: calc(100vh - 260px); }
}

/* 4. zakładki statusów na telefonie: wygaszenie krawędzi jako wskazówka przewijania (jedyny dopuszczony gradient) */
@media (max-width: 767.98px) {
    .status-tabs { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); padding-right: 36px; }
    .status-tabs.at-end { -webkit-mask-image: none; mask-image: none; }
    .status-tabs a { padding: 10px 10px; }
}

/* 3. kompaktowe karty rekordów na telefonie: wiersz 1 tytuł + status, wiersz 2 podtytuł, wiersz 3 meta, akcje */
@media (max-width: 767.98px) {
    .table-cards tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 10px 14px; }
    .table-cards td { display: inline-flex; width: auto; padding: 0; gap: 4px; text-align: left; font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; }
    .table-cards td[data-label]::before { content: none; }
    .table-cards td.card-keep-label[data-label]::before { content: attr(data-label) ": "; color: var(--ink-3); font-size: var(--fs-sm); text-transform: none; letter-spacing: 0; }
    .table-cards td.card-title-cell { order: 0; flex: 1 1 auto; font-size: 15px; color: var(--ink); white-space: normal; padding-bottom: 0; }
    .table-cards td[data-label="Status"] { order: 1; margin-left: auto; }
    .table-cards td.card-sub-cell { order: 2; flex: 1 1 100%; color: var(--ink); font-size: var(--fs); white-space: normal; }
    .table-cards td.card-sub-cell:empty { display: none; }
    .table-cards td:not(.card-title-cell):not(.card-sub-cell):not(.card-actions-cell):not([data-label="Status"]) { order: 3; }
    .table-cards td.card-amount { margin-left: auto; color: var(--ink); font-size: var(--fs); font-weight: 600; text-align: right; }
    .table-cards td.card-hide, .table-cards td.d-md-table-cell { display: none !important; }
    .table-cards td.card-actions-cell { order: 9; flex: 1 1 100%; justify-content: flex-end; padding-top: 6px; }
    .table-cards td.card-actions-cell .btn-group { gap: 6px; }
    .table-cards td.empty-state { display: block; flex: 1 1 100%; text-align: center; white-space: normal; }
    .table-cards td small, .table-cards td .d-block { display: inline !important; }
    .table-cards td br { display: none; }
    .table-cards td .badge { font-size: 10.5px; }
}

/* edytor pozycji oferty: stały układ kolumn, bez wewnętrznego przewijania od 1280 px */
@media (min-width: 1200px) { .items-editor .offer-items-table { table-layout: fixed; width: 100%; } }
.items-editor .offer-items-table .item-name { min-width: 0; }
/* karty na telefonie: bez wysokości wiersza tabeli i bez łatek tła przy najechaniu */
@media (max-width: 767.98px) {
    .table-cards td, .table-cards tbody td { height: auto; min-height: 0; background: transparent !important; }
    .table-cards tbody tr:hover { background: var(--panel-2); }
    .table-cards td.card-title-cell .tag { font-size: 10px; }
}

/* kompletacja: nagłówek grupy miejsc składowania; pole zebrano w karcie */
.pick-group { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 14px 0 8px; display: flex; gap: 6px; align-items: center; }
.pick .pick-actions .input-group { flex: 1; }
.pick .pick-actions .input-group .form-control { max-width: none; font-size: 18px; font-weight: 600; text-align: right; min-height: var(--touch); }
.pick .pick-actions .input-group-text { min-height: var(--touch); font-size: var(--fs); }
.pick-bar .btn { min-height: var(--touch); }

.filter-bar .form-check-input, .filters-bar .form-check-input { min-width: 0; width: 16px; height: 16px; }

/* ---------- audyt układu 23.10: odstępy od ramek, gęstość 4/8 px ---------- */
/* komórki tabel: pionowy odstęp 6 px także przy dwóch liniach tekstu (height działa jak minimum) */
.table > :not(caption) > * > * { padding: 6px 12px; }
.table-sm > :not(caption) > * > * { padding: 5px 10px; }
.table thead th, .table > thead > tr > th { padding-top: 0; padding-bottom: 0; }
.items-editor .table th { padding: 0 8px; }
.items-editor .table td { padding: 6px 8px; }
.items-editor .table td:first-child, .items-editor .table th:first-child { padding-left: 12px; }
.items-editor .offer-items-table td { padding: 6px 6px; }
.kv-table th, .kv-table td, .card-body > .table-sm th, .card-body > .table-sm td { padding: 7px 0; }
.table tfoot td { padding: 8px 12px; }
.table td.empty-state, .table-cards td.empty-state { padding: 32px 16px; }
/* odznaki, etykiety, liczniki */
.tag { padding: 2px 8px; line-height: 1.4; }
.badge { --bs-badge-padding-y: 3px; --bs-badge-padding-x: 9px; }
.status-tabs .cnt { padding: 1px 7px; line-height: 15px; }
.item-avail .badge, .offer-items-table .item-avail .badge, .stock-info .badge { padding: 3px 8px; }
/* podsumowania kwot: odstęp od linii nad sumą */
.totals .grand { padding-top: 8px; }
/* wybór klienta: pole rośnie z tekstem zamiast ucinać */
.form-control.client-select-display { height: auto; min-height: var(--control); padding-top: 5px; padding-bottom: 5px; align-items: center; }
.form-control.client-select-display .flex-grow-1 { white-space: normal; overflow-wrap: anywhere; line-height: 1.3; }
/* kalendarz: etykiety zdarzeń z oddechem */
.calendar-event { padding: 2px 8px !important; border-radius: 3px; }
/* tekst pomocniczy w .form-control-plaintext bez ramki */
.form-control-plaintext { border: 0; padding-left: 0; }
/* karty klucz-wartość: podtytuł sekcji wewnątrz karty */
.card-body .border-top.fw-bold, .card-body .small.fw-bold.mt-3 { padding-top: 8px; padding-bottom: 6px; }
/* alerty: ikona i tekst nie dotykają ramki przy zawijaniu */
.alert { display: flex; gap: 8px; align-items: flex-start; line-height: 1.45; }
.alert > .bi { flex-shrink: 0; margin-top: 2px; }
.alert.alert-dismissible { padding-right: 44px; }
/* pola z ikonami (input-group): tekst nie dotyka ikony */
.input-group > .form-control { padding-left: 10px; }
/* kompletacja: przycisk anulowania w pasku akcji zamiast pod przyklejonym paskiem */
.pick-bar + form { display: none; }
/* 768 px: nagłówek strony w jednym wierszu, akcje poniżej bez marginesu ujemnego */
@media (max-width: 991.98px) { .page-header .page-actions { width: 100%; margin-left: 0; } .page-header .page-actions .btn { flex: 1 1 auto; } }
/* stare listy: kolorowy lewy pasek statusu wyłączony także gdy ustawiony inline */
.table tbody tr[style*="border-left"] { border-left-width: 0 !important; }
/* wydruk w przeglądarce: układ płynny na wąskim ekranie */
@media screen and (max-width: 767.98px) {
    body.print-page { padding: 12px !important; }
    .print-header { flex-wrap: wrap; gap: 8px; }
    .print-company { text-align: left; }
    .print-info, .print-footer { grid-template-columns: 1fr !important; gap: 12px !important; }
    .print-totals { float: none !important; width: 100% !important; }
    .print-table { display: block; overflow-x: auto; }
}

/* karty szczegółów: długie wartości zawijają się, siatka nie rozpycha strony */
.detail-grid > * { min-width: 0; }
.detail-section { min-width: 0; }
.detail-row { align-items: flex-start; }
.detail-value { overflow-wrap: anywhere; min-width: 0; }
.detail-label { flex-shrink: 0; }
.card-body > .table-responsive > .table-sm th, .card-body > .table-responsive > .table-sm td { padding-left: 12px; padding-right: 12px; }

/* ---------- audyt układu 23.10, część 2: stare komponenty Bootstrap w design systemie ---------- */
.nav-tabs { --bs-nav-tabs-border-color: var(--line); --bs-nav-link-color: var(--ink-2); --bs-nav-tabs-link-active-color: var(--ink); --bs-nav-tabs-link-active-bg: transparent; --bs-nav-tabs-link-active-border-color: transparent transparent var(--ink); --bs-nav-tabs-link-hover-border-color: transparent transparent var(--line-strong); --bs-nav-link-padding-x: 12px; --bs-nav-link-padding-y: 9px; --bs-nav-tabs-border-radius: 0; gap: 2px; margin-bottom: 10px !important; }
.nav-tabs .nav-link { border-width: 0 0 2px; margin-bottom: -1px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.nav-tabs .nav-link.active { font-weight: 600; }
.nav-tabs .nav-link .badge { margin-left: 2px; }
/* nagłówki sekcji wewnątrz formularzy (Ustawienia, Klient, Produkt) */
.card-body > form > h5, .card-body > h5, .card-body h5.text-muted { font-size: var(--fs-xs) !important; font-weight: 600; letter-spacing: .06em !important; text-transform: uppercase !important; color: var(--ink-3) !important; margin: 4px 0 12px !important; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.card-body > form > h5:not(:first-of-type), .card-body h5.text-muted:not(:first-of-type) { margin-top: 8px !important; }
/* akordeon (Pytania i odpowiedzi) */
.accordion { --bs-accordion-border-color: var(--line); --bs-accordion-btn-color: var(--ink); --bs-accordion-active-color: var(--ink); --bs-accordion-active-bg: var(--panel-2); --bs-accordion-btn-focus-box-shadow: 0 0 0 3px rgba(26,25,24,.12); --bs-accordion-btn-padding-x: 16px; --bs-accordion-btn-padding-y: 12px; --bs-accordion-body-padding-x: 16px; --bs-accordion-body-padding-y: 14px; }
.accordion-button { font-size: var(--fs); font-weight: 500; }
.card-header h5 { font-size: inherit; font-weight: inherit; margin: 0; }
/* lista wyników wyszukiwania */
.list-group { --bs-list-group-border-color: var(--line); --bs-list-group-item-padding-x: 14px; --bs-list-group-item-padding-y: 10px; --bs-list-group-action-hover-bg: var(--panel-2); }
.list-group-item .badge { flex-shrink: 0; margin-left: 10px; }
/* strona błędu */
.error-card { text-align: center; }
.error-code { font-size: 56px; font-weight: 600; letter-spacing: -.02em; color: var(--ink); line-height: 1; margin: 6px 0 10px; }
.error-text { color: var(--ink-2); margin-bottom: 18px; }
/* pre w historii zmian */
.table pre { font-size: var(--fs-xs); background: var(--panel) !important; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px !important; margin: 6px 0 0 !important; max-height: 220px; overflow: auto; }
.table td.bg-light { background: var(--panel-2) !important; padding: 12px 16px; white-space: normal; }
/* kafelki raportów bez ikony */
.stat-card > div:only-child { min-width: 0; }
.stat-card .stat-value { overflow-wrap: anywhere; }
/* kosz: pusta karta */
.card-body.text-center.py-5 .bi { color: var(--line-strong) !important; }

.calendar-event { padding: 5px 8px !important; line-height: 1.3; }
.kv-table td, .card-body > .table-sm td, .card-body > .table-responsive > .table-sm td { overflow-wrap: anywhere; white-space: normal; }
/* Ustawienia: pola tylko dla administratora */
.form-text.admin-only { color: var(--ink-3); }

/* komunikaty w komórkach z colspan (puste stany) zawijają się */
.table tbody td[colspan], .table td.empty-state, .table-cards td.empty-state { white-space: normal; }
.table tbody td[colspan].text-center { padding: 24px 16px; color: var(--ink-3); }

/* ---------- audyt układu 23.10, część 3: tabele w kartach i pływające przyciski ---------- */
/* numery dokumentów, daty i kwoty nigdy nie łamią się w środku */
.table td a[href*="/offers/"], .table td a[href*="/orders/"], .table td a[href*="/warehouse-docs/"], .table td a[href*="/pick-lists/"],
.table td a[href*="/purchase-orders/"], .table td a[href*="/inquiries/"], .table td.text-end, .table td.num, .table td.date, .table td.money,
.table td time, .table .badge, .table .tag { white-space: nowrap; }
/* zawijanie tylko w tabelach klucz-wartość i komórkach .text-wrap */
.card-body > .table-responsive > .table-sm td { white-space: nowrap; }
.card-body > .table-responsive > .table-sm td.text-wrap, .kv-table td, .card-body > .table-sm.kv-table td { white-space: normal; }
/* tabele osadzone w kartach: na telefonie tryb kart (numer + status, kwota + data) */
@media (max-width: 767.98px) {
    .card .table-cards td.card-title-cell { font-size: 14px; }
    .card .table-cards tr { padding: 8px 14px; }
}
/* pływające przyciski czatu: na telefonie schowane, czat jest w dolnym menu; treść ma zapas pod dolnym menu */
@media (max-width: 767.98px) {
    .chat-widget-bubble, .ai-chatbot-bubble { display: none !important; }
    .chat-widget-panel, .ai-chatbot-panel { display: none !important; }
    .main-content { padding-bottom: calc(60px + 24px + env(safe-area-inset-bottom)); }
}
.bottom-nav a { position: relative; }
.bottom-nav-badge { position: absolute; top: 6px; right: calc(50% - 18px); min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; background: var(--brand-strong); color: #fff; font-size: 10px; font-weight: 600; text-align: center; padding: 0 4px; }
.table td.text-center { white-space: nowrap; }

@media (min-width: 768px) and (max-width: 991.98px) { .main-content { padding-bottom: 150px; } }

/* ---------- po scaleniu audytu (runda 2) ---------- */
@media (min-width: 768px) and (max-width: 991.98px) { .main-content { padding-bottom: 180px; } }
.form-check { display: flex; align-items: center; gap: 8px; min-height: var(--control-sm); padding-left: 0; }
.form-check .form-check-input { margin: 0; float: none; flex-shrink: 0; }
.form-check-inline { display: inline-flex; margin-right: 12px; }
.form-check-input:disabled ~ .form-check-label, .form-control:disabled ~ .form-text { color: var(--ink-3); }
.table-foot .pagination, .card-footer .pagination { justify-content: flex-end; }
.card-footer > nav:only-child .pagination { justify-content: center; }
.pagination .page-link { font-variant-numeric: tabular-nums; }
.search-result-type, .list-group-item .badge { font-weight: 600; }

@media (max-width: 575.98px) { .pick-bar { flex-wrap: wrap; } .pick-bar > span { flex: 1 1 100%; } .pick-bar .btn { flex: 1 1 auto; margin-left: 0 !important; } }

/* ---------- runda 3: zapas pod pływającymi przyciskami na każdej szerokości (treść da się przewinąć ponad przyciski) ---------- */
.main-content { --pb: 96px; padding-bottom: var(--pb); }
body:has(.form-actions) .main-content, body:has(.pick-bar) .main-content { --pb: 150px; }
.form-actions { margin-bottom: calc(-1 * var(--pb)); }
.pick-bar { margin-bottom: calc(-1 * var(--pb)); }
@media (max-width: 991.98px) {
    .main-content { --pb: 100px; padding-bottom: var(--pb); }
    body:has(.form-actions) .main-content, body:has(.pick-bar) .main-content { --pb: 190px; }
    .form-actions, .pick-bar { margin-bottom: calc(-1 * var(--pb)); }
}
@media (max-width: 767.98px) {
    .main-content { --pb: calc(60px + 24px + env(safe-area-inset-bottom)); }
    body:has(.form-actions) .main-content, body:has(.pick-bar) .main-content { --pb: calc(60px + 24px + env(safe-area-inset-bottom)); }
}
/* kafelki pulpitu: kwota w jednej linii */
.stat-card .stat-value { white-space: nowrap; }
@media (max-width: 575.98px) { .stat-card .stat-value { font-size: 17px; } .stat-card { padding: 12px; gap: 10px; } .stat-card .stat-icon { display: none; } }

/* przyklejony pasek akcji: przyciski czatu siedzą w pasku (prawy róg), treść nad paskiem nie jest zasłonięta */
@media (min-width: 768px) {
    body:has(.form-actions) .chat-widget-bubble, body:has(.form-actions) .ai-chatbot-bubble,
    body:has(.pick-bar) .chat-widget-bubble, body:has(.pick-bar) .ai-chatbot-bubble { bottom: 6px; }
    body:has(.form-actions) .chat-widget-panel, body:has(.form-actions) .ai-chatbot-panel,
    body:has(.pick-bar) .chat-widget-panel, body:has(.pick-bar) .ai-chatbot-panel { bottom: 64px; }
    .form-actions, .pick-bar { padding-right: 150px; min-height: 60px; }
}
@media (min-width: 768px) and (max-width: 991.98px) {
    .form-actions, .pick-bar { bottom: 0; }
    body:has(.form-actions) .main-content, body:has(.pick-bar) .main-content { --pb: 120px; }
}
