/* ==========================================================================
   appBHP – szata „Plac budowy”: jedna dla panelu, stron modułów, portalu i stron bez logowania.
   Jak oznakowanie budowy: tło w kolorze betonu, białe karty z cienką linią, wąskie liczby jak na tablicach
   (Barlow Condensed), tekst i dane w Public Sans, niebieski Electry (--brand, z Ustawień) do działania,
   żółć kamizelki (--hivis) tylko tam, gdzie trzeba zwrócić uwagę; czerwień (--accent) – zgłoszenia i alarmy.
   Zasady: pola dotykowe min. 44 px, ruch tylko jako odpowiedź na działanie, „ogranicz ruch” respektowane.
   ========================================================================== */
:root {
  --brand: 11 92 173;           /* niebieski Electry (RGB) – działanie, linki, zaznaczenia */
  --accent: 200 38 30;          /* czerwień sygnałowa – zgłoszenia, alarmy */
  --hivis: #FFC400;             /* żółć kamizelki – pasek nagłówka, wyróżnienia */
  --ink: #15191E;               /* atrament – tekst, tablica budowy, aktywne zakładki */
  --ink-2: #252B32;
  --night: #15191E;
  --night-2: #252B32;
  --bg: #EDEFEC;                /* beton */
  --surface: #ffffff;
  --surface-2: #F6F7F5;
  --sunken: #ECEEEB;
  --text: #15191E;
  --muted: #5C6670;
  --border: #D9DDD8;
  --border-strong: #BFC5BE;
  --grid-line: rgb(255 255 255 / .055);
  --ok-bg: #E2F3EA; --ok-fg: #145C38; --ok-bd: #9FD6B8;
  --warn-bg: #FFF3D1; --warn-fg: #7A4F00; --warn-bd: #F2C94C;
  --over-bg: #FDE7E5; --over-fg: #A11F15; --over-bd: #F3A9A2;
  --focus: #FFC400;
  --radius-xl: 10px;            /* karty, nagłówki stron */
  --radius-lg: 8px;             /* mniejsze kontenery */
  --radius: 6px;                /* pola, przyciski */
  --shadow: 0 1px 0 rgb(21 25 30 / .04);
  --shadow-float: 0 18px 40px -16px rgb(21 25 30 / .35);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font-sans: "Public Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Barlow Condensed", "Public Sans", ui-sans-serif, sans-serif;
  color-scheme: light;
}
/* Wysoki kontrast – praca w pełnym słońcu */
:root[data-contrast="high"] { --text: #000; --muted: #1d2733; --border: #1d2733; --border-strong: #000; --bg: #fff; --surface-2: #fff; }
/* --- Podstawy --------------------------------------------------------------- */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { color: var(--text); font-family: var(--font-sans); line-height: 1.55; text-rendering: optimizeLegibility;
  background: var(--bg); }
:root[data-contrast="high"] body { background: var(--bg); }
h1, h2, h3, .font-display { font-family: var(--font-display); letter-spacing: 0; color: inherit; }
h1 { font-weight: 700; line-height: 1.02; }
h2, h3 { font-weight: 700; line-height: 1.15; }
/* Tytuły z klasami Tailwind (text-2xl…) – wąski krój tablic jest optycznie mniejszy, więc nieco większy */
h1.text-2xl, .page-head h1 { font-size: 2rem; }
h2.text-lg { font-size: 1.35rem; }
h2.text-xl { font-size: 1.6rem; }
:focus-visible { outline-color: var(--focus); }
a { color: inherit; }
.text-muted { color: var(--muted); }
.surface { background: var(--surface); }
.surface-2 { background: var(--surface-2); }
.border-app { border-color: var(--border); }
.tabular { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 100; background: #fff; color: #000; padding: .75rem 1rem; font-weight: 600; }
.skip-link:focus { left: .5rem; top: .5rem; }
::selection { background: rgb(var(--brand) / .2); }

/* --- Karty: obramowanie zamiast cienia; hierarchia przez nagłówek ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.card-body { padding: 1.25rem; }
.card-title { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; display: flex; align-items: center; gap: .5rem; }

/* --- Przyciski ------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .55rem 1.05rem; border-radius: var(--radius); font-weight: 700; font-size: .9rem; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; position: relative;
  transition: background-color .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), transform .12s var(--ease), box-shadow .18s var(--ease); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { flex: none; }
.btn-wrap { white-space: normal; text-align: left; line-height: 1.2; }
.btn-primary { background: rgb(var(--brand)); color: #fff; }
.btn-primary:hover { background: rgb(var(--brand) / .88); }
.btn-brand { background: rgb(var(--brand)); color: #fff; }
.btn-brand:hover { background: rgb(var(--brand) / .9); }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; }
.btn-accent { background: rgb(var(--accent)); color: #fff; }
.btn-accent:hover { background: rgb(var(--accent) / .9); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-danger { background: #b4231c; color: #fff; }
.btn-danger:hover { background: #961c16; }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--sunken); }
.btn-sm { min-height: 36px; padding: .3rem .7rem; font-size: .86rem; }
.btn-lg { min-height: 54px; padding: .8rem 1.4rem; font-size: 1.02rem; }

/* --- Formularze -------------------------------------------------------------- */
.label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: .35rem; color: var(--text); }
.label .req { color: rgb(var(--accent)); margin-left: .15rem; }
.input, .select, .textarea { width: 100%; min-height: 46px; padding: .6rem 1rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 1rem; font-family: inherit;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.textarea { min-height: 110px; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { border-color: rgb(var(--brand)); outline: none; box-shadow: 0 0 0 4px rgb(var(--brand) / .16); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .75; }
.input-error { border-color: var(--over-bd) !important; background: var(--over-bg); }
.field-error { color: var(--over-fg); font-size: .85rem; margin-top: .3rem; font-weight: 600; display: flex; gap: .35rem; align-items: flex-start; }
.field-error::before { content: "!"; flex: none; display: inline-flex; align-items: center; justify-content: center; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--over-bd); color: #fff; font-size: .72rem; margin-top: .1rem; }
.help { color: var(--muted); font-size: .84rem; margin-top: .3rem; line-height: 1.45; }
.check { display: inline-flex; align-items: center; gap: .6rem; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: rgb(var(--brand)); flex: none; }
/* Uprawnienia indywidualne: przyznane / odebrane ponad rolę */
td.uperm-grant { background: rgb(22 163 74 / .12); }
td.uperm-deny { background: rgb(220 38 38 / .12); }
.uperm-dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; vertical-align: -1px; }
.uperm-dot.uperm-grant { background: rgb(22 163 74 / .45); }
.uperm-dot.uperm-deny { background: rgb(220 38 38 / .45); }
/* Wybór piktogramów (GHS, ŚOI) – kafelki z obrazkiem */
.picto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem; }
.picto { position: relative; display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .6rem .4rem .5rem; border: 2px solid var(--border); border-radius: 14px; background: var(--surface, #fff); cursor: pointer; text-align: center; min-height: 44px; transition: border-color .15s, box-shadow .15s, background .15s; }
.picto:hover { border-color: rgb(var(--brand) / .5); }
.picto img { width: 56px; height: 56px; object-fit: contain; }
.picto input { position: absolute; top: .45rem; left: .45rem; width: 18px; height: 18px; accent-color: rgb(var(--brand)); }
.picto-name { font-size: .75rem; font-weight: 700; line-height: 1.2; }
.picto-hint { font-size: .68rem; line-height: 1.2; color: var(--muted, #64748b); }
.picto:has(input:checked) { border-color: rgb(var(--brand)); background: rgb(var(--brand) / .08); box-shadow: 0 0 0 3px rgb(var(--brand) / .15); }
.picto:has(input:focus-visible) { outline: 3px solid rgb(var(--brand) / .5); outline-offset: 2px; }

/* --- Tabele ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Pole z listą pozycji (np. wyposażenie we wniosku): nie wychodzi poza formularz; w wąskim formularzu wiersze jako
   kafelki z podpisami pól zamiast tabeli przewijanej w poziomie */
.rows-field { min-width: 0; max-width: 100%; container-type: inline-size; }
.rows-field .table { width: 100%; }
.rows-field td .input, .rows-field td .select, .rows-field td .textarea { width: 100%; min-width: 0; }
.rows-field td .select { min-width: 10rem; }
@container (max-width: 820px) {
  .rows-field .table-wrap { overflow: visible; }
  .rows-field .table, .rows-field .table tbody { display: block; }
  .rows-field .table thead { display: none; }
  .rows-field tr[data-row] { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem .75rem; padding: .75rem; margin-bottom: .6rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); position: relative; }
  .rows-field tr[data-row] td .select { min-width: 0; }
  .rows-field tr[data-row] td { display: block; min-width: 0 !important; padding: 0 !important; border: 0 !important; }
  .rows-field tr[data-row] td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .25rem; }
  .rows-field tr[data-row] td.rows-del { position: absolute; top: .35rem; right: .35rem; }
  .rows-field tr[data-row] td:first-child { padding-right: 2.75rem !important; }
  .rows-field tr[data-row] td:nth-last-child(2):nth-child(odd) { grid-column: 1 / -1; }
}
@container (max-width: 460px) {
  .rows-field tr[data-row] { grid-template-columns: minmax(0, 1fr); }
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .93rem; }
.table th { text-align: left; font-family: var(--font-display); font-weight: 700; font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: .7rem .8rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th a { color: inherit; text-decoration: none; }
.table td { padding: .7rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr { transition: background-color .12s var(--ease); }
.table tbody tr:hover td { background: rgb(var(--brand) / .035); }
.table tbody tr:last-child td { border-bottom: 0; }
.table a.row-link { font-weight: 600; color: rgb(var(--brand)); text-decoration: none; background-image: linear-gradient(currentColor, currentColor); background-size: 0 1.5px; background-repeat: no-repeat; background-position: 0 100%; transition: background-size .2s var(--ease); }
.table a.row-link:hover { background-size: 100% 1.5px; }

/* --- Znaczniki terminów: zielony – aktualne, żółty – wygasa, czerwony – po terminie
       (kształt symbolu dubluje kolor dla osób z zaburzeniami widzenia barw) --- */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 4px; font-size: .75rem; font-weight: 700; border: 1px solid; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.badge-over { background: var(--over-bg); color: var(--over-fg); border-color: var(--over-bd); }
.badge-neutral { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.badge-brand { background: rgb(var(--brand) / .08); color: rgb(var(--brand)); border-color: rgb(var(--brand) / .35); }
.badge-ok::before { content: "●"; font-size: .7em; } .badge-warn::before { content: "▲"; font-size: .7em; } .badge-over::before { content: "■"; font-size: .7em; }

/* --- Komunikaty (flash) – wjeżdżają jako potwierdzenie akcji ------------------- */
.alert { padding: .85rem 1.1rem; border-radius: var(--radius); border: 1px solid; border-left-width: 4px; font-weight: 500; }
.alert-success { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.alert-warning { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.alert-error { background: var(--over-bg); color: var(--over-fg); border-color: var(--over-bd); }
.alert-info { background: rgb(var(--brand) / .06); color: var(--text); border-color: rgb(var(--brand) / .35); }
.flash { animation: flash-in .45s var(--ease) both; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* --- Nagłówek: biały pasek z żółtym paskiem kamizelki u góry ------------------- */
.topbar { background: var(--surface); color: var(--text); border-top: 4px solid var(--hivis); border-bottom: 1px solid var(--border); }
.topbar .btn-ghost { color: var(--text); }
.topbar .btn-ghost:hover { background: var(--sunken); color: var(--text); }
.topbar .select { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.brand-logo { flex: none; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); background: #fff; padding: .2rem .35rem; }
@media (max-width: 639px) { .brand-logo { padding: .2rem .3rem; } }
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; letter-spacing: 0; color: var(--text); }
.topbar .text-slate-300 { color: var(--muted); }
.topbar .\!bg-white\/15 { background: var(--sunken) !important; }
/* --- Menu boczne: grupy rozwijane, aktywna pozycja jak zakładka portalu ------- */
.nav-link { position: relative; display: flex; align-items: center; gap: .7rem; min-height: 42px; padding: .45rem .8rem; border-radius: var(--radius); font-size: .9rem; font-weight: 600; color: var(--text); text-decoration: none; transition: background-color .15s var(--ease), color .15s var(--ease); }
.nav-link svg { color: var(--muted); flex: none; transition: color .15s var(--ease); }
.nav-link:hover { background: var(--sunken); }
.nav-link:hover svg { color: var(--text); }
.nav-link.active { background: rgb(var(--brand) / .1); color: rgb(var(--brand)); }
.nav-link.active svg { color: rgb(var(--brand)); }
.nav-group { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-display); font-size: .85rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; padding: .9rem .8rem .35rem; cursor: pointer; list-style: none; border-radius: var(--radius); user-select: none; }
.nav-group::-webkit-details-marker { display: none; }
.nav-group:hover { color: var(--text); }
.nav-group .chev { transition: transform .25s var(--ease); }
details[open] > .nav-group .chev { transform: rotate(180deg); }
.nav-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .28s var(--ease); }
details[open] > .nav-panel { grid-template-rows: 1fr; }
.nav-panel > div { overflow: hidden; }
/* Odtwarzanie stanu menu po przejściu na inną stronę – bez animacji */
.sb-restoring .nav-panel, .sb-restoring .chev { transition: none !important; }

.mobile-nav { background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 20px -12px rgb(15 23 42 / .25); padding-bottom: env(safe-area-inset-bottom); }
.mobile-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; font-size: .74rem; font-weight: 700; color: var(--text); text-decoration: none; }
.mobile-nav a.report { color: rgb(var(--accent)); }

/* --- Nagłówki stron: baner strony głównej modułu i nagłówek podstrony ------------ */
.page-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 1.6rem + 1.4vw, 2.8rem); line-height: 1; letter-spacing: 0; }
.page-lead { color: var(--muted); max-width: 70ch; }
.ui-hero { margin-bottom: 1.5rem; border-radius: var(--radius-xl); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-top: 6px solid var(--hivis); padding: 1.5rem; }
@media (min-width: 768px) { .ui-hero { padding: 1.75rem 2rem; } }
.ui-hero__kicker { font-family: var(--font-display); font-size: .9rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.ui-hero__title { margin-top: .35rem; display: flex; align-items: center; gap: .75rem; font-family: var(--font-display); font-size: clamp(2.25rem, 1.8rem + 1.6vw, 3rem); font-weight: 700; line-height: 1; letter-spacing: 0; color: var(--text); }
.ui-hero__title svg { color: rgb(var(--brand)); }
.ui-hero__lead { margin-top: .6rem; max-width: 48rem; font-size: .95rem; line-height: 1.6; color: var(--muted); }
/* Zawartość banerów pisana dla ciemnego tła – w nowej szacie na białej karcie */
.ui-hero .text-white { color: var(--text); }
.ui-hero .text-slate-300, .ui-hero .text-slate-200, .ui-hero .text-amber-100, .ui-hero .text-emerald-100 { color: var(--muted); }
.ui-hero .bg-white\/10, .ui-hero .bg-white\/15, .ui-hero .bg-white\/20 { background: var(--surface-2); border: 1px solid var(--border); }
.ui-hero .hover\:bg-white\/15:hover, .ui-hero .hover\:bg-white\/25:hover { background: var(--sunken); }
.ui-hero .ring-white\/20 { --tw-ring-color: var(--border-strong); }
.ui-hero .bg-amber-500\/25 { background: var(--warn-bg); border: 1px solid var(--warn-bd); color: var(--warn-fg); }
.ui-hero .bg-red-500\/30 { background: var(--over-bg); border: 1px solid var(--over-bd); color: var(--over-fg); }
.ui-hero .bg-white.text-slate-900 { border: 1px solid var(--border-strong); }
.ui-hero .text-2xl.font-extrabold, .ui-hero .text-3xl.font-extrabold { font-family: var(--font-display); font-weight: 700; font-size: 2.4rem; line-height: 1; }
.ui-hero__stat { display: block; border-radius: var(--radius-lg); background: var(--surface-2); border: 1px solid var(--border); padding: 1rem; color: var(--text); }
.ui-hero__stat b { display: block; font-family: var(--font-display); font-size: 2.4rem; font-weight: 700; line-height: 1; }
.ui-hero__stat span { font-size: .75rem; color: var(--muted); }
.ui-panel { border-radius: var(--radius-xl); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.page-head { margin-bottom: 1.5rem; border-radius: var(--radius-xl); border: 1px solid var(--border); border-top: 4px solid var(--hivis); background: var(--surface); padding: 1.25rem 1.5rem; }
.page-head h1 { font-family: var(--font-display); font-size: clamp(1.9rem, 1.6rem + 1vw, 2.5rem); font-weight: 700; letter-spacing: 0; line-height: 1; color: var(--text); }
.page-head h1 + p, .page-head h1 + .text-muted { margin-top: .25rem; }
.ui-kicker { font-family: var(--font-display); font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }

/* --- Kafelki KPI ------------------------------------------------------------- */
.kpi { padding: 1rem 1.1rem; border-radius: var(--radius-xl); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.kpi-value { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--muted); font-size: .84rem; font-weight: 600; line-height: 1.3; }

/* --- Tablica „dni bez wypadku” (element wyróżniający) ------------------------ */
.site-board { position: relative; overflow: hidden; border-radius: var(--radius-xl); color: #fff; background-color: var(--ink); border: 1px solid rgb(255 255 255 / .06); box-shadow: var(--shadow); }
.site-board::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--hivis); }
.board-digits { display: inline-flex; gap: 6px; }
.board-digit { position: relative; width: clamp(46px, 9vw, 68px); height: clamp(64px, 12vw, 92px); border-radius: 8px; overflow: hidden;
  background: linear-gradient(#f9fbfd 0 49.5%, #e9eef3 50.5% 100%); color: var(--night); box-shadow: inset 0 -3px 0 rgb(0 0 0 / .12), 0 6px 14px -8px rgb(0 0 0 / .6); }
.board-digit::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgb(14 42 71 / .18); }
.board-reel { display: flex; flex-direction: column; transition: transform 1.4s var(--ease); }
.board-reel span { display: flex; align-items: center; justify-content: center; height: clamp(64px, 12vw, 92px); font-weight: 800; font-size: clamp(2.6rem, 6.5vw, 4.2rem); line-height: 1; font-variant-numeric: tabular-nums; }
.board-label { font-weight: 700; font-size: 1.15rem; line-height: 1.2; }

/* --- Ocena ryzyka ------------------------------------------------------------- */
.risk-ok { background: var(--ok-bg); color: var(--ok-fg); }
.risk-warn { background: var(--warn-bg); color: var(--warn-fg); }
.risk-bad { background: var(--over-bg); color: var(--over-fg); }
.risk-cell { font-weight: 700; text-align: center; border-radius: var(--radius); padding: .35rem .5rem; transition: background-color .25s var(--ease), color .25s var(--ease); }

/* --- Podpis odręczny ---------------------------------------------------------- */
.sig-pad { width: 100%; height: 200px; border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); background: #fff; touch-action: none; cursor: crosshair; }

/* --- Kalendarz ---------------------------------------------------------------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-day { min-height: 98px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px; font-size: .75rem; overflow: hidden; }
.cal-day.other { opacity: .45; }
.cal-day.today { border: 2px solid rgb(var(--brand)); background: rgb(var(--brand) / .04); }
.cal-item { display: block; border-radius: 4px; padding: 1px 5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }

/* --- Pasek postępu ------------------------------------------------------------ */
.progress { height: 10px; background: var(--sunken); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: rgb(var(--brand)); border-radius: 999px; transform-origin: left; animation: progress-in .9s var(--ease) both; }
@keyframes progress-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* --- Szuflada menu na telefonie ------------------------------------------------ */
.drawer-backdrop { transition: opacity .25s var(--ease); }

/* --- Logowanie: trasa instalacji rysowana raz przy wejściu ---------------------- */
.route path { stroke-dasharray: 620; stroke-dashoffset: 620; animation: route-draw 1.8s var(--ease) .25s forwards; }
.route circle { opacity: 0; transform-box: fill-box; transform-origin: center; animation: node-in .35s var(--ease) forwards; }
.route circle:nth-of-type(1) { animation-delay: .2s; }
.route circle:nth-of-type(2) { animation-delay: .65s; }
.route circle:nth-of-type(3) { animation-delay: 1s; }
.route circle:nth-of-type(4) { animation-delay: 1.4s; }
.route circle:nth-of-type(5) { animation-delay: 1.85s; }
@keyframes route-draw { to { stroke-dashoffset: 0; } }
@keyframes node-in { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }

/* --- Menu rozwijane i tło szuflady: animacja CSS (niezależna od skryptu) ------- */
.dropdown { transform-origin: top right; animation: drop-in .16s var(--ease) both; }
@keyframes drop-in { from { opacity: 0; transform: translateY(-4px) scale(.97); } to { opacity: 1; transform: none; } }
.fade-in { animation: fade-in .25s var(--ease) both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* --- Wydruk ------------------------------------------------------------------- */
@media print {
  .no-print, header, nav, aside, .mobile-nav { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: none; }
  main { padding: 0 !important; margin: 0 !important; }
}
[x-cloak] { display: none !important; }
.is-offline .is-offline-banner { display: block !important; }

/* Ogranicz ruch – wyłączenie animacji i przejść */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   PORTAL – wygląd dotychczasowej strony appBHP (baner, przepis dnia, moduły,
   aktualności, komunikaty). Stały jasny motyw (html[data-theme-lock]).
   ========================================================================== */
body.portal { color: var(--text); background: var(--bg); }
html[data-theme-lock] { scroll-behavior: smooth; scroll-padding-top: 6rem; }
.portal-header { position: sticky; top: 0; z-index: 30; border-top: 4px solid var(--hivis); border-bottom: 1px solid var(--border); background: var(--surface); }
.portal-header .text-white { color: var(--text); }
.portal-header .text-slate-300 { color: var(--muted); }
.portal-header .portal-logo { border-color: transparent; box-shadow: none; padding: .2rem .35rem; }
.portal-logo { flex: none; display: flex; align-items: center; justify-content: center; border-radius: .75rem; border: 1px solid rgb(255 255 255 / .1); background: #fff; padding: .4rem .7rem; box-shadow: 0 6px 14px rgb(2 6 23 / .2); }
.portal-nav { border-radius: var(--radius); padding: .5rem .75rem; font-size: .875rem; font-weight: 600; color: var(--muted); transition: background-color .2s, color .2s; }
.portal-nav:hover { background: var(--sunken); color: var(--text); }
.portal-cta { white-space: nowrap; display: inline-flex; align-items: center; gap: .45rem; min-height: 40px; border-radius: var(--radius); background: rgb(var(--brand)); padding: .5rem .9rem; font-size: .85rem; font-weight: 700; color: #fff; transition: background-color .2s; }
.portal-cta:hover { background: rgb(var(--brand) / .88); }
.portal-footer { border-top: 6px solid var(--hivis); background: var(--ink); color: #E8ECF1; }

.portal-panel { position: relative; border-radius: var(--radius-xl); background: var(--surface); border: 1px solid var(--border); }
.hero-shell {
  position: relative; overflow: hidden; isolation: isolate; min-height: 405px;
  background-color: #071a33;
  background-image: linear-gradient(90deg, rgba(3, 19, 39, .28) 0%, rgba(3, 19, 39, .08) 44%, rgba(3, 19, 39, 0) 70%), url("portal-banner.webp");
  background-size: cover; background-position: center; background-repeat: no-repeat;
  border: 0; border-bottom: 6px solid var(--hivis); border-radius: var(--radius-xl);
}
.hero-shell::before { content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; background: linear-gradient(90deg, rgba(3, 19, 39, .5) 0%, rgba(3, 19, 39, .22) 38%, rgba(3, 19, 39, 0) 66%); }
.hero-shell::after { content: ""; position: absolute; inset: auto 0 0; height: 42%; z-index: 0; pointer-events: none; background: linear-gradient(180deg, transparent, rgba(2, 13, 28, .18)); }
.hero-content { position: relative; z-index: 1; animation: portal-rise .7s cubic-bezier(.2, .7, .2, 1) both; }
.hero-kicker { letter-spacing: .18em; }
.hero-scope-chip { border-radius: .5rem; padding: .375rem .75rem; font-size: .75rem; font-weight: 600; color: #fff; border: 1px solid rgb(255 255 255 / .16); background: rgba(3, 19, 39, .28); box-shadow: inset 0 1px 0 rgb(255 255 255 / .06); backdrop-filter: blur(7px); }
.portal-hero-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border-radius: var(--radius); border: 1px solid rgb(255 255 255 / .2); background: rgb(2 6 23 / .2); padding: .75rem 1.25rem; font-size: .875rem; font-weight: 600; color: #fff; backdrop-filter: blur(4px); transition: background-color .2s; }
.portal-hero-btn:hover { background: rgb(2 6 23 / .35); }
.portal-hero-btn-primary { border-color: transparent; background: rgb(var(--brand)); box-shadow: 0 10px 26px rgb(var(--brand) / .3); }
.portal-hero-btn-primary:hover { background: rgb(var(--brand) / .9); }
@media (max-width: 767px) {
  .hero-shell { min-height: 460px; background-position: 67% center; }
  .hero-shell::before { background: linear-gradient(90deg, rgba(3, 19, 39, .88) 0%, rgba(3, 19, 39, .7) 55%, rgba(3, 19, 39, .42) 100%); }
}
@keyframes portal-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.dashboard-layout { display: grid; gap: 1.4rem; align-items: start; }
.dashboard-main { min-width: 0; }
@media (min-width: 1280px) {
  .dashboard-layout { grid-template-columns: 320px minmax(0, 1fr); }
  .dashboard-sidebar { position: sticky; top: 6.5rem; max-height: calc(100vh - 7.5rem); overflow-y: auto; scrollbar-width: thin; }
}
.module-sidebar-group + .module-sidebar-group { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(226, 232, 240, .9); }
.module-sidebar-card {
  display: block; min-height: 88px; border-radius: var(--radius-lg); border: 1px solid rgba(226, 232, 240, .95); padding: .75rem;
  background: var(--surface);
  box-shadow: none;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.module-sidebar-card:hover { transform: translateY(-3px); box-shadow: 0 18px 34px rgba(15, 23, 42, .1); border-color: rgba(148, 163, 184, .65); }
.module-sidebar-card__icon {
  width: 2.6rem; height: 2.6rem; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 1rem; border: 1px solid rgb(var(--brand) / .18); color: rgb(var(--brand));
  background: rgb(var(--brand) / .06); box-shadow: inset 0 1px 0 rgb(255 255 255 / .55);
  transition: transform .2s ease, border-color .2s ease, background-color .2s ease;
}
.module-sidebar-card:hover .module-sidebar-card__icon { border-color: rgb(var(--brand) / .4); background: rgb(var(--brand) / .1); transform: scale(1.04); }
.module-sidebar-card__title { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: .9rem; line-height: 1.24rem; font-weight: 600; color: #0f172a; }
.module-sidebar-card__desc { margin-top: .28rem; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: .76rem; line-height: 1.08rem; color: #64748b; }

.portal-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: .15rem .55rem; font-size: .68rem; font-weight: 600; border: 1px solid; }
.portal-badge-blue { background: rgb(var(--brand) / .06); color: rgb(var(--brand)); border-color: rgb(var(--brand) / .25); }
.portal-badge-amber { background: #fffbeb; color: #92400e; border-color: #fcd34d; }
.portal-badge-red { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.portal-badge-slate { background: #f8fafc; color: #475569; border-color: #e2e8f0; }
.portal-chip { display: inline-flex; align-items: center; min-height: 32px; border-radius: 999px; border: 1px solid #e2e8f0; background: #fff; padding: .25rem .8rem; font-weight: 600; color: #475569; transition: all .2s; }
.portal-chip:hover { border-color: rgb(var(--brand) / .4); color: rgb(var(--brand)); }
.portal-chip.is-active { background: rgb(var(--brand)); border-color: rgb(var(--brand)); color: #fff; }
.portal-btn-ghost { display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; border-radius: .75rem; border: 1px solid #e2e8f0; background: #fff; padding: .4rem .8rem; font-size: .8rem; font-weight: 600; color: #1e293b; transition: all .2s; }
.portal-btn-ghost:hover { border-color: rgb(var(--brand) / .4); color: rgb(var(--brand)); }
.portal-tab { display: inline-flex; align-items: center; gap: .45rem; min-height: 42px; border-radius: .75rem; border: 1px solid #e2e8f0; background: #fff; padding: .5rem 1rem; font-size: .875rem; font-weight: 600; color: #1e293b; transition: all .2s; }
.portal-tab:hover, .portal-tab.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.portal-article.is-clamped { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 7; overflow: hidden; }
.portal-message { position: relative; border-radius: 1.25rem; border: 1px solid rgba(148, 163, 184, .22); padding: 1.1rem 1.1rem 1rem; overflow: hidden;
  background: radial-gradient(circle at top right, rgba(148, 163, 184, .1), transparent 34%), linear-gradient(135deg, rgba(248, 250, 252, .96), #fff 52%, rgba(241, 245, 249, .94)); }
.portal-message::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, #475569, #64748b 52%, #94a3b8); }
.portal-scroll { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.portal-article-card { flex: 0 0 auto; width: 236px; overflow: hidden; scroll-snap-align: start; border-radius: 1rem; border: 1px solid rgba(203, 213, 225, .95); background: linear-gradient(180deg, #fff, rgba(248, 250, 252, .92)); transition: box-shadow .2s, border-color .2s, transform .2s; }
.portal-article-card:hover { border-color: rgba(148, 163, 184, .6); box-shadow: 0 12px 24px rgba(15, 23, 42, .08); transform: translateY(-2px); }
.portal-article-card.is-current { border-color: rgb(var(--brand)); box-shadow: 0 0 0 2px rgb(var(--brand) / .15); }
.portal-dialog { width: min(48rem, calc(100vw - 2rem)); max-height: 85vh; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-xl); background: #fff; color: #1e293b; box-shadow: 0 30px 60px rgb(2 6 23 / .35); }
.portal-dialog::backdrop { background: rgb(2 6 23 / .65); backdrop-filter: blur(4px); }
.portal-dialog[open] { animation: portal-rise .25s ease-out; }
.portal-x { display: flex; height: 2.25rem; width: 2.25rem; flex: none; align-items: center; justify-content: center; border-radius: 999px; background: #f1f5f9; color: #475569; }
.portal-x:hover { background: #e2e8f0; }
.portal .alert { border-radius: var(--radius); }
@media (prefers-reduced-motion: reduce) {
  html[data-theme-lock] { scroll-behavior: auto; }
  .hero-content, .portal-dialog[open] { animation: none; }
  .module-sidebar-card, .module-sidebar-card:hover, .portal-article-card:hover { transform: none; }
}
.portal-article h2 { margin: 1rem 0 .4rem; font-size: 1.05rem; font-weight: 700; color: #0f172a; }
.portal-article h3, .portal-article h4 { margin: .8rem 0 .3rem; font-weight: 700; color: #0f172a; }
.portal-article p + p { margin-top: .5rem; }
.portal-article ul { list-style: disc; padding-left: 1.25rem; margin: .4rem 0; }
.portal-article ol { list-style: decimal; padding-left: 1.25rem; margin: .4rem 0; }
.portal-article a { color: rgb(var(--brand)); text-decoration: underline; }
.portal-article blockquote { border-left: 3px solid rgb(var(--brand) / .4); padding-left: .8rem; color: #475569; }
.portal-article table { border-collapse: collapse; margin: .5rem 0; }
.portal-article th, .portal-article td { border: 1px solid #e2e8f0; padding: .3rem .5rem; }

/* Katalog instrukcji ŚOI w portalu */
.soi-card { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-xl); background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); transition: box-shadow .15s, transform .15s; }
.soi-card:hover { box-shadow: 0 10px 28px rgba(15, 23, 42, .10); transform: translateY(-1px); }
.soi-card__img { display: flex; align-items: center; justify-content: center; height: 11rem; background: linear-gradient(135deg, #f1f5f9, #f8fafc); border-bottom: 1px solid rgb(226 232 240); }
.soi-card__img img { max-height: 10rem; max-width: 90%; object-fit: contain; }
.soi-card__body { padding: 1rem; flex: 1; display: flex; flex-direction: column; }
.soi-card__body > div:last-child { margin-top: auto; padding-top: .75rem; }
.ppe-photo { display: flex; align-items: center; justify-content: center; min-height: 10rem; padding: .75rem; text-align: center; border-radius: .75rem; border: 1px solid var(--border); background: linear-gradient(135deg, #f1f5f9, #f8fafc); }
.ppe-photo img { max-height: 14rem; max-width: 100%; object-fit: contain; }
.ppe-doc + .ppe-doc { border-top: 1px dashed var(--border); padding-top: .25rem; }
.public-photo { max-height: 18rem; max-width: 100%; object-fit: contain; border-radius: 1rem; border: 1px solid rgb(226 232 240); background: #f8fafc; }

/* Szybkie dodanie lokalizacji w formularzach */
.site-quick-box { background: var(--surface-2); }
[data-site-quick] summary { list-style: none; }
[data-site-quick] summary::-webkit-details-marker { display: none; }

/* Wybór położenia na mapie */
.map-picker__map { width: 100%; border-radius: 1rem; border: 1px solid var(--border); overflow: hidden; z-index: 0; position: relative; background: var(--surface-2); cursor: crosshair; }
.map-picker__results { list-style: none; margin: 0 0 .5rem; padding: .25rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--surface); max-height: 14rem; overflow: auto; }
.map-picker__results button { display: block; width: 100%; text-align: left; padding: .45rem .6rem; border-radius: .5rem; font-size: .875rem; }
.map-picker__results button:hover, .map-picker__results button:focus-visible { background: var(--surface-2); outline: none; }
.site-quick-map summary { list-style: none; }
.site-quick-map summary::-webkit-details-marker { display: none; }
/* Pole uzupełnione adresem z pinezki – krótkie podświetlenie */
@keyframes mpFilled { from { box-shadow: 0 0 0 3px rgba(22, 163, 74, .45); background-color: rgba(22, 163, 74, .08); } to { box-shadow: none; } }
.mp-filled { animation: mpFilled 1.6s ease-out; }

/* Formularze rejestrów na stronie (jak dawne moduły) */
.register-form .input, .register-form .select, .register-form .textarea { border-radius: var(--radius); padding: .7rem 1rem; }
.register-form .label { font-weight: 700; color: rgb(15 23 42); }

/* Przełącznik aktywnego projektu */
.project-switch { display: flex; align-items: center; gap: .4rem; margin-right: .25rem; }
.project-switch__label { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.project-switch__select { min-height: 36px !important; padding-top: .25rem !important; padding-bottom: .25rem !important; font-size: .85rem; width: 11rem; }
@media (min-width: 640px) { .project-switch__select { width: 14rem; } }
.project-switch--dark .project-switch__label { color: var(--muted); }
.project-switch--dark.is-active .project-switch__select { box-shadow: 0 0 0 2px rgb(var(--accent)); }
.project-switch--light .project-switch__label { color: rgb(71 85 105); }
.project-switch--light .project-switch__select { border-radius: var(--radius); }
.project-switch--light.is-active .project-switch__select { border-color: rgb(5 150 105); box-shadow: 0 0 0 2px rgba(5,150,105,.25); }
/* Na telefonie projekt wybiera się z paska strony (podstrony, listy modułów) – nagłówek zostaje czytelny */
@media (max-width: 639px) { .project-switch--dark { display: none; } }
.project-bar { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; }
.project-bar a { flex: none; }

/* ==========================================================================
   CIEMNY MOTYW – ta sama szata w ciemnych barwach (panel, strony modułów, portal po zalogowaniu).
   Włączany przełącznikiem w nagłówku (zapamiętany na urządzeniu) albo wg ustawień systemu.
   1) tokeny komponentów (.card, .btn, .input, .table, .badge, .alert, menu boczne);
   2) odpowiedniki klas Tailwind używanych na stronach modułów (tła, tekst, obramowania, znaczniki stanu).
   Działa na wszystkich stronach (także bez logowania); paleta łagodna – grafit zamiast czerni, przygaszone akcenty.
   ========================================================================== */
:root[data-theme="dark"] {
  /* Stonowany, ale barwny: grafit z nutą granatu (zamiast szarości), przygaszone akcenty marki i stanów */
  --brand-on-dark: 150 188 228;  /* niebieski Electry rozjaśniony do czytelności na ciemnym tle */
  --ink: #42739F;                /* główne przyciski, aktywne pozycje (stonowany niebieski) */
  --ink-2: #4E80AD;
  --hivis: #CFA94C;              /* żółć kamizelki przygaszona – akcenty nie rażą na ciemnym tle */
  --teal-on-dark: 120 196 186;   /* morski – dodatkowy akcent (nagłówki grup menu, podkłady) */
  --night: #18202A;
  --night-2: #1F2833;
  --bg: #1A212B;
  --surface: #222B36;
  --surface-2: #28323F;
  --sunken: #2D3846;
  --text: #DCE3EA;
  --muted: #A7B4C2;
  --border: #354253;
  --border-strong: #445366;
  --ok-bg: #1E3330; --ok-fg: #8FD6B6; --ok-bd: rgb(143 214 182 / .4);
  --warn-bg: #36301E; --warn-fg: #E6C77A; --warn-bd: rgb(230 199 122 / .4);
  --over-bg: #3A2529; --over-fg: #EBA8A6; --over-bd: rgb(235 168 166 / .45);
  --shadow: none;
  --shadow-float: 0 18px 40px -18px rgb(0 0 0 / .45);
  color-scheme: dark;
}
:root[data-theme="dark"] body, :root[data-theme="dark"] body.portal { background: var(--bg); }
:root[data-theme="dark"][data-contrast="high"] { --text: #fff; --muted: #e3e9f0; --border: #e3e9f0; --border-strong: #fff; --bg: #000; --surface: #050a10; --surface-2: #0a121c; }
:root[data-theme="dark"][data-contrast="high"] body { background: #000; }

.theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: inline-flex; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }

/* 1) Komponenty */
:root[data-theme="dark"] .site-board { background: #191C21; border: 1px solid var(--border); }
:root[data-theme="dark"] .nav-link.active, :root[data-theme="dark"] .nav-link.active svg { background: rgb(var(--brand-on-dark) / .14); color: rgb(var(--brand-on-dark)); }
:root[data-theme="dark"] .btn-primary { background: var(--ink); }
:root[data-theme="dark"] .portal-header .portal-logo, :root[data-theme="dark"] .brand-logo { background: #fff; }
:root[data-theme="dark"] .btn-secondary:hover { background: var(--sunken); }
:root[data-theme="dark"] .btn-brand, :root[data-theme="dark"] .portal-cta, :root[data-theme="dark"] .portal-hero-btn-primary { background: var(--ink); }
:root[data-theme="dark"] .badge-brand { color: rgb(var(--brand-on-dark)); border-color: rgb(var(--brand-on-dark) / .4); background: rgb(var(--brand-on-dark) / .1); }
:root[data-theme="dark"] .alert-info { background: rgb(var(--brand-on-dark) / .08); border-color: rgb(var(--brand-on-dark) / .35); }
:root[data-theme="dark"] .table a.row-link, :root[data-theme="dark"] .text-brand, :root[data-theme="dark"] .hover\:text-brand:hover { color: rgb(var(--brand-on-dark)); }
:root[data-theme="dark"] .table tbody tr:hover td { background: rgb(255 255 255 / .03); }
:root[data-theme="dark"] .input:focus, :root[data-theme="dark"] .select:focus, :root[data-theme="dark"] .textarea:focus { border-color: rgb(var(--brand-on-dark)); box-shadow: 0 0 0 4px rgb(var(--brand-on-dark) / .2); }
:root[data-theme="dark"] .sig-pad { background: #fff; }
:root[data-theme="dark"] #sidebar { background: rgb(19 28 47 / .96); border-color: var(--border); }
:root[data-theme="dark"] .board-digit { box-shadow: inset 0 -3px 0 rgb(0 0 0 / .2), 0 6px 14px -8px rgb(0 0 0 / .8); }

/* Pola formularzy ze stron modułów (klasy Tailwind bez własnego tła) */
:root[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
:root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background-color: var(--surface-2); color: var(--text); }
:root[data-theme="dark"] input::placeholder, :root[data-theme="dark"] textarea::placeholder { color: var(--muted); }

/* 2) Strony modułów – tła i obramowania */
:root[data-theme="dark"] .bg-white, :root[data-theme="dark"] .bg-white\/95, :root[data-theme="dark"] .bg-white\/90 { background-color: var(--surface); }
:root[data-theme="dark"] .bg-slate-50, :root[data-theme="dark"] .bg-slate-50\/70, :root[data-theme="dark"] .hover\:bg-slate-50:hover, :root[data-theme="dark"] .hover\:bg-white:hover { background-color: var(--surface-2); }
:root[data-theme="dark"] .bg-slate-100, :root[data-theme="dark"] .hover\:bg-slate-100:hover { background-color: var(--sunken); }
:root[data-theme="dark"] .bg-slate-900 { background-color: var(--ink); }
:root[data-theme="dark"] .bg-slate-700, :root[data-theme="dark"] .hover\:bg-slate-700:hover { background-color: var(--ink-2); }
:root[data-theme="dark"] .ui-hero .bg-white, :root[data-theme="dark"] .ui-hero .hover\:bg-slate-100:hover { background-color: var(--surface-2); color: var(--text); }
:root[data-theme="dark"] .border-slate-100, :root[data-theme="dark"] .border-slate-200, :root[data-theme="dark"] .divide-slate-100 > * + *, :root[data-theme="dark"] .divide-slate-200 > * + * { border-color: var(--border); }
:root[data-theme="dark"] .border-slate-300, :root[data-theme="dark"] .border-slate-400, :root[data-theme="dark"] .hover\:border-slate-300:hover, :root[data-theme="dark"] .hover\:border-slate-500:hover { border-color: var(--border-strong); }
:root[data-theme="dark"] .ring-slate-100, :root[data-theme="dark"] .ring-slate-200, :root[data-theme="dark"] .ring-slate-300 { --tw-ring-color: var(--border-strong); }
:root[data-theme="dark"] .focus\:border-slate-900:focus, :root[data-theme="dark"] .focus\:border-brand:focus { border-color: rgb(var(--brand-on-dark)); }
:root[data-theme="dark"] .bg-brand\/5, :root[data-theme="dark"] .hover\:bg-brand\/5:hover { background-color: rgb(var(--brand-on-dark) / .08); }
:root[data-theme="dark"] .bg-brand\/10 { background-color: rgb(var(--brand-on-dark) / .12); }
:root[data-theme="dark"] .bg-brand\/30 { background-color: rgb(var(--brand-on-dark) / .25); }
:root[data-theme="dark"] .bg-brand, :root[data-theme="dark"] .hover\:bg-brand\/90:hover { background-color: var(--ink); }
:root[data-theme="dark"] .border-brand\/20, :root[data-theme="dark"] .hover\:border-brand\/20:hover { border-color: rgb(var(--brand-on-dark) / .3); }
:root[data-theme="dark"] .ring-brand\/20 { --tw-ring-color: rgb(var(--brand-on-dark) / .3); }

/* Strony modułów – tekst */
:root[data-theme="dark"] .text-slate-900, :root[data-theme="dark"] .text-slate-800, :root[data-theme="dark"] .text-black { color: var(--text); }
:root[data-theme="dark"] .text-slate-700, :root[data-theme="dark"] .text-slate-600 { color: #C3CAD1; }
:root[data-theme="dark"] .text-slate-500, :root[data-theme="dark"] .text-slate-400 { color: var(--muted); }
:root[data-theme="dark"] .ui-hero .bg-white.text-slate-900, :root[data-theme="dark"] .ui-hero .text-slate-900 { color: var(--text); }

/* Znaczniki stanu (zielony / bursztynowy / czerwony / pomarańczowy) – przyciemnione tła, jaśniejszy tekst */
:root[data-theme="dark"] .bg-emerald-50 { background-color: rgb(110 200 160 / .17); }
:root[data-theme="dark"] .text-emerald-700, :root[data-theme="dark"] .text-emerald-800, :root[data-theme="dark"] .text-emerald-900, :root[data-theme="dark"] .text-green-700 { color: #93D3B4; }
:root[data-theme="dark"] .ring-emerald-200, :root[data-theme="dark"] .border-emerald-200, :root[data-theme="dark"] .border-emerald-300 { --tw-ring-color: rgb(16 185 129 / .4); border-color: rgb(16 185 129 / .4); }
:root[data-theme="dark"] .bg-amber-50, :root[data-theme="dark"] .bg-amber-50\/80, :root[data-theme="dark"] .bg-amber-100\/60 { background-color: rgb(225 185 90 / .17); }
:root[data-theme="dark"] .text-amber-700, :root[data-theme="dark"] .text-amber-800, :root[data-theme="dark"] .text-amber-900, :root[data-theme="dark"] .text-amber-600 { color: #E3C77A; }
:root[data-theme="dark"] .ring-amber-200, :root[data-theme="dark"] .border-amber-200, :root[data-theme="dark"] .border-amber-300 { --tw-ring-color: rgb(245 158 11 / .4); border-color: rgb(245 158 11 / .4); }
:root[data-theme="dark"] .bg-red-50 { background-color: rgb(230 120 115 / .17); }
:root[data-theme="dark"] .text-red-700, :root[data-theme="dark"] .text-red-800, :root[data-theme="dark"] .text-red-900, :root[data-theme="dark"] .text-red-600 { color: #E8A9A5; }
:root[data-theme="dark"] .ring-red-200, :root[data-theme="dark"] .border-red-200, :root[data-theme="dark"] .border-red-300 { --tw-ring-color: rgb(239 68 68 / .45); border-color: rgb(239 68 68 / .45); }
:root[data-theme="dark"] .bg-orange-50 { background-color: rgb(230 150 100 / .17); }
:root[data-theme="dark"] .text-orange-800 { color: #E8B98C; }
:root[data-theme="dark"] .ring-orange-200 { --tw-ring-color: rgb(249 115 22 / .4); }

/* Elementy portalu widoczne po zalogowaniu (portal, katalog ŚOI, aktualności) */
:root[data-theme="dark"] body.portal { color: var(--text); }
:root[data-theme="dark"] .portal-panel, :root[data-theme="dark"] .portal-dialog, :root[data-theme="dark"] .soi-card { background: var(--surface); border-color: var(--border); color: var(--text); }
:root[data-theme="dark"] .module-sidebar-card, :root[data-theme="dark"] .portal-article-card, :root[data-theme="dark"] .portal-message { background: var(--surface-2); border-color: var(--border); }
:root[data-theme="dark"] .module-sidebar-card__title, :root[data-theme="dark"] .portal-article h2, :root[data-theme="dark"] .portal-article h3, :root[data-theme="dark"] .portal-article h4 { color: var(--text); }
:root[data-theme="dark"] .module-sidebar-card__desc { color: var(--muted); }
:root[data-theme="dark"] .module-sidebar-card__icon { color: rgb(var(--brand-on-dark)); background: rgb(var(--brand-on-dark) / .1); border-color: rgb(var(--brand-on-dark) / .25); }
:root[data-theme="dark"] .portal-chip, :root[data-theme="dark"] .portal-btn-ghost, :root[data-theme="dark"] .portal-tab { background: var(--surface); border-color: var(--border); color: var(--text); }
:root[data-theme="dark"] .portal-chip.is-active, :root[data-theme="dark"] .portal-tab.is-active, :root[data-theme="dark"] .portal-tab:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
:root[data-theme="dark"] .portal-badge-slate { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
:root[data-theme="dark"] .portal-x { background: var(--sunken); color: var(--text); }
:root[data-theme="dark"] .ppe-photo, :root[data-theme="dark"] .soi-card__img, :root[data-theme="dark"] .public-photo { background: var(--surface-2); border-color: var(--border); }
:root[data-theme="dark"] .portal-article a { color: rgb(var(--brand-on-dark)); }
:root[data-theme="dark"] .project-switch--light .project-switch__label { color: var(--muted); }
:root[data-theme="dark"] .register-form .label { color: var(--text); }

/* Plac budowy – ciemny motyw: stopka zostaje „atramentowa”, a żółte/bursztynowe przyciski mają ciemny tekst */
:root[data-theme="dark"] .portal-footer { background: #191C21; border-top-color: var(--hivis); }
:root[data-theme="dark"] .portal-footer .text-slate-400 { color: #AEB6BF; }
:root[data-theme="dark"] .bg-amber-400.text-slate-900, :root[data-theme="dark"] .bg-amber-300.text-slate-900,
:root[data-theme="dark"] .bg-hivis.text-slate-900, :root[data-theme="dark"] .bg-yellow-400.text-slate-900 { color: #15191E; }
/* Zielone przyciski „Dodaj” z białym tekstem – ciemniejsza zieleń dla czytelności w obu motywach */
.bg-emerald-500.text-white { background-color: #047857; }
.bg-emerald-500.text-white:hover { background-color: #065F46; }
:root[data-theme="dark"] .portal-badge-blue { color: #9DBEDF; border-color: rgb(157 190 223 / .35); background: rgb(157 190 223 / .08); }
/* Łagodny ciemny motyw – jaskrawe przyciski bursztynowe i żółte przygaszone */
:root[data-theme="dark"] .bg-amber-400, :root[data-theme="dark"] .bg-yellow-400, :root[data-theme="dark"] .bg-hivis { background-color: var(--hivis); }
:root[data-theme="dark"] .hover\:bg-amber-300:hover { background-color: #D6B45A; }
:root[data-theme="dark"] .btn-accent, :root[data-theme="dark"] .btn-danger, :root[data-theme="dark"] .bg-accent { background-color: #A8433D; }
:root[data-theme="dark"] .btn-accent:hover, :root[data-theme="dark"] .btn-danger:hover { background-color: #B54F48; }

/* Ciemny motyw „kolorowy, ale stonowany” – barwne akcenty bez jaskrawości */
:root[data-theme="dark"] .ui-hero { background: linear-gradient(135deg, rgb(var(--brand-on-dark) / .13) 0%, rgb(var(--teal-on-dark) / .06) 45%, transparent 75%), var(--surface); }
:root[data-theme="dark"] .page-head { background: linear-gradient(135deg, rgb(var(--brand-on-dark) / .09), transparent 60%), var(--surface); }
:root[data-theme="dark"] .table th { background: rgb(var(--brand-on-dark) / .09); color: #B8CBE0; }
:root[data-theme="dark"] .nav-group { color: rgb(var(--teal-on-dark)); }
:root[data-theme="dark"] .nav-group:hover { color: #A9DED6; }
:root[data-theme="dark"] #sidebar { background-color: #1D2530; }
:root[data-theme="dark"] .topbar, :root[data-theme="dark"] .portal-header { background-color: #1F2732; }
:root[data-theme="dark"] .bg-brand\/5 { background-color: rgb(var(--brand-on-dark) / .10); }
:root[data-theme="dark"] .border-brand\/20 { border-color: rgb(var(--brand-on-dark) / .3); }
:root[data-theme="dark"] .card:hover, :root[data-theme="dark"] a.card:hover { border-color: rgb(var(--brand-on-dark) / .35); }
:root[data-theme="dark"] .ui-kicker { color: var(--hivis); }
:root[data-theme="dark"] .portal-footer { background: #151B23; }
/* Diagram Ishikawy – grafika na białym tle w obu motywach; na telefonie przewijana w poziomie */
.ishikawa-canvas { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.ishikawa-canvas svg { display: block; width: 100%; min-width: 760px; height: auto; }
.ishikawa-box[hidden] { display: none; }

/* ==========================================================================
   EDYTOR TEKSTU (jak w MS Word) – pola „richtext”: aktualności, komunikaty
   ========================================================================== */
.rte { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); overflow: visible; }
.rte:focus-within { border-color: rgb(var(--brand)); box-shadow: 0 0 0 4px rgb(var(--brand) / .15); }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: .25rem .5rem; align-items: center; padding: .4rem .5rem; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; position: sticky; top: 72px; z-index: 5; }
.rte-group { display: flex; align-items: center; gap: .125rem; padding-right: .5rem; border-right: 1px solid var(--border); }
.rte-group:last-child { border-right: 0; }
.rte-btn { min-width: 2.25rem; height: 2.25rem; display: inline-flex; align-items: center; justify-content: center; gap: 1px; border-radius: 6px; color: var(--text); font-size: .95rem; line-height: 1; padding: 0 .4rem; flex-direction: column; }
.rte-btn:hover { background: var(--sunken); }
.rte-btn:focus-visible, .rte-swatch:focus-visible, .rte-select:focus-visible { outline: 3px solid rgb(var(--brand) / .55); outline-offset: 1px; }
.rte-btn[aria-pressed="true"] { background: rgb(var(--brand) / .14); color: rgb(var(--brand)); box-shadow: inset 0 0 0 1px rgb(var(--brand) / .35); }
.rte-select { height: 2.25rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: .85rem; padding: 0 1.6rem 0 .5rem; max-width: 9.5rem; }
.rte-color .rte-a { font-weight: 800; font-size: .95rem; }
.rte-bar { display: block; width: 1.1rem; height: 4px; border-radius: 2px; border: 1px solid rgb(0 0 0 / .15); }
.rte-menu { position: relative; }
.rte-pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1.75rem); gap: .35rem; padding: .6rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-float); }
.rte-pop[hidden] { display: none; }
.rte-swatch { width: 1.75rem; height: 1.75rem; border-radius: 6px; border: 1px solid rgb(0 0 0 / .18); }
.rte-swatch:hover { transform: scale(1.08); }
.rte-none { background: linear-gradient(135deg, transparent 45%, #C8261E 46%, #C8261E 54%, transparent 55%), #fff; }
.rte-custom { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .8rem; color: var(--muted); }
.rte-custom input { width: 2.25rem; height: 1.75rem; border: 0; background: none; padding: 0; }
.rte-area { min-height: 16rem; max-height: 70vh; overflow-y: auto; padding: .9rem 1rem; color: var(--text); outline: none; font-size: 1rem; line-height: 1.6; }
.rte-area:empty::before { content: attr(aria-label); color: var(--muted); }
.rte + .help, .rte .help { margin: 0; padding: .4rem .75rem .6rem; }
/* Treść sformatowana (edytor i wyświetlanie) */
.rich-content h1, .rich-content h2 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1.15; margin: 1rem 0 .5rem; }
.rich-content h3 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; margin: .9rem 0 .4rem; }
.rich-content h4 { font-size: 1.05rem; font-weight: 700; margin: .8rem 0 .3rem; }
.rich-content p, .rich-content div { margin: 0 0 .6rem; }
.rich-content ul { list-style: disc; padding-left: 1.6rem; margin: 0 0 .6rem; }
.rich-content ol { list-style: decimal; padding-left: 1.6rem; margin: 0 0 .6rem; }
.rich-content blockquote { border-left: 4px solid var(--hivis); padding: .3rem 0 .3rem .9rem; margin: .6rem 0; color: var(--muted); font-style: italic; }
.rich-content a { color: rgb(var(--brand)); text-decoration: underline; }
.rich-content hr { border: 0; border-top: 2px solid var(--border-strong); margin: 1rem 0; }
.rich-content > :first-child { margin-top: 0; }
:root[data-theme="dark"] .rich-content a { color: rgb(var(--brand-on-dark)); }
:root[data-theme="dark"] .rich-content [style*="color: rgb(21, 25, 30)"]:not([style*="background-color: rgb(21, 25, 30)"]), :root[data-theme="dark"] .rich-content [style*="color: #15191e"], :root[data-theme="dark"] .rich-content [style*="color: #15191E"] { color: var(--text) !important; }
:root[data-theme="dark"] .rich-content [style*="color: rgb(92, 102, 112)"]:not([style*="background-color: rgb(92, 102, 112)"]), :root[data-theme="dark"] .rich-content [style*="color: #5c6670"], :root[data-theme="dark"] .rich-content [style*="color: #5C6670"] { color: #A7B4C2 !important; }
:root[data-theme="dark"] .rich-content [style*="color: rgb(200, 38, 30)"]:not([style*="background-color: rgb(200, 38, 30)"]), :root[data-theme="dark"] .rich-content [style*="color: #c8261e"], :root[data-theme="dark"] .rich-content [style*="color: #C8261E"] { color: #EBA8A6 !important; }
:root[data-theme="dark"] .rich-content [style*="color: rgb(194, 65, 12)"]:not([style*="background-color: rgb(194, 65, 12)"]), :root[data-theme="dark"] .rich-content [style*="color: #c2410c"], :root[data-theme="dark"] .rich-content [style*="color: #C2410C"] { color: #F2B48C !important; }
:root[data-theme="dark"] .rich-content [style*="color: rgb(161, 98, 7)"]:not([style*="background-color: rgb(161, 98, 7)"]), :root[data-theme="dark"] .rich-content [style*="color: #a16207"], :root[data-theme="dark"] .rich-content [style*="color: #A16207"] { color: #E6C77A !important; }
:root[data-theme="dark"] .rich-content [style*="color: rgb(27, 122, 75)"]:not([style*="background-color: rgb(27, 122, 75)"]), :root[data-theme="dark"] .rich-content [style*="color: #1b7a4b"], :root[data-theme="dark"] .rich-content [style*="color: #1B7A4B"] { color: #8FD6B6 !important; }
:root[data-theme="dark"] .rich-content [style*="color: rgb(11, 92, 173)"]:not([style*="background-color: rgb(11, 92, 173)"]), :root[data-theme="dark"] .rich-content [style*="color: #0b5cad"], :root[data-theme="dark"] .rich-content [style*="color: #0B5CAD"] { color: #96BCE4 !important; }
:root[data-theme="dark"] .rich-content [style*="color: rgb(30, 58, 138)"]:not([style*="background-color: rgb(30, 58, 138)"]), :root[data-theme="dark"] .rich-content [style*="color: #1e3a8a"], :root[data-theme="dark"] .rich-content [style*="color: #1E3A8A"] { color: #A9BCF0 !important; }
:root[data-theme="dark"] .rich-content [style*="color: rgb(109, 40, 217)"]:not([style*="background-color: rgb(109, 40, 217)"]), :root[data-theme="dark"] .rich-content [style*="color: #6d28d9"], :root[data-theme="dark"] .rich-content [style*="color: #6D28D9"] { color: #C4B5FD !important; }
:root[data-theme="dark"] .rich-content [style*="background-color: rgb(255, 243, 163)"], :root[data-theme="dark"] .rich-content [style*="background-color: #fff3a3"], :root[data-theme="dark"] .rich-content [style*="background-color: #FFF3A3"] { background-color: rgb(255 214 0 / .28) !important; }
:root[data-theme="dark"] .rich-content [style*="background-color: rgb(209, 242, 223)"], :root[data-theme="dark"] .rich-content [style*="background-color: #d1f2df"], :root[data-theme="dark"] .rich-content [style*="background-color: #D1F2DF"] { background-color: rgb(110 200 160 / .25) !important; }
:root[data-theme="dark"] .rich-content [style*="background-color: rgb(220, 235, 250)"], :root[data-theme="dark"] .rich-content [style*="background-color: #dcebfa"], :root[data-theme="dark"] .rich-content [style*="background-color: #DCEBFA"] { background-color: rgb(150 188 228 / .25) !important; }
:root[data-theme="dark"] .rich-content [style*="background-color: rgb(251, 221, 228)"], :root[data-theme="dark"] .rich-content [style*="background-color: #fbdde4"], :root[data-theme="dark"] .rich-content [style*="background-color: #FBDDE4"] { background-color: rgb(235 168 180 / .28) !important; }
:root[data-theme="dark"] .rich-content [style*="background-color: rgb(253, 227, 200)"], :root[data-theme="dark"] .rich-content [style*="background-color: #fde3c8"], :root[data-theme="dark"] .rich-content [style*="background-color: #FDE3C8"] { background-color: rgb(242 180 140 / .28) !important; }

/* ==========================================================================
   Tabele w treści sformatowanej (edytor tekstu, aktualności, komunikaty)
   ========================================================================== */
.rich-content table { width: 100%; border-collapse: collapse; margin: .25rem 0 1rem; font-size: .92rem; }
.rich-content th, .rich-content td { border: 1px solid var(--border-strong); padding: .4rem .6rem; text-align: left; vertical-align: top; }
.rich-content th { background: var(--surface-2); font-weight: 700; width: 32%; }
.rich-content tr:first-child th + th { width: auto; }

/* Przełącznik włącz / wyłącz (lista lokalizacji) */
.site-toggle { display: inline-flex; align-items: center; gap: .5rem; padding: .25rem .6rem .25rem .3rem; border-radius: 999px; border: 1px solid var(--border, #d6dbe1); background: var(--surface, #fff); font-size: .8125rem; font-weight: 700; color: var(--muted, #646D76); cursor: pointer; white-space: nowrap; }
.site-toggle__knob { position: relative; width: 2rem; height: 1.15rem; border-radius: 999px; background: #c5ccd4; transition: background .15s; flex: none; }
.site-toggle__knob::after { content: ""; position: absolute; top: .15rem; left: .15rem; width: .85rem; height: .85rem; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.site-toggle.is-on { color: #14532d; border-color: #86c9a2; background: #effaf3; }
.site-toggle.is-on .site-toggle__knob { background: #1B7A4B; }
.site-toggle.is-on .site-toggle__knob::after { transform: translateX(.85rem); }
.site-toggle:focus-visible { outline: 2px solid var(--brand, #0B5CAD); outline-offset: 2px; }
:root[data-theme="dark"] .site-toggle.is-on { color: #bfe8cf; background: rgba(27,122,75,.18); border-color: rgba(134,201,162,.45); }

/* Pole daty: ukryte natywne pole (sr-only) zostaje w obrębie pola – bez poziomego przewijania strony w tabelach */
.date-wrap { position: relative; }
