/* =========================================================================
   Aufgabenapp – zentrales Stylesheet
   Schlichtes, modernes Design ohne Framework. Kein CDN.
   ========================================================================= */

:root {
  --primaer: #2563eb;
  --primaer-dunkel: #1d4ed8;
  --topbar-bg: #1e3a8a;
  --erfolg: #16a34a;
  --fehler: #dc2626;
  --warnung: #d97706;
  --hintergrund: #f4f6fa;
  --karte: #ffffff;
  --text: #1f2937;
  --text-dezent: #6b7280;
  --rand: #e5e7eb;
  --radius: 10px;
  --schatten: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background: var(--hintergrund);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--primaer);
}

a:hover {
  color: var(--primaer-dunkel);
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.2rem;
  margin: 1.25rem 0 0.6rem;
}

h3 {
  font-size: 1.05rem;
  margin: 1rem 0 0.5rem;
}

/* ------------------------------------------------------------- Topbar */

.topbar {
  background: var(--topbar-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.6rem 1.25rem;
}

.topbar a {
  color: #fff;
  text-decoration: none;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
}

.topbar a:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.topbar nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.group-name {
  font-weight: 400;
  font-size: 0.85rem;
  color: #c7d2fe;
  background: rgba(255, 255, 255, 0.12);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.user-chip {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
  margin: 0 0.3rem;
}

/* ------------------------------------------------- Impersonation-Banner */

.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fef3c7;
  color: #78350f;
  border-bottom: 1px solid #f59e0b;
  padding: 0.5rem 1.25rem;
  text-align: center;
  font-size: 0.95rem;
}

.impersonation-banner a {
  color: #92400e;
  font-weight: 600;
}

/* ------------------------------------------------------------- Layout */

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

.footer {
  text-align: center;
  color: var(--text-dezent);
  font-size: 0.85rem;
  padding: 1.5rem 1rem 2rem;
}

.footer a {
  color: var(--text-dezent);
}

/* Rechtstexte (Impressum, Datenschutz) */
.rechtstext {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.rechtstext h3 {
  margin-top: 1.3rem;
}

.rechtstext ul {
  padding-left: 1.2rem;
}

.rechtstext li {
  margin: 0.35rem 0;
}

/* -------------------------------------------------------------- Karten */

.card {
  background: var(--karte);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2:first-child,
.card h3:first-child {
  margin-top: 0;
}

/* ------------------------------------------------------------ Tabellen */

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--karte);
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--text-dezent);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

th,
td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rand);
  vertical-align: middle;
}

tbody tr:hover {
  background: #eef2ff;
}

/* Wochenmatrix */
.matrix td {
  text-align: center;
}

.matrix td:first-child {
  text-align: left;
}

/* Rangliste: eigene Zeile hervorheben */
tr.rang-ich,
tr.rang-ich:hover {
  background: #dbeafe;
  font-weight: 600;
}

/* ------------------------------------------------------------ Formulare */

form {
  margin: 0;
}

label {
  display: block;
  font-weight: 600;
  margin: 0.8rem 0 0.25rem;
  font-size: 0.92rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--primaer);
  outline-offset: 1px;
  border-color: var(--primaer);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-right: 0.4rem;
}

input[type="file"] {
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
}

fieldset {
  border: 1px solid var(--rand);
  border-radius: 8px;
  margin: 1rem 0;
  padding: 0.75rem 1rem 1rem;
}

legend {
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0 0.4rem;
}

.gps-hinweis {
  color: var(--warnung);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

#foto-vorschau {
  max-width: 100%;
  max-height: 320px;
  margin-top: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--rand);
}

/* -------------------------------------------------------------- Buttons */

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-top: 0.8rem;
  transition: background 0.12s ease, filter 0.12s ease;
}

.btn:hover {
  background: #f1f5f9;
}

.btn-primary {
  background: var(--primaer);
  border-color: var(--primaer);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primaer-dunkel);
  color: #fff;
}

.btn-danger {
  background: var(--fehler);
  border-color: var(--fehler);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
  color: #fff;
}

.btn-success {
  background: var(--erfolg);
  border-color: var(--erfolg);
  color: #fff;
}

.btn-success:hover {
  background: #15803d;
  color: #fff;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  margin-top: 0;
}

.inline-form {
  display: inline-block;
  margin: 0;
}

/* Aktionszeilen: Buttons statt nackter Links, sauber ausgerichtet */
.zeilen-aktionen {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.aktionen {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.aktionen .btn {
  margin-top: 0;
}

.subnav {
  margin-bottom: 1rem;
}

/* Filter-/Tab-Buttons (Rangliste, Statistik-Zeitraum) */
.btn-tab {
  background: #fff;
  border-color: #cbd5e1;
}

.btn-tab.aktiv {
  background: var(--primaer);
  border-color: var(--primaer);
  color: #fff;
}

/* -------------------------------------- Aufgaben-Formular: Abschnitte */

details.formular-abschnitt {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  margin: 0.75rem 0;
}

details.formular-abschnitt > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.65rem 1rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

details.formular-abschnitt > summary::-webkit-details-marker {
  display: none;
}

details.formular-abschnitt > summary::before {
  content: "▸";
  color: var(--text-dezent);
  transition: transform 0.12s ease;
}

details.formular-abschnitt[open] > summary::before {
  transform: rotate(90deg);
}

details.formular-abschnitt[open] > summary {
  border-bottom: 1px solid var(--rand);
}

.summary-info {
  margin-left: auto;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--text-dezent);
}

.abschnitt-inhalt {
  padding: 0.5rem 1rem 0.9rem;
}

.radio-zeile {
  display: block;
  font-weight: 400;
  margin: 0.35rem 0;
}

.radio-zeile.eingerueckt {
  margin-left: 1.6rem;
}

.wiederholung-wahl label {
  display: block;
  font-weight: 400;
  margin: 0.3rem 0;
}

/* Wochentage als anklickbare Pills */
.wochentag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.wochentag-pills label {
  margin: 0;
}

.wochentag-pills input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.wochentag-pills span {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.wochentag-pills input:checked + span {
  background: var(--primaer);
  border-color: var(--primaer);
  color: #fff;
}

.wochentag-pills input:focus-visible + span {
  outline: 2px solid var(--primaer);
  outline-offset: 1px;
}

/* ------------------------------------------- Wochenmatrix: Zuweisungs-Zellen */

.matrix-zelle {
  min-width: 96px;
  vertical-align: top;
}

.chip-form {
  display: block;
  margin: 0 0 0.2rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.1rem 0.55rem;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.chip-x {
  font-weight: 700;
  opacity: 0.6;
}

.chip-team {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.zelle-add {
  margin-bottom: 0.25rem; /* Dropdown steht immer in der ersten Zeile der Zelle */
}

.zelle-add select {
  width: auto;
  min-width: 3.2rem;
  max-width: 110px;
  padding: 0.15rem 0.3rem;
  font-size: 0.8rem;
  border-radius: 6px;
  color: var(--text-dezent);
}

/* Wochenaufgaben ohne einen einzigen Zuständigen: rot hervorheben */
tr.matrix-leer,
tr.matrix-leer:hover {
  background: #fee2e2;
}

tr.matrix-leer td:first-child {
  color: #991b1b;
  font-weight: 600;
}

/* ------------------------------------------------------- Flash-Meldungen */

.flash {
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin: 0 0 1rem;
  border: 1px solid transparent;
  font-size: 0.95rem;
}

.flash-success {
  background: #dcfce7;
  border-color: #86efac;
  color: #14532d;
}

.flash-error {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #7f1d1d;
}

.flash-info {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e3a8a;
}

/* --------------------------------------------------------- Status-Badges */

.badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-open {
  background: #e0e7ff;
  color: #3730a3;
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
}

.badge-done {
  background: #dcfce7;
  color: #166534;
}

.badge-missed {
  background: #fee2e2;
  color: #991b1b;
}

.badge-overdue {
  background: #ffedd5;
  color: #9a3412;
}

/* --------------------------------------------- Heute-Ansicht / Tagesphasen */

.phase-block {
  margin-bottom: 1.5rem;
}

.phase-block h2 {
  font-size: 1.05rem;
  color: var(--text-dezent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--rand);
  padding-bottom: 0.3rem;
  margin-bottom: 0.6rem;
}

/* Kompakte Heute-Karten (hk = Heute-Karte), farbcodiert nach Status */

.heute-titel {
  margin-bottom: 0.75rem;
}

.heute-datum {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-dezent);
  margin-left: 0.4rem;
}

.phase-section {
  margin-bottom: 1rem;
}

.phase-h {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dezent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0.9rem 0 0.35rem;
}

.phase-h.ph-rot {
  color: #c2410c;
}

.phase-window {
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  margin-left: 0.35rem;
}

.hk {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 10px;
  padding: 0.45rem 0.6rem 0.45rem 0.75rem;
  margin-bottom: 0.35rem;
  box-shadow: var(--schatten);
  border-left: 5px solid transparent;
}

.hk-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem 0.5rem;
  text-decoration: none;
  color: var(--text);
}

.hk-titel {
  font-weight: 600;
  font-size: 0.98rem;
}

.hk-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text-dezent);
  white-space: nowrap;
}

.tag-rot {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.tag-gelb {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

/* Status-Farben */
.hk-open {
  background: #eff6ff;
  border-left-color: var(--primaer);
}

.hk-pending {
  background: #fffbeb;
  border-left-color: #f59e0b;
}

.hk-done {
  background: #ecfdf5;
  border-left-color: var(--erfolg);
}

.hk-done .hk-titel {
  color: #15803d;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.hk-missed {
  background: #fef2f2;
  border-left-color: var(--fehler);
}

.hk-missed .hk-titel {
  color: #991b1b;
}

.hk-ueberfaellig {
  background: #fff7ed;
  border-left-color: #ea580c;
}

.hk-haken {
  color: var(--erfolg);
  font-size: 1.3rem;
  font-weight: 700;
  padding: 0 0.4rem;
}

.hk-form {
  flex-shrink: 0;
}

.btn-check {
  display: inline-block;
  background: var(--erfolg);
  color: #fff;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(22, 163, 74, 0.4);
  transition: background 0.12s ease, transform 0.08s ease;
}

.btn-check:hover {
  background: #15803d;
}

.btn-check:active {
  transform: scale(0.97);
}

.empty {
  text-align: center;
  color: var(--text-dezent);
  font-size: 1.05rem;
  padding: 2rem 0;
}

.task-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  background: var(--karte);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
}

.task-card .titel {
  font-weight: 600;
}

.task-card .titel a {
  text-decoration: none;
  color: var(--text);
}

.task-card .titel a:hover {
  color: var(--primaer);
}

.task-card .punkte {
  color: var(--text-dezent);
  font-size: 0.88rem;
  white-space: nowrap;
}

/* ---------------------------------------------------- Statistik-Balken */

.balken {
  background: var(--rand);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  min-width: 80px;
}

.balken > div {
  background: var(--primaer);
  height: 100%;
  border-radius: 999px;
}

/* -------------------------------------------------------------- QR-Druck */

.qr-print {
  text-align: center;
}

.qr-print img {
  max-width: 320px;
  width: 100%;
}

@media print {
  body * {
    visibility: hidden;
  }
  .qr-print,
  .qr-print * {
    visibility: visible;
  }
  .qr-print {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    box-shadow: none;
  }
  .topbar,
  .footer,
  .impersonation-banner,
  .flash,
  .btn {
    display: none !important;
  }
}

/* ------------------------------------------------------- Mobiles Menü */

.nav-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}

/* ------------------------------------------------------------ Responsive */

@media (max-width: 700px) {
  .topbar {
    position: relative;
    flex-wrap: nowrap;
  }

  .nav-toggle {
    display: block;
  }

  /* Obere Links wandern in ein aufklappbares Menü */
  .topbar nav {
    display: none;
  }

  .topbar nav.open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    order: 10;
    flex-basis: 100%;
    gap: 0.1rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 0.5rem;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .topbar nav.open a {
    padding: 0.55rem 0.6rem;
    border-radius: 8px;
  }

  .topbar nav.open .user-chip {
    margin: 0.3rem 0.3rem 0.1rem;
    align-self: flex-start;
  }

  main {
    margin-top: 0.75rem;
    padding: 0 0.6rem;
  }

  .card {
    padding: 1rem;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  h1 {
    font-size: 1.25rem;
  }

  /* Heute-Karten mobil: noch kompakter, Button bleibt gut tippbar */
  .hk {
    padding: 0.4rem 0.45rem 0.4rem 0.6rem;
  }

  .hk-titel {
    font-size: 0.93rem;
  }

  .btn-check {
    padding: 0.45rem 0.85rem;
    font-size: 0.9rem;
  }
}
