/* =========================
   THEME / BASE
   ========================= */
:root{
  --bg:#0b0f14;
  --text:#e8eef7;
  --muted:#9bb0c7;
  --line:#1e2a3a;

  --accent:#f59e0b;
  --bad:#fb7185;
  --good:#34d399;
  --warn:#fbbf24;

  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius:18px;

  --range:#22c55e; /* podświetlenie zakresu */
}

*{ box-sizing:border-box; }

body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;
  background:
    radial-gradient(1000px 600px at 20% 0%, rgba(245,158,11,.12), transparent 55%),
    radial-gradient(900px 700px at 80% 10%, rgba(251,113,133,.10), transparent 60%),
    var(--bg);
  color:var(--text);
}

header{
  position:sticky;
  top:0;
  z-index:5;
  backdrop-filter:blur(10px);
  background:rgba(11,15,20,.6);
  border-bottom:1px solid rgba(30,42,58,.7);
}

.wrap{ max-width:1100px; margin:0 auto; padding:16px; }

.topbar{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
}

.brand{ display:flex; align-items:center; gap:10px; }

.logo{
  width:36px; height:36px;
  border-radius:12px;
  background:linear-gradient(135deg,rgba(245,158,11,.9),rgba(251,113,133,.9));
  box-shadow:var(--shadow);
}

h1{ font-size:16px; margin:0; }
.subtitle{ font-size:12px; color:var(--muted); margin:2px 0 0; }

.card{
  background:linear-gradient(180deg, rgba(17,24,36,.92), rgba(15,22,32,.92));
  border:1px solid rgba(30,42,58,.8);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}

/* =========================
   FORMS / BUTTONS
   ========================= */
.controls{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:end;
  padding:14px;
}

label{
  font-size:12px;
  color:var(--muted);
  display:block;
  margin-bottom:6px;
}

input,select,textarea,button{
  background:rgba(15,22,32,.9);
  border:1px solid rgba(30,42,58,.9);
  color:var(--text);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
  font-size:16px; /* kluczowe na iOS: zapobiega auto-zoom */
}

input[type="date"]{ padding:9px 12px; }
textarea{ min-height:90px; resize:vertical; }

button{
  cursor:pointer;
  transition:.15s transform,.15s border-color;
}
button:hover{
  transform:translateY(-1px);
  border-color:rgba(245,158,11,.5);
}

.btn-accent{
  background:linear-gradient(135deg, rgba(245,158,11,.9), rgba(251,113,133,.7));
  border:0;
}
.btn-ghost{ background:transparent; }

.btn-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

.hint{
  font-size:11px;
  color:rgba(155,176,199,.8);
  margin-top:6px;
  line-height:1.35;
}

.danger{ border-color:rgba(251,113,133,.45)!important; }

.field-error{
  margin-top:6px;
  font-size:11px;
  color:rgba(251,113,133,.95);
  line-height:1.25;
}

/* =========================
   LAYOUT
   ========================= */
.grid{
  display:grid;
  grid-template-columns:1.2fr .8fr;
  gap:14px;
  padding:14px;
}
@media(max-width:980px){
  .grid{ grid-template-columns:1fr; }
}

.calendar{ padding:14px; }
.side{ padding:14px; display:flex; flex-direction:column; gap:12px; }

.cal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:10px;
}

.month-title{ font-size:18px; letter-spacing:.2px; }

.pill{
  font-size:12px;
  color:var(--muted);
  border:1px solid rgba(30,42,58,.9);
  background:rgba(15,22,32,.7);
  padding:7px 10px;
  border-radius:999px;
}

.legend{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  padding:10px;
  border-radius:16px;
  border:1px dashed rgba(30,42,58,.9);
  background:rgba(15,22,32,.35);
}

/* =========================
   CALENDAR GRID
   ========================= */
.dow{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:10px;
  margin-bottom:10px;
}
.dow div{
  font-size:12px;
  color:var(--muted);
  text-align:center;
  padding:6px 0;
}

.days{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:10px;
}

.day{
  min-height:92px;
  border-radius:16px;
  border:1px solid rgba(30,42,58,.85);
  background:rgba(15,22,32,.65);
  padding:10px;
  cursor:pointer;
  transition:.12s transform,.12s border-color,.12s background;
}
.day:hover{
  transform:translateY(-1px);
  border-color:rgba(245,158,11,.35);
  background:rgba(15,22,32,.85);
}

.day.muted{ opacity:.35; cursor:default; }
.day.muted:hover{
  transform:none;
  border-color:rgba(30,42,58,.85);
  background:rgba(15,22,32,.65);
}

.daynum{
  font-weight:650;
  font-size:14px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
}


/* === Kalendarz: weekendy i święta === */

/* Sobota */
.day.is-saturday {
  background: rgba(148, 163, 184, 0.08);   /* chłodny szary */
  border-color: rgba(148, 163, 184, 0.25);
}

/* Niedziela */
.day.is-sunday {
  background: rgba(239, 68, 68, 0.12);     /* delikatna czerwień */
  border-color: rgba(239, 68, 68, 0.35);
}

/* Święto (również w tygodniu) */
.day.is-holiday {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.30);
}

/* Gdy dzień jest i świętem i niedzielą – lekko mocniej */
.day.is-holiday.is-sunday {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
}

/* Numer dnia – delikatny akcent */
.day.is-sunday .dateNum,
.day.is-holiday .dateNum {
  color: #f87171; /* tailwindowa czerwień */
}

.day.is-saturday .dateNum {
  color: #cbd5e1; /* jasny szary */
}


.badge{
  font-size:11px;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.06);
  white-space:nowrap;
}

.b-duty{ border-color:rgba(245,158,11,.35); background:rgba(255,217,102,.40); }
.b-night{ border-color:rgba(59,130,246,.45); background:rgba(59,130,246,.18); color:#dbeafe; }
.b-off{ border-color:rgba(155,176,199,.25); background:rgba(155,176,199,.08); color:var(--muted); }
.b-vac{ border-color:rgba(52,211,153,.35); background:rgba(52,211,153,.12); }
.b-vacn{ border-color:rgba(177,255,0,.35); background:rgba(177,255,0,.12); }
.b-blood{ border-color:rgba(255,0,0,.95); background:rgba(255,0,0,.65); }
.b-custom{ border-color:rgba(236,198,0,.35); background:rgba(236,198,0,.10); }

.meta{
  margin-top:10px;
  font-size:12px;
  color:var(--muted);
  display:flex;
  flex-direction:column;
  gap:4px;
}
.meta strong{ color:var(--text); font-weight:650; }

.tiny{
  font-size:11px;
  color:rgba(155,176,199,.85);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* =========================
   SIDEBAR STATS
   ========================= */
.stat{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  padding:12px;
  border-radius:16px;
  border:1px solid rgba(30,42,58,.85);
  background:rgba(15,22,32,.55);
}
.stat .k{ font-size:12px; color:var(--muted); }
.stat .v{ font-size:18px; font-weight:750; }
.v.good{ color:var(--good); }
.v.bad{ color:var(--bad); }
.v.warn{ color:var(--warn); }
.u {color:#0054db;
font-size:18px;
font-weight:750;}

.hr{ height:1px; background:rgba(30,42,58,.75); margin:10px 0; }

/* =========================
   OVERLAY / MODAL / TABS / TOAST
   ========================= */
.overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.55);
  display:none;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:10;
}
.overlay.show{ display:flex; }

.modal{
  width:min(700px,100%);
  border-radius:22px;
  border:1px solid rgba(30,42,58,.85);
  background:linear-gradient(180deg, rgba(17,24,36,.98), rgba(15,22,32,.98));
  box-shadow:var(--shadow);
  padding:14px;
}

.modal{
  width: min(900px, 96vw);   /* było 700 – to za mało na 2 kolumny */
  max-height: 92vh;          /* żeby nie wychodził poza ekran */
  overflow-y: auto;          /* przewijanie w środku modala */
  border-radius: 22px;
  border: 1px solid rgba(30,42,58,.85);
  background: linear-gradient(180deg, rgba(17,24,36,.98), rgba(15,22,32,.98));
  box-shadow: var(--shadow);
  padding: 18px;
  box-sizing: border-box;    /* kluczowe przy paddingu */
}


.modal-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.modal h2{ margin:0; font-size:16px; }
.modal p{ margin:4px 0 0; font-size:12px; color:var(--muted); }

.form{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-top:10px;
}
.form .full{ grid-column:1/-1; }

.foot{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
}

.smallnote{ font-size:11px; color:rgba(155,176,199,.8); }

.tabs{ display:flex; gap:10px; margin-top:6px; flex-wrap:wrap; }
.tab{
  padding:8px 10px;
  border-radius:999px;
  border:1px solid rgba(30,42,58,.85);
  background:rgba(15,22,32,.5);
  cursor:pointer;
  font-size:12px;
  color:var(--muted);
}
.tab.active{
  border-color:rgba(245,158,11,.5);
  color:var(--text);
}

.toast{
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  bottom:18px;
  background:rgba(15,22,32,.95);
  border:1px solid rgba(30,42,58,.9);
  border-radius:999px;
  padding:10px 14px;
  font-size:12px;
  color:var(--text);
  display:none;
  z-index:50;
}
.toast.show{ display:block; }

/* =========================
   RANGE SELECTION (DAYS)
   ========================= */
.day.range-start{ outline:2px solid var(--range); }
.day.range-end{ outline:2px solid var(--range); }
.day.in-range{ box-shadow: inset 0 0 0 2px rgba(34,197,94,.35); }

#rangeModal{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,0.45);
  z-index:1000;
}
.modal-card{
  background:#111;
  border-radius:12px;
  padding:16px;
  max-width:420px;
  width:90%;
  box-shadow:0 10px 40px rgba(0,0,0,0.6);
}

.hidden-block{ display:none; }

/* =========================
   NOTES
   ========================= */
.note{
  color:var(--accent, #ff9800);
  font-weight:600;
  margin-top:4px;
  line-height:1.3;
  background:rgba(255, 152, 0, 0.12);
  padding:4px 6px;
  border-radius:6px;
}
.note-icon{
  color:#ff9800;
  font-size:14px;
  margin-top:4px;
}

/* =========================
   DESKTOP TWEAKS
   ========================= */
@media (min-width: 981px) {
  .tiny{
    white-space:normal;
    overflow:visible;
    text-overflow:unset;
    word-break:break-word;
  }
  .day{ min-height:120px; } /* większe kafle na PC */
}

/* =========================
   MOBILE (<= 980px)
   ========================= */
@media (max-width: 980px) {
  .wrap{ padding:12px; }

  .topbar{ gap:10px; }
  .logo{ width:32px; height:32px; border-radius:10px; }
  h1{ font-size:15px; }
  .subtitle{ font-size:12px; }

  .controls{
    padding:12px;
    gap:12px;
    align-items:stretch;
  }
  .controls > div{ width:100%; }

  .btn-row{ width:100%; gap:10px; }
  .btn-row button{
    flex:1 1 auto;
    min-height:44px;
  }

  #vacFrom, #vacTo{ width:100%; }
  #btnApplyVacation{ width:100%; }

  .grid{ gap:12px; padding:12px; }
  .calendar{ padding:12px; }
  .side{ padding:12px; }

  .legend{ gap:6px; padding:10px; }
  .badge{ font-size:11px; padding:4px 8px; }

  .days{ gap:8px; }
  .day{
    min-height:78px;
    padding:9px;
    border-radius:14px;
  }
  .daynum{ font-size:13px; }
  .meta{ margin-top:8px; }

  .stat{ padding:10px; border-radius:14px; }
  .stat .v{ font-size:16px; }
  .stat .u {color:#0054db;
font-size:18px;}
}

/* =========================
   SMALL PHONES (<= 600px) MODAL
   ========================= */
@media (max-width: 600px) {
  .overlay{
    padding:10px;
    align-items:flex-end; /* bottom sheet */
  }
  .modal{
    width:95%;
    border-radius:18px 18px 0 0;
    padding:12px;
    max-height:88vh;
    overflow:auto;
  }

  .form{
    grid-template-columns:1fr;
    gap:10px;
  }

  .foot{ gap:10px; }

  #btnSaveDay, #btnClearDay,
  #btnDoLogin, #btnDoRegister, #btnChangePass{
    min-height:46px;
    padding:12px 14px;
  }
}

/* =========================
   EXTRA SMALL (<= 420px)
   ========================= */
@media (max-width: 420px) {
  .dow{ gap:6px; }
  .days{ gap:6px; }

  .dow div{
    font-size:11px;
    padding:5px 0;
  }

  .day{
    min-height:70px;
    padding:8px;
  }

  .day .badge{
    font-size:10px;
    padding:3px 6px;
  }

  #prevMonth, #todayMonth, #nextMonth{
    flex:1 1 30%;
    min-width:0;
  }
}

/* =========================
   MINI MONTH VIEW (<= 520px)
   ========================= */
@media (max-width: 520px) {
  /* więcej miejsca na 7 kolumn */
  .calendar{ padding:10px; }
  .grid{ padding:10px; }

  /* ciaśniejsza siatka */
  .days{
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    width:100%;
    gap:4px;
  }
  .dow{
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    width:100%;
    gap:4px;
    margin-bottom:6px;
  }
  .dow div{
    font-size:10px;
    padding:4px 0;
  }

  .day{
    min-height:44px;
    padding:6px;
    border-radius:12px;
    min-width:0;
    overflow:hidden;
  }

  .daynum{
    font-size:12px;
    font-weight:650;
    gap:6px;
    min-width:0;
  }
  .daynum > span:first-child{ min-width:0; }

  /* chowamy metę (godziny/opis) */
  .meta{ display:none !important; }

  .badge{
    font-size:10px;
    padding:2px 6px;
    line-height:1.1;
    min-width:0;
    max-width:100%;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
}

/* =========================
   MICRO (<= 380px)
   ========================= */
@media (max-width: 380px) {
  .days{ gap:3px; }
  .day{ min-height:40px; padding:5px; }
  .badge{ font-size:9px; padding:2px 5px; }
}

@media (max-width: 520px){
  .meta-mobile{ margin-top:6px; }
  .meta-mobile .m1{ display:flex; gap:6px; align-items:center; }
  .meta-mobile .m2{ margin-top:2px; opacity:.9; }

  .srcTag{ font-weight:700; }
  .noteDot{ margin-left:auto; }

  /* notatka pomarańczowa */
  .note{ color: rgba(255, 138, 0, .95); }
}
@media (max-width: 520px){
  .day .note{
    display: none;
  }

  .day.show-note .note{
    display: block;
    margin-top: 6px;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(255,138,0,.15);
    border: 1px solid rgba(255,138,0,.45);
    color: #ffd8a8;
  }

  .day.show-note{
    outline: 2px solid rgba(255,138,0,.6);
    box-shadow: inset 0 0 0 2px rgba(255,138,0,.2);
  }
}
@media (max-width: 520px){
  /* ikonka notatki zawsze widoczna i czytelna */
  .noteDot{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    font-size: 14px;
    line-height: 1;
    color: #ff8a00;
    filter: drop-shadow(0 0 6px rgba(255,138,0,.25));
  }

  /* na mobile domyślnie chowamy pełną notatkę, bo mało miejsca */
  .day .note{
    display: none;
  }

  /* po long-press pokazujemy notatkę w kafelku */
  .day.show-note .note{
    display: block;
    margin-top: 6px;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(255,138,0,.14);
    border: 1px solid rgba(255,138,0,.45);
    color: #ffd8a8;
  }

  .day.show-note{
    outline: 2px solid rgba(255,138,0,.65);
    box-shadow: inset 0 0 0 2px rgba(255,138,0,.18);
  }

  /* jeśli coś ucina meta na mobile */
  .meta-mobile{
    overflow: visible;
  }
}

.noteDot{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  margin-left:6px;
  font-size:14px;
  line-height:1;
  opacity:1;
}
/* MOBILE: notatka - ikonka zawsze widoczna */
@media (max-width: 520px){
  .meta-mobile .noteDot{
    display:inline-flex !important;
    align-items:center;
    justify-content:center;
    margin-left:6px;
    font-size:14px;
    line-height:1;
    opacity:1 !important;
    visibility:visible !important;
    pointer-events:none; /* ważne: nie trzeba w nią trafiać */
  }
}
/* MOBILE: blokuj zaznaczanie tekstu i systemowe menu przy przytrzymaniu */
@media (max-width: 520px){
  .days .day, .days .day *{
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none; /* iOS: wyłącz lupkę/menu */
  }
  .days .day{
    touch-action: manipulation; /* szybkie tapy, mniej konfliktów */
  }
}
/* Ikona notatki w badge (działa i na mobile i na desktop) */
.badge .noteMark{
  margin-left: 6px;
  font-size: 14px;
  line-height: 1;
  opacity: .95;
}

/* Na telefonie trochę mniejsza, żeby nie rozwalało badge */
@media (max-width: 520px){
  .badge .noteMark{
    font-size: 13px;
    margin-left: 4px;
  }
}
@media (max-width: 520px){
  .badge .noteMark{
    display:inline-block;
    opacity:1;
  }
}
.full {
  grid-column: 1 / -1;
}
/* badge w prawym górnym rogu kafelka */
.note-badge{
  position:absolute;
  top:8px; right:8px;
  min-width:20px; height:20px;
  padding:0 6px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  font-size:12px;
  background:rgba(245,158,11,.18);
  border:1px solid rgba(245,158,11,.35);
  color:var(--text);
}

/* podgląd notatki na dole kafelka */
.note-preview{
  margin-top:6px;
  font-size:11px;
  color:var(--muted);
  line-height:1.1;

  /* max 2 linie i ucinanie */
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.day-tile{ position:relative; }
.muted { color: var(--muted); }

.notesAll{
  margin-top:6px;
  display:flex;
  flex-direction:column;
  gap:3px;
}

.noteLine{
  font-size:11px;
  color: var(--muted);
  line-height:1.15;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  
    font-size: 11px;
  line-height: 1.2;
  margin-top: 4px;

  white-space: normal;        /* pozwala zawijać */
  word-break: break-word;     /* łamie długie słowa */
  overflow: hidden;

  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;      /* ← ILE LINII (zmień na 1, 2, 3) */
  
}
/* tylko box z urlopem */
#vacInfo{
  white-space: pre-line;   /* żeby \n działało */
  font-size: 14px;         /* zmniejsza tekst w środku */
  line-height: 1.15;       /* ciaśniej, ale czytelnie */
  font-weight: 700;        /* jeśli chcesz bold jak na screenie */
  text-align: left;        /* albo center jeśli wolisz */
}
/* ===== Mobile notes list ===== */
.mobile-notes{
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(15,22,32,.4);
  border-radius: 16px;
  margin-top: 12px;
  margin-left: 20px;
}

.mobile-notes-title{
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.mobile-note{
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  line-height: 1.3;
}

.mobile-note-date{
  font-weight: 700;
  margin-right: 6px;
  color: var(--accent);
}

/* tylko mobile */
@media (min-width: 3769px){
  .mobile-notes{
    max-width: 600px;
    margin: 16px auto 0;
  }
}

/* ===== cal-head: miesiąc+legenda u góry, strzałki na dole w środku ===== */

.calendar .cal-head{
  display: grid;
  grid-template-columns: 1fr 320px 1fr;  /* lewo | środek | prawo */
  grid-template-rows: auto auto;         /* góra | dół */
  gap: 10px 14px;
  align-items: start;
}

/* 1) Lewy blok (miesiąc + subtitle) -> góra lewa */
.calendar .cal-head > div:first-child{
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  min-width: 0;
}

/* 2) Blok "Miesiąc" (label + strzałki) -> dół środek */
.calendar .cal-head > div:nth-child(2){
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  justify-self: center;
  width: 100%;
  max-width: 320px;
}

/* 3) Legenda -> góra prawa */
.calendar .legend{
  grid-column: 3 / 4;
  grid-row: 1 / 2;
  justify-self: end;
  max-width: 520px;
}

/* Przyciskowy pasek: nieruchomy, 3 kolumny */
.calendar .btn-row{
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  gap: 10px;
  width: 100%;
  align-items: center;
}

.calendar .btn-row button{
  width: 100%;
  height: 44px;
  padding: 0;
  border-radius: 14px;
  white-space: nowrap;
}

/* (opcjonalnie) żeby "Miesiąc" nie pchał przycisków */
.calendar .cal-head > div:nth-child(2) > label{
  display: block;
  margin-bottom: 6px;
}

/* ===== Mobile: wszystko w 1 kolumnie, ale przyciski nadal centralnie ===== */
@media (max-width: 520px){
  .calendar .cal-head{
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 10px;
  }

  /* miesiąc + subtitle */
  .calendar .cal-head > div:first-child{
    grid-column: 1;
    grid-row: 1;
  }

  /* legenda pod miesiącem */
  .calendar .legend{
    grid-column: 1;
    grid-row: 2;
    justify-self: stretch;
    max-width: none;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  /* strzałki na dole i centralnie */
  .calendar .cal-head > div:nth-child(2){
    grid-column: 1;
    grid-row: 3;
    justify-self: center;
    width: 100%;
    max-width: 360px;
  }
}
.b-sick{
  background: rgba(99,102,241,.18);   /* spokojny fiolet */
  border-color: rgba(99,102,241,.45);
}

/* 1) ZABLOKUJ poziomy overflow globalnie */
html, body { overflow-x: hidden; }

/* 2) Wrap nie może wypychać poza ekran */
.wrap { max-width: 100%; }

/* 3) GRID: poprawne kolumny i kluczowe min-width:0 */
.grid{
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px; /* lewa elastyczna, prawa stała */
  gap: 16px;
  align-items: start;
}

/* bardzo ważne: lewa kolumna ma prawo się "ściskać" zamiast robić overflow */
.calendar { min-width: 0; }

/* prawa kolumna: stała szerokość, nie rozpycha całości */
.side{
  width: 360px;
  min-width: 360px;
  max-width: 360px;
}

/* 4) Laptop 1366px: zmniejsz prawą kolumnę, żeby nie było scrolla poziomego */
@media (max-width: 1400px){
  .grid{
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 14px;
  }
  .side{
    width: 320px;
    min-width: 320px;
    max-width: 320px;
  }
}

/* 5) Niska wysokość: prawa kolumna sticky + pionowy scroll (estetycznie) */
@media (max-width: 1400px) and (max-height: 820px){
  .side{
    position: sticky;
    top: 76px; /* dopasuj jeśli header ma inną wysokość */
    max-height: calc(100vh - 90px);
    overflow: auto;
    padding-right: 6px;
  }

  .side::-webkit-scrollbar { width: 10px; }
  .side::-webkit-scrollbar-thumb { background: rgba(255,255,255,.10); border-radius: 10px; }
  .side::-webkit-scrollbar-track { background: transparent; }
}

@media (min-width: 981px){
  .day{ min-height: 120px; padding: 12px; overflow: visible; }
  .meta{ display:block !important; }
  .tiny, .meta .tiny{
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
    word-break: break-word;
  }
}
/* ===== układ 1 kolumna (kalendarz + staty pod spodem) dla 1366px ===== */
@media (max-width: 1400px) {
  .grid{
    grid-template-columns: 1fr !important;
  }

  .calendar{
    width: 100%;
    min-width: 0;
  }

  .side{
    width: 100%;
    min-width: 0;
    max-width: none;
    position: static;      /* wyłącz sticky */
    max-height: none;
    overflow: visible;
    padding-right: 0;
    margin-top: 14px;
  }
}
@media (max-width: 1400px) {
  /* same kafelki statów w siatce */
  .side{
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  /* elementy, które mają zostać na całą szerokość */
  #anchorsBox,
  .side .card{
    grid-column: auto;
  }
}

/* jak jest trochę szerzej, możesz dać 3 kolumny */
@media (min-width: 1100px) and (max-width: 1400px) {
  .side{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}



/* ===== RANGE MODAL – wyśrodkowanie ===== */
#rangeModal{
  position: fixed;
  inset: 0;                 /* top:0 right:0 bottom:0 left:0 */
  z-index: 1000;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0,0,0,.45);  /* lekkie przyciemnienie tła */
}

/* karta modala */
#rangeModal .modal-card{
  margin: 0;
  max-width: 520px;          /* dopasuj szerokość */
  width: calc(100% - 32px);  /* żeby na laptopie nie dotykał krawędzi */
  max-height: 90vh;
  overflow: auto;
}

/* ===== RangeModal (Twoja struktura) – animacja ===== */
#rangeModal{
  /* display kontrolujesz JS (none/flex) */
  position:fixed;
  inset:0;
  z-index:999;

  /* overlay */
  background:rgba(0,0,0,.55);

  /* centrowanie okna */
  justify-content:center;
  align-items:center;

  /* animacja overlay */
  opacity:0;
  pointer-events:none;
  transition: opacity .18s ease;
}

/* okno modala */
#rangeModal .modal-card{
  transform: translateY(14px) scale(.985);
  opacity:0;
  transition: transform .18s ease, opacity .18s ease;
  will-change: transform, opacity;
}

/* stan otwarty */
#rangeModal.is-open{
  opacity:1;
  pointer-events:auto;
}

#rangeModal.is-open .modal-card{
  transform: translateY(0) scale(1);
  opacity:1;
}

/* preferencje dostępności */
@media (prefers-reduced-motion: reduce){
  #rangeModal, #rangeModal .modal-card{
    transition:none !important;
  }
}

/* === TEST: brutalna animacja RangeModal === */
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(120px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(120px) scale(0.85);
  }
}

#rangeModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#rangeModal.show {
  display: flex;
}

#rangeModal.show .modal-card {
  animation: modalIn .35s ease-out forwards;
}

#rangeModal.hide .modal-card {
  animation: modalOut .25s ease-in forwards;
}
/* === RangeModal: animacja pewniak (działa też przy zamykaniu) === */
@keyframes rangeModalIn {
  from { opacity: 0; transform: translateY(120px) scale(.88); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

@keyframes rangeModalOut {
  from { opacity: 1; transform: translateY(0)    scale(1); }
  to   { opacity: 0; transform: translateY(120px) scale(.88); }
}

#rangeModal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.60);
  align-items:center;
  justify-content:center;
  z-index:9999;
  display:none;
}

/* w trakcie otwierania i zamykania overlay MUSI być widoczny */
#rangeModal.is-open,
#rangeModal.is-closing{
  display:flex;
}

/* animacje okna (modal-card) */
#rangeModal.is-open .modal-card{
  animation: rangeModalIn .25s ease-out forwards !important;
}

#rangeModal.is-closing .modal-card{
  animation: rangeModalOut .25s ease-in forwards !important;
}
.range-row{
  display:flex;
  gap:10px;
  align-items:center;
  margin-top:6px;
}

.range-row select{
  flex:1;
  min-width:0;
}

.range-row button{
  white-space:nowrap;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}
.settings-box{
  margin-top: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(30,42,58,.85);
  background: rgba(15,22,32,.35);
}

.settings-box-title{
  font-weight: 700;
  margin-bottom: 10px;
}

.settings-box-label{
  display:block;
  margin-bottom: 6px;
}

.settings-box-row{
  margin-top: 10px;
}
.day.is-today{
  outline: 2px solid rgba(255,170,0,.95);
  outline-offset: 2px;
  border-radius: 14px;
  box-shadow: 0 0 18px rgba(255,170,0,.25);
}

/* ===== Annual PDF (print) ===== */
.annual-print{ padding: 10mm; color:#000; background:#fff; }

.annual-head{
  display:flex;
  justify-content:space-between;
  gap:10mm;
  align-items:flex-end;
  margin-bottom:6mm;
}
.annual-title{ font-weight:800; font-size:14px; }
.annual-sub{ font-size:12px; }
.annual-ot{ font-weight:800; font-size:12px; text-align:right; }

.annual-table{
  width:100%;
  border-collapse:collapse;
  table-layout:fixed;
  font-size:9px;
}
.annual-table th,
.annual-table td{
  border:1px solid #222;
  padding:1.2mm 0.6mm;
  vertical-align:top;
  text-align:center;
}
.annual-table th.monthcol,
.annual-table td.monthcol{
  width: 12mm;
  font-weight: 800;
}
.annual-table td.empty{ background:#fff; }

.annual-cell{
  display:flex;
  flex-direction:column;
  gap:1mm;
  line-height:1.05;
}
.annual-code{ font-weight:800; }
.annual-time{ font-size:8px; opacity:.95; }

@media print{
  @page { size: A4 landscape; margin: 6mm; }

  html, body{
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }

  /* USUŃ wszystko z układu (nie tylko ukryj) */
  body > *{ display:none !important; }

  /* POKAŻ tylko roczny wydruk */
  #annualPrint{
    display:block !important;
    position: static !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
}

@media print{
  .annual-table{
    width: 100% !important;
  }
  .annual-table tr{ page-break-inside: avoid; }
  .annual-head{ page-break-after: avoid; }
}

.day.blood-next-date{
  box-shadow: inset 0 0 0 2px #dc2626;
  border-radius: 12px;
}

.day.blood-next-date .next-blood-info{
  color: #b91c1c;
  font-weight: 700;
}

.next-blood-note{
  color: #dc2626;
  font-weight: 700;
  margin-top: 4px;
}


.nextBloodNote{
  color: #dc2626;
  font-weight: 700;
}

.grid{
  display:grid;
  grid-template-columns:minmax(0,1fr) 360px;
  gap:16px;
}
.cards-row{
  grid-column: 1 / 2;
  display:grid;
  grid-template-columns:repeat(2, minmax(320px, 1fr));
  gap:12px;
  margin-top:12px;
}

.cards-row{
  grid-column: 1 / 2;
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(450px, 450px));
  gap:12px;
  max-width:1501px;
}
@media (max-width: 800px){
  .cards-row{
    grid-template-columns:1fr;
  }
}