:root {
  --marke: #1f3a5f;
  --marke-hell: #e8eef6;
  --text: #111827;
  --text-2: #4b5563;
  --linie: #e5e7eb;
  --flaeche: #ffffff;
  --grund: #f4f5f7;
  --ok: #166534;
  --ok-bg: #dcfce7;
  --fehler: #991b1b;
  --fehler-bg: #fee2e2;
  --warn-bg: #fef3c7;
  --radius: 10px;
  --schatten: 0 1px 2px rgb(0 0 0 / 0.06), 0 1px 1px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--grund);
}
a { color: var(--marke); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .25rem; }
p { margin: 0 0 .75rem; }
.klein { font-size: .85rem; color: var(--text-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.vorformatiert { white-space: pre-line; overflow-wrap: anywhere; }

/* Kopfzeile */
.kopf {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem 1rem; padding-top: max(.5rem, env(safe-area-inset-top));
  background: var(--marke); color: #fff;
}
.marke { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 600; }
.hauptnav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.hauptnav a { color: #dbe4f0; text-decoration: none; padding: .4rem .7rem; border-radius: 8px; white-space: nowrap; }
.hauptnav a[aria-current] { background: rgb(255 255 255 / .15); color: #fff; }
.nutzer { position: relative; }
.nutzer summary { cursor: pointer; list-style: none; padding: .4rem .6rem; border-radius: 8px; color: #dbe4f0; white-space: nowrap; }
.nutzer summary::-webkit-details-marker { display: none; }
.nutzer .initialen { display: none; }
.nutzer-menue {
  position: absolute; right: 0; top: 2.4rem; min-width: 12rem;
  background: var(--flaeche); color: var(--text); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / .15); padding: .5rem; display: grid; gap: .25rem;
}
.nutzer-menue a, .nutzer-menue .link { padding: .4rem .5rem; text-align: left; }

.inhalt { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.seitenkopf { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: .5rem 0 1rem; flex-wrap: wrap; }
.zurueck { margin: 0 0 .5rem; }
.zurueck a { text-decoration: none; }

/* Meldungen */
.meldung { padding: .6rem .8rem; border-radius: 8px; margin-bottom: 1rem; background: var(--ok-bg); color: var(--ok); }
.meldung.fehler { background: var(--fehler-bg); color: var(--fehler); }
.hinweis { background: var(--marke-hell); padding: .6rem .8rem; border-radius: 8px; font-size: .9rem; }
.leerhinweis { color: var(--text-2); padding: 2rem 0; text-align: center; }

/* Knöpfe & Formulare */
.knopf {
  display: inline-block; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--linie);
  background: var(--flaeche); color: var(--text); text-decoration: none; font: inherit; cursor: pointer; line-height: 1.3;
}
.knopf.primaer { background: var(--marke); border-color: var(--marke); color: #fff; }
.knopf.gefahr { color: var(--fehler); border-color: #fecaca; }
.knopf.breit { width: 100%; }
.link { background: none; border: 0; color: var(--marke); font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: inherit; padding: .5rem .6rem; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; width: 100%;
}
input[type=checkbox], input[type=radio] { width: auto; }
input:focus, select:focus, textarea:focus, .knopf:focus-visible { outline: 2px solid #93c5fd; outline-offset: 1px; }
label { display: block; font-weight: 500; }
.haken { display: flex; align-items: center; gap: .4rem; font-weight: 400; }
.formular { display: grid; gap: 1rem; max-width: 560px; }
.feld { display: grid; gap: .25rem; }
.feld small { color: var(--text-2); }
.feld .label { font-weight: 500; }
.fehlertext { color: var(--fehler) !important; }
.ok { color: var(--ok); font-weight: 600; }
.ergebnis { margin: 0; padding-left: 1.1rem; display: grid; gap: .3rem; }
.tabelle .aktion form { display: inline; margin-right: .75rem; }
.hat-fehler input, .hat-fehler select { border-color: var(--fehler); }
.knopfleiste { display: flex; gap: .5rem; flex-wrap: wrap; }
.loeschen { margin-top: 1rem; }
.farbwahl { display: flex; gap: .5rem; }
.farbwahl input[type=color] { width: 3rem; padding: .2rem; height: 2.4rem; }
.farbfeld { display: inline-block; width: 1rem; height: 1rem; border-radius: 4px; vertical-align: -2px; border: 1px solid rgb(0 0 0 / .1); }

/* Formular Veranstaltung */
.formular-breit { display: grid; gap: 1rem; max-width: 900px; }
.feldraster { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem 1rem; }
.feldraster .voll { grid-column: 1 / -1; }
.einsatzzeilen, .kontaktzeilen { display: grid; gap: .75rem; margin-bottom: .75rem; }
.einsatzzeile, .kontaktzeile {
  display: grid; grid-template-columns: 9rem 10rem 7rem 7rem 1fr; gap: .5rem .75rem; align-items: end;
  padding: .75rem; border: 1px solid var(--linie); border-radius: 8px; margin: 0; background: #fafafa;
}
.kontaktzeile { grid-template-columns: 1fr 1fr 1fr 1fr; }
.einsatzzeile label, .kontaktzeile label { font-size: .85rem; font-weight: 500; display: grid; gap: .2rem; }
.kontaktzeile .breit { grid-column: 1 / -1; }
.einsatzzeile .entfernen, .kontaktzeile .entfernen { grid-column: 1 / -1; display: flex; font-weight: 400; color: var(--fehler); }
.einsatzzeile .fehlertext { grid-column: 1 / -1; }
.hat-fehler.einsatzzeile { border-color: var(--fehler); }
.knopfleiste.unten { position: sticky; bottom: 0; background: var(--grund); padding: .75rem 0; }
.seitenkopf .knopfleiste form { display: inline; }
textarea { resize: vertical; }

/* Karten */
.karte { background: var(--flaeche); border-radius: var(--radius); box-shadow: var(--schatten); padding: 1rem 1.1rem; }
.karte.schmal { max-width: 480px; margin: 2rem auto; }
.raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.raster .breit { grid-column: 1 / -1; }

/* Filter */
.filter { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filter select { width: auto; min-width: 9rem; }
.filter input[type=search] { flex: 1; min-width: 12rem; }
.segmente { display: inline-flex; background: var(--flaeche); border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; }
.segmente input { position: absolute; opacity: 0; }
.segmente span { display: block; padding: .45rem .8rem; cursor: pointer; }
.segmente input:checked + span { background: var(--marke); color: #fff; }
.segmente input:focus-visible + span { outline: 2px solid #93c5fd; }

/* Terminliste */
.monat { margin: 1.5rem 0 .5rem; font-size: .95rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.terminliste { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.termin a {
  display: flex; gap: .9rem; align-items: stretch; text-decoration: none; color: inherit;
  background: var(--flaeche); border-radius: var(--radius); box-shadow: var(--schatten);
  border-left: 6px solid var(--kunde, #ccc); padding: .65rem .9rem;
}
.termin a:hover { box-shadow: 0 2px 8px rgb(0 0 0 / .08); }
.tag { display: grid; justify-items: center; align-content: center; min-width: 2.6rem; }
.tag .wt { font-size: .75rem; color: var(--text-2); text-transform: uppercase; }
.tag .nr { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.was { min-width: 0; flex: 1; }
.zeile1 { display: flex; flex-wrap: wrap; gap: .35rem .5rem; align-items: center; margin-bottom: .15rem; }
.messe { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.termin.storniert .messe, .termin.storniert .tag { text-decoration: line-through; color: var(--text-2); }
.kunde { display: inline-block; font-size: .75rem; font-weight: 700; padding: .1rem .45rem; border-radius: 6px; }
.art { font-size: .78rem; font-weight: 600; padding: .1rem .45rem; border-radius: 6px; background: #f3f4f6; }
.art-aufbau { background: #dbeafe; color: #1e40af; }
.art-abbau { background: #fde68a; color: #78350f; }
.zeit { font-size: .85rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.badge { font-size: .72rem; font-weight: 700; padding: .1rem .4rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.badge.neu { background: #ef4444; color: #fff; }
.badge.storno, .status-storniert { background: var(--fehler-bg); color: var(--fehler); }
.status-neu { background: #fee2e2; color: #b91c1c; }
.status-geplant { background: var(--ok-bg); color: var(--ok); }

/* Detail */
.einsaetze { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .6rem; }
.einsaetze li { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline; }
.einsaetze li .klein { flex-basis: 100%; }
.kontakt { padding: .5rem 0; border-top: 1px solid var(--linie); }
.kontakt:first-of-type { border-top: 0; padding-top: 0; }
.werte { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.werte dt { color: var(--text-2); }
.werte dd { margin: 0; }
.verlauf { padding-left: 1.1rem; margin: 0; }

/* Tabellen */
.unternav { display: flex; gap: .25rem; overflow-x: auto; margin-bottom: .5rem; border-bottom: 1px solid var(--linie); }
.unternav a { padding: .5rem .75rem; text-decoration: none; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.unternav a[aria-current] { color: var(--marke); border-color: var(--marke); font-weight: 600; }
.tabelle-rahmen { background: var(--flaeche); border-radius: var(--radius); box-shadow: var(--schatten); overflow-x: auto; }
.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th, .tabelle td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--linie); vertical-align: top; }
.tabelle th { font-size: .8rem; color: var(--text-2); font-weight: 600; background: #fafafa; }
.tabelle tr:last-child td { border-bottom: 0; }
.tabelle tr.inaktiv td { color: #9ca3af; }
.tabelle .aktion { text-align: right; white-space: nowrap; }

/* Login */
body.leer { display: grid; min-height: 100vh; place-items: center; background: var(--marke); }
.login { width: 100%; padding: 1rem; }
.login .karte { max-width: 380px; margin: 0 auto; display: grid; gap: .9rem; padding: 1.75rem; }
.login h1 { margin: 0; }

/* Handy */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .kopf { gap: .5rem; padding: .5rem .75rem; }
  .marke span { display: none; }
  .hauptnav a { padding: .4rem .55rem; }
  .nur-gross { display: none; }
  .nutzer .name { display: none; }
  .nutzer .initialen { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: rgb(255 255 255 / .18); color: #fff; font-weight: 600; font-size: .85rem; }
  .inhalt { padding: .75rem .75rem 3rem; }
  .filter .segmente { width: 100%; }
  .filter .segmente label { flex: 1; text-align: center; }
  .filter select, .filter input[type=search] { flex: 1 1 100%; width: 100%; }
  .termin a { padding: .6rem .7rem; gap: .7rem; }
  .messe { white-space: normal; }
  .einsatzzeile { grid-template-columns: 1fr 1fr; }
  .einsatzzeile .breit { grid-column: 1 / -1; }
  .kontaktzeile { grid-template-columns: 1fr; }
  .tabelle thead { display: none; }
  .tabelle tr { display: block; border-bottom: 1px solid var(--linie); padding: .5rem 0; }
  .tabelle td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem .8rem; }
  .tabelle td::before { content: attr(data-label); color: var(--text-2); font-size: .85rem; }
  .tabelle td.aktion { justify-content: flex-end; }
  .tabelle td.aktion::before { content: none; }
}
