:root {
  --grund: #f4f5f7;
  --flaeche: #ffffff;
  --rand: #d8dce2;
  --text: #1f2933;
  --leise: #62707f;
  --akzent: #1f6feb;
  --warnung: #b8860b;
  --fehler: #c0392b;
  --ok: #1e7d44;
}

* { box-sizing: border-box; }

/* Das hidden-Attribut muss stärker sein als die display-Regeln weiter unten. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--grund);
  padding-bottom: env(safe-area-inset-bottom);
}

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; color: var(--leise); text-transform: uppercase; letter-spacing: .04em; }

/* ---- Anmeldung ---- */

.anmeldebildschirm {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 1.75rem;
  width: 100%;
  max-width: 24rem;
}

label { display: block; margin-bottom: 1rem; }
label span { display: block; font-size: .8rem; color: var(--leise); margin-bottom: .3rem; }

input {
  width: 100%;
  padding: .7rem .8rem;
  font-size: 1.1rem;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: #fff;
  letter-spacing: .08em;
}

button {
  width: 100%;
  padding: .8rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--akzent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

button:disabled { opacity: .55; cursor: default; }
button.klein { width: auto; padding: .35rem .7rem; font-size: .8rem; background: transparent; color: var(--leise); border: 1px solid var(--rand); }
button.zweit {
  width: auto;
  background: var(--flaeche);
  color: var(--text);
  border: 1px solid var(--rand);
  font-weight: 500;
  white-space: nowrap;
}

/* Deutsches Datumsfeld: Text in TT.MM.JJJJ plus Kalenderknopf */
.datumsfeld { display: inline-flex; align-items: center; gap: .3rem; }
.datums-text {
  width: 8.5rem;
  padding: .5rem .6rem;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: #fff;
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
}
.datumsfeld button.klein { padding: .5rem .6rem; }
tr.team-detail .datums-text { padding: .25rem .35rem; font-size: .8rem; width: 7.5rem; }

/* Breite Tabellen (Dienstplan) waagerecht scrollbar halten. */
.breit { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.breit table { min-width: 46rem; }

tr.team-detail td > table { min-width: 0; }

.fehler { color: var(--fehler); font-size: .85rem; margin: .8rem 0 0; }
.hinweis { color: var(--leise); font-size: .9rem; margin: 0 0 1.2rem; }

/* ---- Rahmen ---- */

header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 5;
}

.marke { font-weight: 700; }
.wer { margin-left: auto; font-size: .85rem; color: var(--leise); }

nav {
  display: flex;
  gap: .25rem;
  padding: .5rem 1rem;
  overflow-x: auto;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 3.1rem;
  z-index: 4;
}

nav button {
  width: auto;
  white-space: nowrap;
  background: transparent;
  color: var(--leise);
  font-weight: 500;
  padding: .45rem .8rem;
  border-radius: 20px;
}

nav button[aria-current="page"] { background: var(--akzent); color: #fff; }

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

/* ---- Karten und Tabellen ---- */

.abschnitt {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.zeile { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.zeile.gleich { justify-content: space-between; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--rand); }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--leise); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.rechts, th.rechts { text-align: right; }

.pflicht td { font-weight: 600; }
.unterbesetzt { background: #fdf0ee; }
.offen { background: #fdf8e7; }
/* Abwesenheitstage in der eigenen Liste: zurueckgenommen, nicht erledigt. */
tr.abwesend td { color: var(--leise); }
tr.abwesend { background: #f2f3f5; }

.marke-klein {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 700;
  background: #e6e9ed;
  color: var(--leise);
}
.marke-klein.meister { background: #e2edfb; color: #17458f; }
.marke-klein.vertreter { background: #e4f2ea; color: #17603a; }
.marke-klein.leitstand { background: #fdf0d8; color: #7a5600; }
.marke-klein.laeufer { background: #eee7fa; color: #4c2f8f; }
.marke-klein.kran { background: #e2edfb; color: #17458f; }
.marke-klein.springer { background: #e6e9ed; }

.plus { color: var(--ok); }
.minus { color: var(--fehler); }
.leise { color: var(--leise); }

.tag { display: inline-block; padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 700; }
.tag.ss { background: #fdf0d8; color: #7a5600; }
.tag.ns { background: #e4e9f7; color: #26324f; }
.tag.fs { background: #fdeceb; color: #8a2c22; }
.tag.f { background: #e6e9ed; color: var(--leise); }

.meldung {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: .7rem 1.1rem;
  border-radius: 8px;
  font-size: .9rem;
  z-index: 20;
  max-width: 90vw;
}
.meldung.fehler { background: var(--fehler); }

/* Pulldown in der Mitarbeiterliste */
.klein-auswahl {
  width: 100%;
  max-width: 11rem;
  padding: .35rem .45rem;
  font-size: .85rem;
  border: 1px solid var(--rand);
  border-radius: 6px;
  background: #fff;
}

/* Eingabefeld in der Mitarbeiterliste */
.klein-feld {
  width: 100%;
  max-width: 10rem;
  padding: .35rem .45rem;
  font-size: .85rem;
  letter-spacing: 0;
  border: 1px solid var(--rand);
  border-radius: 6px;
  background: #fff;
}

button.gefaehrlich { color: var(--fehler); border-color: #e6c4bf; }
button.gefaehrlich:hover { background: #fdf0ee; }

tr.archiviert td { opacity: .55; }

/* Besetzung in der Meldungsliste: Rollen mit Namen untereinander */
.besetzung { display: flex; flex-direction: column; gap: .2rem; align-items: flex-start; }

/* Teamzeile im Dienstplan: aufklappbar */
tr.team-zeile td:first-child { white-space: nowrap; }

.team-knopf {
  width: auto;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  padding: .25rem .5rem;
  border: 1px solid transparent;
  text-align: left;
}

.team-knopf:hover { border-color: var(--rand); background: var(--flaeche); }
tr.team-zeile.offen { background: #eef3fb; }
tr.team-zeile.offen .team-knopf { border-color: #b9cdf0; }

tr.team-detail > td {
  background: #f7f9fc;
  border-left: 3px solid #b9cdf0;
  padding: .6rem .8rem;
}

tr.team-detail table { background: transparent; }

tr.team-detail .name-zelle { min-width: 12rem; }
tr.team-detail .name-zelle .name { display: block; font-weight: 600; }
tr.team-detail .name-zelle .klein { display: block; font-size: .78rem; }

tr.team-detail td.status {
  font-size: .82rem;
  white-space: nowrap;
  font-weight: 500;
}
tr.team-detail td.status.anwesend { color: #17603a; }
tr.team-detail td.status.frei { color: #9aa5b1; }
tr.team-detail td.status.weg { color: var(--fehler); }
tr.team-detail td.status.vertretung { color: #4c2f8f; font-weight: 600; }

/* Grund und Stichtag erscheinen in der Zeile, sobald ein anderes Team
   gewaehlt ist. */
.wechsel-feld {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin-top: .4rem;
  padding: .4rem;
  background: #fdf8e7;
  border: 1px solid #ecd9a8;
  border-radius: 6px;
}

.wechsel-feld input {
  width: 100%;
  padding: .3rem .4rem;
  font-size: .8rem;
  border: 1px solid var(--rand);
  border-radius: 5px;
  background: #fff;
  letter-spacing: 0;
}

form.feld { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
form.feld label { margin-bottom: 0; }
form.feld input, form.feld select { padding: .5rem .6rem; font-size: .95rem; letter-spacing: 0; }
form.feld button { width: auto; padding: .5rem 1rem; }
form.feld select { border: 1px solid var(--rand); border-radius: 8px; background: #fff; }

.lade { color: var(--leise); padding: 2rem; text-align: center; }

/* ---- Bestaetigungsfenster ---- */

.dialog-schleier {
  position: fixed;
  inset: 0;
  background: rgba(31, 41, 51, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
}

.dialog-fenster {
  background: var(--flaeche);
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 26rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}

.dialog-fenster h2 { margin-bottom: .9rem; }
.dialog-fenster p { margin: .35rem 0; font-size: .95rem; }

.dialog-paar { display: flex; justify-content: space-between; gap: 1rem; }
.dialog-paar span:first-child { flex: 0 0 5.5rem; }
.dialog-paar span:last-child { text-align: right; font-weight: 600; }

.dialog-knoepfe { display: flex; gap: .6rem; margin-top: 1.2rem; }
.dialog-knoepfe button { flex: 1; }
