:root {
  --bg: #f4f5f7; --card-bg: #fff; --text: #1c2430; --muted: #6b7280;
  --border: #e2e5ea; --primary: #2563eb; --primary-text: #fff;
  --accent-gedaempft: #9ca3af;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f; --card-bg: #1c222c; --text: #e6e9ef;
    --muted: #98a1af; --border: #2c3340; --primary: #3b82f6; --primary-text: #0b1220;
    --accent-gedaempft: #6b7280;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.45;
}
.topbar {
  padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.topbar h1 { margin: 0; font-size: 1.4rem; }
.topbar-aktionen { display: flex; gap: .5rem; align-items: center; }
.brand { text-decoration: none; color: inherit; }
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-ok { background: #dcfce7; color: #166534; }
.flash-err { background: #fee2e2; color: #991b1b; }
@media (prefers-color-scheme: dark) {
  .flash-ok { background: #14532d; color: #bbf7d0; }
  .flash-err { background: #7f1d1d; color: #fecaca; }
}
.login-shell { display: flex; justify-content: center; padding-top: 3rem; }
.login-shell .card { width: 100%; max-width: 340px; }
.feld { margin-bottom: .9rem; display: flex; flex-direction: column; gap: .3rem; }
.feld label { font-size: .85rem; color: var(--muted); }
.feld input {
  padding: .55rem .7rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 1rem;
}
.login-shell button { width: 100%; margin-top: .3rem; padding: .6rem; font-size: 1rem; }
.projekt-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem;
  margin-bottom: 1.5rem;
}
.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.1rem 1.3rem;
  /* CSS-Grid-Falle: Grid-Items haben per Default min-width:auto, wodurch ein langes
     unzerbrechliches Wort (URL, Domain, Token) die Spalte sprengt statt umzubrechen. */
  min-width: 0;
}
.card-kopf { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 1.1rem; }
.card ul { margin: 0; padding-left: 1.2rem; }
.card li { margin-bottom: .25rem; overflow-wrap: break-word; }
.card p, .card li { overflow-wrap: break-word; }
.card .gedaempft { color: var(--muted); }
.abschnitt { margin-top: .7rem; }
.abschnitt summary {
  cursor: pointer; list-style: none; font-size: .85rem; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); display: flex; align-items: center; gap: .4rem;
  user-select: none;
}
.abschnitt summary::-webkit-details-marker { display: none; }
.abschnitt summary::before { content: "▶"; font-size: .7em; transition: transform .15s; }
.abschnitt[open] summary::before { transform: rotate(90deg); }
.abschnitt ul { margin-top: .4rem; }
.beschreibung { color: var(--muted); margin: .5rem 0 0; }
.stand { color: var(--muted); font-size: .82rem; margin: .2rem 0 0; }
.card-geplante { margin-bottom: 1.5rem; }
.geplante-liste { list-style: none; padding: 0; margin: .6rem 0 0; }
.geplante-zeile {
  display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem;
  padding: .5rem 0; border-bottom: 1px solid var(--border);
}
.geplante-zeile:last-child { border-bottom: none; }
.geplante-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-top: .8rem; }
.geplante-form label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); flex: 1; min-width: 160px; }
.geplante-form input {
  padding: .5rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
.btn {
  display: inline-block; padding: .4rem .8rem; border-radius: 6px; text-decoration: none;
  font-size: .85rem; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-klein { background: var(--border); color: var(--text); padding: .3rem .6rem; font-size: .8rem; }
.mandant {
  border: 1px solid var(--border); border-radius: 8px; margin-top: .7rem; overflow: hidden;
}
.mandant summary {
  padding: .8rem 1rem; cursor: pointer; display: flex; align-items: center; gap: .8rem;
  flex-wrap: wrap; list-style: none; user-select: none;
}
.mandant summary::-webkit-details-marker { display: none; }
.mandant summary::before { content: "▶"; font-size: .7em; color: var(--muted); transition: transform .15s; }
.mandant[open] summary::before { transform: rotate(90deg); }
.mandant-name { font-weight: 600; }
.mandant-domain { color: var(--muted); font-size: .88rem; }
.badge-gesetzt, .badge-nicht-gesetzt {
  display: inline-block; padding: .15rem .6rem; border-radius: 10px; font-size: .78rem;
}
.badge-gesetzt { background: #dcfce7; color: #166534; }
.badge-nicht-gesetzt { background: var(--border); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .badge-gesetzt { background: #14532d; color: #bbf7d0; }
}
.mandant summary .badge-gesetzt, .mandant summary .badge-nicht-gesetzt { margin-left: auto; }
.mandant-details { padding: 0 1rem 1rem; border-top: 1px solid var(--border); }
.modul-liste { margin-top: .6rem; }
.modul-zeile {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .5rem 0; border-bottom: 1px solid var(--border);
}
.modul-zeile:last-child { border-bottom: none; }
.modul-checkbox { display: inline-flex; cursor: pointer; }
.modul-checkbox input { width: 1.3rem; height: 1.3rem; cursor: pointer; }
.geraete-limit-form { display: inline-flex; align-items: center; gap: .3rem; }
.geraete-limit-form input { padding: .3rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.hinweis { color: var(--muted); font-size: .82rem; }

/* Job-Status (Mandant anlegen) */
.job-liste { margin: .8rem 0; display: flex; flex-direction: column; gap: .5rem; }
.job-zeile {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .6rem .8rem; border-radius: 8px; border: 1px solid var(--border); flex-wrap: wrap;
}
.job-zeile .hinweis { margin: .2rem 0 0; }
.job-neu, .job-laeuft { background: #fef9c3; }
.job-fertig { background: #dcfce7; }
.job-fehler { background: #fee2e2; }
@media (prefers-color-scheme: dark) {
  .job-neu, .job-laeuft { background: #422006; }
  .job-fertig { background: #14532d; }
  .job-fehler { background: #450a0a; }
}
.badge-job, .badge-job-ok, .badge-job-fehler { font-size: .82rem; margin-left: .5rem; }

/* Modal (Neuen Mandanten anlegen) */
dialog {
  border: none; border-radius: 12px; padding: 0; background: var(--card-bg); color: var(--text);
  max-width: 480px; width: 92vw;
}
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog-form { padding: 1.3rem 1.5rem; display: flex; flex-direction: column; gap: .2rem; }
.dialog-form h2 { margin: 0 0 .3rem; }
.dialog-form .feld input {
  padding: .5rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); width: 100%;
}
.dialog-aktionen { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }
.checkbox-zeile { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); margin-top: .5rem; }
.kontakt-form { margin-top: .6rem; display: flex; flex-direction: column; gap: .5rem; max-width: 320px; }
.kontakt-form input {
  padding: .4rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); width: 100%;
}
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem; }
