:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2733; --muted: #66707d; --line: #dde1e6;
  --accent: #1f6feb; --accent-soft: #e3edff; --ok: #1a7f37; --warn: #9a6700; --bad: #cf222e;
  --ok-bg: #dafbe1; --warn-bg: #fff8c5; --bad-bg: #ffebe9;
  --side: #17212f; --side-text: #c9d3df; --side-muted: #7f8c9c; --side-active: #24344a; --side-line: #263448; --side-strong: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d; --card: #1c2128; --text: #e6edf3; --muted: #8b949e; --line: #30363d;
    --accent: #58a6ff; --accent-soft: #15263d; --ok: #3fb950; --warn: #d29922; --bad: #f85149;
    --ok-bg: #12351f; --warn-bg: #3a2f0b; --bad-bg: #3d1618;
    --side: #0d1117; --side-text: #c9d3df; --side-muted: #6e7a88; --side-active: #1c2a3c; --side-line: #1f2a37; --side-strong: #ffffff;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
h1 { margin: 0; font-size: 20px; text-wrap: balance; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Rahmen: Seitenleiste links (Bereiche), oben Titel + Reiter (Unterpunkte), darunter der Inhalt ---- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.shell.collapsed { grid-template-columns: 64px minmax(0, 1fr); }
aside { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 16px 14px; border-bottom: 1px solid var(--side-line); text-align: center; }
.brand-full { width: 112px; height: 112px; display: block; }
/* Eigenes Logo (Erscheinungsbild): beliebiges Seitenverhältnis, auf heller Fläche, damit auch dunkle Logos auf der dunklen Leiste lesbar sind. */
.brand.custom .brand-full { width: auto; height: auto; max-width: 184px; max-height: 80px; background: #fff; padding: 8px 10px; border-radius: 8px; object-fit: contain; }
.brand.custom .logo { width: 34px; height: 34px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }
.login-brand.custom img { width: auto; height: auto; max-width: 260px; max-height: 110px; object-fit: contain; }
.about.custom img { width: auto; height: auto; max-width: 220px; max-height: 100px; object-fit: contain; }
.brand-preview { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 8px 0 14px; }
.brand-preview img { max-width: 220px; max-height: 90px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--line); vertical-align: middle; margin-right: 6px; }
.brand .logo { display: none; }
.collapsed .brand-full { display: none; }
.collapsed .brand .logo { display: block; }
.collapsed .brand { padding: 14px 8px; }
.logo { width: 34px; height: 34px; flex: none; display: block; }
.brand b { display: block; font-size: 17px; letter-spacing: .01em; color: var(--side-strong); }
.brand small { color: var(--side-muted); font-size: 12px; }
.health { display: flex; align-items: center; gap: 8px; margin: 12px 12px 4px; padding: 8px 10px; border-radius: 8px; background: var(--side-active); font-size: 13px; color: var(--side-text); text-decoration: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--side-muted); flex: none; }
.dot.ok { background: #3fb950; box-shadow: 0 0 0 3px rgba(63, 185, 80, .2); }
.dot.warn { background: #d29922; box-shadow: 0 0 0 3px rgba(210, 153, 34, .2); }
.dot.bad { background: #f85149; box-shadow: 0 0 0 3px rgba(248, 81, 73, .25); }
aside .group { padding: 14px 12px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); }
.navlist { list-style: none; margin: 0; padding: 0 8px; display: grid; gap: 2px; }
.navlist button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 0; border-radius: 8px; background: none; color: var(--side-text); font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
.navlist button:hover { background: var(--side-active); color: var(--side-strong); }
.navlist button[aria-current="page"] { background: var(--side-active); color: var(--side-strong); box-shadow: inset 3px 0 0 var(--accent); }
.navlist li.subgroup { padding: 8px 10px 2px; font-size: 12px; color: var(--side-muted); }
.navlist li.sub button { padding-left: 26px; }
aside .group.spacer { padding: 6px 0 0; border-top: 1px solid var(--side-line); margin-top: 10px; }
.collapsed .navlist li.subgroup { display: none; }
.collapsed .navlist li.sub button { padding-left: 10px; }
.navlist svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.count { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--bad); color: #fff; }
.count.soft { background: #d29922; color: #1d1600; }
.side-foot { margin-top: auto; border-top: 1px solid var(--side-line); padding: 12px 16px; font-size: 13px; color: var(--side-muted); display: grid; gap: 4px; }
.side-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.linkish { background: none; border: 0; padding: 0; color: var(--side-text); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.collapsed .label, .collapsed aside .group, .collapsed .brand-text, .collapsed .count, .collapsed #healthText, .collapsed #logoutSlot { display: none; }
.collapsed .navlist button, .collapsed .health { justify-content: center; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 14px 24px 0; position: sticky; top: 0; z-index: 5; }
.titlerow { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; }
.crumb { font-size: 12px; letter-spacing: .04em; color: var(--muted); }
.menu-btn { display: none; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 5px 10px; cursor: pointer; font: inherit; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: thin; }
.tabs button { border: 0; background: none; padding: 8px 14px 11px; font: inherit; font-size: 14px; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.devbar { background: var(--warn-bg); color: var(--warn); font-weight: 600; padding: 8px 24px; border-bottom: 1px solid var(--line); }
.devbar small { display: block; font-weight: 400; }
.supportbar.inside { background: var(--bad-bg); color: var(--bad); border-bottom-color: var(--bad); }
.supportbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--accent-soft); color: var(--accent); font-weight: 600; padding: 8px 24px; border-bottom: 2px solid var(--accent); }
#view { padding: 24px; max-width: 1100px; width: 100%; min-width: 0; }
/* Breite Tabellen (Mitarbeiter): den Platz nutzen, statt bei 1100 px umzubrechen. */
#view:has(.card.wide) { max-width: 1800px; }
.backdrop { display: none; }
@media (max-width: 860px) {
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); }
  aside { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .shell.open aside { transform: none; }
  .shell.open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 15; }
  .shell.collapsed .label, .shell.collapsed aside .group, .shell.collapsed .brand-text, .shell.collapsed #healthText, .shell.collapsed #logoutSlot, .shell.collapsed .brand-full { display: revert; }
  .shell.collapsed .brand .logo { display: none; }
  .shell.collapsed .brand { padding: 18px 16px 14px; }
  .menu-btn { display: inline-block; }
  #collapse { display: none; }
  .topbar { padding: 12px 16px 0; }
  #view { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { aside { transition: none; } }

/* Mitarbeiter: eine Tabelle für alle Funktionen */
table.matrix th.center, table.matrix td.center { text-align: center; }
table.matrix th { white-space: nowrap; }
table.matrix td input[type="checkbox"] { width: 17px; height: 17px; }
table.matrix .grp { border-left: 1px solid var(--line); }
table.matrix tr.groups th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 0; padding-bottom: 0; }
table.matrix td select { min-width: 9em; }
.colbtns { display: flex; gap: 4px; justify-content: center; margin-top: 3px; }
button.mini { font: inherit; font-size: 11px; font-weight: 400; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); color: var(--muted); cursor: pointer; }
button.mini:hover { color: var(--text); border-color: var(--muted); }
.table-wrap { overflow-x: auto; }
.savebar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0 0; }
details.small { font-size: 13px; margin-top: 10px; }
details.small summary { cursor: pointer; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px 20px; margin-bottom: 16px; }
.banner { border-radius: 8px; padding: 14px 18px; margin-bottom: 16px; font-weight: 600; }
.banner small { display: block; font-weight: 400; margin-top: 2px; }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.row { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(160px, 260px) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .help { color: var(--muted); font-size: 13px; }
input[type="number"], input[type="text"], input[type="password"], select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); width: 100%; }
textarea { min-height: 70px; }
a.button { display: inline-block; text-decoration: none; }
button.primary, button.secondary, a.button.primary, a.button.secondary { font: inherit; padding: 7px 14px; border-radius: 6px; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--text); }
button.primary, a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
button:disabled { opacity: .5; cursor: default; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--line); color: var(--muted); margin-left: 6px; }
.badge.over { background: var(--warn-bg); color: var(--warn); }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field .help { color: var(--muted); font-size: 13px; margin-top: 3px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 8px; background: var(--text); color: var(--bg); opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.error { background: var(--bad); color: #fff; }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); } .warn-text { color: var(--warn); }
@media (max-width: 700px) { .row { grid-template-columns: 1fr; } }
.hidden { display: none; }
.mt { margin-top: 6px; }
.block { display: block; margin: 4px 0; }

/* Auswahl der Aktionen-Liste: Schnellwahl, Zeitraum, Suche */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 6px; }
.filters input[type="date"] { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); }
.filters input[type="text"] { width: auto; flex: 1 1 220px; min-width: 180px; }


/* Info: Versionshistorie und Hilfe */
h2.section { margin: 24px 0 10px; font-size: 16px; color: var(--muted); }
details.help { padding: 0; }
details.help > summary { cursor: pointer; padding: 14px 18px; list-style-position: inside; }
details.help[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
details.help > :not(summary) { margin-left: 18px; margin-right: 18px; }
details.help > :last-child { margin-bottom: 16px; }
.help-list { padding-left: 22px; }
.help-list li { margin: 6px 0; }

/* Logo unter Info */
.about { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.about img { width: 120px; height: 120px; flex: none; }
.about-name { font-size: 20px; font-weight: 700; }
.about-maker { margin-top: 8px; font-size: 13px; color: var(--muted); }

/* Anmeldeseite: eine Spalte in der Mitte (Logo, Name, Formular) */
body.login-page { min-height: 100vh; }
/* Senkrecht gestapelt statt Raster: Elemente, die Browser-Erweiterungen (z. B. Passwort-Manager) in die Seite schieben, landen darunter und schieben die Karte nicht zur Seite. */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.login > * { flex: none; }
.login-box { width: 100%; max-width: 24rem; display: grid; gap: 20px; }
.login-brand { display: grid; justify-items: center; gap: 2px; text-align: center; }
.login-brand img { width: 132px; height: 132px; margin-bottom: 8px; }
.login-brand h1 { font-size: 24px; }
.login-card { padding: 22px 24px 24px; }
.login-card h2 { margin-bottom: 6px; }
.login-card .field { margin-bottom: 16px; }
.login-card p.muted { margin: 0 0 16px; font-size: 14px; }
button.wide { width: 100%; padding: 9px 14px; }
.or { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
#form.hidden + #windows .or { display: none; }
.or.hidden { display: none; }   /* sonst gewinnt .or (später in der Datei) gegen .hidden: Trennlinie ohne etwas darunter (Portal: nur Microsoft) */
#message:not(.hidden) { margin: 14px 0 0; }

/* Rollen: "Nur lesen" sieht keine Speicherknöpfe (der Server lehnt Änderungen ohnehin ab); Benutzerseite */
body[data-readonly="true"] #view button.primary, body[data-readonly="true"] #view button.mini { display: none; }
.readonly-note { background: var(--accent-soft); color: var(--accent); font-weight: 600; padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; }
input.rolename { width: 9rem; text-align: center; }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; word-break: break-all; }
.adduser { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(140px, 1fr) auto; gap: 12px; align-items: end; }
.adduser .field { margin-bottom: 0; }
@media (max-width: 700px) { .adduser { grid-template-columns: 1fr; } }
/* Betreiber: Mandant löschen (Bestätigung mit dem Namen) */
.remove-box { margin-top: 8px; display: grid; gap: 6px; max-width: 340px; }
.remove-box[hidden] { display: none; }
button.danger { border-color: var(--bad); color: var(--bad); }
/* Einrichtungscode (System → Einrichtung): groß, gut lesbar, mit Knopf zum Kopieren */
.setup-code { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--accent-soft); }
.setup-code strong { font-size: 22px; letter-spacing: .08em; user-select: all; }

/* Betreiber: Abrechnungsart als unauffälliger Knopf unter der Benutzerzahl */
button.link { background: none; border: none; padding: 0; margin-top: 2px; font: inherit; font-size: 0.85em; cursor: pointer; text-decoration: underline dotted; color: inherit; }
