:root {
  --color-bg: #f5f5f4;
  --color-surface: #ffffff;
  --color-border: #ddd;
  --color-text: #1f2124;
  --color-muted: #666;
  --color-primary: #2d5b8a;
  --color-primary-dark: #1f4266;
  --color-danger: #b3261e;
  --color-ok: #1b7f3a;
  --color-warn: #a15c00;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
}

h1, h2, h3, h4 {
  margin: 0.4em 0 0.3em;
}

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-view[hidden],
.app-view[hidden] {
  display: none !important;
}

.login-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

input, select, button {
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

button {
  background: var(--color-primary);
  color: white;
  border: none;
  cursor: pointer;
}

button:hover {
  background: var(--color-primary-dark);
}

.link-btn {
  background: none;
  color: var(--color-primary);
  padding: 0;
  text-decoration: underline;
}

.link-btn:hover {
  background: none;
  color: var(--color-primary-dark);
}

.error {
  color: var(--color-danger);
  min-height: 1.2em;
  font-size: 0.9rem;
}

.status {
  min-height: 1.2em;
  font-size: 0.9rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.badge {
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--color-primary);
  color: white;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.nav-btn {
  background: transparent;
  color: var(--color-text);
  border: 1px solid transparent;
}

.nav-btn.active {
  background: var(--color-primary);
  color: white;
}

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

.view h2 {
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 0.25rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
  background: var(--color-surface);
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.subnav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.subnav-btn {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.subnav-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.legende {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.abwesenheit-tag {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  font-size: 0.72rem;
  color: white;
  margin: 0.1rem 0.15rem 0 0;
}

.abwesenheit-urlaub { background: var(--color-primary); }
.abwesenheit-fehlzeit { background: var(--color-danger); }
.abwesenheit-zeitausgleich { background: #8a6d00; }

.monatsraster {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.monatsraster-kopf {
  background: #eee;
  padding: 0.3rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
}

.monatsraster-tag {
  background: var(--color-surface);
  min-height: 5.5rem;
  padding: 0.25rem;
  font-size: 0.75rem;
}

.monatsraster-tag.ausserhalb {
  background: #f7f7f6;
  color: #aaa;
}

.monatsraster-tag.heute {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.tag-nummer {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.schichtplan-summe td {
  font-weight: 600;
  background: #f0f0ee;
}

td.unterbesetzt {
  background: #fbe9e7;
  color: var(--color-danger);
  font-weight: 600;
}

.wochen-navigation {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.wochen-navigation button {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.datum-klein {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.mitarbeiter-zelle {
  color: white;
  font-weight: 600;
  border-radius: 4px;
}

td.abwesenheit-zelle {
  color: var(--color-muted);
  font-size: 0.8rem;
  font-style: italic;
}

td.vertretung-zelle {
  font-size: 0.8rem;
  font-weight: 600;
}

th, td {
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

th {
  background: #eee;
}

.table-wrap {
  overflow-x: auto;
}

tr.unterbesetzt td {
  background: #fbe9e7;
}

.tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: white;
}

.tag-offen { background: var(--color-warn); }
.tag-ok { background: var(--color-ok); }
.tag-fehler { background: var(--color-danger); }
.tag-neutral { background: #777; }

.row-actions {
  display: flex;
  gap: 0.4rem;
}

.row-actions button {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.btn-secondary {
  background: #777;
}

.btn-secondary:hover {
  background: #555;
}

.unread {
  font-weight: 600;
}

@media (max-width: 600px) {
  .app-header {
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    padding: 0.5rem 0.75rem;
  }

  /* alle Menüpunkte sichtbar (mehrzeilig) statt seitlich zu scrollen */
  .app-nav {
    gap: 0.25rem;
    padding: 0.4rem 0.5rem;
  }

  .nav-btn {
    padding: 0.5rem 0.65rem;
    font-size: 0.9rem;
  }

  main {
    padding: 0.5rem 0.75rem 1.5rem;
  }

  /* Formulare: jedes Feld volle Breite, große Bedienflächen */
  .inline-form {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .inline-form label,
  .inline-form label input,
  .inline-form label select {
    width: 100%;
  }

  input, select, button {
    min-height: 2.6rem;
    font-size: 1rem;
  }

  .row-actions {
    flex-wrap: wrap;
  }

  .row-actions button {
    min-height: 2.4rem;
  }

  .subnav {
    flex-wrap: wrap;
  }

  /* Monatsraster: kompakte Zellen, Namen werden gekürzt statt die Spalte zu sprengen */
  .monatsraster-tag {
    min-height: 3.2rem;
    padding: 0.15rem;
  }

  .abwesenheit-tag,
  .feiertag-tag {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.62rem;
    padding: 0.05rem 0.2rem;
    margin: 0.1rem 0 0;
  }

  table {
    font-size: 0.85rem;
  }

  th, td {
    padding: 0.35rem 0.4rem;
  }
}


/* Feiertage */
.feiertag-tag {
  display: block;
  font-size: 0.7rem;
  line-height: 1.2;
  color: var(--color-warn);
  font-weight: 600;
}
.monatsraster-tag.feiertag { background: #fdf6e7; }
th.feiertag-kopf { background: #fdf6e7; }
tr.gestrichen td { color: var(--color-muted); text-decoration: line-through; }
tr.gestrichen td.row-actions { text-decoration: none; }

/* Start/Ende-Stempel: große Schaltflächen, am Handy nebeneinander über die ganze Breite */
#zeit-start-btn,
#zeit-stop-btn {
  flex: 1 1 8rem;
  min-height: 3.5rem;
  font-size: 1.15rem;
  font-weight: 600;
}

#zeit-stop-btn:not(:disabled) {
  background: var(--color-danger);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  /* Schichtplan: Namensspalte bleibt beim seitlichen Wischen stehen */
  .table-wrap th:first-child,
  .table-wrap td.mitarbeiter-zelle {
    position: sticky;
    left: 0;
    z-index: 1;
  }
}

/* Monatsübersicht: Monatsname über dem Raster; senkrechtes Scrollen bleibt, waagrechtes Wischen wechselt den Monat */
.monat-titel {
  font-weight: 600;
  text-align: center;
  margin: 0.25rem 0 0.4rem;
  text-transform: capitalize;
}

#monat-ergebnis {
  touch-action: pan-y;
}


/* Bestätigungs-Pop-up (siehe zeigeMeldung in app.js) */
.meldung-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(20, 22, 26, 0.45);
  animation: meldung-ein 0.15s ease-out;
}

.meldung-karte {
  width: 100%;
  max-width: 380px;
  padding: 1.5rem 1.25rem 1.25rem;
  text-align: center;
  background: var(--color-surface);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.meldung-karte h3 {
  margin: 0.6rem 0 0.4rem;
  font-size: 1.25rem;
}

.meldung-karte p {
  margin: 0 0 1rem;
  color: var(--color-muted);
  line-height: 1.4;
}

.meldung-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.6rem;
  height: 3.6rem;
  margin: 0 auto;
  border-radius: 50%;
  color: white;
  font-size: 2rem;
  font-weight: 700;
}

.meldung-ok .meldung-symbol { background: var(--color-ok); }
.meldung-fehler .meldung-symbol { background: var(--color-danger); }

.meldung-ok .meldung-ok,
.meldung-karte button.meldung-ok {
  min-width: 7rem;
}

@keyframes meldung-ein {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Roter Zähler am Menü (ungelesene Mitteilungen, offene Anträge) */
.badge {
  display: inline-block;
  min-width: 1.25rem;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #c62828;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
  vertical-align: middle;
}

.badge[hidden] {
  display: none;
}

input.email-fehlt {
  border-color: #c62828;
  background: #fff4f4;
}

.hinweis-zeile td {
  color: var(--color-warn);
  font-weight: 600;
}

/* ausgeblendete Felder bleiben trotz display:flex ausgeblendet */
.inline-form label[hidden] {
  display: none;
}
