:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #1d5fa8;
  --accent-dark: #164b85;
  --danger: #b42318;

  --c-termin: #2f6fd0;
  --c-krank: #d23c3c;
  --c-abwesend: #8a93a0;
  --c-urlaub: #2e9a4f;
  --c-antrag: #7cc590;
  --c-we: #eef0f3;
  --c-hol: #fbe9b4;

  --name-w: 170px;
  --lane: 24px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .8rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .6rem; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }
.nowrap { white-space: nowrap; }
.pad { padding: 1rem; }

/* Kopfzeile */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.2rem;
  background: #fff; border-bottom: 1px solid var(--line); padding: .5rem 1rem;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand small { font-weight: 400; color: var(--muted); margin-left: .3rem; }
nav.main { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem; flex: 1; }
nav.main > a, nav.user > a { padding: .35rem .6rem; border-radius: 6px; color: var(--text); }
nav.main > a.active, nav.user > a.active { background: #e8eef7; color: var(--accent-dark); }
nav.main > a.has-badge { font-weight: 600; color: var(--danger); }
nav.user { display: flex; align-items: center; gap: .4rem; }
nav.user form { margin: 0; }

main { padding: 1rem; max-width: 1600px; margin: 0 auto; }

/* Buttons & Formulare */
.btn, button.btn {
  display: inline-block; padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--text); font: inherit; cursor: pointer; line-height: 1.3;
}
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: #f0c4c0; }
.btn.danger:hover { background: #fdecea; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: .35rem .3rem; }
button.link:hover { text-decoration: underline; }

label { display: block; margin: 0 0 .8rem; font-weight: 500; }
label > input, label > select, label > textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .45rem .55rem;
  border: 1px solid #cfd4db; border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
label.check { display: flex; align-items: center; gap: .45rem; font-weight: 400; }
label.check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 1rem; padding: .6rem .9rem .2rem; }
legend { font-weight: 600; padding: 0 .3rem; }
input.copy { width: 100%; padding: .45rem; font: 13px ui-monospace, monospace; border: 1px solid #cfd4db; border-radius: 6px; margin: .3rem 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
form.actions, form.aktion { margin-top: .6rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem 1.3rem; margin-bottom: 1rem; }
.card.narrow { max-width: 620px; margin-left: auto; margin-right: auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }

.flash { padding: .6rem .9rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid; }
.flash.ok { background: #e9f7ee; border-color: #b9e2c6; }
.flash.warn { background: #fff6e0; border-color: #f1d58a; }
.flash.err { background: #fdecea; border-color: #f3b9b3; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.2rem; margin: 1rem 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 600; color: var(--muted); font-size: .85rem; }
.table.compact td { padding: .3rem .5rem; font-size: .9rem; }
tr.inactive td { color: var(--muted); }
.tasks { margin: 0; padding-left: 1.2rem; }
.tasks li { margin: .3rem 0; }

/* Menüs */
details.menu, details.filter { position: relative; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 200px; z-index: 30;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .3rem;
}
.menu-list a { display: block; padding: .45rem .7rem; border-radius: 6px; color: var(--text); }
.menu-list a:hover { background: #f0f2f5; text-decoration: none; }
details.more { margin-top: .8rem; }
details.more > summary { cursor: pointer; color: var(--accent); }
details.more[open] > summary { margin-bottom: .5rem; }

/* Toolbar / Filter */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .8rem; }
.toolbar h1 { margin: 0; }
.nav-month { display: flex; align-items: center; gap: .4rem; }
.nav-month h1 { margin-left: .5rem; }
.filter-box {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; width: min(560px, 92vw);
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 1rem;
}
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .1rem .8rem; }
.checks label.check { margin: 0 0 .4rem; }

.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin: 0 0 .6rem; font-size: .88rem; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: .35rem; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; }
.swatch.hol { background: var(--c-hol); }

/* Farben der Ebenen (Balken und Musterkästchen) */
.l-termin { background: var(--c-termin); }
.l-krank { background: var(--c-krank); }
.l-abwesend { background: var(--c-abwesend); }
.l-urlaub { background: var(--c-urlaub); }
.l-antrag {
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.55) 0 4px, transparent 4px 8px) var(--c-antrag);
}

/* Planer (Plantafel) */
.planer-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.planer { min-width: calc(var(--name-w) + var(--days) * 30px); }
.pl-row {
  display: grid;
  grid-template-columns: var(--name-w) repeat(var(--days), minmax(30px, 1fr));
  border-bottom: 1px solid var(--line);
  min-height: calc(var(--lane) + 8px);
  padding: 4px 0;
}
.pl-row:last-child { border-bottom: 0; }
.pl-head { position: sticky; top: 0; z-index: 4; background: #fff; padding: 0; }
.pl-name {
  grid-column: 1; position: sticky; left: 0; z-index: 3; background: #fff;
  padding: 0 .7rem; display: flex; align-items: center; font-weight: 500;
  border-right: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-row.ich .pl-name { color: var(--accent-dark); font-weight: 700; }
.pl-row.allgemein .pl-name { font-style: italic; color: var(--muted); }
.pl-day {
  text-align: center; font-size: .75rem; color: var(--muted); padding: .3rem 0; line-height: 1.15;
  border-left: 1px solid transparent;
}
.pl-day span { display: block; }
.pl-day b { display: block; font-size: .95rem; color: var(--text); }
.pl-cell { margin: -4px 0; border-left: 1px solid #f1f2f4; }
.pl-day.we, .pl-cell.we { background: var(--c-we); }
.pl-day.hol, .pl-cell.hol { background: var(--c-hol); }
.pl-day.today b { background: var(--accent); color: #fff; border-radius: 50%; width: 1.6rem; height: 1.6rem; line-height: 1.6rem; margin: 0 auto; }
.pl-cell.today { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }

.bar {
  position: relative; z-index: 2; align-self: center; height: calc(var(--lane) - 4px);
  margin: 0 2px; padding: 0 6px; border-radius: 5px;
  color: #fff; font-size: .78rem; line-height: calc(var(--lane) - 4px); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.bar:hover { text-decoration: none; filter: brightness(1.08); outline: 2px solid rgba(0,0,0,.25); }
.bar.l-antrag { color: #14532d; }
.bar.storno { outline: 2px dashed #b45309; outline-offset: -2px; }
.bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }

/* Antragsfortschritt „Wo hängt's?" */
.steps { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: .4rem 0 1rem; }
.step {
  display: flex; align-items: center; gap: .55rem; padding: .5rem .8rem; border-radius: 8px;
  border: 1px solid var(--line); background: #fafbfc; flex: 1 1 160px;
}
.step .dot {
  flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; color: #fff; background: #cfd4db;
}
.step .txt small { display: block; color: var(--muted); font-size: .8rem; }
.step.done { border-color: #b9e2c6; background: #f1faf4; }
.step.done .dot { background: var(--c-urlaub); }
.step.current { border-color: #f1d58a; background: #fff8e6; }
.step.current .dot { background: #d99a06; }
.step.failed { border-color: #f3b9b3; background: #fdf1ef; }
.step.failed .dot { background: var(--c-krank); }
.step.todo { opacity: .65; }

.status { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .82rem; background: #eef0f3; }
.status.s-genehmigt { background: #dcf3e3; color: #166534; }
.status.s-wartet_vertreter, .status.s-wartet_gl, .status.s-storno_angefragt { background: #fff1cc; color: #8a5a00; }
.status.s-abgelehnt, .status.s-storniert, .status.s-zurueckgezogen { background: #f3f4f6; color: var(--muted); }

@media (max-width: 700px) {
  :root { --name-w: 110px; }
  main { padding: .6rem; }
  .row2 { grid-template-columns: 1fr; }
  nav.main { order: 3; flex-basis: 100%; }
  .card { padding: 1rem; }
}

@media print {
  .top, .toolbar .filter, .legend { display: none; }
  .planer-wrap { overflow: visible; border: 0; }
  main { max-width: none; padding: 0; }
}
