﻿/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Arial, Helvetica, sans-serif;
  background: #d4d4d4;
  min-height: 100vh;
  color: #000;
}

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════
   LOGIN
════════════════════════════════════════════════════ */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: #d4d4d4;
}
.login-box {
  background: #fff;
  border: 1px solid #999;
  padding: 32px 28px 28px;
  width: 360px;
  box-shadow: 2px 4px 16px rgba(0,0,0,0.15);
}
.login-box h1 { font-size: 1.4rem; margin-bottom: 8px; text-align: center; }
.login-subtitle { color: #555; font-size: 0.88rem; margin-bottom: 16px; text-align: center; }

/* Apotheken-Karten im Login */
.pharmacy-grid {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 10px;
}
.pharmacy-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: #f5f7fa; border: 2px solid #ddd;
  border-radius: 6px; cursor: pointer;
  font-family: Arial; font-size: 0.95rem; font-weight: bold;
  text-align: left; width: 100%;
  transition: all 0.15s;
}
.pharmacy-card:hover   { border-color: #1F3864; background: #eef2f8; }
.pharmacy-card.selected,
.pharmacy-card.pre-selected { border-color: #1F3864; background: #dce6f5; }
.pharmacy-icon { font-size: 1.5rem; line-height: 1; }
.pharmacy-name { flex: 1; }

/* Admin-Login-Zeile */
.admin-row {
  margin-top: 12px; text-align: center;
}
.btn-admin-login {
  background: none; border: none; color: #888;
  font-family: Arial; font-size: 0.8rem; cursor: pointer;
  padding: 4px 10px; border-radius: 4px; transition: all 0.12s;
}
.btn-admin-login:hover  { color: #1F3864; background: #f0f0f0; }
.btn-admin-login.selected { color: #1F3864; font-weight: bold; }

/* Zurück-Button im Login */
.btn-back {
  background: none; border: none; color: #1F3864;
  font-family: Arial; font-size: 0.82rem; cursor: pointer;
  padding: 0; margin-bottom: 10px; display: block;
}
.btn-back:hover { text-decoration: underline; }

/* Passwort-Eingabe im Login */
.login-box input[type="password"] {
  display: block; width: 100%;
  padding: 8px 10px; margin-bottom: 10px;
  border: 1px solid #999; font-family: Arial; font-size: 1rem;
  outline: none; box-sizing: border-box;
}
.login-box input[type="password"]:focus { border-color: #333; }

.login-box button[type="submit"] {
  width: 100%; padding: 9px;
  background: #1F3864; color: #fff;
  border: none; font-family: Arial; font-size: 0.95rem; font-weight: bold;
  cursor: pointer;
}
.login-box button[type="submit"]:hover { background: #2d4f91; }
.error-msg { color: #c00; font-size: 0.85rem; margin-top: 8px; min-height: 18px; }

/* ═══════════════════════════════════════════════════
   HEADER
════════════════════════════════════════════════════ */
header {
  background: #1F3864;
  color: #fff;
  height: 46px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.hdr-title {
  font-size: 1rem; font-weight: bold;
  letter-spacing: 0.3px; white-space: nowrap;
}

/* KW-Navigation */
.kw-nav {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px; padding: 3px 8px;
}
.kw-nav .nav-btn {
  background: none; border: none; color: #fff;
  font-size: 1.1rem; line-height: 1; padding: 1px 5px;
  cursor: pointer; border-radius: 3px;
  transition: background 0.12s;
}
.kw-nav .nav-btn:hover { background: rgba(255,255,255,0.2); }

.kw-label { font-size: 0.78rem; opacity: 0.9; white-space: nowrap; }

#kwYear {
  cursor: pointer; text-align: center;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff; border-radius: 3px;
  padding: 2px 3px; font-size: 0.9rem; font-weight: bold;
  font-family: Arial; outline: none;
}
#kwYear option { color: #000; }

#kwNum {
  width: 40px; text-align: center;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff; border-radius: 3px;
  padding: 2px 3px; font-size: 0.9rem; font-weight: bold;
  font-family: Arial; outline: none;
}
#kwNum::-webkit-outer-spin-button,
#kwNum::-webkit-inner-spin-button { opacity: 0.4; }

.btn-today {
  font-size: 0.72rem; padding: 3px 8px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25); color: #fff;
  border-radius: 3px; cursor: pointer; font-family: Arial;
  white-space: nowrap; transition: background 0.12s;
}
.btn-today:hover { background: rgba(255,255,255,0.22); }

.hdr-spacer { flex: 1; }

/* Action buttons */
.hdr-actions { display: flex; align-items: center; gap: 6px; }

/* + Mitarbeiter */
.btn-add-emp {
  font-size: 0.72rem; font-family: Arial;
  padding: 4px 9px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.85);
  border-radius: 3px; cursor: pointer;
  transition: background 0.12s;
}
.btn-add-emp:hover { background: rgba(255,255,255,0.18); }

/* Bearbeiten */
.btn-edit {
  font-size: 0.75rem; font-weight: bold; font-family: Arial;
  padding: 4px 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.3); color: #fff;
  border-radius: 3px; cursor: pointer; white-space: nowrap;
  transition: background 0.12s;
}
.btn-edit:hover { background: rgba(255,255,255,0.22); }
.btn-edit.active { background: #27AE60; border-color: #27AE60; }

/* Urlaub */
.btn-urlaub {
  font-size: 0.75rem; font-weight: bold; font-family: Arial;
  padding: 4px 9px;
  background: transparent;
  border: 1.5px solid #C0392B; color: #C0392B;
  border-radius: 3px; cursor: pointer; white-space: nowrap;
  transition: all 0.12s;
}
.btn-urlaub:hover { background: rgba(192,57,43,0.15); }
.btn-urlaub.active { background: #C0392B; border-color: #C0392B; color: #fff; }

/* Pflegeurlaub */
.btn-pflegeurlaub {
  font-size: 0.75rem; font-weight: bold; font-family: Arial;
  padding: 4px 9px;
  background: transparent;
  border: 1.5px solid #00897B; color: #00897B;
  border-radius: 3px; cursor: pointer; white-space: nowrap;
  transition: all 0.12s;
}
.btn-pflegeurlaub:hover { background: rgba(0,137,123,0.15); }
.btn-pflegeurlaub.active { background: #00897B; border-color: #00897B; color: #fff; }

/* Sonderdienst */
.btn-sonderdienst {
  font-size: 0.75rem; font-weight: bold; font-family: Arial;
  padding: 4px 9px;
  background: transparent;
  border: 1.5px solid #8E44AD; color: #BB8FCE;
  border-radius: 3px; cursor: pointer; white-space: nowrap;
  transition: all 0.12s;
}
.btn-sonderdienst:hover { background: rgba(142,68,173,0.2); }
.btn-sonderdienst.active { background: #8E44AD; border-color: #8E44AD; color: #fff; }

/* Dienständerung */
.btn-dienstaenderung {
  font-size: 0.75rem; font-weight: bold; font-family: Arial;
  padding: 4px 9px;
  background: transparent;
  border: 1.5px solid #F9A825; color: #FFD54F;
  border-radius: 3px; cursor: pointer; white-space: nowrap;
  transition: all 0.12s;
}
.btn-dienstaenderung:hover { background: rgba(249,168,37,0.2); }
.btn-dienstaenderung.active { background: #F9A825; border-color: #F9A825; color: #fff; }

/* Schule */
.btn-schule {
  font-size: 0.75rem; font-weight: bold; font-family: Arial;
  padding: 4px 9px;
  background: transparent;
  border: 1.5px solid var(--schule-color, #1565C0); color: var(--schule-color, #1565C0);
  border-radius: 3px; cursor: pointer; white-space: nowrap;
  transition: all 0.12s;
}
.btn-schule:hover { background: color-mix(in srgb, var(--schule-color, #1565C0) 15%, transparent); }
.btn-schule.active { background: var(--schule-color, #1565C0); border-color: var(--schule-color, #1565C0); color: #fff; }

.btn-nachtdienst {
  font-size: 0.72rem; font-family: Arial;
  padding: 4px 9px;
  background: transparent;
  border: 1.5px solid #e65100; color: #e65100;
  border-radius: 3px; cursor: pointer; white-space: nowrap;
  transition: all 0.12s;
}
.btn-nachtdienst:hover { background: rgba(230,81,0,0.12); }
.btn-nachtdienst.active { background: #e65100; border-color: #e65100; color: #fff; }

.btn-sondertag {
  font-size: 0.72rem; font-family: Arial;
  padding: 4px 9px;
  background: transparent;
  border: 1.5px solid #6a1b9a; color: #6a1b9a;
  border-radius: 3px; cursor: pointer; white-space: nowrap;
  transition: all 0.12s;
}
.btn-sondertag:hover  { background: rgba(106,27,154,0.12); }
.btn-sondertag.active { background: #6a1b9a; border-color: #6a1b9a; color: #fff; }

/* Krankenstand */
.btn-krankenstand {
  font-size: 0.75rem; font-weight: bold; font-family: Arial;
  padding: 4px 9px;
  background: transparent;
  border: 1.5px solid #757575; color: #757575;
  border-radius: 3px; cursor: pointer; white-space: nowrap;
  transition: all 0.12s;
}
.btn-krankenstand:hover { background: rgba(117,117,117,0.15); }
.btn-krankenstand.active { background: #757575; border-color: #757575; color: #fff; }

/* Verwaltung */
.btn-management {
  font-size: 0.72rem; font-family: Arial;
  padding: 4px 9px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.85);
  border-radius: 3px; cursor: pointer;
  transition: background 0.12s;
}
.btn-management:hover { background: rgba(255,255,255,0.18); }

/* Einstellungen (nur Admin) */
.btn-settings {
  font-size: 0.72rem; font-family: Arial;
  padding: 4px 9px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.85);
  border-radius: 3px; cursor: pointer;
  transition: background 0.12s;
}
.btn-settings:hover { background: rgba(255,255,255,0.18); }

/* Abmelden */
.btn-logout {
  font-size: 0.72rem; font-family: Arial;
  padding: 4px 9px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.85);
  border-radius: 3px; cursor: pointer;
  transition: background 0.12s;
}
.btn-logout:hover { background: rgba(192,0,0,0.3); border-color: #c00; }

/* ─── Mode-Banner ─── */
#modeBanner {
  padding: 4px 14px;
  font-size: 0.8rem; font-weight: bold;
  text-align: center;
}
#modeBanner.banner-edit         { background: #d5f5e3; color: #1a5c32; }
#modeBanner.banner-urlaub        { background: #fdebd0; color: #935116; }
#modeBanner.banner-pflegeurlaub  { background: #e0f2f1; color: #00574b; }
#modeBanner.banner-sonderdienst { background: #e8daef; color: #5b2c6f; }
#modeBanner.banner-dienstaenderung { background: #fff8e1; color: #8d6e00; }
#modeBanner.banner-krankenstand { background: #eeeeee; color: #424242; }
#modeBanner.banner-schule       { background: color-mix(in srgb, var(--schule-color,#1565C0) 12%, white); color: var(--schule-color,#1565C0); }
#modeBanner.banner-nachtdienst  { background: #fff3e0; color: #e65100; }
#modeBanner.banner-sondertag    { background: #f3e5f5; color: #6a1b9a; }
#modeBanner.banner-test         { background: #fff3cd; color: #7d5a00; border-bottom: 2px solid #f0c040; }

/* Nachtdienst-Info-Leiste (unterhalb Banner) */
.nachtdienst-info {
  background: #ffe0b2;
  color: #bf360c;
  font-size: 0.78rem;
  font-weight: bold;
  padding: 3px 14px;
  text-align: center;
}

.pw-reminder {
  background: #E3F2FD;
  color: #0D47A1;
  font-size: 0.78rem;
  font-weight: bold;
  padding: 5px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.pw-reminder button {
  font-family: Arial; font-size: 0.75rem; font-weight: bold;
  border: 1px solid #0D47A1; color: #0D47A1; background: #fff;
  border-radius: 3px; padding: 2px 8px; cursor: pointer;
}
.pw-reminder button:hover { background: #0D47A1; color: #fff; }
#btnPwReminderClose { border: none; background: none; font-size: 1rem; padding: 0 4px; }
#btnPwReminderClose:hover { background: none; color: #c00; }

/* ═══════════════════════════════════════════════════
   DIENSTPLAN-TABELLE
════════════════════════════════════════════════════ */
.table-wrap {
  padding: 16px;
  overflow-x: auto;
}

.table-page {
  background: #fff;
  border: 1px solid #aaa;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.18);
  display: block;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0;
}

/* Adaptive Spaltenbreiten (% statt px) */
#col-name   { width: 9%; }
.col-sub    { width: 3.79%; }

#scheduleTable {
  border-collapse: collapse;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11pt;
  border: 1px solid #000;
  background: #fff;
  table-layout: fixed;
  width: 100%;
}

/* ─── Kopfzeile Reihe 1: Tages-Namen ─── */
#scheduleTable thead tr:first-child th {
  font-weight: bold;
  font-size: 12pt;
  text-align: center;
  vertical-align: middle;
  padding: 7px 6px;
  height: 42px;
  background: #fff;
  color: #000;
  border: 1px solid #000;
  white-space: nowrap;
}

/* Woche-Zelle (rowspan=3) */
#scheduleTable thead tr:first-child th:first-child {
  text-align: center;
  vertical-align: middle;
  padding: 4px 3px;
  width: 110px;
  border-right: 3px solid #000;
}

/* Kleines Datums-Label in den Tages-Headern */
.th-date {
  display: block;
  font-size: 7.5pt;
  font-weight: normal;
  color: #555;
  line-height: 1.2;
}

/* Feiertags-Markierung im Tabellen-Header */
th.th-feiertag {
  background: #FFEBEE !important;
}
.th-feiertag-name {
  display: block;
  font-size: 6.5pt;
  font-weight: bold;
  color: #c62828;
  line-height: 1.3;
  white-space: nowrap;
}

/* Benannter Jahrestag im Header (wiederkehrend, z.B. Geburtstage) – sperrt den Tag NICHT */
th.th-customday {
  background: #E8EAF6 !important;
}
.th-customday-name {
  display: block;
  font-size: 6.5pt;
  font-weight: bold;
  color: #3949AB;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

/* Nachtdienst-Markierung im Tabellen-Header */
th.th-nachtdienst {
  background: #fff3e0 !important;
}
.th-nd-label {
  display: block;
  font-size: 6.5pt;
  font-weight: bold;
  color: #e65100;
  line-height: 1.3;
  white-space: nowrap;
}
th.th-nachtdienst-cursor { cursor: pointer; }

/* Nachtdienst-Spalte: leichter Orange-Schimmer auf allen Zellen */
td.td-nachtdienst {
  background: rgba(230,81,0,0.08) !important;
}

/* Nachtdienst-Modus: Tages-Header anklickbar */
body.mode-nachtdienst #headRow1 th.th-day {
  cursor: pointer;
}
body.mode-nachtdienst #headRow1 th.th-day:hover {
  background: rgba(230,81,0,0.15) !important;
}

/* Sonder-Tag im Header */
th.th-sondertag {
  background: color-mix(in srgb, var(--sd-color,#FFD700) 18%, white) !important;
}
.th-sondertag-name {
  display: block;
  font-size: 6.5pt;
  font-weight: bold;
  color: color-mix(in srgb, var(--sd-color,#c47e00) 90%, #000);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}
/* Sonder-Tag Zellen: leichter Farbschimmer */
td.td-sondertag {
  background: color-mix(in srgb, var(--sd-color,#FFD700) 10%, white) !important;
}
/* Sonder-Tag Modus: Header anklickbar */
body.mode-sondertag #headRow1 th.th-day { cursor: pointer; }
body.mode-sondertag #headRow1 th.th-day:hover {
  background: rgba(106,27,154,0.12) !important;
}

/* Feiertag im Druck / PDF */
.pth-feiertag {
  background: #FFEBEE !important;
}
.pth-feiertag-name {
  display: block;
  font-size: 6pt;
  font-weight: bold;
  color: #c62828;
  line-height: 1.3;
}
.pth-customday-name {
  display: block;
  font-size: 6pt;
  font-weight: bold;
  color: #3949AB;
  line-height: 1.3;
}

/* Feiertag-Zelle in der Tabelle (colspan=4, kein Bearbeiten) */
td.td-feiertag {
  background: #F5F5F5 !important;
  color: #616161;
  font-weight: bold;
  font-size: 9pt;
  text-align: center;
  cursor: default;
}

/* Tages-Header: dicke linke Linie als Tagtrennlinie */
#scheduleTable thead tr:first-child th.th-day {
  border-left: 3px solid #000;
}

/* ─── Kopfzeile Reihe 2: Sub-Header (von/bis) ─── */
#scheduleTable thead tr:nth-child(2) th {
  font-weight: normal;
  font-size: 8pt;
  text-align: center;
  vertical-align: middle;
  padding: 2px 2px;
  height: 18px;
  background: #fff;
  color: #555;
  border: 1px solid #000;
  border-top: none;
  white-space: nowrap;
}

#scheduleTable thead tr:nth-child(2) th.th-day-first {
  border-left: 3px solid #000;
}

/* ─── Datenzeilen ─── */
#scheduleTable tbody tr td {
  border: 1px solid #000;
  padding: 4px 3px;
  text-align: center;
  vertical-align: middle;
  height: 46px;
  background: #fff;
  color: #000;
  white-space: nowrap;
  font-size: 11pt;
}

/* Name-Spalte */
#scheduleTable tbody td.td-name {
  font-weight: bold;
  text-align: left;
  padding-left: 5px;
  border-right: 3px solid #000;
  width: 110px;
  min-width: 110px;
  position: relative;
}

/* ─── Mitarbeiter-Rollen: Zeilenhintergrundfarben ─── */
tr.role-pharmazeut td { background: #FFF3E0 !important; }
tr.role-pka td        { background: #E3F2FD !important; }
tr.role-lehrling td   { background: #E8F5E9 !important; }

/* Sonderdienst-Override-Indikator – violett, 2 Klassen → schlägt Rollfarben (0,2,1) > (0,1,1) */
td.td-sub.td-override,
td.ptd-sub.td-override { background: #E1BEE7 !important; }

/* Dienständerung-Override-Indikator – gold, 2 Klassen → schlägt Rollfarben (0,2,1) > (0,1,1) */
td.td-sub.td-dienstaenderung,
td.ptd-sub.td-dienstaenderung { background: #FFE082 !important; }

/* ─── Sortier-Pfeile (Reihenfolge) ─── */
.order-btns {
  display: none;
  flex-direction: column;
  gap: 1px;
  float: left;
  margin-right: 3px;
}
body.mode-edit .order-btns { display: flex; }

.btn-order {
  background: none;
  border: 1px solid #aaa;
  border-radius: 2px;
  width: 15px;
  height: 13px;
  font-size: 8px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  color: #444;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-order:hover { background: #ddd; }

/* Löschen-Button in Name-Zelle */
.btn-del-emp {
  display: none;
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: #c00;
  color: #fff;
  border: none;
  border-radius: 3px;
  width: 18px;
  height: 18px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  font-family: Arial;
  padding: 0;
  font-weight: bold;
}
.btn-del-emp:hover { background: #900; }
body.mode-edit .btn-del-emp { display: flex; align-items: center; justify-content: center; }

/* Sichtbarkeitszeitraum-Button in Name-Zelle */
.btn-visibility {
  display: none;
  position: absolute;
  right: 23px;
  top: 50%;
  transform: translateY(-50%);
  background: #455a64;
  color: #fff;
  border: none;
  border-radius: 3px;
  width: 18px;
  height: 18px;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  font-family: Arial;
  padding: 0;
}
.btn-visibility:hover { background: #263238; }
.btn-visibility.has-range { background: #e65100; }
.btn-visibility.has-range:hover { background: #bf360c; }
body.mode-edit .btn-visibility { display: flex; align-items: center; justify-content: center; }

/* Mitarbeiter außerhalb des eigenen Sichtbarkeitszeitraums (nur im Edit-Modus sichtbar) */
tr.row-out-of-range td { opacity: 0.5; }
tr.row-out-of-range td.td-name { font-style: italic; }

/* Erste Sub-Spalte eines Tages: dicke linke Linie */
#scheduleTable tbody td.td-day-first {
  border-left: 3px solid #000;
}

/* Sub-Zellen */
#scheduleTable tbody td.td-sub {
  font-size: 10pt;
  overflow: hidden;
}

/* Urlaub: rote Zelle – 2 Klassen → schlägt Rollfarben (0,2,1) > (0,1,1) */
td.td-sub.is-urlaub {
  background: #E06060 !important;
  color: #fff !important;
  font-weight: bold;
}

/* Pflegeurlaub: lila Zelle */
td.td-sub.is-pflegeurlaub {
  background: #00897B !important;
  color: #fff !important;
  font-weight: bold;
}

/* Schule: eigene Farbe (CSS-Variable, per Apotheke konfigurierbar) */
td.td-sub.is-schule {
  background: var(--schule-color, #1565C0) !important;
  color: #fff !important;
  font-weight: bold;
}

/* Krankenstand: graue Zelle – 2 Klassen → schlägt Rollfarben (0,2,1) > (0,1,1) */
td.td-sub.is-krankenstand {
  background: #9E9E9E !important;
  color: #fff !important;
  font-weight: bold;
}

/* Anklickbar in Edit-Modus */
body.mode-edit #scheduleTable tbody td.td-sub {
  cursor: pointer;
}
body.mode-edit #scheduleTable tbody td.td-sub:hover {
  outline: 2px solid #2E86C1;
  outline-offset: -2px;
  background: #EBF5FB !important;
}

/* Anklickbar in Urlaub-Modus (ganzer Tag-Block) */
body.mode-urlaub #scheduleTable tbody td.td-day-first {
  cursor: pointer;
}
body.mode-urlaub #scheduleTable tbody td.td-sub:hover {
  outline: 2px solid #C0392B;
  outline-offset: -2px;
  background: #FDEDEC !important;
}

/* Anklickbar in Krankenstand-Modus (ganzer Tag-Block) */
body.mode-krankenstand #scheduleTable tbody td.td-day-first {
  cursor: pointer;
}
body.mode-krankenstand #scheduleTable tbody td.td-sub:hover {
  outline: 2px solid #757575;
  outline-offset: -2px;
  background: #F5F5F5 !important;
}

/* Anklickbar in Sonderdienst-Modus */
body.mode-sonderdienst #scheduleTable tbody td.td-sub {
  cursor: pointer;
}
body.mode-sonderdienst #scheduleTable tbody td.td-sub:hover {
  outline: 2px solid #8E44AD;
  outline-offset: -2px;
  background: #F5EEF8 !important;
}

/* Anklickbar in Dienständerung-Modus */
body.mode-dienstaenderung #scheduleTable tbody td.td-sub {
  cursor: pointer;
}
body.mode-dienstaenderung #scheduleTable tbody td.td-sub:hover {
  outline: 2px solid #F9A825;
  outline-offset: -2px;
  background: #FFF8E1 !important;
}

/* Drucken-Button */
.btn-print {
  font-size: 0.72rem; font-family: Arial;
  padding: 4px 9px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.85);
  border-radius: 3px; cursor: pointer;
  transition: background 0.12s;
}
.btn-print:hover { background: rgba(255,255,255,0.18); }

/* PDF-Export-Button */
.btn-pdf {
  font-size: 0.72rem; font-family: Arial;
  padding: 4px 9px;
  background: rgba(255,200,0,0.12);
  border: 1px solid rgba(255,200,0,0.35); color: #FFD966;
  border-radius: 3px; cursor: pointer;
  transition: background 0.12s;
}
.btn-pdf:hover { background: rgba(255,200,0,0.22); }

/* PDF-speichern-Button im Modal */
.btn-pdf-save {
  flex: 1; padding: 8px; border: none;
  font-family: Arial; font-size: 0.85rem; font-weight: bold; cursor: pointer;
  background: #B8860B; color: #fff;
}
.btn-pdf-save:hover { background: #9A7209; }

/* Eingabefelder im Druck-Modal */
.print-input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #999;
  font-family: Arial;
  font-size: 0.9rem;
  outline: none;
}
.print-input:focus { border-color: #333; }

/* Form-Row (nebeneinander im Druck-Modal) */
.form-row {
  display: flex;
  gap: 10px;
}

/* ─── Druck-/PDF-Container ─── */
#printContainer { display: none; }
body.printing-kw #printContainer,
body.exporting-pdf #printContainer { display: block; }

/* ─── Druck-Tabellen-Styles (für print + html2pdf) ─── */
.print-week {
  width: 100%;
  margin: 0 auto;
  page-break-after: always;
  break-after: page;
}
.print-week:last-child,
.print-week-last {
  page-break-after: avoid;
  break-after: avoid;
}

.print-table {
  border-collapse: collapse;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8pt;
  border: 1px solid #000;
  background: #fff;
  table-layout: fixed;
  width: 100%;
}

#pcol-name  { width: 8.3%; }
.pcol-sub   { width: 3.82%; }

.pth-week {
  font-weight: bold; font-size: 8pt;
  text-align: left; vertical-align: middle;
  padding: 2px 4px; height: auto;
  border: 1px solid #000;
  border-right: 3px solid #000;
  background: #fff;
}

.pth-day {
  font-weight: bold; font-size: 11pt;
  text-align: center; vertical-align: middle;
  padding: 2px 2px; height: auto;
  border: 1px solid #000;
  border-left: 3px solid #000;
  background: #fff;
}

.pth-sub {
  font-weight: normal; font-size: 7.5pt;
  text-align: center; vertical-align: middle;
  padding: 2px 2px; height: auto;
  border: 1px solid #000;
  border-top: none;
  color: #333;
  background: #fff;
}
.pth-day-first { border-left: 3px solid #000 !important; }

.ptd-name {
  font-weight: bold; font-size: 7.5pt;
  text-align: center; padding: 1px 2px;
  border: 1px solid #000;
  border-right: 3px solid #000;
  vertical-align: middle;
  height: 1px;
  background: #fff;
}

.ptd-sub {
  font-size: 7pt;
  text-align: center; padding: 0px 1px;
  border: 1px solid #000;
  vertical-align: middle;
  height: 1px;
  background: #fff;
  overflow: hidden;
  white-space: nowrap;
}
.ptd-day-first { border-left: 3px solid #000 !important; }

td.is-urlaub.ptd-sub {
  background: #E06060 !important;
  color: #fff !important;
  font-weight: bold;
}

td.is-krankenstand.ptd-sub {
  background: #9E9E9E !important;
  color: #fff !important;
  font-weight: bold;
}

td.is-pflegeurlaub.ptd-sub {
  background: #00897B !important;
  color: #fff !important;
  font-weight: bold;
}

td.is-schule.ptd-sub {
  background: var(--schule-color, #1565C0) !important;
  color: #fff !important;
  font-weight: bold;
}

/* ═══════════════════════════════════════════════════
   ZEIT-PICKER
════════════════════════════════════════════════════ */
#pickerOverlay { position: fixed; inset: 0; z-index: 499; }

#pickerPopup {
  position: fixed;
  background: #fff;
  border: 1px solid #000;
  box-shadow: 3px 3px 8px rgba(0,0,0,0.25);
  z-index: 500;
  width: 160px;
  max-height: 300px;
  overflow-y: auto;
  font-family: Arial, sans-serif;
  font-size: 10.5pt;
}

.picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px;
  background: #1F3864; color: #fff;
  position: sticky; top: 0;
}
.picker-head span { font-size: 0.78rem; font-weight: bold; }
.picker-head button {
  background: none; border: none; color: rgba(255,255,255,0.8);
  cursor: pointer; font-size: 1rem; line-height: 1;
}
.picker-head button:hover { color: #fff; }

#pickerList { list-style: none; padding: 2px 0; }
#pickerList li {
  padding: 5px 12px;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: background 0.1s;
  border-bottom: 1px solid #eee;
}
#pickerList li:last-child { border-bottom: none; }
#pickerList li:hover { background: #e8f4fd; }
#pickerList li.is-selected { font-weight: bold; background: #ddeeff; }
#pickerList li .check { font-size: 0.72rem; color: #1F3864; }
#pickerList li.is-empty-opt { color: #999; font-style: italic; }

/* ═══════════════════════════════════════════════════
   MODALS (Settings + Mitarbeiter)
════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 600;
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: #fff;
  border: 1px solid #999;
  padding: 26px 28px;
  width: 340px;
  box-shadow: 3px 3px 10px rgba(0,0,0,0.2);
}
.modal-box h2 { font-size: 1rem; margin-bottom: 18px; font-weight: bold; }
.form-group { margin-bottom: 13px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: bold; margin-bottom: 4px; }
.form-group input[type="password"],
.form-group input[type="text"] {
  width: 100%; padding: 7px 9px;
  border: 1px solid #999; font-family: Arial; font-size: 0.9rem; outline: none;
}
.form-group input:focus { border-color: #333; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-actions button {
  flex: 1; padding: 8px; border: none;
  font-family: Arial; font-size: 0.85rem; font-weight: bold; cursor: pointer;
}
.btn-save   { background: #1F3864; color: #fff; }
.btn-save:hover { background: #2d4f91; }
.btn-cancel { background: #e0e0e0; color: #333; }
.btn-cancel:hover { background: #ccc; }
#pwMsg, #empMsg { font-size: 0.8rem; margin-top: 9px; min-height: 16px; }
#pwMsg.ok, #empMsg.ok   { color: #1a5c32; }
#pwMsg.err, #empMsg.err { color: #c00; }

/* ─── Verwaltungs-Modal ─── */
.modal-box-wide { width: 480px; max-width: 95vw; }
#mgmtList { max-height: 55vh; overflow-y: auto; padding-right: 4px; margin-top: 4px; }
.mgmt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #eee;
}
.mgmt-row:last-child { border-bottom: none; }
.mgmt-name {
  flex: 1;
  font-weight: bold;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mgmt-role-sel {
  font-family: Arial;
  font-size: 0.82rem;
  padding: 3px 5px;
  border: 1px solid #aaa;
  background: #fff;
  outline: none;
}
.btn-mgmt-rename {
  font-size: 0.78rem;
  padding: 3px 8px;
  background: #1F3864;
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  font-family: Arial;
}
.btn-mgmt-rename:hover { background: #2d4f91; }
#mgmtAuthMsg { font-size: 0.8rem; margin-top: 9px; min-height: 16px; }
#mgmtAuthMsg.err { color: #c00; }
#mgmtAuthMsg.ok  { color: #1a5c32; }

/* ═══════════════════════════════════════════════════
   TOAST
════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 18px; right: 18px;
  background: #27AE60; color: #fff;
  padding: 8px 16px; border-radius: 4px;
  font-family: Arial; font-size: 0.85rem; font-weight: bold;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
  z-index: 999;
  animation: fadeInOut 2.2s ease forwards;
}
@keyframes fadeInOut {
  0%   { opacity: 0; transform: translateY(6px); }
  12%  { opacity: 1; transform: translateY(0); }
  78%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(6px); }
}

/* Lade-/Fehlerstatus */
.state-row td {
  padding: 20px !important; text-align: center !important;
  color: #666; font-style: italic; font-size: 10.5pt;
}
.state-row.err td { color: #c00; font-style: normal; }

/* ═══════════════════════════════════════════════════
   MOBILE (≤ 768 px)
════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Header umbrechbar, nicht sticky (würde Plan verdecken) ── */
  header {
    height: auto;
    flex-wrap: wrap;
    padding: 6px 10px;
    gap: 6px;
    position: relative;
  }
  .hdr-title { font-size: 0.9rem; }
  .hdr-spacer { display: none; }

  /* KW-Nav kompakter */
  .kw-nav { padding: 3px 6px; gap: 3px; }
  .kw-label { display: none; }          /* "KW" + Jahr-Zahl weglassen */
  #kwYear    { display: none; }
  #kwNum     { width: 34px; font-size: 0.85rem; }
  .btn-today { display: none; }         /* Heute-Button auf kleinen Screens weglassen */

  /* Actions: volle Breite, umgebrochen */
  .hdr-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-start;
  }
  .hdr-actions button {
    font-size: 0.7rem;
    padding: 5px 8px;
    min-height: 32px;
  }
  /* Drucken + Einstellungen auf Mobile ausblenden */
  .btn-print, .btn-settings { display: none !important; }

  /* ── Tabelle: horizontal scrollbar + sticky Namensspalte ── */
  .table-wrap {
    padding: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-page {
    width: max-content;
    min-width: 100%;
    max-width: none;
  }
  #scheduleTable {
    width: max-content;
    font-size: 9pt;
    table-layout: fixed;
  }

  /* Feste Spaltenbreiten – px statt % auf Mobile */
  #col-name { width: 85px !important; }
  .col-sub  { width: 36px !important; }

  /* Sticky Namensspalte (Header + Body) */
  #scheduleTable thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #fff;
    box-shadow: 2px 0 4px rgba(0,0,0,0.12);
  }
  #scheduleTable tbody td.td-name {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 2px 0 4px rgba(0,0,0,0.10);
    width: 85px;
    min-width: 85px;
  }
  /* Rollen-Farben für sticky Zelle übernehmen */
  tr.role-pharmazeut td.td-name { background: #FFF3E0 !important; }
  tr.role-pka        td.td-name { background: #E3F2FD !important; }
  tr.role-lehrling   td.td-name { background: #E8F5E9 !important; }

  /* Zeilenhöhe für Touch */
  #scheduleTable tbody tr td {
    height: 42px;
    padding: 2px;
    font-size: 9pt;
  }
  #scheduleTable thead tr:first-child th {
    height: auto;
    padding: 4px 2px;
    font-size: 8.5pt;
  }
  .th-date { font-size: 6.5pt; }
  .th-feiertag-name { font-size: 6pt; }

  /* Picker – größere Touch-Ziele */
  #pickerPopup { width: 200px; max-height: 60vh; }
  #pickerList li { padding: 10px 14px; font-size: 11pt; }
}

/* ═══════════════════════════════════════════════════
   DRUCK – Ctrl+P (normale Haupttabelle)
════════════════════════════════════════════════════ */
@media print {
  @page { size: A4 landscape; margin: 8mm; }

  /* Hintergrundfarben im Druck erzwingen */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  header, #modeBanner, .toast,
  #pickerOverlay, #pickerPopup,
  #settingsOverlay, #addEmpOverlay,
  #printOverlay { display: none !important; }

  body { background: #fff !important; }

  /* KW-Druck: Haupttabelle ausblenden, printContainer einblenden */
  body.printing-kw .table-wrap,
  body.printing-kw .table-page { display: none !important; }
  body.printing-kw #printContainer {
    display: block !important;
    width: 281mm !important;   /* A4 quer 297mm − 2×8mm Rand */
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* KW-Druck: jede Woche füllt die gesamte A4-Seite (quer) */
  body.printing-kw .print-week {
    width: 281mm !important;
    height: 194mm !important;
    overflow: hidden !important;
    break-after: page;
    page-break-after: always;
  }
  body.printing-kw .print-week:last-child,
  body.printing-kw .print-week-last {
    break-after: avoid !important;
    page-break-after: avoid !important;
  }
  body.printing-kw .print-table {
    width: 281mm !important;
    height: 194mm !important;
    table-layout: fixed !important;
  }

  /* Normaler Ctrl+P: Haupttabelle als A4 quer */
  body:not(.printing-kw) .table-wrap {
    padding: 0 !important; overflow: visible !important;
    display: block !important;
  }
  body:not(.printing-kw) .table-page {
    border: none !important; box-shadow: none !important;
    max-width: none !important; width: 100% !important;
  }

  body:not(.printing-kw) #col-name { width: 8.3% !important; }
  body:not(.printing-kw) .col-sub  { width: 3.82% !important; }

  body:not(.printing-kw) #scheduleTable {
    width: 100% !important;
    font-size: 8pt !important; table-layout: fixed !important;
    page-break-inside: avoid;
  }
  body:not(.printing-kw) #scheduleTable thead tr:first-child th {
    height: auto !important; padding: 2px !important; font-size: 8pt !important;
  }
  body:not(.printing-kw) #scheduleTable thead tr:nth-child(2) th {
    height: auto !important; padding: 1px !important; font-size: 6pt !important;
  }
  body:not(.printing-kw) #scheduleTable tbody tr td {
    height: 1px !important; padding: 0 2px !important; font-size: 8pt !important;
  }
}
/* ═══════════════════════════════════════════════════
   PHARMACY BADGE + SWITCH BUTTON (Header)
════════════════════════════════════════════════════ */
.pharmacy-badge {
  display: inline-block;
  background: #1F3864;
  color: #fff;
  font-size: 0.78rem;
  font-weight: bold;
  padding: 3px 10px;
  border-radius: 12px;
  margin-left: 10px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

.btn-switch-pharmacy {
  font-size: 0.72rem; font-family: Arial;
  padding: 4px 9px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
  border-radius: 3px; cursor: pointer;
  transition: background 0.12s;
}
.btn-switch-pharmacy:hover {
  background: rgba(255,255,255,0.18);
}

/* ═══════════════════════════════════════════════════
   ADMIN APOTHEKEN-ÜBERSICHT (pharmacyOverview)
════════════════════════════════════════════════════ */
#pharmacyOverview {
  min-height: calc(100vh - 56px);
  background: #d4d4d4;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px;
}

.po-container {
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 2px 4px 16px rgba(0,0,0,0.12);
  padding: 32px 36px 36px;
  max-width: 760px;
  width: 100%;
}

.po-container h2 {
  font-size: 1.3rem;
  margin-bottom: 24px;
  color: #1F3864;
}

.po-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.po-card {
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 20px 16px;
  text-align: center;
  background: #f7f9fc;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s, background 0.15s;
}

.po-card:hover {
  border-color: #1F3864;
  background: #eef2f8;
}

.po-icon {
  font-size: 2.4rem;
  line-height: 1;
}

.po-name {
  font-size: 1rem;
  font-weight: bold;
  color: #1F3864;
}

.po-info {
  font-size: 0.78rem;
  color: #666;
}

.po-pw-hint {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
}

.pw-ok {
  background: #d4edda;
  color: #155724;
}

.pw-missing {
  background: #f8d7da;
  color: #721c24;
}

.po-btn {
  margin-top: 6px;
  padding: 7px 18px;
  background: #1F3864;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-family: Arial;
  font-size: 0.88rem;
  font-weight: bold;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

.po-btn:hover {
  background: #2d4f91;
}
