/*!
 * Fixspot — © 2026 Dominik Gonsiorczyk · DG Project. Wszelkie prawa zastrzeżone.
 * Utwór chroniony prawem autorskim. Kopiowanie, rozpowszechnianie i modyfikowanie bez
 * pisemnej zgody autora jest zabronione. Zob. LICENSE.txt.
 */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e0e2e8;
  --text: #1b1f27;
  --muted: #63697a;
  --accent: #7D509E;
  --accent-ink: #ffffff;
  --danger: #d1372f;
  --warn: #b5790a;
  --ok: #1f8a4c;
  --radius: 10px;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0 0 8px; }
.hidden { display: none !important; }

/* --- auth screens --- */
#authScreen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 420px; box-shadow: 0 6px 24px rgba(20,20,40,.06); }
.auth-card h1 { font-size: 22px; }
.auth-card p.sub { color: var(--muted); margin-top: 0; margin-bottom: 20px; font-size: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.field textarea { resize: vertical; min-height: 70px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-weight: 600; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.error-box { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c2; border-radius: 8px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }
.note-box { background: #eef2ff; color: #1e3a8a; border: 1px solid #c7d2fe; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }

/* --- app shell --- */
/* height (nie min-height) + overflow:hidden przypina układ do wysokości ekranu,
   dzięki czemu przewija się tylko #content, a menu po lewej zawsze zostaje na miejscu. */
#appShell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
#sideNav { width: 220px; flex: none; background: #12131a; color: #dfe1ea; display: flex; flex-direction: column; padding: 16px 10px; overflow-y: auto; }
#sideNav .brand { color: #fff; font-weight: 700; font-size: 16px; padding: 6px 10px 18px; }
.brand-marks { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand-marks img { display: block; width: auto; }
.brand-marks img.mark-deepspot { height: 15px; }
.brand-marks img.mark-flyspot { height: 24px; }
.auth-card .brand-marks { margin-bottom: 18px; }
.auth-card h1.wordmark { margin: 4px 0 14px; line-height: 1; }
.auth-card h1.wordmark img { height: 26px; width: auto; display: block; }
#sideNav .brand { padding-bottom: 14px; }
#sideNav .brand .wm-nav { height: 17px; width: auto; display: block; }
#sideNav .brand .brand-marks-dark { margin-top: 12px; gap: 8px; }
#sideNav .brand .brand-marks-dark img.mark-deepspot { height: 11px; }
#sideNav .brand .brand-marks-dark img.mark-flyspot { height: 17.6px; }
.logo-dark { display: none !important; }
html[data-theme="dark"] .logo-light { display: none !important; }
html[data-theme="dark"] .logo-dark { display: block !important; }
#sideNav button.navlink { display: block; width: 100%; text-align: left; background: none; border: none; color: #c7c9d6; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 2px; }
#sideNav button.navlink:hover { background: #1f212c; color: #fff; }
#sideNav button.navlink.active { background: var(--accent); color: #fff; }
#sideNav .spacer { flex: 1; }
#sideNav .userbox { padding: 10px; font-size: 12.5px; color: #9296a8; border-top: 1px solid #262836; margin-top: 8px; }
#sideNav .userbox strong { color: #fff; display: block; font-size: 13.5px; }

#mainArea { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topBar { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; background: var(--panel); border-bottom: 1px solid var(--border); }
#topBar h2 { font-size: 18px; }
#content { padding: 22px; flex: 1; overflow-y: auto; }

.bell-wrap { position: relative; }
#bellBtn { position: relative; }
.badge { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; border-radius: 10px; font-size: 10.5px; padding: 1px 5px; font-weight: 700; }
#notifPanel { position: absolute; right: 0; top: 40px; width: 360px; max-height: 420px; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 30px rgba(20,20,40,.14); z-index: 30; padding: 6px; }
.notif-item { padding: 10px; border-radius: 8px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #f1f1f4; }
.notif-item:hover { background: #f6f7fb; }
.notif-item.unread { font-weight: 600; }
.notif-item .type { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.notif-item.urgent .type { color: var(--danger); }

/* --- generic layout helpers --- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr.clickable:hover { background: #f7f8fb; cursor: pointer; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.st-Nowe { background: #e0e7ff; color: #3730a3; }
.pill.st-DoPrzypisania { background: #fef3c7; color: #92400e; }
.pill.st-Zlecono { background: #cffafe; color: #155e75; }
.pill.st-WRealizacji { background: #dbeafe; color: #1e40af; }
.pill.st-Oczekuje { background: #fee2e2; color: #991b1b; }
.pill.st-DoWeryfikacji { background: #fae8ff; color: #86198f; }
.pill.st-Zamkniete { background: #dcfce7; color: #166534; }
.pill.p-Krytyczny { background: #fee2e2; color: #991b1b; }
.pill.p-Wysoki { background: #ffedd5; color: #9a3412; }
.pill.p-Normalny { background: #f1f5f9; color: #334155; }
.pill.p-Niski { background: #f8fafc; color: #64748b; }
.pill.lvl-0 { background: #dcfce7; color: #166534; }
.pill.lvl-1 { background: #fef9c3; color: #854d0e; }
.pill.lvl-2 { background: #fee2e2; color: #991b1b; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,16,26,.45); display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 720px; padding: 24px; }
.modal.wide { max-width: 900px; }
.modal .modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }

.history-list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.history-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.history-list li .when { color: var(--muted); font-size: 11.5px; }

.photo-thumb { width: 90px; height: 68px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.photo-cell { text-align: center; font-size: 11px; color: var(--muted); }

.zone-row { display: grid; grid-template-columns: 1.3fr 1.4fr 2fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.zone-row .result-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.zone-row .result-btns button { padding: 4px 8px; font-size: 12px; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.zone-row .result-btns button.active-Dobry { background: #dcfce7; border-color: #86efac; }
.zone-row .result-btns button.active-Uwaga { background: #fee2e2; border-color: #fca5a5; }
.zone-row .result-btns button.active-Krytyczny { background: #fecaca; border-color: #f87171; font-weight: 700; }
.zone-row .result-btns button.active-NieDotyczy { background: #f1f5f9; border-color: #cbd5e1; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #17181f; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13.5px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* Maintenance — kolorystyka podpunktów (systemów/urządzeń) obiektu */
.maint-system { border-left: 4px solid var(--mc, #94a3b8); background: var(--mc-bg, #f8fafc); border-radius: 8px; padding: 10px 12px; margin-top: 12px; }
.maint-chip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--mc, #94a3b8); margin-right: 7px; vertical-align: middle; }
.maint-c0 { --mc: #2454ff; --mc-bg: #eef2ff; }
.maint-c1 { --mc: #0d9488; --mc-bg: #ecfdf5; }
.maint-c2 { --mc: #b5790a; --mc-bg: #fffbeb; }
.maint-c3 { --mc: #a21caf; --mc-bg: #fdf4ff; }
.maint-c4 { --mc: #d1372f; --mc-bg: #fef2f2; }
.maint-c5 { --mc: #4338ca; --mc-bg: #eef2ff; }
.maint-c6 { --mc: #0f766e; --mc-bg: #f0fdfa; }
.maint-c7 { --mc: #9a3412; --mc-bg: #fff7ed; }
.maint-cost-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: #334155; }
.maint-cost-badge.zero { background: #f8fafc; color: #94a3b8; }

/* Magazyn — pozycje wg kategorii */
.inv-category { border-left: 4px solid #0d9488; background: #f0fdfa; border-radius: 8px; padding: 10px 12px; margin-top: 12px; }
.inv-qty { display: inline-block; min-width: 28px; text-align: center; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #e0e7ff; color: #3730a3; }
.inv-qty.low { background: #fee2e2; color: #991b1b; }
.inv-category th.clickable { cursor: pointer; text-decoration: underline dotted; }
.inv-category th.clickable:hover { color: var(--text); }

/* Rozliczenie zaliczki */
.adv-balance { font-size: 22px; font-weight: 700; }
.adv-balance.negative { color: var(--danger); }
.adv-balance.positive { color: var(--ok); }
.adv-round { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-top: 14px; }
.adv-round.open { border-left: 4px solid var(--accent); }
.adv-round.closed { border-left: 4px solid #94a3b8; background: #fafafc; }
.pill.adv-open { background: #e0e7ff; color: #3730a3; }
.pill.adv-closed { background: #f1f5f9; color: #475569; }

/* Sprawy — sortowanie, filtrowanie, zamknięte sprawy wyszarzone i na dole */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable .arrow { display: inline-block; margin-left: 3px; opacity: .5; }
th.sortable.active .arrow { opacity: 1; color: var(--accent); }
tr.task-done { opacity: .55; }
tr.task-done:hover { opacity: .85; }

/* Lightbox zdjęć — pełnoekranowy podgląd z nawigacją */
.photo-thumb { cursor: zoom-in; transition: transform .12s ease; }
.photo-thumb:hover { transform: scale(1.04); box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.lightbox-backdrop { position: fixed; inset: 0; background: rgba(10,10,16,.9); z-index: 80; display: flex; align-items: center; justify-content: center; }
.lightbox-img { max-width: 90vw; max-height: 82vh; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox-close { position: absolute; top: 18px; right: 22px; background: rgba(255,255,255,.12); color: #fff; border: none; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.lightbox-close:hover { background: rgba(255,255,255,.22); }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff; border: none; width: 48px; height: 48px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.lightbox-nav:hover { background: rgba(255,255,255,.22); }
.lightbox-nav.prev { left: 18px; }
.lightbox-nav.next { right: 18px; }
.lightbox-caption { position: absolute; bottom: 24px; left: 0; right: 0; text-align: center; color: #dfe1ea; font-size: 13px; }

/* Maintenance — zwijanie starszych wpisów */
.maint-more { margin-top: 8px; }

/* Magazyn — edycja w komórce (jak w arkuszu) i wiersz podsumowania */
td.editable { cursor: text; }
td.editable:hover { background: #eef2ff; }
td.editable input { width: 100%; border: 1px solid var(--accent); border-radius: 4px; padding: 3px 5px; font: inherit; background: #fff; }
tr.inv-total td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: none; background: #fafbfc; }
tr.inv-total-new td { color: var(--muted); font-style: italic; }

/* Rozliczenie zaliczki — zwinięte (rozliczone) rundy */
.adv-round.closed.collapsed .adv-round-body { display: none; }
.adv-round-head { cursor: pointer; }

/* Okno sprawy: karta, realizacja, zwijane szczegóły, historia na dole */
.task-summary { margin-bottom: 12px; }
.task-summary .row { margin-bottom: 6px; }
.task-banner { border-radius: 8px; padding: 7px 11px; font-size: 13px; margin: 6px 0; }
.task-banner.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.task-banner.board { background: #fdf4ff; color: #86198f; border: 1px solid #f5d0fe; }
.task-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 16px; margin: 10px 0; font-size: 13.5px; }
.task-desc { white-space: pre-wrap; font-size: 13.5px; margin-top: 8px; }
.task-desc.clamped { max-height: 5.4em; overflow: hidden; position: relative; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.task-progress { margin-bottom: 12px; background: #f8f9fc; }
.task-details { margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 16px 12px; background: var(--panel); }
.task-details > summary { cursor: pointer; font-weight: 600; font-size: 13.5px; padding: 12px 0; color: var(--muted); }
.task-details[open] > summary { color: var(--text); margin-bottom: 4px; }
.task-photos { margin: 12px 0; }
.task-milestones { list-style: none; padding: 0; margin: 4px 0 8px; font-size: 13.5px; border-left: 2px solid var(--border); }
.task-milestones li { padding: 3px 0 3px 12px; position: relative; }
.task-milestones li::before { content: ''; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.task-log { margin-top: 8px; }
.task-log summary { cursor: pointer; color: var(--muted); }

/* Zdjęcia sprawy: klikalne kwadraty PRZED / PO z miniaturkami */
.photo-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 230px)); gap: 14px; margin: 8px 0; }
.photo-tile { display: flex; flex-direction: column; gap: 6px; }
.photo-tile-title { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.photo-tile-count { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 11px; }
.photo-tile-body { aspect-ratio: 1 / 1; border: 2px solid var(--border); border-radius: 12px; overflow: hidden; background: #f1f3f8; display: flex; }
.photo-minis { display: grid; width: 100%; height: 100%; gap: 2px; }
.photo-minis.n1 { grid-template-columns: 1fr; }
.photo-minis.n2 { grid-template-columns: 1fr 1fr; }
.photo-minis.n3, .photo-minis.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.photo-mini { position: relative; overflow: hidden; cursor: zoom-in; }
.photo-mini img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s ease; }
.photo-mini:hover img { transform: scale(1.06); }
.photo-more { position: absolute; inset: 0; background: rgba(15,16,26,.55); color: #fff; font-size: 22px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.photo-tile-empty { margin: auto; padding: 10px; text-align: center; color: var(--muted); font-size: 12.5px; }
.photo-tile-add { width: 100%; }

/* Dokumentacja obiektu */
.doc-section h3 { font-size: 16px; }
.doc-due { margin: 4px 0 6px; color: var(--muted); }
.doc-due.late { color: var(--danger); font-weight: 600; }
.doc-entry { border-top: 1px solid var(--border); padding: 8px 0; }
.doc-entry-head { cursor: pointer; }
.doc-entry-head:hover strong { color: var(--accent); }
.doc-nodoc { margin: 2px 0 0 4px; }
.doc-chip { display: flex; align-items: center; gap: 8px; margin: 4px 0 0 2px; padding: 5px 10px; background: #f8f9fc; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; flex-wrap: wrap; }
.doc-main { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; min-width: 160px; }
.doc-main a { text-decoration: none; color: var(--text); font-weight: 600; word-break: break-word; }
.doc-main a:hover { color: var(--accent); }
.doc-main a.doc-view { font-weight: 400; color: var(--accent); }

/* Czat przy sprawie */
.chat-count { margin-left: 8px; font-size: 11.5px; color: var(--muted); background: #eef2ff; border-radius: 999px; padding: 1px 7px; white-space: nowrap; }
.chat-panel { margin-top: 16px; background: #f8f9fc; }
.chat-panel.dragging { outline: 2px dashed var(--accent); outline-offset: -4px; }
.chat-list { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px 2px; margin: 8px 0; }
.chat-empty { text-align: center; padding: 18px 0; }
.chat-msg { align-self: flex-start; max-width: 82%; background: #fff; border: 1px solid var(--border); border-radius: 12px 12px 12px 3px; padding: 8px 12px; }
.chat-msg.mine { align-self: flex-end; background: #e8eeff; border-color: #c7d2fe; border-radius: 12px 12px 3px 12px; }
.chat-head { display: flex; align-items: center; gap: 4px; font-size: 12.5px; margin-bottom: 3px; }
.chat-del { margin-left: auto; border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0 4px; }
.chat-del:hover { color: var(--danger); }
.chat-text { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.chat-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chat-img { max-width: 180px; max-height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; }
.chat-file { display: block; margin-top: 6px; padding: 6px 10px; background: #fff; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; text-decoration: none; color: var(--text); }
.chat-file:hover { background: #f4eff8; border-color: var(--accent); }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chat-chip { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12.5px; }
.chat-chip-x { border: none; background: transparent; cursor: pointer; color: var(--muted); }
.chat-input { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; resize: vertical; min-height: 54px; background: #fff; }
.chat-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.spacer-grow { flex: 1; }

/* Baza wykonawców */
.contractor-usage { color: var(--muted); font-size: 12px; }

/* Aplikacja mobilna (Android/iOS, PWA): menu jako szuflada, pełnoekranowe okna, karty zamiast tabeli spraw */
#menuBtn, #navBackdrop { display: none; }
#offlineBar { position: fixed; top: 0; left: 0; right: 0; z-index: 90; background: #92400e; color: #fff; text-align: center; font-size: 13px; padding: 6px 10px; }
.update-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 95; background: #17181f; color: #fff; border-radius: 10px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
@media (max-width: 820px) {
  #menuBtn { display: inline-flex; padding: 8px 12px; font-size: 18px; line-height: 1; }
  .hide-sm { display: none; }
  #sideNav { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(82vw, 300px); transform: translateX(-102%); transition: transform .22s ease; padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  #appShell.nav-open #sideNav { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  #appShell.nav-open #navBackdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; }
  #sideNav button.navlink { padding: 13px 12px; font-size: 15px; }
  #topBar { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); gap: 8px; flex-wrap: nowrap; position: sticky; top: 0; z-index: 20; }
  #topBar h2 { font-size: 16px; flex: 1; min-width: 0; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #topBar .row { flex-wrap: nowrap; gap: 6px; }
  #topBar .field select { max-width: 150px; }
  #content { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .card { padding: 14px; overflow-x: auto; }
  .card table:not(.tasks-table) { min-width: 560px; }
  /* lista spraw jako karty */
  table.tasks-table, .tasks-table tbody { display: block; min-width: 0; }
  .tasks-table thead { display: none; }
  .tasks-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
  .tasks-table td { display: block; border: none; padding: 0; font-size: 13px; }
  .tasks-table td:nth-child(3) { order: -2; flex: 0 0 100%; font-weight: 600; font-size: 15px; }
  .tasks-table td:nth-child(1), .tasks-table td:nth-child(2) { order: -1; font-size: 11.5px; color: var(--muted); }
  .tasks-table td:nth-child(6)::before { content: '📅 '; }
  .tasks-table td:nth-child(7)::before { content: '👤 '; }
  #topBar .field label { display: none; }
  .row.between { gap: 8px; }
  .btn { min-height: 40px; }
  .btn.small { min-height: 34px; }
  .field input, .field select, .field textarea, .chat-input, #topBar select { font-size: 16px; }
  .modal-backdrop { padding: 0; }
  .modal, .modal.wide { max-width: none; min-height: 100%; border-radius: 0; padding: 14px; padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .photo-tiles { grid-template-columns: 1fr 1fr; }
  .chat-msg { max-width: 94%; }
  .chat-list { max-height: 55vh; }
  .task-facts { grid-template-columns: 1fr 1fr; }
  #notifPanel { position: fixed; left: 8px; right: 8px; top: 58px; width: auto; max-height: 70vh; }
  .adv-balance { font-size: 18px; }
  .auth-card { padding: 22px; }
  .lightbox-nav { width: 42px; height: 42px; }
  .lightbox-img { max-width: 96vw; }
  #toast { bottom: calc(20px + env(safe-area-inset-bottom)); max-width: 92vw; }
}

@media print {
  #sideNav, #topBar, .no-print { display: none !important; }
  #appShell, #mainArea, #content { display: block; height: auto; overflow: visible; }
  body { background: #fff; }
}

/* dymki wyjaśnień przy polach formularza */
.hint-btn { margin-left: 6px; width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 1px solid #9aa0b4; background: #fff; color: #5c6178; font-size: 11px; font-weight: 700; line-height: 16px; cursor: help; vertical-align: 1px; }
.hint-btn:hover { background: #eef0f7; }
.hint-text { font-size: 12px; color: #4a4f66; background: #f3f5fb; border-radius: 6px; padding: 6px 9px; margin: 2px 0 6px; line-height: 1.45; }

.focus-pill { display: inline-block; margin-left: 10px; padding: 2px 10px; border-radius: 999px; background: #e8efff; color: #1d3f9e; font-size: 13px; font-weight: 600; vertical-align: 2px; }
.btn.big { width: 100%; padding: 18px 14px; font-size: 18px; }
.task-camera-step { text-align: center; }
.task-more > summary, .archive-group > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.task-people h4 { margin: 14px 0 6px; font-size: 14px; color: #3a3f55; }
.pill.warranty-on { background: #e3f4e8; color: #1e6b34; }
.pill.warranty-off { background: #eceef3; color: #6a7086; }
.rec-row.rec-late td.rec-due { color: #a32d2d; font-weight: 700; }
.rec-row.rec-soon td.rec-due { color: #8a5a00; font-weight: 700; }
.rec-row.rec-off { opacity: .55; }

/* kontrolki stanu (przeglądy, serwisy, urządzenia) */
.sdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; background: #888780; }
.sdot-ok, .sdot-planned { background: #3b6d11; } .sdot-soon { background: #ba7517; } .sdot-overdue, .sdot-expired { background: #a32d2d; } .sdot-noprotocol, .sdot-none { background: #888780; }
.stag { font-size: 12px; padding: 2px 9px; border-radius: 8px; white-space: nowrap; display: inline-block; }
.stag-ok, .stag-planned { background: #eaf3de; color: #27500a; } .stag-soon { background: #faeeda; color: #633806; } .stag-overdue, .stag-expired { background: #fceaea; color: #791f1f; }
.stag-noprotocol, .stag-none { background: #eceef3; color: #444441; }
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; border: 1px solid #e2e5ee; border-radius: 8px; padding: 9px 12px; margin-bottom: 6px; background: #fff; }
.list-row.clickable { cursor: pointer; } .list-row.clickable:hover { background: #f5f7fc; }
.list-title { font-weight: 600; font-size: 14px; }
.sec-label { font-size: 11px; letter-spacing: .05em; color: #7a7f95; margin: 14px 0 6px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 5px 12px; font-size: 14px; margin: 10px 0 12px; }
.catalog-list { max-height: 46vh; overflow: auto; border: 1px solid #e2e5ee; border-radius: 8px; padding: 4px 10px 8px; }
.catalog-row { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; font-size: 14px; cursor: pointer; }
.catalog-row input { margin-top: 3px; }
.tile.clickable { cursor: pointer; } .tile.clickable:hover { box-shadow: 0 2px 10px rgba(20, 30, 70, .12); }
.tile-line { display: block; }
@media (max-width: 820px) { .kv { grid-template-columns: 1fr; } .list-row { grid-template-columns: 1fr; } }

.defect-row { border: 1px solid #e2e5ee; border-radius: 8px; padding: 8px 10px; margin: 8px 0; background: #fff; }
.defect-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.defect-row .result-btns { margin-top: 6px; }

details.maint-system > summary.maint-summary { cursor: pointer; padding: 6px 2px; list-style: none; }
details.maint-system > summary.maint-summary::-webkit-details-marker { display: none; }
details.maint-system > summary.maint-summary::before { content: '▸ '; color: #7a7f95; }
details.maint-system[open] > summary.maint-summary::before { content: '▾ '; }
.facility-details > summary { cursor: pointer; }

/* menu: etykiety grup */
.nav-sec { font-size: 13px; letter-spacing: .14em; color: #ffffff; padding: 20px 12px 7px; margin-top: 12px; border-top: 1px solid #2a2c3a; font-weight: 800; text-transform: uppercase; }
.nav-sec ~ button.navlink { padding-left: 26px; font-size: 13.5px; font-weight: 400; }
.nav-sec ~ button.navlink.active { font-weight: 600; }
.cost-box { background: #f7f8fb; }
.focus-clear { margin-left: 6px; border: none; background: transparent; color: #1d3f9e; font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0; }
/* Magazyn: kolory działów */
.inv-category { border-left-color: var(--ic, #0d9488); background: var(--ic-bg, #f0fdfa); }
.inv-chip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--ic, #0d9488); margin-right: 7px; vertical-align: middle; }
.inv-category h4 { display: flex; align-items: center; }
.inv-c0 { --ic: #2454ff; --ic-bg: #eef2ff; } .inv-c1 { --ic: #0d9488; --ic-bg: #ecfdf5; } .inv-c2 { --ic: #b5790a; --ic-bg: #fffbeb; } .inv-c3 { --ic: #a21caf; --ic-bg: #fdf4ff; }
.inv-c4 { --ic: #d1372f; --ic-bg: #fef2f2; } .inv-c5 { --ic: #4338ca; --ic-bg: #eef2ff; } .inv-c6 { --ic: #0f766e; --ic-bg: #f0fdfa; } .inv-c7 { --ic: #9a3412; --ic-bg: #fff7ed; }
.works-table td, .works-table th { font-size: 13px; }
.works-card { border-left: 4px solid var(--accent); margin-top: 6px; }
.works-info { margin: 8px 0; }
.work-link { color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 600; }
.work-link:hover { text-decoration: none; }
/* wyraźny podział na obiekty */
.fac-card { border-top: 4px solid var(--accent); padding-top: 14px; }
.fac-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 12px; }
.fac-head h3 { font-size: 20px; margin: 0; }
details.inv-category > summary.inv-summary { cursor: pointer; list-style: none; padding: 4px 2px; }
details.inv-category > summary.inv-summary::-webkit-details-marker { display: none; }
details.inv-category > summary.inv-summary::before { content: '▸ '; color: #7a7f95; margin-right: 4px; }
details.inv-category[open] > summary.inv-summary::before { content: '▾ '; }
details.inv-category[open] > summary.inv-summary { margin-bottom: 6px; }
/* ---- Planowanie zadań: kompaktowe okno, podzadania, załączniki, lampka faktury ---- */
.field textarea { min-height: 44px; }
.photo-tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 200px)); }
.photo-tile-body { aspect-ratio: 4 / 3; }
.photo-tile-body.empty { aspect-ratio: auto; min-height: 56px; }
.chat-input { min-height: 44px; }
.chat-list { min-height: 0; }
.btn.ghost.danger { background: transparent; color: var(--danger); border-color: #f1c0bd; }
.task-banner.danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.chip-warn { background: #fff7ed; color: #9a3412; }
.lamp { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: middle; margin-left: 6px; background: #94a3b8; box-shadow: 0 0 0 2px rgba(148,163,184,.25); }
.lamp-red { background: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.28), 0 0 8px rgba(220,38,38,.65); animation: lamp-pulse 1.6s ease-in-out infinite; }
.lamp-green { background: #16a34a; box-shadow: 0 0 0 2px rgba(22,163,74,.25); animation: none; }
.lamp-grey { background: #94a3b8; animation: none; }
@keyframes lamp-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(220,38,38,.25), 0 0 6px rgba(220,38,38,.5); } 50% { box-shadow: 0 0 0 5px rgba(220,38,38,.12), 0 0 12px rgba(220,38,38,.9); } }
.progress { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress-bar { height: 100%; background: #16a34a; border-radius: 999px; transition: width .2s ease; }

.task-subtasks h4, .task-attachments h4 { margin: 0 0 4px; }
.sub-row { border-top: 1px solid var(--border); padding: 8px 0; }
.sub-row.done .sub-title { text-decoration: line-through; color: var(--muted); }
.sub-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sub-meta { margin-top: 6px; padding-left: 26px; }
.sub-num { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sub-title { flex: 1; min-width: 160px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.sub-meta select, .sub-meta input { padding: 5px 7px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 13px; }
.sub-owner { width: 130px; }
.sub-cost { width: 96px; }
.att-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 7px 0; border-top: 1px solid var(--border); }
.att-name { font-weight: 600; word-break: break-word; flex: 1; min-width: 160px; }
.att-btns { display: inline-flex; gap: 6px; margin-left: auto; }
.att-kind { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eef2ff; color: #3730a3; white-space: nowrap; }
.att-kind.att-2 { background: #fee2e2; color: #991b1b; }
.att-kind.att-3 { background: #ffedd5; color: #9a3412; }
.att-kind.att-0 { background: #dcfce7; color: #166534; }
.att-kind.att-1 { background: #fef9c3; color: #854d0e; }
.tpl-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }

/* ---- Kalendarz i harmonogram ---- */
.cal-bar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.seg-btn { border: none; background: transparent; padding: 8px 14px; font-weight: 600; font-size: 13.5px; cursor: pointer; border-right: 1px solid var(--border); }
.seg-btn:last-child { border-right: none; }
.seg-btn.active { background: var(--accent); color: #fff; }
.cal-nav { display: inline-flex; align-items: center; gap: 6px; }
.cal-title { margin-left: 8px; font-size: 16px; }
.cal-kinds { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 13px; }
.cal-kind { display: inline-flex; align-items: center; gap: 5px; }
.cal-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.cal-dot.ev-task, .cal-ev.ev-task { background: #dbeafe; border-color: #93c5fd; color: #1e3a8a; }
.cal-dot.ev-subtask, .cal-ev.ev-subtask { background: #e0e7ff; border-color: #a5b4fc; color: #3730a3; }
.cal-dot.ev-inspection, .cal-ev.ev-inspection { background: #dcfce7; border-color: #86efac; color: #166534; }
.cal-dot.ev-contract, .cal-ev.ev-contract { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.cal-dot.ev-recurring, .cal-ev.ev-recurring { background: #f3e8ff; border-color: #d8b4fe; color: #6b21a8; }
.cal-ev.ev-p-Krytyczny { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.cal-ev.ev-p-Wysoki { background: #ffedd5; border-color: #fdba74; color: #9a3412; }
.cal-ev { display: block; width: 100%; text-align: left; border: 1px solid; border-radius: 5px; padding: 1px 6px; margin: 2px 0; font-size: 11.5px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; min-height: 18px; }
.cal-ev.cont { border-left-color: transparent; border-radius: 0 5px 5px 0; opacity: .85; }
.cal-ev.ev-late { border-color: #dc2626; box-shadow: inset 3px 0 0 #dc2626; }
.cal-ev.ev-approx { border-style: dashed; background-image: repeating-linear-gradient(135deg, rgba(0,0,0,.05) 0 6px, transparent 6px 12px); }
.cal-ev-full { white-space: normal; padding: 6px 9px; font-size: 13px; margin: 5px 0; }
.cal-card { padding: 8px; overflow-x: auto; }
.cal-month { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 640px; }
.cal-month th { text-align: center; font-size: 12px; padding: 6px 2px; }
.cal-month th.cal-wk, .cal-month td.cal-wk { width: 46px; background: #f1f5f9; color: var(--muted); text-align: center; font-weight: 700; cursor: pointer; }
.cal-month td.cal-day { height: 104px; vertical-align: top; padding: 3px 4px; border: 1px solid var(--border); background: #fff; }
.cal-month td.cal-day.other { background: #f8fafc; color: #94a3b8; }
.cal-month td.cal-day.weekend { background: #fafafa; }
.cal-month td.cal-day.today { outline: 2px solid var(--accent); outline-offset: -2px; background: #f4eff8; }
.cal-daynum { font-size: 12px; font-weight: 700; color: var(--muted); text-align: right; }
.cal-more { border: none; background: transparent; color: var(--accent); font-size: 11.5px; cursor: pointer; padding: 0 2px; }
.cal-approx { padding: 10px 14px; }
.cal-approx-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cal-approx-row .cal-ev { width: auto; max-width: 100%; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-wcol { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-height: 160px; }
.cal-wcol.today { outline: 2px solid var(--accent); background: #f4eff8; }
.cal-wcol.weekend { background: #fafafa; }
.cal-whead { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.cal-listweek h4 { margin: 0 0 6px; }
.cal-listrow { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--border); cursor: pointer; }
.cal-list-date { min-width: 120px; font-size: 13px; font-weight: 600; }
.cal-list-title { flex: 1; min-width: 200px; width: auto; display: inline-block; }
.pill.ev-pill-task { background: #dbeafe; color: #1e3a8a; }
.pill.ev-pill-subtask { background: #e0e7ff; color: #3730a3; }
.pill.ev-pill-inspection { background: #dcfce7; color: #166534; }
.pill.ev-pill-contract { background: #fef9c3; color: #854d0e; }
.pill.ev-pill-recurring { background: #f3e8ff; color: #6b21a8; }

/* Harmonogram (Gantt) */
.gantt-card { padding: 0; overflow: hidden; }
.gantt-scroll { overflow: auto; max-height: 70vh; }
.gantt { min-width: 100%; width: max-content; }
.g-row { display: flex; border-bottom: 1px solid var(--border); }
.g-label { position: sticky; left: 0; z-index: 3; flex: 0 0 270px; width: 270px; background: #fff; padding: 6px 10px; border-right: 1px solid var(--border); overflow: hidden; }
.g-clickable { cursor: pointer; }
.g-clickable:hover { background: #f1f5ff; }
.g-lt { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-track { position: relative; flex: 0 0 auto; min-height: 44px; background-image: linear-gradient(to right, rgba(100,116,139,.14) 1px, transparent 1px); background-size: var(--wk) 100%; }
.g-head { position: sticky; top: 0; z-index: 5; background: #f8fafc; }
.g-head .g-label { background: #f8fafc; z-index: 6; display: flex; align-items: center; gap: 4px; }
.g-headtrack { background-image: none; min-height: 0; }
.g-hrow { position: relative; height: 24px; }
.g-hrow.top { border-bottom: 1px solid var(--border); background: #eef2f7; }
.g-hcell { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--border); font-size: 11.5px; padding: 4px 5px; color: var(--muted); white-space: nowrap; overflow: hidden; font-weight: 600; }
.g-facrow { background: #eef2f7; }
.g-facrow .g-label { background: #eef2f7; }
.g-facrow .g-track { min-height: 30px; background: #eef2f7; }
.g-subrow .g-track { min-height: 32px; }
.g-sublabel { padding-left: 24px; background: #fcfcfd; }
.g-bar { position: absolute; top: 9px; height: 26px; border-radius: 6px; border: 1px solid rgba(0,0,0,.18); display: flex; align-items: center; overflow: hidden; touch-action: none; user-select: none; background: #60a5fa; color: #fff; }
.g-bar.p-Krytyczny { background: #dc2626; }
.g-bar.p-Wysoki { background: #f97316; }
.g-bar.p-Normalny { background: #3b82f6; }
.g-bar.p-Niski { background: #64748b; }
.g-bar.g-late { box-shadow: 0 0 0 2px rgba(220,38,38,.55); }
.g-bar.g-approx { opacity: .6; border-style: dashed; background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 6px, transparent 6px 12px); cursor: pointer; }
.g-bar.g-edit { cursor: grab; }
.g-bar.g-edit:active { cursor: grabbing; }
.g-bartext { padding: 0 10px; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.g-h { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; background: rgba(0,0,0,.18); }
.g-h.l { left: 0; }
.g-h.r { right: 0; }
.g-subbar { top: 8px; height: 16px; background: #94a3b8 !important; opacity: .95; cursor: default; }
.g-subbar.done { background: #86efac !important; }
.g-ms { position: absolute; top: 9px; width: 14px; height: 14px; background: #475569; transform: rotate(45deg); border-radius: 2px; }
.g-ms.done { background: #16a34a; }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: #dc2626; z-index: 2; opacity: .75; pointer-events: none; }
.gantt-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 4px 0 14px; }
.lg { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 2px; vertical-align: middle; }
.lg-p-Krytyczny { background: #dc2626; } .lg-p-Wysoki { background: #f97316; } .lg-p-Normalny { background: #3b82f6; } .lg-p-Niski { background: #64748b; }
.lg-approx { background: #93c5fd; background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.7) 0 3px, transparent 3px 6px); }
.lg-ms { background: #475569; width: 9px; height: 9px; transform: rotate(45deg); }
.lg-today { background: #dc2626; width: 3px; }
.settle-firm { border-top: 1px solid var(--border); padding: 6px 0; }
.settle-firm > summary { cursor: pointer; padding: 4px 0; }

@media (max-width: 760px) {
  .cal-week { grid-template-columns: 1fr; }
  .g-label { flex-basis: 150px; width: 150px; }
  .cal-month td.cal-day { height: 84px; }
  .sub-meta { padding-left: 0; }
  .att-btns { margin-left: 0; }
}

/* ---- Portal wykonawcy, kafelki obiektów w Sprawach ---- */
.task-banner.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.chip-ok { background: #dcfce7; color: #166534; }
.sub-title-ro { font-size: 14px; }
.fac-tiles { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.fac-tile { text-align: left; background: #fff; border: 2px solid var(--border); border-radius: 12px; padding: 10px 14px; min-width: 170px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.fac-tile:hover { border-color: #93a8ff; }
.fac-tile.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(125,80,158,.15); background: #f6f1f9; }
.fac-tile.all { background: #f8fafc; }
.fac-tile.all.active { background: #f3f6ff; }
.fac-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.fac-stats { display: flex; flex-wrap: wrap; gap: 3px 10px; font-size: 12px; color: var(--muted); }
.fac-stats .fs-red { color: #b91c1c; font-weight: 700; }
.fac-stats .fs-blue { color: #1d4ed8; font-weight: 700; }
@media (max-width: 760px) { .fac-tile { flex: 1 1 calc(50% - 10px); min-width: 140px; } }

/* ---- Wykonawcy: zwijane obiekty ---- */
details.fac-fold > summary { cursor: pointer; font-size: 16px; padding: 4px 0; list-style-position: inside; }
details.fac-fold[open] > summary { margin-bottom: 12px; }

/* ---- Przeglądy: wyraźne, zwijane sekcje; strefa dodawania plików; zlecenia ---- */
.ins-sec { border: 1px solid var(--border); border-left: 6px solid #3b6d11; border-radius: 10px; margin: 12px 0; background: #fff; overflow: hidden; }
.ins-sec.has-soon { border-left-color: #ba7517; }
.ins-sec.has-late { border-left-color: #a32d2d; }
.ins-sec > summary.ins-sec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 13px 16px; cursor: pointer; list-style: none; background: #eef1f8; }
.ins-sec > summary.ins-sec-head::-webkit-details-marker { display: none; }
.ins-sec > summary.ins-sec-head::before { content: '▸'; font-size: 15px; color: #4a5068; transition: transform .15s; }
.ins-sec[open] > summary.ins-sec-head::before { transform: rotate(90deg); }
.ins-sec[open] > summary.ins-sec-head { border-bottom: 1px solid var(--border); }
.ins-sec > summary.ins-sec-head:hover { background: #e4e9f5; }
.ins-sec-name { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.ins-sec-count { font-size: 13px; color: var(--muted); }
.ins-sec-chips { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ins-sec-body { padding: 2px 16px 8px; }
.ins-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.ins-order { color: var(--accent); margin-top: 2px; }
.stag-noprotocol { border: 1px dashed #b4b2a9; }
.ins-last .ins-next { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.ins-noproto { background: #fff8e6; color: #7a5200; border: 1px solid #f3dca0; border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 4px 0 8px; }
.ins-run { border-top: 1px solid var(--border); padding: 8px 0; }
.ins-acct-ok { color: #166534; font-weight: 600; }
.dropbox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 4px; padding: 12px 14px; border: 2px dashed #b9c0d4; border-radius: 10px; background: #f8f9fc; color: var(--muted); font-size: 13px; transition: border-color .12s, background .12s; }
.dropbox-ico { font-size: 20px; }
.dropbox-text { flex: 1; min-width: 140px; }
.dropbox.busy { opacity: .6; pointer-events: none; }
.drop-active { outline: 3px dashed var(--accent); outline-offset: -3px; background: #f4eff8; }
.dropbox.drop-active { border-color: var(--accent); background: #f4eff8; }
.ord-late { color: #a32d2d; font-weight: 700; }
.ord-soon { color: #ba7517; font-weight: 700; }
.orders-panel .works-table { min-width: 560px; }

/* ---- Zgłoszenie: uproszczony formularz ---- */
.task-new .field { margin-bottom: 12px; }
.prio-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.prio-chip { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-size: 13px; font-weight: 600; }
.prio-chip.active { border-color: var(--accent); background: #f4eff8; color: #4a2d63; box-shadow: 0 0 0 2px rgba(125,80,158,.18); }
.opt-block { margin: 14px 0 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.opt-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.opt-chip.active { border-color: var(--accent); background: #f4eff8; color: #4a2d63; }
.opt-sec { margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fafbfd; }
.files-opts { margin-top: 6px; }
.files-opts summary { cursor: pointer; }
.file-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.file-thumb { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); cursor: zoom-in; background: #f1f2f6; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(15,16,26,.7); color: #fff; font-size: 12px; line-height: 1; cursor: pointer; }
.file-thumb-phase { position: absolute; left: 0; bottom: 0; right: 0; background: rgba(15,16,26,.6); color: #fff; font-size: 11px; text-align: center; padding: 2px 0; }
details.task-fold { margin-top: 12px; }
details.task-fold > summary { cursor: pointer; font-weight: 700; font-size: 15px; list-style-position: inside; }
details.task-fold[open] > summary { margin-bottom: 10px; }

.exec-block { margin: 4px 0 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fafbfd; }
.exec-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.exec-seg { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.exec-opt { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-size: 13.5px; font-weight: 600; }
.exec-opt.active { border-color: var(--accent); background: #f4eff8; color: #4a2d63; box-shadow: 0 0 0 2px rgba(125,80,158,.18); }
.task-banner.info { background: #eef2ff; color: #1e3a8a; border: 1px solid #c7d2fe; }

.field input[type=checkbox], .exec-block input[type=checkbox] { width: auto; }

.chip-red { background: #fee2e2; color: #991b1b; }
.chip-info { background: #e0e7ff; color: #3730a3; }

.ack-tile { border: 2px solid var(--accent); background: #f6f1f9; }
.btn.big { padding: 14px 22px; font-size: 16px; }
.protocol-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 150px; padding: 24px; border: 3px dashed var(--accent); border-radius: 14px; background: #f6f1f9; text-align: center; cursor: pointer; transition: background .12s, border-color .12s; }
.protocol-tile:hover, .protocol-tile.drop-active { background: #e4ebff; }
.protocol-ico { font-size: 44px; line-height: 1; }
.protocol-title { font-size: 22px; font-weight: 700; color: #1e3a8a; }

.tile-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile-pair .protocol-tile { height: 100%; min-height: 190px; justify-content: flex-start; padding-top: 30px; }
.tile-num { width: 100%; max-width: 260px; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; text-align: center; }
@media (max-width: 640px) { .tile-pair { grid-template-columns: 1fr; } .tile-pair .protocol-tile { min-height: 150px; } }

details.fac-history { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
details.fac-history > summary { cursor: pointer; font-size: 15px; }
details.fac-history[open] > summary { margin-bottom: 8px; }

/* ---- Wiadomości: wyraźne plakietki, skrzynka, odznaka w menu ---- */
.chat-new { display: inline-block; margin-left: 6px; padding: 2px 9px; border-radius: 999px; background: #dc2626; color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; animation: chatpulse 2.4s ease-in-out infinite; }
.chat-new.ext { background: #ea580c; }
@keyframes chatpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.45); } 50% { box-shadow: 0 0 0 5px rgba(220,38,38,0); } }
.chat-preview { margin-top: 3px; font-size: 12.5px; color: var(--muted); font-style: italic; max-width: 560px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.has-unread { box-shadow: inset 4px 0 0 #dc2626; background: #fff7f5; }
tr.has-unread:hover { background: #ffefeb; }
.task-title-unread { font-weight: 700; }
.nav-badge { float: right; min-width: 20px; margin-top: 1px; padding: 0 7px; border-radius: 999px; background: #dc2626; color: #fff; font-size: 11.5px; line-height: 19px; text-align: center; font-weight: 700; }
.inbox-card.has-unread { border-color: #fca5a5; }
.inbox-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 4px; border-top: 1px solid var(--border); cursor: pointer; }
.inbox-row:first-of-type { border-top: none; }
.inbox-row:hover { background: #f7f8fb; }
.inbox-row.unread { background: #fff7f5; box-shadow: inset 3px 0 0 #dc2626; padding-left: 10px; }
.inbox-row.unread .inbox-title { font-weight: 700; }
.inbox-main { min-width: 0; flex: 1; }
.inbox-title { font-size: 14px; }
.inbox-preview { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.chat-msg.new { box-shadow: 0 0 0 2px #fb923c; }
.chat-new-tag { margin-right: 6px; padding: 0 6px; border-radius: 6px; background: #ea580c; color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.chat-newbar { position: sticky; top: 0; z-index: 1; margin-bottom: 6px; padding: 5px 10px; border-radius: 8px; background: #fee2e2; color: #991b1b; font-size: 12.5px; font-weight: 700; text-align: center; }
@media (max-width: 760px) { .tasks-table tr.has-unread { border-left: 4px solid #dc2626; } .chat-preview { max-width: 100%; white-space: normal; } }

.hist-num { font-size: 28px; font-weight: 700; line-height: 1.2; }
.card.hist-late { border-color: #fca5a5; }
.card.hist-late .hist-num { color: #b91c1c; }
.login-stats th.sortable { cursor: pointer; user-select: none; }
.login-stats th.sortable.active { color: var(--accent); }

.attention-card { border: 2px solid #f59e0b; background: #fffbeb; }
.attn-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 6px; border-top: 1px solid #fde68a; cursor: pointer; }
.attn-row:first-of-type { border-top: none; }
.attn-row:hover { background: #fef3c7; }
.attn-row.attn-withdrawn { background: #fef2f2; }
.attn-main { min-width: 0; flex: 1; }
.attn-title { font-weight: 700; font-size: 14px; }

/* prawa autorskie */
.legal-foot { margin-top: 18px; font-size: 11px; line-height: 1.5; color: var(--muted); text-align: center; }
#sideNav .legal-foot.nav-legal { margin-top: 10px; color: #8b90a3; font-size: 10px; }
.about-card .about-name { font-size: 16px; font-weight: 700; }
.about-card .about-notice { margin-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* @@dark-start */
/* ciemny motyw: osobny plik app-dark.css, generowany przez tools/gen-dark.js */


html[data-font="large"] body { zoom: 1.12; }
