/* ============ Mebstyle Produkcja — jeden CSS, zero frameworków ============
   Reguły hali (sekcja 7): cele dotyku 72px+, czcionka 18-20px+, wysoki
   kontrast, kolor ZAWSZE z ikoną/tekstem, układ jednokolumnowy, brak gestów. */

:root {
    --tlo: #f4f5f7;
    --karta: #ffffff;
    --tekst: #1a1c20;
    --tekst-2: #5b6470;
    --linia: #dde1e6;
    --akcent: #1565c0;
    --ok: #2e7d32;
    --uwaga: #ef6c00;
    --blad: #c62828;
    --ciemne: #1a1c20;
    --promien: 14px;
    --cien: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* BUG-3: modale z display:flex ignorowały hidden */
html, body { margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--tlo);
    color: var(--tekst);
    font-size: 18px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--akcent); }
img { max-width: 100%; }

.kontener { max-width: 1200px; margin: 0 auto; padding: 18px; }

/* ---------- Górna nawigacja (backoffice) ---------- */
.topnav {
    display: flex; align-items: center; gap: 18px;
    background: var(--ciemne); color: #fff; padding: 10px 18px;
    position: sticky; top: 0; z-index: 50; flex-wrap: wrap;
}
.brand { color: #fff; text-decoration: none; font-weight: 800; letter-spacing: .06em; font-size: 18px; }
.brand span { color: #e5a33b; font-weight: 500; margin-left: 6px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.topnav-links { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav-links a {
    color: #cfd6df; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 15px;
}
.topnav-links a:hover { background: rgba(255,255,255,.08); color: #fff; }
.topnav-links a.akt { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.topnav-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip {
    background: #e5a33b; color: #1a1c20; font-weight: 800; border-radius: 50%;
    width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
}
.btn-wyloguj { background: none; border: 1px solid #48505b; color: #cfd6df; border-radius: 8px; padding: 7px 12px; font-size: 14px; }
.btn-wyloguj:hover { border-color: #fff; color: #fff; }
.dzwonek { position: relative; cursor: pointer; font-size: 20px; user-select: none; }
.dzwonek b {
    position: absolute; top: -6px; right: -10px; background: var(--blad); color: #fff;
    border-radius: 10px; font-size: 11px; padding: 1px 5px; font-weight: 700;
}
.dzwonek-panel {
    position: fixed; top: 58px; right: 12px; width: min(380px, 92vw); max-height: 60vh; overflow: auto;
    background: #fff; border-radius: var(--promien); box-shadow: 0 8px 30px rgba(0,0,0,.18); z-index: 60; padding: 6px;
}
.powiadomienie { padding: 10px 12px; border-bottom: 1px solid var(--linia); font-size: 15px; }
.powiadomienie small { display: block; color: var(--tekst-2); margin-top: 2px; }
.powiadomienie.nowe { background: #fff8e8; }

.flash { padding: 12px 18px; font-weight: 600; }
.flash-ok { background: #e6f4ea; color: #1e4620; border-bottom: 2px solid var(--ok); }
.flash-blad { background: #fdecea; color: #611a15; border-bottom: 2px solid var(--blad); }

/* ---------- Logowanie PIN ---------- */
.ekran-pin { background: var(--ciemne); }
.pin-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.pin-box { text-align: center; width: min(360px, 94vw); }
.pin-logo { color: #fff; font-size: 30px; font-weight: 800; letter-spacing: .08em; }
.pin-logo span { display: block; color: #e5a33b; font-size: 13px; letter-spacing: .35em; text-transform: uppercase; font-weight: 500; margin-top: 2px; }
.pin-info { color: #9aa4b2; margin: 26px 0 14px; font-size: 17px; }
.pin-kropki { display: flex; gap: 16px; justify-content: center; margin-bottom: 10px; }
.pin-kropki i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #5b6470; }
.pin-kropki i.pelna { background: #e5a33b; border-color: #e5a33b; }
.pin-blad { color: #ff8a80; min-height: 24px; font-weight: 600; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.pin-pad button {
    height: 76px; font-size: 30px; font-weight: 700; border: none; border-radius: 16px;
    background: #2a2e35; color: #fff;
}
.pin-pad button:active { background: #3a404a; transform: scale(.97); }
.pin-pad .pad-pusty { background: transparent; }
.pin-pad .pad-usun { font-size: 24px; background: #22262c; color: #9aa4b2; }

/* ---------- Ekran hali ---------- */
.ekran-praca { background: var(--tlo); }
.praca-main { max-width: 680px; margin: 0 auto; padding: 0 12px 170px; }
.praca-top {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 4px; position: sticky; top: 0; background: var(--tlo); z-index: 20;
    border-bottom: 3px solid var(--dzial-kolor, #455A64); flex-wrap: wrap;
}
.praca-dzial { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.dzial-znacznik { width: 16px; height: 16px; border-radius: 4px; background: var(--dzial-kolor, #455A64); display: inline-block; }
.kropka-siec { color: var(--ok); font-size: 14px; }
.kropka-siec.offline { color: var(--blad); }
.offline-info { font-size: 13px; background: #fff3cd; color: #7a5c00; padding: 3px 10px; border-radius: 12px; font-weight: 700; }
.praca-user { display: flex; align-items: center; gap: 10px; }
.praca-przelacznik { font-size: 15px; text-decoration: none; font-weight: 600; }

.praca-chipy { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 2px; }
.chip { background: #e8ebf0; border-radius: 20px; padding: 6px 14px; font-size: 15px; font-weight: 700; }
.chip-spozniony { background: #fdecea; color: var(--blad); }
.chip-dzis { background: #fff3cd; color: #7a5c00; }
.chip-pilny { background: #fdecea; color: var(--uwaga); }

.praca-lista { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.pusta-lista { text-align: center; color: var(--tekst-2); padding: 44px 16px; font-size: 18px; background: var(--karta); border-radius: var(--promien); }

.karta {
    display: flex; gap: 12px; background: var(--karta); border-radius: var(--promien);
    box-shadow: var(--cien); padding: 12px; min-height: 96px; align-items: center;
    border-left: 6px solid var(--dzial-kolor, #90a4ae);
}
.karta:active { transform: scale(.995); }
.karta-blokada { border-left-color: var(--blad); background: #fff7f7; }
.karta-foto { width: 84px; height: 84px; flex: none; border-radius: 10px; overflow: hidden; background: #eef1f4; display: flex; align-items: center; justify-content: center; }
.karta-foto img { width: 100%; height: 100%; object-fit: cover; }
.foto-brak { font-size: 36px; }
.karta-tresc { flex: 1; min-width: 0; }
.karta-naglowek { font-size: 19px; }
.karta-detale { color: var(--tekst-2); font-size: 15px; margin-top: 2px; }
.karta-stan { font-size: 15px; font-weight: 600; margin-top: 4px; }
.karta-plakietki { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.karta-zestaw { font-size: 13px; color: var(--tekst-2); }
.karta-akcje-pion { display: flex; flex-direction: column; gap: 8px; }

.plakietka { font-size: 13px; font-weight: 800; border-radius: 8px; padding: 3px 9px; white-space: nowrap; }
.pl-zielona { background: #e6f4ea; color: #1e4620; }
.pl-zolta { background: #fff3cd; color: #7a5c00; }
.pl-czerwona { background: #fdecea; color: var(--blad); }
.pl-pilna { background: #4a148c; color: #fff; }
.pl-szara { background: #e8ebf0; color: var(--tekst-2); }
.pl-zewn { background: #263238; color: #ffd54f; }

/* Duży przycisk Skanuj — kciukiem, bez przewijania */
.btn-skan {
    position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 12px; z-index: 30;
    background: var(--dzial-kolor, #1565c0); color: #fff; border: none; border-radius: 40px;
    font-size: 24px; font-weight: 800; padding: 20px 44px; box-shadow: 0 6px 20px rgba(0,0,0,.28);
    min-height: 76px;
}
.btn-skan:active { transform: translateX(-50%) scale(.97); }
.ekran-praca .btn-skan { background: #1a1c20; }

.praca-dol {
    position: fixed; bottom: 0; left: 0; right: 0; display: flex; z-index: 30;
    background: #fff; border-top: 1px solid var(--linia); padding-bottom: env(safe-area-inset-bottom);
}
.praca-dol button {
    flex: 1; border: none; background: none; font-size: 16px; font-weight: 700; color: var(--tekst-2);
    padding: 16px 4px; min-height: 60px;
}
.praca-dol button.akt { color: var(--akcent); box-shadow: inset 0 3px 0 var(--akcent); }

.wpis-historii { background: var(--karta); border-radius: 10px; padding: 12px 14px; box-shadow: var(--cien); font-size: 16px; }

/* ---------- Skaner ---------- */
.skaner { position: fixed; inset: 0; background: #000; z-index: 100; }
.skaner video { width: 100%; height: 100%; object-fit: cover; }
.skaner-ramka {
    position: absolute; top: 50%; left: 50%; width: min(70vw, 340px); aspect-ratio: 1;
    transform: translate(-50%, -60%); border: 3px solid rgba(255,255,255,.9); border-radius: 18px;
    box-shadow: 0 0 0 200vmax rgba(0,0,0,.45);
}
.skaner-pasek {
    position: absolute; bottom: 0; left: 0; right: 0; display: flex; gap: 10px; padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.skaner-pasek button {
    flex: 1; min-height: 64px; font-size: 18px; font-weight: 700; border: none; border-radius: 14px;
    background: rgba(255,255,255,.92); color: #1a1c20;
}

/* ---------- Potwierdzenie po skanie ---------- */
.potwierdzenie { position: fixed; inset: 0; background: rgba(10,12,16,.6); z-index: 110; display: flex; align-items: flex-end; }
.potw-box {
    background: #fff; width: 100%; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    max-height: 88vh; overflow: auto;
}
.potw-mebel { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; font-size: 18px; }
.potw-mebel .karta-foto { width: 74px; height: 74px; }
.potw-stan { color: var(--tekst-2); }
.btn-akcja {
    width: 100%; min-height: 84px; font-size: 24px; font-weight: 800; color: #fff;
    background: var(--dzial-kolor, var(--ok)); border: none; border-radius: 18px;
}
.btn-akcja:active { transform: scale(.98); }
.btn-akcja.btn-maly { min-height: 60px; font-size: 18px; width: auto; padding: 0 22px; }
.btn-zielony { background: var(--ok) !important; }
.btn-szary { background: #e8ebf0; color: var(--tekst); border: none; border-radius: 12px; min-height: 56px; padding: 0 18px; font-size: 16px; font-weight: 700; }
.potw-stopka { display: flex; gap: 10px; margin-top: 14px; justify-content: space-between; }
.potw-blok { border-radius: 14px; padding: 16px; font-size: 18px; }
.potw-stop { background: #fdecea; color: #611a15; border: 2px solid var(--blad); }
.potw-info { background: #eef3fb; }
.potw-kto { margin: 6px 0 0; color: var(--tekst-2); font-size: 15px; }
.potw-metraz label { display: block; font-weight: 700; margin-bottom: 8px; }
.potw-metraz input {
    width: 100%; font-size: 30px; padding: 14px; border: 2px solid var(--linia); border-radius: 14px;
    margin-bottom: 12px; font-weight: 700; text-align: center;
}
.potw-powod-label { color: var(--blad); }

/* ---------- Wybór ręczny ---------- */
.wybor-reczny { position: fixed; inset: 0; background: rgba(10,12,16,.6); z-index: 110; display: flex; align-items: center; justify-content: center; padding: 14px; }
.wybor-reczny-box { background: #fff; border-radius: 18px; padding: 16px; width: min(560px, 96vw); max-height: 86vh; display: flex; flex-direction: column; gap: 10px; }
.wybor-reczny-box h3 { margin: 0; }
.wybor-reczny-box input { font-size: 18px; padding: 12px; border: 2px solid var(--linia); border-radius: 12px; }
#wybor-lista { overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.wybor-pozycja { text-align: left; background: #f4f5f7; border: none; border-radius: 12px; padding: 14px; font-size: 17px; min-height: 64px; }
.wybor-pozycja small { color: var(--tekst-2); }

/* ---------- Toast + błysk ---------- */
.toast {
    position: fixed; bottom: 150px; left: 50%; transform: translateX(-50%);
    background: #1a1c20; color: #fff; border-radius: 14px; padding: 14px 20px; z-index: 130;
    display: flex; gap: 14px; align-items: center; font-size: 17px; font-weight: 600;
    max-width: min(560px, 94vw); box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.toast-blad { background: var(--blad); }
.toast-offline { background: #7a5c00; }
.toast button { background: #fff; color: #1a1c20; border: none; border-radius: 10px; padding: 8px 16px; font-weight: 800; font-size: 16px; }
.blysk-ok {
    position: fixed; inset: 0; background: rgba(46,125,50,.85); z-index: 140;
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 120px;
    animation: blysk .55s ease forwards; pointer-events: none;
}
@keyframes blysk { 0% { opacity: 0; } 15% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }

.btn-instaluj {
    position: fixed; bottom: 16px; right: 16px; z-index: 90;
    background: var(--akcent); color: #fff; border: none; border-radius: 30px;
    padding: 14px 22px; font-size: 16px; font-weight: 800; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

/* ---------- Pulpit / backoffice ---------- */
.siatka-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--karta); border-radius: var(--promien); box-shadow: var(--cien); padding: 16px 18px; }
.kpi b { display: block; font-size: 34px; }
.kpi span { color: var(--tekst-2); font-size: 14px; font-weight: 600; }
.kpi.kpi-blad b { color: var(--blad); }

.sekcja { background: var(--karta); border-radius: var(--promien); box-shadow: var(--cien); padding: 18px; margin-bottom: 18px; }
.sekcja h2 { margin: 0 0 12px; font-size: 19px; }

.uwaga-lista { display: flex; flex-direction: column; gap: 8px; }
.uwaga-wpis { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: #f8f9fb; font-size: 15px; }
.uwaga-wpis.po_terminie { background: #fdecea; }
.uwaga-wpis.blokada { background: #fff3cd; }
.uwaga-wpis.bez_ruchu { background: #eef3fb; }

.oblozenie-pasek { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.oblozenie-pasek .dz-nazwa { width: 130px; font-weight: 700; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.oblozenie-pasek .dz-tor { flex: 1; height: 26px; background: #eef1f4; border-radius: 8px; overflow: hidden; position: relative; }
.oblozenie-pasek .dz-slupek { height: 100%; border-radius: 8px; min-width: 4px; }
.oblozenie-pasek .dz-liczba { width: 90px; text-align: right; font-size: 14px; color: var(--tekst-2); font-weight: 700; }
.wip-alarm { color: var(--blad); font-weight: 800; }

/* Kanban */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; }
.kanban-kolumna { min-width: 250px; max-width: 280px; background: #eceff3; border-radius: var(--promien); padding: 10px; flex: none; }
.kanban-kolumna h3 { margin: 2px 4px 10px; font-size: 15px; display: flex; justify-content: space-between; }
.kanban-kolumna h3 span { background: #fff; border-radius: 10px; padding: 0 8px; font-size: 13px; }
.kanban-kolumna.gardlo { outline: 3px solid var(--uwaga); }
.kanban-karta {
    background: #fff; border-radius: 10px; box-shadow: var(--cien); padding: 10px; margin-bottom: 8px;
    font-size: 13.5px; border-left: 5px solid #90a4ae; cursor: pointer;
}
.kanban-karta b { font-size: 14px; }
.kanban-karta small { color: var(--tekst-2); display: block; }
.kanban-karta .plakietka { font-size: 11px; padding: 1px 7px; }
.kanban-karta.kk-blokada { border-left-color: var(--blad); background: #fff7f7; }
.kk-rownolegle { color: #4a148c; font-weight: 800; font-size: 11px; }

/* Tabele */
table.tabela { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--promien); overflow: hidden; box-shadow: var(--cien); font-size: 15px; }
.tabela th { text-align: left; background: #1a1c20; color: #fff; padding: 10px 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.tabela td { padding: 10px 12px; border-bottom: 1px solid var(--linia); vertical-align: top; }
.tabela tr:hover td { background: #f8f9fb; }

/* Formularze backoffice */
.form-siatka { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.pole label { display: block; font-size: 13px; font-weight: 700; color: var(--tekst-2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }
.pole input, .pole select, .pole textarea {
    width: 100%; font-size: 16px; padding: 11px 12px; border: 1.5px solid var(--linia); border-radius: 10px; background: #fff;
}
.pole input:focus, .pole select:focus, .pole textarea:focus { outline: 2px solid var(--akcent); border-color: var(--akcent); }
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--akcent); color: #fff; border: none; border-radius: 10px; padding: 12px 20px; font-size: 16px; font-weight: 700; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn.btn-ok { background: var(--ok); }
.btn.btn-czerwony { background: var(--blad); }
.btn.btn-obrys { background: #fff; color: var(--tekst); border: 1.5px solid var(--linia); }
.pasek-akcji { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; align-items: center; }

.pozycja-wiersz { border: 1.5px solid var(--linia); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.znaczek-galezi { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 800; }
.zg-ok { background: #e6f4ea; color: #1e4620; }
.zg-czeka { background: #fff3cd; color: #7a5c00; }

@media (max-width: 720px) {
    .topnav-links { order: 3; width: 100%; }
    .kontener { padding: 12px; }
    body { font-size: 17px; }
}
@media print {
    .topnav, .btn-skan, .praca-dol, .flash { display: none !important; }
}
