:root {
  /* Core Colors */
  --bg0: #f6f7fb;
  --bg1: #ffffff;
  --text: #0b1220;
  --muted: rgba(11, 18, 32, .62);
  --line: rgba(11, 18, 32, .12);

  /* Brand Colors */
  --accent: #4f46e5;
  --accent2: #7c3aed;

  /* Status Colors */
  --good: #16a34a;
  --warn: #f59e0b;
  --bad: #ef4444;

  /* Effects */
  --shadow-lg: 0 22px 60px rgba(11, 18, 32, .14);
  --shadow-md: 0 12px 26px rgba(11, 18, 32, .11);
  --shadow-sm: 0 6px 14px rgba(11, 18, 32, .10);

  --r-lg: 22px;
  --r-md: 18px;
  --r-sm: 14px;

  --tap: 48px; /* min target mobile */
}

/* Reset & Base */
* { box-sizing: border-box; }
html, body { height: 100%; }

html {
  background: var(--bg0);
}

/* Glassmorphism Background */
html::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 8% 0%, rgba(79, 70, 229, .22), transparent 55%),
    radial-gradient(900px 520px at 92% 6%, rgba(124, 58, 237, .14), transparent 55%),
    linear-gradient(180deg, var(--bg0), #eef2ff 60%, var(--bg0));
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(79, 70, 229, .25); }

/* Layout */
.container {
  flex: 1;
  max-width: 1100px;
  margin: 25px auto 0;
  padding: 0 14px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  width: 100%;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(246, 247, 251, .86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
}

.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 46px; height: 46px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 18px 40px rgba(79, 70, 229, .22);
  color: #fff;
  font-weight: 800;
  letter-spacing: .6px;
  user-select: none;
}
.brand-title { font-weight: 800; font-size: 16px; letter-spacing: .2px; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Cards */
.card {
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  margin-bottom: 26px;
  backdrop-filter: blur(8px);
}

.h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .2px;
  margin: 0 0 6px;
  color: var(--text);
}
.h2 {
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* Grid & Layout Helpers */
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
}

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; }
.col { flex: 1; min-width: 200px; }

.label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 14px;
  margin-bottom: 6px;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 20px 0;
}

/* Inputs */
.input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(11, 18, 32, .16);
  outline: none;
  background: #fff;
  color: var(--text);
  font-size: 16px; /* iOS zoom prevent */
  box-shadow: 0 2px 0 rgba(11, 18, 32, .03);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.input.error { border-color: var(--bad); background: #fff5f5; }

textarea {
  min-height: 92px;
  resize: vertical;
}

.input:focus, select:focus, textarea:focus {
  border-color: rgba(79, 70, 229, .55);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .14);
}
.input:disabled, select:disabled {
  background: #f1f2f6;
  color: var(--muted);
  cursor: not-allowed;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(11, 18, 32, .18);
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 700;
  min-height: var(--tap);
  box-shadow: var(--shadow-sm);
  transition: all .15s ease;
  text-decoration: none;
  font-size: 14px;
  user-select: none;
}

.btn:hover { background: #f9fafb; border-color: rgba(11, 18, 32, .25); text-decoration: none; }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.6; pointer-events: none; }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .25);
}
.btn.primary:hover { filter: brightness(1.1); }

.btn.danger {
  background: rgba(254, 242, 242, 1);
  border-color: rgba(239, 68, 68, .2);
  color: #b91c1c;
}
.btn.danger:hover { background: #fee2e2; }

.btn.ghost {
  background: transparent;
  box-shadow: none;
  border-color: transparent;
}
.btn.ghost:hover { background: rgba(11, 18, 32, .05); }

/* Pills & Badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(11, 18, 32, .12);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, .7);
  text-decoration: none;
}

/* Tiles (Dashboard) */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 780px) {
  .cards { grid-template-columns: 1fr 1fr; }
}

.tile {
  border-radius: var(--r-md);
  border: 1px solid rgba(11, 18, 32, .1);
  background: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.tile-title { font-weight: 800; font-size: 14px; }
.tile-sub { color: var(--muted); font-size: 12px; line-height: 1.4; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, .4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal {
  width: min(600px, 100%);
  border-radius: var(--r-lg);
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .98);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  transform-origin: center;
  animation: zoomIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-title { font-weight: 800; font-size: 18px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 24px; }
@media (max-width: 520px) {
  .modal-actions .btn { flex: 1; }
}

.hint { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* Autocomplete dropdown */
.suggest {
  position: absolute;
  top: 100%; left: 0; right: 0;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-md);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}
.suggest-item {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(11, 18, 32, .05);
  font-size: 14px;
  font-weight: 600;
}
.suggest-item:hover { background: #f0f4ff; color: var(--accent); }
.suggest-item:last-child { border-bottom: none; }

/* Calendar */
.calendar {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  overflow: hidden;
}
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: #fcfcfd;
  border-bottom: 1px solid var(--line);
}
.cal-title { font-weight: 800; font-size: 16px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow {
  padding: 10px 0; text-align: center; font-size: 11px; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  border-bottom: 1px solid var(--line); background: #fafafa;
}
.cal-cell {
  position: relative; min-height: 70px; padding: 6px;
  border-right: 1px solid rgba(11, 18, 32, .06);
  border-bottom: 1px solid rgba(11, 18, 32, .06);
  cursor: pointer; background: #fff;
  transition: background .1s;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: #f9fafb; }
.cal-cell.empty { background: #fcfcfd; cursor: default; }
/* Nowy styl dla zablokowanych (przeszłych) dni */
.cal-cell.disabled { opacity: 0.4; cursor: not-allowed; background: #f3f4f6; }
.cal-cell.disabled:hover { background: #f3f4f6; }

.cal-day { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #e5e7eb; box-shadow: 0 0 0 2px #fff;
  display: inline-block;
}
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.note {
  margin-top: 4px; font-size: 10px; color: var(--text);
  background: #f3f4f6; padding: 2px 4px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* --- TOAST (Powiadomienia) --- */
.toast {
  position: fixed;
  bottom: 30px;  /* ZMIANA: Zamiast top, dajemy bottom */
  right: 30px;
  
  /* ZMIANA: Ciemne tło i biały tekst dla lepszej widoczności */
  background: #1f2937; 
  color: #ffffff;
  border-left: 5px solid var(--accent);
  
  padding: 16px 24px;
  border-radius: 12px;
  
  /* ZMIANA: Mocniejszy cień, żeby "odkleić" go od tła */
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
  
  font-weight: 600;
  font-size: 14px;
  z-index: 10000; /* Musi być na samym wierzchu */
  
  /* Nowa animacja wjazdu od dołu */
  animation: toastUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Animacja wjazdu od dołu */
@keyframes toastUp {
  from { opacity: 0; transform: translateY(50px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Footer */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(10px);
  padding: 24px 0;
}
.footer-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 14px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px;
}
.footer-title { font-weight: 800; font-size: 14px; }
.footer-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.footer-right { display: flex; gap: 16px; }
.footer-link { font-size: 12px; color: var(--muted); font-weight: 600; }
.footer-link:hover { color: var(--accent); }

/* Utilities / Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes zoomIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* Mobile Tweaks */
@media (max-width: 600px) {
  .topbar { flex-direction: column; gap: 10px; align-items: flex-start; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* --- CALENDAR V3 STYLES --- */

/* Komórka kalendarza musi rosnąć, by pomieścić listę oddziałów */
.cal-cell {
    height: auto !important; 
    min-height: 90px;        
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    overflow: visible;
}

/* Szare tło dla dni z przeszłości */
.cal-cell.disabled {
    opacity: 0.5;
    background-color: #f3f4f6;
    cursor: not-allowed;
}

/* Kontener na listę wewnątrz kratki */
.cal-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    margin-top: 4px;
}

/* Pojedynczy wiersz w kalendarzu: Kropka + Tekst */
.cal-row {
    display: flex;
    align-items: center;
    gap: 3px;
    line-height: 1;
    margin-bottom: 2px;
}

/* Etykieta z nazwą */
.cal-label {
    font-size: 9px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Kropka */
.dot {
    width: 6px; height: 6px; 
    min-width: 6px;
    border-radius: 50%;
    background: #ccc; 
    flex-shrink: 0;
}
.dot.good { background-color: var(--good); }
.dot.warn { background-color: var(--warn); }
.dot.bad  { background-color: var(--bad); }

/* Notatka */
.note {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    font-size: 9px;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 4px;
}