/* ==========================================================================
   Komunikator Kabo — design tokens
   Paleta marki: granat #011971 + biel. Odcienie szarości ciągnięte w stronę
   tego granatu (chłodny, niebieskawy neutral), zamiast ciepłego beżu.
   System-ui zamiast webfontów — zero ryzyka FOUT na słabszych telefonach na
   hali, szybki start offline.
   ========================================================================== */
:root {
  --bg: #f2f3f8;
  --bg-raised: #ffffff;
  --ink: #0a0f2e;
  --ink-soft: #4d5473;
  --line: #d7dae6;
  --accent: #011971;
  --accent-ink: #ffffff;
  --accent-soft: #dde2f2;
  --ok: #2f7a43;
  --ok-soft: #e1f0e4;
  --warn: #c65a1f;
  --warn-soft: #f2dfd0;
  --danger: #b3261e;
  --danger-soft: #fbe4e2;
  --focus-ring: #2f6fed;

  --radius-sm: 8px;
  --radius-md: 14px;
  --shadow: 0 1px 2px rgba(1, 25, 113, 0.04), 0 4px 16px rgba(1, 25, 113, 0.05);
  --tap-min: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0d1e;
    --bg-raised: #131735;
    --ink: #eef0fa;
    --ink-soft: #9aa1c4;
    --line: #2a2f52;
    --accent: #5470e0;
    --accent-ink: #ffffff;
    --accent-soft: #1c2350;
    --ok: #6cbf7f;
    --ok-soft: #1c3324;
    --warn: #e07a3a;
    --warn-soft: #3a2a1c;
    --danger: #e5776e;
    --danger-soft: #3a1e1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 24px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0a0d1e; --bg-raised: #131735; --ink: #eef0fa; --ink-soft: #9aa1c4;
  --line: #2a2f52; --accent: #5470e0; --accent-ink: #ffffff; --accent-soft: #1c2350;
  --ok: #6cbf7f; --ok-soft: #1c3324; --warn: #e07a3a; --warn-soft: #3a2a1c;
  --danger: #e5776e; --danger-soft: #3a1e1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 24px rgba(0, 0, 0, 0.4);
}
:root[data-theme="light"] {
  --bg: #f2f3f8; --bg-raised: #ffffff; --ink: #0a0f2e; --ink-soft: #4d5473;
  --line: #d7dae6; --accent: #011971; --accent-ink: #ffffff; --accent-soft: #dde2f2;
  --ok: #2f7a43; --ok-soft: #e1f0e4; --warn: #c65a1f; --warn-soft: #f2dfd0;
  --danger: #b3261e; --danger-soft: #fbe4e2;
  --shadow: 0 1px 2px rgba(1, 25, 113, 0.06), 0 6px 20px rgba(1, 25, 113, 0.06);
}

/* ---------- logo: jasna/ciemna wersja wg motywu ---------- */
.logo-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  .logo-light { display: none !important; }
  .logo-dark { display: block !important; }
}
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
:root[data-theme="light"] .logo-light { display: block !important; }
:root[data-theme="light"] .logo-dark { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
/* Przy "rubber band" (odbicie po przeciągnięciu poza krawędź strony na iOS)
   widać tło kanwy, czyli <html> — żaden element strony tam nie sięga. Strony
   z topbarem mają białą górę, więc i kanwa musi być biała; login jest jednolicie
   szary, więc zostaje przy --bg. */
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
html.has-shell, body.has-shell { background: var(--bg-raised); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  /* viewport-fit=cover przestaje rezerwować miejsce pod notchem/paskiem statusu
     automatycznie — bez tego treść wjeżdżała pod niego. Strony z app-shell (klasa
     has-shell) same rezerwują to miejsce przez padding-top na .topbar (żeby mógł
     pomalować ten obszar na biało) — tu dotyczy to tylko stron bez topbara (login). */
  padding-bottom: env(safe-area-inset-bottom);
}
body:not(.has-shell) { padding-top: env(safe-area-inset-top); }
h1, h2 { text-wrap: balance; }
h1 { font-size: 26px; font-weight: 700; margin: 0 0 24px; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------- formularze ---------- */
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  min-height: var(--tap-min);
  padding: 12px 14px;
  font-size: 17px;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
textarea { min-height: 140px; resize: vertical; }
input[type="checkbox"] { width: 22px; height: 22px; vertical-align: middle; margin-right: 8px; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-min);
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: var(--accent-ink);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
button:hover, .button:hover { opacity: 0.9; }
button:active, .button:active { transform: scale(0.98); }
button:disabled { background: var(--line); color: var(--ink-soft); cursor: not-allowed; opacity: 1; transform: none; }
button.danger { background: var(--danger); }
button.danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  min-height: 40px;
  padding: 8px 16px;
  font-size: 14px;
}
button.danger-ghost:hover { background: var(--danger-soft); opacity: 1; }
button.secondary, .button.secondary {
  background: var(--bg-raised);
  color: var(--ink);
  border: 1px solid var(--line);
}
button.secondary:hover, .button.secondary:hover { opacity: 1; background: var(--bg); }

.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 15px;
}
.notice {
  background: var(--ok-soft);
  color: var(--ok);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 15px;
}
.hint { color: var(--ink-soft); font-size: 14px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-neutral { background: var(--line); color: var(--ink-soft); }
.badge-fixed { min-width: 170px; justify-content: center; }
.badge-fixed-placeholder { display: inline-block; width: 170px; text-align: center; }
td .status-time { display: block; width: 160px; text-align: center; margin-top: 4px; font-size: 13px; color: var(--ink-soft); }
td .status-time.status-time-empty { width: 160px; text-align: center; }
td .ack-time { display: block; width: 170px; text-align: center; margin-top: 4px; font-size: 13px; color: var(--ink-soft); }
.meta-time { font-size: 13px; color: var(--ink-soft); }
.new-password {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin-top: 8px;
}
.new-password-value {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 8px 0;
  letter-spacing: 0.02em;
  user-select: all;
}

fieldset { border: 1px solid var(--line); background: var(--bg); border-radius: var(--radius-md); padding: 6px 14px 14px; margin: 16px 0; }
legend { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); padding: 0 6px; }
fieldset label { display: flex; align-items: center; font-weight: 500; margin: 10px 0; }
#dept-picker.disabled { opacity: 0.4; pointer-events: none; }
.checkbox-row {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
}
.checkbox-row:hover { background: var(--bg-raised); }
.checkbox-row-standalone { margin: 4px 0 0; font-weight: 600; }
.message-form button[type="submit"] { margin-top: 20px; }

/* ---------- logowanie ---------- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 340px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.login-form h1 { text-align: center; margin-bottom: 8px; }
.login-logo { display: block; width: 200px; height: auto; aspect-ratio: 1 / 1; margin: 0 auto 16px; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.login-form button { margin-top: 18px; }
.password-field { position: relative; display: flex; }
.password-field input { flex: 1; padding-right: 44px; }
.password-field button {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  margin-top: 0;
  width: 40px;
  min-height: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink-soft);
  border: none;
  cursor: pointer;
}
.password-field button:hover { color: var(--ink); }

/* ---------- layout ogólny ---------- */
.admin-page { max-width: 720px; margin: 0 auto; padding: 32px 20px 48px; }
.admin-page-wide { max-width: 1100px; margin: 0 auto; padding: 32px 20px 48px; }

/* ---------- sidebar (Slack-style) ---------- */
:root { --sidebar-w: 240px; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: var(--sidebar-w);
  background: var(--bg-raised);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}
.sidebar-header { padding: 20px 16px 8px; padding-top: calc(20px + env(safe-area-inset-top)); }
.sidebar-header > a { display: block; }
.new-message-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  min-height: 42px;
  padding: 12px 14px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}
/* -1px koryguje optyczny środek: sam plus w SVG jest idealnie wyśrodkowany,
   ale litery bez dolnych wydłużeń (jak "N") mają wizualny środek wyżej niż
   geometryczny środek linii tekstu */
.new-message-btn svg { vertical-align: middle; flex-shrink: 0; transform: translateY(-1px); }
.new-message-btn.active { opacity: 0.85; }
/* aspect-ratio rezerwuje miejsce, zanim obrazek się wczyta — bez tego logo
   "mrugało" przy przeładowaniu strony (np. po odświeżeniu pociągnięciem) */
.sidebar-logo { display: block; width: 100%; max-width: 140px; height: auto; aspect-ratio: 1 / 1; margin: 0 auto; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px; flex: 1; overflow-y: auto; }
.sidebar-nav a {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar-nav a:hover { background: var(--bg); }
.sidebar-nav a.active { color: var(--accent); background: var(--accent-soft); }
.sidebar-nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-nav a.has-unread { color: var(--ink); font-weight: 700; }
.sidebar-nav a { justify-content: flex-start; }
.sidebar-nav a .nav-badge { margin-left: auto; }
.nav-emoji { font-size: 15px; line-height: 1; }
.sidebar-section {
  display: block;
  padding: 14px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}
.sidebar-section:first-child { padding-top: 4px; }
/* link do /install ma sens tylko dopóki user nie zainstalował apki na ekran główny */
@media (display-mode: standalone) {
  .sidebar-nav a.install-link { display: none; }
}
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.sidebar-footer {
  padding: 14px 16px;
  /* jedyny odstęp od dołu to obszar kreski gestu home — bez dodatkowego zapasu,
     żeby stopka nie odstawała od krawędzi bardziej, niż wymaga tego system */
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
/* W karcie przeglądarki stopka stykała się z dolnym paskiem Safari — tam dokładamy
   2 px. W zainstalowanej aplikacji tego paska nie ma, więc zostaje przy krawędzi. */
@media (display-mode: browser) {
  .sidebar-footer { padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
}
/* w zainstalowanej apce user + Wyloguj dostają odrobinę więcej powietrza nad
   kreską gestu home — w karcie przeglądarki zostaje bez zmian */
@media (display-mode: standalone) {
  .sidebar-footer { padding-bottom: env(safe-area-inset-bottom); }
}
.sidebar-user { flex: 1; font-weight: 600; font-size: 14px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer button { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.sidebar-footer .icon-btn {
  flex-shrink: 0;
  min-height: 40px;
  width: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.sidebar-footer .icon-btn:hover { background: var(--bg); opacity: 1; }
.sidebar-footer .icon-btn:disabled { background: transparent; border-color: var(--line); color: var(--line); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 46, 0.4);
  z-index: 30;
}

/* szare tło treści siedzi tutaj, a nie na <body> — <body> i <html> muszą zostać
   białe, żeby obszar odsłaniany przy przeciągnięciu (rubber band) na iOS był
   biały, tak jak topbar tuż pod nim */
.app-content { flex: 1; min-width: 0; background: var(--bg); }

.app-scroll-wrap { position: relative; }
/* wskaźnik własnego odświeżania — leży pod obszarem treści i odsłania się,
   gdy pociągnięcie przesunie treść w dół */
.pull-indicator {
  position: absolute;
  top: 0; left: 0; right: 0;
  /* środek wskaźnika ~38 px pod paskiem — tak jak zmierzone na nagraniu */
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  color: var(--accent);
}
/* Wiatraczek jak w natywnym iOS: w trakcie ciągnięcia segmenty zapalają się po
   kolei (pull-refresh.js), a po puszczeniu palca całość kręci się płynnie.
   Wyciszony kolor (opacity na całości) daje ten miękki szary odcień, który
   natywny wskaźnik ma na jasnym tle. */
/* neutralna szarość zmierzona z nagrania (najciemniejsze ramię ≈ #6f6f6f) */
.pull-spinner { color: #6f7073; }
@media (prefers-color-scheme: dark) { .pull-spinner { color: #98989d; } }
:root[data-theme="dark"] .pull-spinner { color: #98989d; }
:root[data-theme="light"] .pull-spinner { color: #6f7073; }
.pull-spinner line { opacity: 0.16; }
.pull-indicator.spinning .pull-spinner { animation: pull-spin 1s linear infinite; }
/* łagodny ogon — na nagraniu ramiona różnią się subtelnie, bez ostrego kontrastu */
.pull-indicator.spinning line:nth-child(1) { opacity: 1; }
.pull-indicator.spinning line:nth-child(2) { opacity: 0.88; }
.pull-indicator.spinning line:nth-child(3) { opacity: 0.76; }
.pull-indicator.spinning line:nth-child(4) { opacity: 0.64; }
.pull-indicator.spinning line:nth-child(5) { opacity: 0.52; }
.pull-indicator.spinning line:nth-child(6) { opacity: 0.42; }
.pull-indicator.spinning line:nth-child(7) { opacity: 0.33; }
.pull-indicator.spinning line:nth-child(8) { opacity: 0.25; }
@keyframes pull-spin { to { transform: rotate(360deg); } }

/* Na telefonie przewija się wyłącznie obszar treści, a nie cały dokument —
   dzięki temu górny pasek stoi nieruchomo jak w natywnej aplikacji. Kosztem
   tego znika systemowe odświeżanie pociągnięciem, więc zastępuje je własne
   (pull-refresh.js). Na szerszych ekranach topbara nie ma, więc zostaje
   zwykłe przewijanie dokumentu. */
@media (max-width: 767px) {
  html.has-shell, body.has-shell { height: 100%; overflow: hidden; }
  body.has-shell { padding-bottom: 0; }
  /* Biała kanwa (patrz reguła przy html.has-shell) była potrzebna, dopóki przewijał
     się cały dokument i odbijał u góry. Tutaj przewija się już tylko .app-scroll,
     więc odbicia nie ma — a biel prześwitywała u dołu, pod paskiem gestu home
     i za paskiem adresu w Safari. Szara kanwa znika w tle treści, tak jak na
     ekranie logowania. Obszar pod zegarkiem nadal maluje .topbar swoim tłem. */
  html.has-shell, body.has-shell { background: var(--bg); }
  /* iOS domalowuje pas pod widocznym obszarem (u nas 62 px) samym kolorem tła
     strony — żaden element pozycjonowany na stałe tam nie sięga, a gradienty i
     obrazy tła nie są tam przenoszone (sprawdzone). Przy zamkniętym menu kolor
     treści sprawia, że pas jest niewidoczny; przy otwartym przechodzi na biel
     menu, bo to ono przykuwa wzrok. */
  body.has-shell.menu-open { background: var(--bg-raised); }
  /* inset: 0 zamiast height: 100% — przy viewport-fit=cover wysokość 100% potrafi
     na iOS pominąć pas gestu home, przez co u samego dołu prześwitywała kanwa.
     Pozycja stała przykleja powłokę dokładnie do krawędzi ekranu. */
  .app-shell { position: fixed; inset: 0; height: auto; min-height: 0; }
  .app-content { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  .app-scroll-wrap { flex: 1; min-height: 0; display: flex; }
  .app-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    /* bez tego iOS dokłada własne odbicie do naszego przesunięcia */
    overscroll-behavior-y: none;
    background: var(--bg);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

.topbar {
  /* pasek stoi poza obszarem przewijania (patrz .app-scroll niżej), więc trzyma
     się w miejscu tak jak w natywnej aplikacji — także przy szarpnięciu palcem */
  position: relative;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  /* iOS w trybie black-translucent nie maluje paska statusu żadnym kolorem —
     pokazuje to, co faktycznie jest wyrenderowane pod nim. Białe tło .topbar
     sięga teraz aż pod notch/zegarek, zamiast zostawiać tam szare tło strony. */
  padding-top: env(safe-area-inset-top);
}
.topbar-row {
  position: relative;
  display: flex;
  align-items: center;
  padding: 12px 16px;
}
.hamburger {
  min-height: 40px;
  width: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink);
  border: none;
  z-index: 1;
}
.topbar-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  height: 52px;
  width: auto;
  aspect-ratio: 1 / 1; /* patrz .sidebar-logo — rezerwacja miejsca przed wczytaniem */
}

@media (min-width: 768px) {
  .sidebar { transform: none; }
  .sidebar-overlay { display: none !important; }
  .app-content { margin-left: var(--sidebar-w); }
  .topbar { display: none; }
}

@media (max-width: 767px) {
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .app-shell.sidebar-open .sidebar-overlay { display: block; }
}

/* ---------- tabele: karty na mobile, tabela na szerszym ekranie ---------- */
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
thead { display: none; }
tbody { display: flex; flex-direction: column; gap: 10px; }
tr {
  display: block;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: background-color 0.15s ease;
}
td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border: none; font-size: 15px; }
td:empty { display: none; }
td::before {
  content: attr(data-label);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13px;
}
.row-menu { position: relative; display: inline-block; }
.row-menu summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  cursor: pointer;
}
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu summary:hover { background: var(--bg); }
.row-menu[open] summary { background: var(--accent-soft); color: var(--accent); }
.row-menu-list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  padding: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}
.row-menu-list form { width: 100%; }
.row-menu-list button {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  justify-content: flex-start;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  font-size: 14px;
  border-radius: var(--radius-sm);
}
.row-menu-list button:hover { background: var(--bg); opacity: 1; }
.row-menu-list button.row-menu-danger { color: var(--danger); }
.row-menu-list button.row-menu-danger:hover { background: var(--danger-soft); }

@media (min-width: 720px) {
  .table-scroll { overflow-x: auto; }
  .table-scroll table { width: auto; min-width: 100%; }
  table {
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    overflow: hidden;
    background: var(--bg-raised);
  }
  thead { display: table-header-group; }
  tbody { display: table-row-group; }
  tr { display: table-row; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0; box-shadow: none; }
  tbody tr:last-child { border-bottom: none; }
  td { display: table-cell; padding: 12px 10px; }
  td::before { content: none; }
  th { text-align: left; padding: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); background: var(--accent-soft); border-bottom: 2px solid var(--line); }
  th.th-center { text-align: center; }
  td.td-center { text-align: center; }
  td.td-center form { display: inline-block; }
  .row-actions { flex-direction: row; justify-content: center; }
  .row-actions button { width: auto; }
  tbody tr:hover { background: var(--bg); }
  th.sortable-col { cursor: pointer; user-select: none; }
  th.sortable-col:hover { background: var(--accent-soft); filter: brightness(0.96); }
  th.sortable-col::after { content: "⇅"; opacity: 0.4; margin-left: 4px; font-size: 10px; }
  th.sortable-col[data-sort-dir="asc"]::after { content: "↑"; opacity: 1; }
  th.sortable-col[data-sort-dir="desc"]::after { content: "↓"; opacity: 1; }
}

/* ---------- nagłówek strony z akcją ---------- */
.add-user-btn { min-height: 44px; padding: 10px 18px; font-size: 15px; margin-bottom: 20px; }

/* ---------- modal (dialog) ---------- */
dialog.modal {
  width: min(560px, calc(100vw - 32px));
  border: none;
  border-radius: var(--radius-md);
  padding: 24px;
  background: var(--bg-raised);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(10, 15, 46, 0.5); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-header h2 { margin: 0; }
.modal-close {
  min-height: 32px;
  width: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink-soft);
  border: none;
  font-size: 16px;
}
dialog.modal .user-form { margin: 0; padding: 0; border: none; box-shadow: none; flex-direction: column; align-items: stretch; }
dialog.modal .user-form .field { min-width: 0; }
dialog.modal .user-form button { margin-top: 8px; }
.password-generate-field { display: flex; gap: 8px; }
.password-generate-field input { flex: 1; min-width: 0; }
.generate-password-btn { flex-shrink: 0; min-height: 48px; padding: 0 14px; font-size: 14px; white-space: nowrap; margin-top: 0 !important; }

/* ---------- pasek filtrów (kompaktowy toolbar) ---------- */
.filter-bar {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 24px;
  padding: 0;
  background: none;
  border: none;
}
.filter-bar select, .filter-bar input {
  width: auto;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 14px;
  margin: 0;
}
.filter-bar select {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-bar button { min-height: 40px; padding: 8px 16px; font-size: 14px; margin: 0; }
.filter-bar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 140px;
  padding: 0 10px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
}
.filter-bar-search input { flex: 1; border: none; padding: 8px 0; min-height: 38px; }
.filter-bar-search input:focus-visible { outline: none; }
.filter-bar-clear { font-size: 14px; font-weight: 600; color: var(--ink-soft); text-decoration: underline; padding: 8px 4px; }

/* ---------- formularze inline (dodawanie działu/usera) ---------- */
.inline-form, .user-form {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin: 0 0 24px;
  padding: 20px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}
.inline-form .field, .user-form .field { display: flex; flex-direction: column; flex: 1; min-width: 160px; }
.inline-form .field label, .user-form .field label { margin: 0 0 6px; }
.inline-form input, .inline-form select { width: auto; margin: 0; }
.user-form input, .user-form select { width: auto; margin: 0; }
.inline-form button, .user-form button { flex-shrink: 0; }

/* ---------- skrzynka ---------- */
.inbox-list { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 10px; }
.inbox-item {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-left: 8px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.inbox-item:hover { box-shadow: 0 2px 4px rgba(1, 25, 113, 0.06), 0 8px 24px rgba(1, 25, 113, 0.08); transform: translateY(-1px); }
.inbox-item.unread { border-left-color: var(--accent); }
.inbox-item.pending-ack { border-left-color: var(--warn); }
.inbox-item a { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; text-decoration: none; color: var(--ink); min-height: var(--tap-min); }
.inbox-item strong { font-size: 16px; font-weight: 700; }
.inbox-item .status { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; min-width: 210px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); white-space: nowrap; }
.inbox-item.unread .status { color: var(--accent); }
.inbox-item.pending-ack .status { color: var(--warn); font-weight: 800; }
.status-icon { flex-shrink: 0; }

.settings-card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.settings-card h2 { margin-top: 0; }
.settings-card button { margin-top: 8px; }
.password-form button[type="submit"] { margin-top: 18px; }
.theme-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.theme-switch-label { font-weight: 600; font-size: 15px; }
.theme-switch {
  position: relative;
  width: 48px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  flex-shrink: 0;
  min-height: 0;
  transition: background-color 0.15s ease;
}
.theme-switch.on { background: var(--accent); }
.theme-switch:disabled { opacity: 0.5; cursor: not-allowed; }
.theme-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.theme-switch.on .theme-switch-knob { transform: translateX(20px); }
.theme-system-check { display: flex; align-items: center; font-weight: 500; font-size: 14px; color: var(--ink-soft); margin-top: 10px; }

.push-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.push-status-on { background: var(--ok-soft); color: var(--ok); }
.push-status-off { background: var(--line); color: var(--ink-soft); }
.push-status-denied, .push-status-unsupported { background: var(--danger-soft); color: var(--danger); }

.message-body {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  font-size: 18px;
  line-height: 1.6;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.ack-confirmed { color: var(--ok); font-weight: 700; }
#ack-form { position: sticky; bottom: 0; background: var(--bg); padding-top: 8px; }
#ack-form label { display: flex; align-items: center; font-weight: 500; }

/* ---------- status komunikatu (nadawca) ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.stats span {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- baner z prośbą o zgodę na push ---------- */
.push-prompt-banner[hidden] { display: none; }
.push-prompt-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 16px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
}
.push-prompt-actions { display: flex; gap: 8px; flex-shrink: 0; }
.push-prompt-actions button, .push-prompt-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
  min-height: auto;
  padding: 8px 16px;
  font-size: 14px;
  white-space: nowrap;
  font-weight: 600;
  font-family: inherit;
  color: var(--accent-ink);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
}
.push-prompt-actions a.secondary, .push-prompt-actions button.secondary {
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--line);
}

/* ---------- instrukcja instalacji ---------- */
.admin-page section { margin: 24px 0; padding: 18px; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-md); }
.admin-page ol { padding-left: 22px; }
.admin-page li { margin-bottom: 6px; }
