/* Motywy (jasny i ciemny) oraz wygląd elementów aplikacji SRiP.
   Kolory są zmiennymi CSS. Klasy pomocnicze w app.css korzystają z tych zmiennych,
   więc ciemny motyw tylko podmienia ich wartości - bez nadpisywania każdej klasy osobno. */

/* ===== Kolory: jasny motyw (domyślny) ===== */

:root {
  /* Kolory PCRP */
  --pcrp-navy: #3546a0;
  --pcrp-orange: #e8582f;
  --pcrp-green: #4f9e3f;

  /* Tło strony i powierzchnie */
  --page: #f3f5f9;
  --surface: #ffffff;

  /* Przyciski i elementy wypełnione */
  --primary: #3546a0;
  --primary-hover: #2b3a88;
  --ink: #1c2433;
  --ink-hover: #2a3446;
  --danger-solid: #b91c1c;
  --danger-solid-hover: #991b1b;
  --warn-solid: #b45309;
  --warn-solid-hover: #92400e;
  --accent: var(--pcrp-orange);
  --focus-ring: rgba(53, 70, 160, 0.28);

  /* Pasek boczny - granatowy w obu motywach */
  --sidebar-bg: #1d2850;
  --sidebar-border: #1d2850;
  --sidebar-text: #e3e8f7;
  --sidebar-muted: #9ba7cc;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(255, 255, 255, 0.13);

  --card-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --popup-shadow: 0 16px 40px -12px rgba(16, 24, 40, 0.25);

  /* Skala szarości (używana przez klasy text-slate-*, bg-slate-*, border-slate-*) */
  --slate-50: #f7f8fb;
  --slate-100: #eef1f6;
  --slate-200: #e1e5ee;
  --slate-300: #c9d0dd;
  --slate-400: #929cb0;
  --slate-500: #636e85;
  --slate-600: #4a5468;
  --slate-700: #353e51;
  --slate-800: #232b3b;
  --slate-900: #151b28;

  /* Niebieski = granat PCRP */
  --blue-50: #eef1fb;
  --blue-100: #dfe4f7;
  --blue-200: #c5cdef;
  --blue-600: #4054b2;
  --blue-700: #3546a0;
  --blue-800: #2b3a88;
  --blue-900: #22306f;

  /* Kolory stanów: zielony = gotowe, bursztynowy = ostrzeżenie, czerwony = problem */
  --emerald-50: #ecfdf5;
  --emerald-200: #a7f3d0;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;
  --emerald-900: #064e3b;
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --amber-800: #92400e;
  --amber-900: #78350f;
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-200: #fecaca;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --red-800: #991b1b;
  --red-900: #7f1d1d;
  --red-950: #450a0a;
}

/* ===== Kolory: ciemny motyw ===== */

html[data-theme='dark'] {
  color-scheme: dark;

  --page: #0e121a;
  --surface: #161b25;

  --primary: #4c60c8;
  --primary-hover: #5b6fd6;
  --ink: #2a3347;
  --ink-hover: #343e55;
  --danger-solid: #c2343f;
  --danger-solid-hover: #d0444f;
  --warn-solid: #b8650f;
  --warn-solid-hover: #c97418;
  --focus-ring: rgba(122, 141, 240, 0.35);

  --sidebar-bg: #121722;
  --sidebar-border: #232a38;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(122, 141, 240, 0.16);

  --card-shadow: none;
  --popup-shadow: 0 18px 44px -12px rgba(0, 0, 0, 0.7);

  /* Skala odwrócona: "jasne" tła stają się ciemne, "ciemny" tekst staje się jasny */
  --slate-50: #131822;
  --slate-100: #1d2430;
  --slate-200: #283040;
  --slate-300: #364053;
  --slate-400: #6f7b91;
  --slate-500: #8b96aa;
  --slate-600: #a9b2c3;
  --slate-700: #c3cad7;
  --slate-800: #dde2ea;
  --slate-900: #eef1f6;

  --blue-50: #172240;
  --blue-100: #1e2c52;
  --blue-200: #2c3d6e;
  --blue-600: #8ea2ff;
  --blue-700: #a3b3ff;
  --blue-800: #bcc8ff;
  --blue-900: #d3dcff;

  --emerald-50: #10261f;
  --emerald-200: #1f4a3b;
  --emerald-600: #4fd1a0;
  --emerald-700: #63d9ab;
  --emerald-800: #86e3bf;
  --emerald-900: #a8edd2;

  --amber-50: #2a2112;
  --amber-100: #3a2d15;
  --amber-200: #5a4521;
  --amber-600: #f0b450;
  --amber-700: #f3c06a;
  --amber-800: #f6cd88;
  --amber-900: #f9dba8;

  --red-50: #2c1519;
  --red-100: #3b1a20;
  --red-200: #5e2a33;
  --red-600: #ff8a94;
  --red-700: #ff9da5;
  --red-800: #ffb3b9;
  --red-900: #ffc9cd;
  --red-950: #ffe0e2;
}

/* ===== Podstawa ===== */

html {
  min-height: 100%;
  background-color: var(--page);
  color: var(--slate-900);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  background-color: var(--page);
  color: var(--slate-900);
}

h1,
h2,
h3,
.font-display {
  letter-spacing: -0.015em;
}

input,
select,
textarea {
  background-color: var(--surface);
  border-color: var(--slate-300);
}

input::placeholder,
textarea::placeholder {
  color: var(--slate-400);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Karty: delikatny cień tylko w jasnym motywie */
.rounded-xl.border,
.rounded-2xl.border {
  box-shadow: var(--card-shadow);
}

/* ===== Znaczek SRiP ===== */

.brand-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--pcrp-navy);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

html[data-theme='dark'] .brand-badge {
  background: #2c3a7a;
}

.brand-logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
}

/* ===== Przyciski ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--slate-200);
  color: var(--slate-700);
}

.btn-secondary:hover {
  background: var(--slate-100);
}

.btn-icon {
  width: 40px;
  padding: 0;
}

.btn-sm {
  min-height: 38px;
  padding: 6px 10px;
  font-size: 12px;
}

.account-button {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  background: var(--surface);
  color: var(--slate-700);
  font-size: 12px;
  white-space: nowrap;
}

.account-button:hover {
  background: var(--slate-100);
}

/* ===== Ekran logowania ===== */

.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--page);
}

.auth-layout {
  width: 100%;
  max-width: 940px;
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.auth-aside {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 36px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 4px solid var(--accent);
}

.auth-aside h2 {
  margin-top: 28px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  color: #fff;
}

.auth-aside-lead {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--sidebar-muted);
}

.auth-aside ul {
  display: grid;
  gap: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.auth-aside li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.auth-aside li svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent);
}

.auth-aside-footer {
  font-size: 12px;
  color: var(--sidebar-muted);
}

@media (min-width: 860px) {
  .auth-layout {
    grid-template-columns: 1fr 1fr;
  }

  .auth-aside {
    display: flex;
  }

  .auth-layout .auth-card {
    padding: 40px;
  }

  /* Logo jest już w lewym panelu */
  .auth-layout .auth-brand-name img {
    display: none;
  }
}

.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 28px;
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.auth-layout .auth-card {
  max-width: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.auth-brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-brand-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
}

.auth-brand-name small {
  display: block;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--slate-500);
}

.auth-brand-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-card h1 {
  margin-bottom: 8px;
  font-size: 24px;
  font-weight: 700;
}

.auth-lead,
.auth-help {
  font-size: 13px;
  line-height: 1.6;
  color: var(--slate-500);
}

.auth-help {
  margin-top: 22px;
}

.auth-form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.auth-field label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-700);
}

.auth-field input,
.gps-fields input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  font-size: 14px;
}

.auth-primary {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.auth-primary:hover {
  background: var(--primary-hover);
}

.auth-primary:disabled {
  opacity: 0.6;
}

.auth-error {
  padding: 12px;
  border: 1px solid var(--red-200);
  border-radius: 8px;
  background: var(--red-50);
  color: var(--red-700);
  font-size: 13px;
  line-height: 1.5;
}

.auth-invitation {
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: var(--slate-100);
  font-size: 13px;
  line-height: 1.6;
}

.pwa-note {
  margin-top: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--slate-600);
}

.pwa-warning {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--amber-50);
  color: var(--amber-700);
  font-size: 13px;
  line-height: 1.5;
}

.gps-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.gps-fields label {
  font-size: 12px;
  color: var(--slate-600);
}

.gps-help {
  grid-column: 1 / -1;
  font-size: 12px;
  line-height: 1.6;
  color: var(--slate-500);
}

@media (max-width: 520px) {
  .auth-page {
    padding: 12px;
  }

  .auth-card {
    padding: 22px;
  }

  .gps-fields {
    grid-template-columns: 1fr;
  }
}

/* ===== Ekrany komunikatów: ładowanie, brak szkoleń, błąd ===== */

.state-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--slate-500);
}

.state-loading .brand-logo {
  width: 44px;
  height: 44px;
}

.state-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--slate-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.state-card {
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  border-top: 4px solid var(--primary);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
  padding: 22px 28px 28px;
  text-align: center;
}

.state-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 26px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--slate-700);
}

.state-brand .brand-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--blue-50);
  color: var(--primary);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--blue-50) 45%, transparent);
}

.state-icon.is-danger {
  background: var(--red-50);
  color: var(--red-700);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--red-50) 45%, transparent);
}

.state-icon svg {
  width: 28px;
  height: 28px;
}

html[data-theme='dark'] .state-icon:not(.is-danger) {
  color: var(--blue-700);
}

.state-card h1 {
  font-size: 21px;
  font-weight: 700;
  color: var(--slate-900);
}

.state-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--slate-700);
}

.state-hint {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--slate-500);
}

.state-actions {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.state-actions .btn {
  width: 100%;
  min-height: 44px;
  font-size: 14px;
}

/* ===== Układ panelu administratora ===== */

.app-shell {
  min-height: 100vh;
  display: flex;
  background: var(--page);
}

.sidebar {
  display: none;
}

.sidebar,
.sidebar-drawer {
  flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
}

@media (min-width: 1024px) {
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 15.5rem;
    z-index: 30;
  }

  .app-main {
    padding-left: 15.5rem;
  }
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-drawer {
  position: relative;
  z-index: 10;
  display: flex;
  width: 17rem;
  max-width: 85vw;
  height: 100%;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
}

.sidebar-brand-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--sidebar-muted);
}

.sidebar-close {
  margin-left: auto;
  padding: 8px;
  border-radius: 8px;
  color: var(--sidebar-muted);
}

.sidebar-close:hover {
  background: var(--sidebar-hover);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 12px;
}

.sidebar-section-label {
  margin: 16px 10px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  margin-bottom: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
}

.sidebar-link.is-active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar-link.is-active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.sidebar-link-label {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.sidebar-link svg {
  width: 17px;
  height: 17px;
  opacity: 0.85;
}

.sidebar-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
}

.sidebar-count.is-alert {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px 12px;
}

.sidebar-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.sidebar-account-text {
  min-width: 0;
}

.sidebar-account-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-account-phone {
  margin-top: 1px;
  font-size: 11px;
  color: var(--sidebar-muted);
}

/* ===== Nagłówek strony ===== */

.page-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--slate-200);
  background: var(--surface);
}

.page-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.page-header-eyebrow {
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-500);
}

.page-header h1 {
  overflow: hidden;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--slate-900);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Przycisk menu tylko na mniejszych ekranach (na komputerze menu jest stale widoczne) */
@media (min-width: 1024px) {
  .page-header-menu {
    display: none;
  }
}

@media (max-width: 640px) {
  .page-header {
    padding: 10px 14px;
  }

  .page-header-export {
    display: none;
  }

  .page-header h1 {
    font-size: 17px;
  }

  .page-header-actions .btn-label {
    display: none;
  }

  .page-header-actions .btn {
    padding: 8px 10px;
  }
}

/* ===== Przełącznik motywu ===== */

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  background: var(--surface);
  color: var(--slate-600);
}

.theme-toggle-icon:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}

.theme-toggle-icon svg {
  width: 17px;
  height: 17px;
}

/* ===== Komunikat o sesji ===== */

.session-notice {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 39;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 560px;
  padding: 10px 14px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  background: var(--surface);
  color: var(--slate-700);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: var(--popup-shadow);
}

.session-notice-btn {
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.session-notice-btn:hover {
  background: var(--primary-hover);
}

@media (max-width: 640px) {
  .session-notice {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ===== Lista rozwijana (CustomSelect) ===== */

.kp-select {
  position: relative;
  display: inline-block;
  min-width: 180px;
}

.kp-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--surface);
  color: var(--slate-800);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}

.kp-select-trigger:hover {
  border-color: var(--slate-400);
}

.kp-select-trigger.is-open,
.kp-select-trigger:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.kp-select-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-select-chevron {
  flex-shrink: 0;
  color: var(--slate-500);
  transition: transform 0.15s ease;
}

.kp-select-chevron.is-open {
  transform: rotate(180deg);
}

.kp-select-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  max-height: 260px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--popup-shadow);
}

.kp-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--slate-700);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
}

.kp-select-option:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}

.kp-select-option.is-selected {
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 700;
}

/* ===== Wybór zakresu dat (DateRangePicker) ===== */

.kp-date-panel {
  /* Od pierwszej chwili poza układem strony - inaczej w wyśrodkowanym oknie
     okienko na moment "rozpychało" okno i lądowało w złym miejscu. */
  position: fixed;
  z-index: 9999;
  padding: 12px;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--popup-shadow);
}

.kp-date-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-900);
}

.kp-date-head button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  color: var(--slate-600);
}

.kp-date-head button:hover {
  background: var(--slate-100);
}

.kp-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.kp-date-weekday {
  padding: 4px 0;
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  color: var(--slate-400);
}

.kp-date-day {
  height: 34px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-800);
}

.kp-date-day:hover {
  background: var(--slate-100);
}

.kp-date-day.is-other {
  color: var(--slate-400);
}

.kp-date-day.is-today {
  box-shadow: inset 0 0 0 1px var(--primary);
}

.kp-date-day.is-in-range {
  border-radius: 0;
  background: var(--blue-50);
  color: var(--blue-800);
}

.kp-date-day.is-selected {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.kp-date-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 26px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--slate-500);
}

.kp-date-clear {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--red-700);
}

.kp-date-clear:hover {
  background: var(--red-50);
}

/* Trzy skróty w jednym równym wierszu */
.kp-date-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--slate-200);
}

.kp-date-actions button {
  padding: 6px 4px;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--slate-700);
  white-space: nowrap;
}

.kp-date-actions button:hover {
  background: var(--slate-100);
}

/* ===== Pasek filtrów listy szkoleń i archiwum ===== */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-bar-label {
  margin-right: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-500);
}

.filter-bar-end {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.filter-clear {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-600);
}

.filter-clear:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}

/* ===== Panele ustawień i powiadomień ===== */

.notification-panel {
  padding: 16px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
  line-height: 1.6;
}

.sms-code {
  font: 700 25px var(--font-mono);
  letter-spacing: 5px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.panel-status {
  margin-top: 10px;
  white-space: pre-wrap;
}

.role-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.role-tabs button[aria-pressed='true'] {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.settings-page {
  display: grid;
  gap: 16px;
  max-width: 720px;
}

.settings-card {
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.settings-card .account-button {
  justify-self: start;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Przełączniki (suwaki) zgód i ustawień */
.kp-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  padding: 2px;
  border-radius: 999px;
  background: var(--slate-300);
  transition: background-color 0.15s ease;
}

.kp-switch.is-on {
  background: var(--primary);
}

.kp-switch-thumb {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.kp-switch.is-on .kp-switch-thumb {
  transform: translateX(20px);
}

/* ===== Animacje (krótkie i spokojne) ===== */

@keyframes kpFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

button,
a,
input,
select,
textarea {
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

[role='dialog'],
[aria-modal='true'] {
  animation: kpFadeIn 0.15s ease both;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Numer szkolenia w nagłówku szczegółów - celowo mało widoczny */
.page-header-id {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--slate-400);
}

/* Ścieżka nad tytułem szczegółów: "← Wszystkie szkolenia › szczegóły" - pierwszy element wraca do listy */
.page-header-crumb {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: -4px;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--blue-700);
}

.page-header-crumb:hover {
  background: var(--blue-50);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.page-header-crumb svg {
  width: 14px;
  height: 14px;
}

/* Ścieżka w jednej równej linii */
.page-header-eyebrow:has(.page-header-crumb) {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .page-header-eyebrow .page-header-id {
    display: none;
  }
}

/* ===== Mapa i wyszukiwarka miejsca (PlacePicker) ===== */

.map-view {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  background: var(--slate-100);
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.map-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  max-width: none;
  pointer-events: none;
}

html[data-theme='dark'] .map-tile {
  filter: brightness(0.85) contrast(1.05);
}

.map-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  color: var(--danger-solid);
  pointer-events: none;
}

.map-pin svg {
  width: 34px;
  height: 34px;
  fill: #fff;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.map-radius {
  position: absolute;
  border: 2px solid var(--primary);
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  pointer-events: none;
}

.map-zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.map-zoom button {
  width: 34px;
  height: 34px;
  font-size: 18px;
  font-weight: 600;
  color: var(--slate-700);
}

.map-zoom button + button {
  border-top: 1px solid var(--slate-200);
}

.map-zoom button:hover {
  background: var(--slate-100);
}

.map-attribution {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 2px 6px;
  border-top-left-radius: 6px;
  background: rgba(255, 255, 255, 0.85);
  font-size: 10px;
  color: #333;
}

.place-busy {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--slate-500);
}

.place-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  padding: 4px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--popup-shadow);
}

.place-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
}

.place-option:hover {
  background: var(--slate-100);
}

/* Wybór daty (dwa skróty) i godziny (przewijane kolumny) */
.kp-date-actions.is-two {
  grid-template-columns: repeat(2, 1fr);
}

.kp-time-display {
  display: block;
  width: 100%;
  padding: 2px 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  text-align: center;
  color: var(--slate-900);
}

.kp-time-label {
  margin: 8px 2px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--slate-500);
}



.kp-time-display:hover {
  border-color: var(--slate-200);
}

/* Przewijane kolumny godzin i minut - wybrana wartość jest w środkowym pasku */
.kp-wheel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kp-wheel-col {
  position: relative;
}

.kp-wheel-list {
  position: relative;
  z-index: 1;
  height: 180px;
  overflow-y: auto;
  padding: 72px 0;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  /* Pozycje wyżej i niżej delikatnie znikają */
  -webkit-mask-image: linear-gradient(transparent, #000 30%, #000 70%, transparent);
  mask-image: linear-gradient(transparent, #000 30%, #000 70%, transparent);
}

.kp-wheel-list::-webkit-scrollbar {
  display: none;
}

.kp-wheel-band {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 72px;
  height: 36px;
  border-radius: 8px;
  background: var(--blue-50);
  pointer-events: none;
}

.kp-wheel-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 36px;
  scroll-snap-align: center;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--slate-400);
}

.kp-wheel-item:hover {
  color: var(--slate-700);
}

.kp-wheel-item.is-selected {
  font-size: 19px;
  color: var(--blue-700);
}


/* Lista urządzeń i historia logowań (SessionsCard) */
.session-current {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--blue-50);
  color: var(--blue-700);
  font-size: 11px;
  font-weight: 600;
}

.session-history summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-600);
}

.auth-channel-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.auth-channel-btn {
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: inherit;
  opacity: 0.72;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.auth-channel-btn:hover {
  opacity: 1;
}

.auth-channel-btn.is-active {
  opacity: 1;
  background: var(--pcrp-orange);
  color: #ffffff;
  box-shadow: 0 4px 12px -4px rgba(235, 89, 55, 0.55);
}

.auth-channel-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(235, 89, 55, 0.35);
  background: rgba(235, 89, 55, 0.08);
  font-size: 13px;
  line-height: 1.45;
}

.auth-channel-banner-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(235, 89, 55, 0.16);
  color: var(--pcrp-orange);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-channel-banner-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.auth-channel-banner-desc {
  display: block;
  font-size: 12.5px;
  opacity: 0.85;
}

.auth-channel-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auth-channel-actions .auth-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-channel-banner-content {
  flex: 1;
  min-width: 0;
}

.auth-channel-banner-switch {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(235, 89, 55, 0.4);
  background: transparent;
  color: var(--pcrp-orange);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.auth-channel-banner-switch:hover:not(:disabled) {
  background: rgba(235, 89, 55, 0.14);
}

.auth-secondary {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(235, 89, 55, 0.45);
  background: rgba(235, 89, 55, 0.1);
  color: var(--pcrp-orange);
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.auth-secondary:hover:not(:disabled) {
  background: rgba(235, 89, 55, 0.18);
}

.auth-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
