@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Source+Sans+3:wght@400;600&display=swap');

:root {
  --ink: #1b1b1b;
  --charcoal: #2e2c29;
  --paper: #faf8f4;
  --paper-alt: #f1ede4;
  --line: #d8d2c4;
  --yellow: #fade45;
  --red: #e02c3d;
  --ok: #3f6b3f;
  --warn: #a9761a;
  --crit: #e02c3d;
  --braun-hell: #b08a5a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Source Sans 3', 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  color: var(--charcoal);
  letter-spacing: 0.01em;
  margin: 0 0 0.5em;
}

a { color: var(--charcoal); }
a:hover { color: var(--red); }

.site-header {
  background: var(--ink);
  color: var(--paper);
  border-bottom: 4px solid var(--yellow);
}

.site-header .inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.35rem;
  color: var(--paper);
  text-decoration: none;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand img.logo {
  width: 40px;
  height: 40px;
  object-fit: cover;
  object-position: left top;
  border-radius: 3px;
  border: 2px solid var(--yellow);
  flex-shrink: 0;
}

.brand small {
  display: block;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #cfc7b3;
}

nav.mainnav {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
}

nav.mainnav a {
  color: #e9e4d8;
  text-decoration: none;
  font-size: 0.92rem;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
}

nav.mainnav a:hover, nav.mainnav a.active {
  color: var(--paper);
  border-bottom-color: var(--yellow);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.collapsible summary {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 1.17rem;
  color: var(--charcoal);
  cursor: pointer;
  list-style: none;
}
.collapsible summary::-webkit-details-marker { display: none; }
.collapsible summary::before {
  content: '';
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin: 0 0.8em 0.1em 0.3em;
  border-right: 2px solid var(--charcoal);
  border-bottom: 2px solid var(--charcoal);
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.collapsible[open] summary::before { transform: rotate(-135deg); margin-bottom: 0; }

.ornament {
  text-align: center;
  color: var(--red);
  letter-spacing: 0.5em;
  font-size: 0.7rem;
  margin: 0.5rem 0 1.5rem;
}

form .field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.92rem; }
input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=date], input[type=time], input[type=number], textarea, select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: inherit;
  font-size: 1rem;
  background: var(--paper);
}
textarea { min-height: 5rem; resize: vertical; }

button, .btn {
  display: inline-block;
  background: var(--braun-hell);
  color: var(--paper);
  border: none;
  padding: 0.6rem 1.3rem;
  border-radius: 3px;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
button:hover, .btn:hover { background: var(--yellow); color: var(--ink); }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--paper-alt); color: var(--ink); }
.btn-danger { background: var(--crit); color: #fff; }
.btn-danger:hover { background: #a81f2d; color: #fff; }
.btn-small { padding: 0.3rem 0.7rem; font-size: 0.82rem; }
button:disabled, button:disabled:hover {
  background: var(--line);
  color: #948d7c;
  cursor: not-allowed;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 3px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--paper-alt); color: var(--ink); }
.btn-icon-delete:hover { border-color: var(--crit); }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { margin-bottom: 0; }

.btn-icon-info {
  border-radius: 50%;
  color: #948d7c;
  flex-shrink: 0;
}
.btn-icon-info:hover { color: var(--braun-hell); border-color: var(--braun-hell); }

dialog.help-dialog {
  max-width: 34rem;
  width: 90%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1.5rem 1.7rem;
  font-size: 0.95rem;
}
dialog.help-dialog::backdrop { background: rgba(27, 27, 27, 0.45); }
dialog.help-dialog h2 { font-size: 1.2rem; margin-bottom: 0.8rem; }
dialog.help-dialog p { margin: 0 0 0.8rem; }
dialog.help-dialog ul, dialog.help-dialog ol { margin: 0 0 0.8rem; padding-left: 1.3rem; }
dialog.help-dialog li { margin-bottom: 0.3rem; }
dialog.help-dialog .dialog-close { margin-top: 1rem; text-align: right; }

.btn-icon-subtle {
  background: transparent;
  border: 1px solid transparent;
  color: #b7b0a0;
  width: 1.7rem;
  height: 1.7rem;
  font-size: 0.75rem;
}
.btn-icon-subtle:hover { background: var(--paper-alt); color: var(--charcoal); }
.btn-icon-subtle:disabled, .btn-icon-subtle:disabled:hover {
  background: transparent;
  color: #e3ddd0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th { font-weight: 600; color: var(--charcoal); border-bottom: 2px solid var(--charcoal); }

/* Spalte mit Aktions-Button(s) am Zeilenende: schrumpft auf die Buttonbreite,
   die übrigen Spalten übernehmen den Rest - dadurch landet der Button
   zuverlässig am rechten Rand, auch wenn Nachbarspalten oft leer sind
   (sonst verteilt das automatische Tabellen-Layout den Freiraum ungleich
   und der Button hängt in der Mitte). */
.col-actions { width: 1%; white-space: nowrap; text-align: right; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
}
.badge-ok { background: var(--ok); }
.badge-kritisch { background: var(--crit); }
.badge-hinweis { background: var(--paper); color: var(--charcoal); border: 1px solid var(--braun-hell); }

.flash { padding: 0.7rem 1rem; border-radius: 3px; margin-bottom: 1rem; font-size: 0.92rem; }
.flash-success { background: #e5efe1; color: var(--ok); border: 1px solid #bfd8b4; }
.flash-error { background: #f6e2e0; color: var(--crit); border: 1px solid #e3b3ae; }
.flash-konflikt { background: #fbedd6; color: var(--warn); border: 1px solid #edc98b; }

.matrix-table th, .matrix-table td { text-align: center; }
.matrix-table td.bereich-name, .matrix-table th.bereich-name { text-align: left; }
.matrix-cell { min-width: 3.2rem; }

/* Kompakte Excel-artige Gesamtübersicht: Bereiche x Termine als Raster */
.matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}
.grid-matrix {
  border-collapse: collapse;
  font-size: 0.76rem;
  white-space: nowrap;
}
.grid-matrix th, .grid-matrix td {
  border: 1px solid var(--line);
  padding: 0.3rem 0.45rem;
  text-align: center;
}
.grid-matrix th.corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 3;
  background: var(--paper-alt);
}
.grid-matrix th.col-head {
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.4rem 0.3rem;
  height: 9rem;
  vertical-align: bottom;
  color: var(--charcoal);
}
.grid-matrix th.col-head .col-head-text {
  /* Auf einem eigenen inline-block-Element statt direkt auf dem <th>, weil
     Safari/WebKit writing-mode+transform auf table-cell-Elementen teils
     falsch (auf dem Kopf) rendert. */
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.grid-matrix th.col-head .titel-marker { color: var(--red); font-weight: 700; }
.grid-matrix th.row-head {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  text-align: left;
  font-weight: 600;
  white-space: normal;
  max-width: 11rem;
  box-shadow: 1px 0 0 var(--line);
}
.grid-matrix a.cell-link { display: block; text-decoration: none; color: inherit; }
.cell-ok { background: #e5efe1; color: var(--ok); font-weight: 700; }
.cell-warnung { background: #fbedd6; color: var(--warn); font-weight: 700; }
.cell-kritisch { background: #f6e2e0; color: var(--crit); font-weight: 700; }
.cell-na { background: var(--paper-alt); color: #b6ae9c; }

.legend {
  display: flex;
  gap: 1.3rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.8rem 0 1.2rem;
  font-size: 0.85rem;
  color: var(--charcoal);
}
.legend .swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 2px;
  margin-right: 0.35rem;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.legend .swatch.ok { background: #e5efe1; }
.legend .swatch.warnung { background: #fbedd6; }
.legend .swatch.kritisch { background: #f6e2e0; }

.helper-checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.4rem 1rem; }
.helper-checklist label { font-weight: 400; display: flex; align-items: center; gap: 0.4rem; }

.avail-row { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.avail-options { display: flex; gap: 1rem; }
.avail-options label { font-weight: 400; display: flex; align-items: center; gap: 0.3rem; }

.muted { color: #756f62; font-size: 0.88rem; }

.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: #756f62;
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
}

.print-only { display: none; }

@media print {
  .site-header, .site-footer, .no-print { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; }
  .container { padding: 0; max-width: 100%; }
  .card { border: none; padding: 0; }
  .matrix-wrap { border: none; overflow: visible; }
  .grid-matrix { font-size: 0.6rem; }
  .grid-matrix th.col-head { height: 6.5rem; }
  .grid-matrix th.row-head, .grid-matrix th.corner { position: static; box-shadow: none; }
  /* Bei einer mehrseitigen Gesamtübersicht (matrix_seiten()) beginnt jede
     Seite ausser der ersten auf einem neuen Blatt. */
  .print-page-break { break-before: page; page-break-before: always; }
}

@page {
  size: A4 landscape;
  margin: 1.2cm;
}

/* Helfer-Seiten: Anlass-Chips und Reiter */
.anlass-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0 1rem; }
.chip { padding: 0.3rem 0.9rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; background: #fff; font-size: 0.9rem; }
.chip.on { background: var(--yellow); border-color: var(--charcoal); font-weight: 600; }
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tab { padding: 0.5rem 1rem; text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; color: var(--charcoal); }
.tab.on { border-bottom-color: var(--red); font-weight: 600; }
.tab-badge { background: var(--ok); color: #fff; border-radius: 999px; padding: 0 0.5rem; font-size: 0.75rem; }
details.kontakt summary { cursor: pointer; display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: baseline; }
details.kontakt[open] summary { margin-bottom: 1rem; }
.einsatz-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.einsatz-row:last-of-type { border-bottom: 0; }
details.kontakt summary { list-style: none; position: relative; padding-right: 2rem; }
details.kontakt summary::-webkit-details-marker { display: none; }
details.kontakt summary::after {
  content: ""; position: absolute; right: 0.4rem; top: 50%;
  width: 0.55rem; height: 0.55rem; margin-top: -0.4rem;
  border-right: 2px solid var(--charcoal); border-bottom: 2px solid var(--charcoal);
  transform: rotate(45deg); transition: transform 0.15s;
}
details.kontakt[open] summary::after { transform: rotate(-135deg); margin-top: -0.1rem; }
label.absagen { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; margin-bottom: 0.8rem; }
label.absagen input { width: auto; }

/* Prüfseite */
.pruef-filter { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.pruef-chip { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem 0.9rem; font-size: 0.9rem; }
.pruef-chip:hover { background: var(--paper-alt); color: var(--ink); }
.pruef-chip.fehler { border-color: var(--crit); }
.pruef-chip.hinweis { border-color: var(--braun-hell); }
.pruef-chip.ok { border-color: var(--ok); color: var(--ok); }
.pruef-chip.aus { opacity: 0.45; }
.pruef-zahl { font-weight: 700; margin-left: 0.3rem; }
.pruef-bereich { display: inline-block; padding: 0.1rem 0.55rem; margin: 0.1rem 0.25rem 0.1rem 0; border-radius: 4px; font-size: 0.85rem; }

/* Helfer-Register: Schrittnummern und Hinweisbox */
.tab-nr { display: inline-block; min-width: 1.4rem; height: 1.4rem; line-height: 1.4rem; margin-right: 0.35rem; text-align: center; border-radius: 50%; border: 1px solid var(--line); font-size: 0.8rem; background: #fff; }
.tab-nr.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.card.hinweis { background: var(--paper-alt); }
@media (max-width: 640px) { .tabs { overflow-x: auto; } .tab { white-space: nowrap; padding: 0.5rem 0.7rem; } }
