:root {
  --line: #e2e2e2;
  --line-strong: #cfcfcf;
  --text: #1a1a1a;
  --muted: #767676;
  --holiday: #d0021b;
  --cell: 42px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: #fff;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--line);
  padding: 28px 24px;
  text-align: center;
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; letter-spacing: 0.08em; }
.login-hint { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-card input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  text-align: center;
  letter-spacing: 0.1em;
}
.login-card button {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--text);
  background: var(--text);
  color: #fff;
  cursor: pointer;
}
.login-card button:hover { background: #000; }
.login-error { margin: 14px 0 0; color: var(--holiday); font-size: 13px; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-title { font-weight: 600; }
.brand-sub { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; }

.year-picker { position: relative; }
.year-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 5px 12px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.year-button:hover { border-color: var(--text); }
.year-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line-strong);
  min-width: 100%;
  z-index: 30;
}
.year-list li {
  padding: 6px 14px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.year-list li:hover { background: #f4f4f4; }
.year-list li[aria-selected="true"] { font-weight: 600; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; display: inline-block; }

.logout { color: var(--muted); font-size: 12px; text-decoration: none; }
.logout:hover { color: var(--text); text-decoration: underline; }

/* ---------- Kalender ---------- */
.calendar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px;
  padding: 24px;
}
/* Schmalere Fenster: weniger Monate pro Reihe, damit nichts gequetscht wird. */
@media (max-width: 1000px) { .calendar { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .calendar { grid-template-columns: 1fr; } }
.month h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.wd {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}
.day {
  position: relative;
  height: var(--cell);
  border: 1px solid var(--line);
  margin: -1px 0 0 -1px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #fff;
  overflow: hidden;
}
.day.empty { border-color: transparent; cursor: default; }
.day:not(.empty):hover { outline: 1px solid var(--text); outline-offset: -1px; z-index: 2; }
.day .num {
  position: relative;
  z-index: 2;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff;
}
.day.weekend .num { font-weight: 700; }
.day.holiday .num { color: var(--holiday); font-weight: 700; }
.day.today { outline: 1px solid var(--text); outline-offset: -1px; }

.segments {
  position: absolute;
  inset: 0;
  display: flex;
  z-index: 1;
}
.seg { flex: 1 1 0; }

.corner {
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-top: 9px solid #000;
  border-left: 9px solid transparent;
  z-index: 3;
}

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  padding: 7px 9px;
  background: #fff;
  border: 1px solid var(--text);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  white-space: pre-line;
}

/* ---------- Popup ---------- */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 40;
}
.modal-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--text);
  padding: 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.icon-button {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.icon-button:hover { color: var(--text); }

.entries { margin: 14px 0 0; }
.entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.4;
}
.entry .swatch { width: 10px; height: 10px; flex: none; margin-top: 4px; }
.entry .del {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
}
.entry .del:hover { color: var(--holiday); }
.entries-empty { color: var(--muted); font-size: 13px; padding: 7px 0; border-top: 1px solid var(--line); }

.block { margin-top: 22px; }
.block h3 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.field-row { display: flex; gap: 10px; margin-bottom: 10px; }
.field-row label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
select, input[type="date"], textarea {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 10px; }
.check input { margin: 0; }

.overlap {
  margin: 0 0 10px;
  padding: 8px 9px;
  border: 1px solid var(--line-strong);
  background: #fafafa;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-line;
}
.overlap.block {
  border-color: var(--holiday);
  background: #fdf3f3;
  color: var(--holiday);
}

/* ---------- Statistik-Zeile ---------- */
.stats {
  padding: 14px 24px 26px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.stats b { color: var(--text); font-weight: 600; }

.primary {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--text);
  background: var(--text);
  color: #fff;
  cursor: pointer;
  margin-top: 4px;
}
.primary:hover { background: #000; }

@media (max-width: 520px) {
  .topbar { gap: 12px; padding: 12px 16px; }
  .legend { margin-left: 0; width: 100%; }
  .calendar { padding: 16px; gap: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

:focus-visible { outline: 2px solid #000; outline-offset: 1px; }
