* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  margin: 0;
  background: #f2f4f0;
  color: #1a1a1a;
}

header {
  background: #6aa22c;
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
header h1 { font-size: 1.25rem; margin: 0; flex: 1; }
header a { color: #eaf6da; }

main { padding: 16px 20px 40px; max-width: 1200px; margin: 0 auto; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

button, .btn {
  background: #6aa22c;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}
button:hover { background: #588723; }
button.secondary { background: #e6e6e6; color: #222; }
button.secondary:hover { background: #d5d5d5; }
button.danger { background: #c0392b; }
button.danger:hover { background: #a53125; }
button.small { padding: 3px 8px; font-size: 0.8rem; }

input, select {
  padding: 6px 8px;
  border: 1px solid #bbb;
  border-radius: 5px;
  font-size: 0.9rem;
  background: #fff;
}
input[type="color"] { padding: 1px; width: 44px; height: 32px; }

.muted { color: #777; }

/* ---------- Plan-Tabellen ---------- */

table.plan {
  border-collapse: collapse;
  background: #fff;
  margin-bottom: 18px;
  width: 100%;
  table-layout: fixed;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
table.plan th.off { background: #d9dcd4; color: #999; }

/* Heutiger Tag: Spalte deutlich markieren */
table.plan th.today {
  background: #3f6d12;
  color: #fff;
  border-left: 2px solid #3f6d12;
  border-right: 2px solid #3f6d12;
}
table.plan th.today .range { color: #d9ecc2; }
table.plan td.cell.today {
  border-left: 2px solid #3f6d12;
  border-right: 2px solid #3f6d12;
}
table.plan tbody tr:last-child td.cell.today { border-bottom: 2px solid #3f6d12; }
table.plan td.cell.off { background: #ececec !important; cursor: default; }

/* Zebra: jede 2. Zeile leicht einfärben – nur bei weißen/grauen Zellen,
   farbige Schichtzellen behalten ihre Farbe */
table.plan td.cell.neutral { background: #fff; }
table.plan tbody tr:nth-child(even) td.cell.neutral,
table.plan tbody tr:nth-child(even) td.emp,
table.plan tbody tr:nth-child(even) td.pnum { background: #f3f7ec; }
table.plan th, table.plan td {
  border: 1px solid #999;
  padding: 6px 8px;
  text-align: center;
  font-size: 0.85rem;
}
table.plan th { background: #92d050; font-weight: 600; }
table.plan th .range { font-weight: 400; font-size: 0.75rem; }
table.plan th.wk { background: #76b83f; color: #fff; min-width: 90px; }
table.plan td.pnum { background: #f2f2f2; width: 40px; }
table.plan td.emp { text-align: left; font-weight: 600; white-space: nowrap; overflow: hidden; }
table.plan td.cell { min-width: 64px; height: 34px; font-weight: 600; position: relative; }
table.plan td.cell.editable { cursor: pointer; }
table.plan td.cell.editable:hover { outline: 2px solid #6aa22c; outline-offset: -2px; }

.badge {
  background: #bdd7ee;
  color: #17456b;
  border-radius: 4px;
  font-size: 0.65rem;
  padding: 1px 4px;
  font-weight: 600;
  vertical-align: middle;
}

/* Zellen-Auswahlmenü */
.cell-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 70;
  background: #fff;
  border: 1px solid #999;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  min-width: 170px;
}
.cell-menu button {
  background: #fff;
  color: #222;
  text-align: left;
  border-radius: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.cell-menu button:hover { background: #eef5e5; }
.cell-menu button.active { font-weight: 700; }

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid #888;
  border-radius: 3px;
  vertical-align: -2px;
  margin-right: 4px;
}

.stats-h { font-size: 1rem; margin: 20px 0 8px; }

/* Kürzel-Auswahl auf der Startseite */
.emp-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.emp-chip {
  background: #fff;
  color: #333;
  border: 1px solid #9bb87d;
  border-radius: 16px;
  padding: 5px 14px;
  font-weight: 600;
}
.emp-chip:hover { background: #eef5e5; }
.emp-chip.active { background: #3f6d12; border-color: #3f6d12; color: #fff; }
.emp-chip.active:hover { background: #33590e; }

/* Hervorgehobene Mitarbeiterzeile */
table.plan tbody tr.hl td {
  border-top: 3px solid #d18f00;
  border-bottom: 3px solid #d18f00;
  font-size: 0.95rem;
}
table.plan tbody tr.hl td:first-child { border-left: 3px solid #d18f00; }
table.plan tbody tr.hl td:last-child { border-right: 3px solid #d18f00; }
table.plan tbody tr.hl td.cell.neutral,
table.plan tbody tr.hl td.emp,
table.plan tbody tr.hl td.pnum { background: #ffe25e; }

/* Solange ein Mitarbeiter gewählt ist, treten die übrigen Zeilen zurück */
body.hl-active table.plan tbody tr:not(.hl) { opacity: 0.45; }

.legend { margin: 8px 0 16px; display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.85rem; }
.legend-item { display: inline-flex; align-items: center; }

/* ---------- Warnungen ---------- */
/* Status bleibt beim Scrollen immer sichtbar */
#planStatus {
  position: sticky;
  top: 8px;
  z-index: 60;
}
#planStatus .warnings, #planStatus .ok-banner {
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  max-height: 40vh;
  overflow-y: auto;
}

.warnings {
  background: #fdecea;
  border: 1px solid #e5b4ae;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: #7a271a;
}
.warnings ul { margin: 4px 0 0; padding-left: 18px; }
.ok-banner {
  background: #e8f4dc;
  border: 1px solid #b9d99a;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: #34531a;
}

/* ---------- Admin-Layout ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: #dfe7d6; color: #333; }
.tabs button.active { background: #6aa22c; color: #fff; }

.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; font-size: 1.05rem; }
.card h3 { font-size: 0.95rem; margin: 14px 0 6px; }

table.list { border-collapse: collapse; width: 100%; }
table.list th, table.list td { border: 1px solid #ddd; padding: 6px 8px; font-size: 0.85rem; text-align: left; }
table.list th { background: #f4f6f1; }

.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.form-row label { min-width: 160px; font-size: 0.9rem; }

.block-matrix td, .block-matrix th { text-align: center; }

/* ---------- Login ---------- */
.login-overlay {
  position: fixed; inset: 0;
  background: #f2f4f0;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.login-box {
  background: #fff; padding: 28px; border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  display: flex; flex-direction: column; gap: 12px; width: 300px;
}
.login-box h1 { font-size: 1.1rem; margin: 0; }
.error { color: #c0392b; font-size: 0.85rem; }

/* ---------- Druck ---------- */
@media print {
  header, .toolbar, .tabs, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  table.plan { box-shadow: none; page-break-inside: avoid; }
}
