/* ---------- Schrift ----------
   "Inter" wird lokal ausgeliefert (frontend/static/fonts/), damit die App
   ohne Internetzugang identisch aussieht - im Firmennetz sind externe
   Font-CDNs oft blockiert. Genau EINE Schrift fuer die gesamte Anwendung;
   wo Ziffern untereinander stehen sollen (KW-Liste, Ring, Uhrzeiten) sorgt
   font-variant-numeric: tabular-nums fuer gleiche Ziffernbreiten, statt wie
   frueher auf eine zweite (Monospace-)Schrift zu wechseln. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --bg: #f5f7fa;
  --panel: #ffffff;
  --border: #e4e8ef;
  --text: #172033;
  --muted: #64748b;
  --input-bg: #f8fafc;
  --ring-track: #e8ecf2;
  --hover-overlay: rgba(100, 116, 139, 0.09);
  --hover-overlay-strong: rgba(5, 150, 105, 0.12);

  --c-anwesend: #059669;
  --c-krank: #d97706;
  --c-urlaub: #2563eb;
  --c-entschuldigt: #7c3aed;
  --c-unentschuldigt: #dc2626;
  --c-nicht-erfasst: #94a3b8;

  /* Ampelstufen fuer Auslastung (Ring + Verlaufsbalken): jeweils ein
     dunklerer und ein hellerer Ton, aus denen der Farbverlauf entsteht. */
  --c-stufe-niedrig: #dc2626;
  --c-stufe-niedrig-hell: #f87171;
  --c-stufe-mittel: #d97706;
  --c-stufe-mittel-hell: #fbbf24;
  --c-stufe-hoch: #059669;
  --c-stufe-hoch-hell: #34d399;

  /* Hinweis-/Warnbaender (Nur-Lese-Banner, Gehaltswarnung) */
  --warn-bg: #fef6dc;
  --warn-text: #92400e;
  --warn-border: #fcd34d;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 25, 35, 0.04), 0 6px 20px rgba(20, 25, 35, 0.05);
}

/* Dunkles Schema bewusst als weiches, entsaettigtes Schiefergrau statt als
   Fast-Schwarz - angenehmer fuer lange Arbeitssitzungen und aktuell die
   verbreitetste Umsetzung (Slate-Palette). Flaechen heben sich klar
   voneinander ab: Hintergrund < Panel < Eingabefeld. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b212c;
  --panel: #242c39;
  --border: #38414f;
  --text: #e9eef6;
  --muted: #a3aec0;
  --input-bg: #2d3643;
  --ring-track: #38414f;
  --hover-overlay: rgba(255, 255, 255, 0.07);
  --hover-overlay-strong: rgba(16, 185, 129, 0.18);

  --c-anwesend: #0ea472;
  --c-krank: #e08c07;
  --c-urlaub: #3b7ff0;
  --c-entschuldigt: #8b5cf6;
  --c-unentschuldigt: #e14b4b;
  --c-nicht-erfasst: #7a8699;

  --c-stufe-niedrig: #e14b4b;
  --c-stufe-niedrig-hell: #f87171;
  --c-stufe-mittel: #e08c07;
  --c-stufe-mittel-hell: #fbbf24;
  --c-stufe-hoch: #0ea472;
  --c-stufe-hoch-hell: #34d399;

  --warn-bg: #3f3419;
  --warn-text: #fcd34d;
  --warn-border: #6f5a1d;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.26), 0 6px 20px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
  transition: background 0.15s ease, color 0.15s ease;
}

/* Formularelemente erben die Schrift nicht automatisch vom body. */
input,
select,
textarea,
button {
  font-family: inherit;
}

/* Ziffern gleicher Breite, damit Listen sauber untereinander stehen. */
.tabellen-ziffern {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(155deg, #1b212c 0%, #14342a 48%, #059669 130%);
}

.login-card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  font-size: 20px;
  margin: 0;
}

.login-sub {
  margin: -8px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.login-card input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--panel);
  color: var(--text);
}

.login-card button {
  margin-top: 8px;
  background: var(--c-anwesend);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.login-error {
  color: var(--c-unentschuldigt);
  font-size: 13px;
  min-height: 16px;
}

/* ---------- App shell ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.app-header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin: 0;
}

.header-right { display: flex; gap: 8px; flex-wrap: wrap; }

.profil-wrap { position: relative; }
.einstellungen-wrap { position: relative; }
.einstellungen-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.einstellungen-dropdown-item {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.einstellungen-dropdown-item:hover { background: var(--hover-overlay); }
.profil-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  max-width: calc(100vw - 32px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 16px;
  z-index: 40;
}
.profil-menu .inline-form { flex-direction: column; }
.profil-menu .inline-form input { flex: 1 1 auto; }
.profil-menu .settings-hint { margin: 0 0 12px; font-size: 12px; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.ghost-btn:hover { background: var(--hover-overlay); }
.ghost-btn.nav-active {
  background: var(--c-anwesend);
  border-color: var(--c-anwesend);
  color: white;
}
.ghost-btn.nav-active:hover { background: #047857; }

.main-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: auto auto auto auto;
  gap: 20px;
  padding: 24px 32px 48px;
  max-width: 1280px;
  margin: 0 auto;
}

.search-panel {
  grid-column: 1 / -1;
  grid-row: 1;
  position: relative;
  z-index: 20;
}

.readonly-banner {
  grid-column: 1 / -1;
  grid-row: 1;
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
}

.header-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.kw-select {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  min-width: 240px;
}
.search-label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.search-wrap { position: relative; }
#mitarbeiter-suche {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  background: var(--panel);
  color: var(--text);
}
#mitarbeiter-suche:focus {
  outline: none;
  border-color: var(--c-anwesend);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}
.suche-ergebnisse {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  z-index: 30;
}
.suche-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.suche-item:last-child { border-bottom: none; }
.suche-item:hover { background: var(--hover-overlay-strong); }
.suche-status {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  color: white;
}
.suche-leer, .suche-fehler {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  position: relative;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.panel:hover {
  box-shadow: 0 2px 4px rgba(20, 25, 35, 0.05), 0 10px 28px rgba(20, 25, 35, 0.07);
}
[data-theme="dark"] .panel:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.4);
}

/* Drag-Griff zum freien Verschieben (Neuanordnen) einer Kachel per Hand.
   Nur innerhalb .settings-grid-Ansichten aktiv (siehe JS initKachelnDraggable). */
.kachel-drag-handle {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: grab;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  user-select: none;
  z-index: 5;
  touch-action: none;
}
.kachel-drag-handle:hover { background: var(--hover-overlay); color: var(--text); }
.kachel-drag-handle:active { cursor: grabbing; }

.panel.kachel-dragging {
  opacity: 0.45;
}
.panel.kachel-drop-before {
  box-shadow: 0 -3px 0 0 var(--c-anwesend), var(--shadow);
}
.panel.kachel-drop-after {
  box-shadow: 0 3px 0 0 var(--c-anwesend), var(--shadow);
}

.ring-panel {
  grid-column: 1;
  grid-row: 2 / span 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.ring-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  max-width: 100%;
}
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--ring-track); stroke-width: 14; }
.ring-progress {
  fill: none;
  /* Die eigentliche Farbe kommt aus dem SVG-Verlauf, dessen beide Stopp-
     Farben je nach Auslastungsstufe (rot/gelb/gruen) in app.js gesetzt
     werden - siehe renderRingUndBreakdown(). */
  stroke: url(#ring-gradient);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 515.2;
  stroke-dashoffset: 515.2;
  transition: stroke-dashoffset 0.5s ease;
}
/* Die Verlaufsstopps selbst weich ueberblenden, damit der Farbwechsel beim
   Stufenwechsel nicht hart umspringt. */
.ring-gradient-stop {
  transition: stop-color 0.45s ease;
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#ring-count {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.ring-caption { color: var(--muted); font-size: 13px; margin-top: 2px; }
.ring-overflow {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--c-stufe-hoch);
  background: var(--hover-overlay-strong);
  padding: 3px 9px;
  border-radius: 20px;
}

.breakdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.breakdown-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.breakdown-list .count { margin-left: auto; font-weight: 600; }

.cards-panel { grid-column: 2; grid-row: 2; }
.abwesend-panel { grid-column: 2; grid-row: 3; }
.history-panel { grid-column: 2; grid-row: 4; }

.panel-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel h2 { margin: 0 0 14px; font-size: 15px; }
.muted { color: var(--muted); font-size: 12.5px; }

.mitarbeiter-verwaltung-kopf {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
#mitarbeiter-filter {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  background: var(--input-bg);
  color: var(--text);
}
#btn-neuer-mitarbeiter-oeffnen,
#btn-neuer-mitarbeiter-anwesenheit-oeffnen {
  flex-shrink: 0;
  background: var(--c-anwesend);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease;
}
#btn-neuer-mitarbeiter-oeffnen:hover,
#btn-neuer-mitarbeiter-anwesenheit-oeffnen:hover { background: #047857; }
#mitarbeiter-filter-leer { margin: 0 0 10px; }

.employee-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.employee-group-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 2px;
  padding-left: 2px;
}
.employee-group-header:first-child { margin-top: 0; }

.employee-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #eef1f6;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.emp-meta { flex: 1; min-width: 0; }
.emp-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-funktion { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.funktion-input {
  width: 78px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  color: var(--text);
  background: var(--input-bg);
}
.funktion-input:focus {
  outline: none;
  border-color: var(--c-anwesend);
  background: var(--panel);
}
.funktion-input::placeholder { color: #8890a0; }

.status-select {
  border: none;
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  appearance: none;
  text-align: center;
}

.status-anwesend { background: var(--c-anwesend); }
.status-krank { background: var(--c-krank); }
.status-urlaub { background: var(--c-urlaub); }
.status-fehlt_entschuldigt { background: var(--c-entschuldigt); }
.status-fehlt_unentschuldigt { background: var(--c-unentschuldigt); }
.status-nicht_erfasst { background: var(--c-nicht-erfasst); color: #2c3542; }

.entfernen-btn {
  background: none;
  border: none;
  color: var(--c-unentschuldigt);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  padding: 4px 6px;
  border-radius: 6px;
}
.entfernen-btn:hover { background: var(--hover-overlay); }

.stempel-select {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  background: var(--input-bg);
  cursor: pointer;
  flex-shrink: 0;
}
.stempel-badge {
  background: var(--hover-overlay);
  color: var(--muted);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}
.history-row {
  display: grid;
  grid-template-columns: 210px 1fr 70px;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 8px;
}
.history-row:hover { background: var(--hover-overlay); }
.history-label {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-bar-track {
  height: 10px;
  border-radius: 6px;
  background: var(--ring-track);
  overflow: hidden;
}
.history-bar-fill {
  height: 100%;
  background: var(--c-anwesend);
  border-radius: 6px;
  transition: width 0.3s ease, background 0.2s ease;
}
.history-ratio {
  font-size: 12.5px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Gleiche Ampelstufen wie beim Ring (<75 % rot, <90 % gelb, ab 90 % gruen),
   damit Ring und Verlauf dieselbe Farbsprache sprechen. */
.history-ratio-niedrig { color: var(--c-stufe-niedrig); }
.history-label-niedrig { color: var(--c-stufe-niedrig); }
.history-bar-fill-niedrig {
  background: linear-gradient(90deg, var(--c-stufe-niedrig), var(--c-stufe-niedrig-hell));
}
.history-ratio-mittel { color: var(--c-stufe-mittel); }
.history-label-mittel { color: var(--c-stufe-mittel); }
.history-bar-fill-mittel {
  background: linear-gradient(90deg, var(--c-stufe-mittel), var(--c-stufe-mittel-hell));
}
.history-ratio-hoch { color: var(--c-stufe-hoch); }
.history-label-hoch { color: var(--c-stufe-hoch); }
.history-bar-fill-hoch {
  background: linear-gradient(90deg, var(--c-stufe-hoch), var(--c-stufe-hoch-hell));
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 28, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  width: 520px;
  max-width: 92vw;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-header h2 { margin: 0; font-size: 16px; }
.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.inline-form input {
  flex: 1 1 140px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
}
.inline-form input[type="file"] {
  flex: 1 1 220px;
}
.inline-form button {
  background: var(--c-anwesend);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s ease, transform 0.08s ease;
}
.inline-form button:hover { background: #047857; }
.inline-form button:active { transform: scale(0.98); }

.manage-list { display: flex; flex-direction: column; gap: 8px; }
.manage-list-scroll {
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
}
.manage-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.manage-row input {
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 6px;
}
.manage-row input:focus { border-color: var(--border); background: var(--panel); }
.manage-row .manage-name { flex: 1.3 1 120px; }
.manage-row .manage-funktion { flex: 1 1 100px; }
.manage-row button {
  background: none;
  border: none;
  color: var(--c-unentschuldigt);
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
}

.manage-row-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.manage-row-stacked .manage-name {
  width: 100%;
  flex: none;
  font-weight: 600;
  font-size: 14px;
  padding: 6px 8px;
  white-space: normal;
  word-break: break-word;
}
.manage-row-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.manage-row-sub .manage-funktion { flex: 1 1 100px; min-width: 0; }
.manage-row-sub .manage-firma {
  flex: 1 1 140px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
}
.manage-row-sub button { flex-shrink: 0; }

.rolle-name { flex: 1; font-size: 13.5px; font-weight: 600; }
.firma-auswahl-row .rolle-name { cursor: pointer; }
.firma-auswahl-row.firma-auswahl-aktiv {
  background: var(--hover-overlay);
  border-color: var(--c-anwesend);
}
.rolle-reorder { display: flex; gap: 4px; }
.rolle-reorder button {
  background: var(--hover-overlay);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.rolle-reorder button:disabled { opacity: 0.35; cursor: default; }
.rolle-reorder button:hover:not(:disabled) { background: var(--hover-overlay-strong); }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 0 0;
  align-self: center;
}
.login-hint { font-size: 12.5px; color: var(--muted); min-height: 16px; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.user-abteilungen-liste {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  width: 100%;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.kw-detail-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.kw-detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kw-detail-row .badge {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: white;
}

/* Frueher CSS-Mehrspalten-Layout (column-width): dabei war die Breite jeder
   Kachel an die feste Spaltenbreite (360px) gekoppelt - eigenstaendige
   Breitenaenderung per Resize-Griff (z.B. bei "Mitarbeiter verwalten")
   griff dadurch effektiv nicht. Jetzt: echtes Flex-Wrap-Layout, jede Kachel
   traegt ihre eigene Breite/Position und ist frei per Hand skalier- und
   verschiebbar (siehe initKachelnResizable / initKachelnDraggable in app.js). */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 32px 48px;
  max-width: 1100px;
  margin: 0 auto;
}
.settings-hint { margin: -4px 0 14px; line-height: 1.5; }
#form-settings input[type="number"] { max-width: 140px; }
#import-result { margin-top: 4px; min-height: 16px; }

/* Jede Kachel ist jetzt eine volle-Breite-Zeile statt einer schmalen,
   unterschiedlich hohen Box neben anderen - dadurch entstehen keine
   Luecken mehr zwischen Kacheln unterschiedlicher Hoehe. */
.settings-grid > .panel {
  width: 100%;
  margin: 0;
}

/* Zwei thematisch verwandte, meist kurze Bereiche in EINER Zeile mit
   gemeinsamem Rahmen, aber zwei Spalten (siehe .kachel-spalte). */
.kachel-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.kachel-spalte h3 {
  font-size: 15px;
  margin: 0 0 10px;
  font-weight: 600;
}
.kachel-spalte:not(:first-child) {
  border-left: 1px solid var(--border);
  padding-left: 28px;
}
@media (max-width: 760px) {
  .kachel-row { grid-template-columns: 1fr; }
  .kachel-spalte:not(:first-child) {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 18px;
  }
}

@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
  .search-panel, .readonly-banner { grid-column: 1; grid-row: 1; }
  .ring-panel { grid-column: 1; grid-row: 2; }
  .cards-panel { grid-column: 1; grid-row: 3; }
  .abwesend-panel { grid-column: 1; grid-row: 4; }
  .history-panel { grid-column: 1; grid-row: 5; }
}

/* ---------- Mobil / Tablet ---------- */
@media (max-width: 720px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
  }
  .header-left,
  .header-right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .header-select {
    width: 100%;
    min-width: 0;
  }
  .kw-select { min-width: 0; }
  .ghost-btn { width: 100%; text-align: center; }
  .profil-wrap { width: 100%; }
  #btn-profil { width: 100%; }
  .profil-menu {
    left: 0;
    right: 0;
    width: auto;
  }

  .main-grid,
  .settings-grid {
    padding-left: 16px;
    padding-right: 16px;
  }

  .settings-grid > .panel {
    width: 100% !important;
  }
  .kachel-drag-handle { display: none; }

  .employee-card {
    flex-wrap: wrap;
  }
  .emp-meta { flex: 1 1 100%; }
  .funktion-input { flex: 1 1 120px; width: auto; }
  .status-select { flex: 1 1 140px; }
  .stempel-select { flex: 1 1 140px; }

  .history-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "label ratio"
      "bar bar";
    row-gap: 6px;
  }
  .history-label { grid-area: label; }
  .history-ratio { grid-area: ratio; }
  .history-bar-track { grid-area: bar; }

  .kw-detail-row { flex-wrap: wrap; }

  .login-card { width: 320px; max-width: 88vw; padding: 32px 24px; }
}

/* ---------- Berichte ---------- */
.bericht-zeitraum-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.bericht-zeitraum-label input[type="week"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
}
#bericht-ausgewaehlter-mitarbeiter { margin: 8px 0 16px; font-weight: 600; }
.bericht-name { margin: 4px 0 2px; font-size: 16px; }
.bericht-zusammenfassung { margin: 16px 0; }
.bericht-liste {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
  margin-top: 12px;
}

/* ---------- Gehalt-Kalkulation ---------- */
.gehalt-search-wrap { position: relative; }
.gehalt-config-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 12px 16px;
  margin-top: 10px;
}
.gehalt-config-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.gehalt-config-form input,
.gehalt-config-form select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--input-bg);
  color: var(--text);
}
.gehalt-config-form .form-span-2 { grid-column: 1 / -1; }
#form-neuer-mitarbeiter-modal button {
  background: var(--c-anwesend);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease;
}
#form-neuer-mitarbeiter-modal button:hover { background: #047857; }
.gehalt-rollen-hinweis {
  grid-column: 1 / -1;
  margin: 8px 0 -2px;
  line-height: 1.5;
}
.gehalt-config-form button {
  grid-column: 1 / -1;
  margin-top: 4px;
}
.gehalt-grenzen-form {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 10px;
}
.gehalt-grenzen-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.gehalt-grenzen-form input[type="time"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  background: var(--input-bg);
  color: var(--text);
}
.gehalt-berechnen-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.gehalt-berechnen-form input[type="month"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--input-bg);
  color: var(--text);
}
.gehalt-ergebnis { margin-top: 18px; }
.gehalt-summe-karte {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.gehalt-summe-betrag {
  font-size: 26px;
  font-weight: 700;
  color: var(--c-anwesend);
}
.gehalt-summe-zeile {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--muted);
}
.gehalt-summe-zeile span:last-child { color: var(--text); font-weight: 600; }
.gehalt-summe-trennlinie {
  border-top: 1px dashed var(--border);
  margin: 10px 0;
}
.gehalt-betrag-ueber-grenze {
  color: var(--c-unentschuldigt) !important;
  font-weight: 700 !important;
}
.gehalt-warnung {
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.5;
}
.gehalt-tage-titel {
  font-size: 14px;
  margin: 0 0 8px;
}
.gehalt-samstage-liste {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.gehalt-samstag-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.gehalt-samstag-zeile:last-child { border-bottom: none; }
.gehalt-samstag-details {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  color: var(--muted);
}
.gehalt-samstag-betrag { font-weight: 700; color: var(--text); }
.gehalt-rollen-badge {
  background: var(--hover-overlay);
  color: var(--text);
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.gehalt-hinweis {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.5;
}

/* ---------- Urlaub/Fehltage vorausplanen (bewusst KEINE Kachel: kein
   resize/drag, volle Breite, dezent andere Optik als die .panel-Kacheln) ---------- */
.plane-abwesenheit {
  flex: 1 1 100%;
  width: 100%;
  background: var(--input-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 4px;
}
.plane-abwesenheit h2 { margin: 0 0 8px; }
.plane-abwesenheit .settings-hint { margin-bottom: 14px; }
.plane-abwesenheit select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
}
#plane-ausgewaehlter-mitarbeiter { font-weight: 600; margin: 8px 0 14px; }
#plane-ergebnis-hinweis { min-height: 16px; margin-top: 4px; }
.plane-liste-titel { font-size: 14px; margin: 0; }
.plane-liste {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.plane-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.plane-row-name { font-weight: 600; flex: 1 1 160px; }
.plane-row-wochen {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 2 1 240px;
}
.plane-kw-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--hover-overlay);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 6px 3px 10px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}
.plane-kw-chip-entfernen {
  background: none;
  border: none;
  color: var(--c-unentschuldigt);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  line-height: 1;
}
.plane-row button { flex-shrink: 0; }

.zeit-eingabe {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.zeit-eingabe input {
  width: 52px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  background: var(--input-bg);
  color: var(--text);
  /* Auf-/Ab-Pfeile ausblenden - wirkt bei einer Uhrzeit-Eingabe unpassend */
  -moz-appearance: textfield;
}
.zeit-eingabe input::-webkit-outer-spin-button,
.zeit-eingabe input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.zeit-eingabe span { color: var(--muted); font-weight: 600; }

/* ---------- Einlass / Pforte ----------
   Eigene Farbsemantik neben den Anwesenheitsfarben: gruen = Einlass und Abteilung
   stimmen ueberein, gelb = im Werk aber keiner Abteilung zugeordnet, rot =
   beide Seiten widersprechen sich. */

.einlass-kennzahlen {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.einlass-kennzahl {
  flex: 1 1 110px;
  min-width: 100px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--input-bg);
}
.einlass-kennzahl-wert {
  display: block;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.einlass-kennzahl-titel {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.einlass-kennzahl-ok .einlass-kennzahl-wert { color: var(--c-anwesend); }
.einlass-kennzahl-warn .einlass-kennzahl-wert { color: var(--c-krank); }
.einlass-kennzahl-krit .einlass-kennzahl-wert { color: var(--c-unentschuldigt); }

.einlass-such-kopf {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.einlass-such-kopf input {
  flex: 1 1 220px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--input-bg);
  color: var(--text);
}
.einlass-such-kopf button {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.einlass-such-kopf button:hover { background: var(--hover-overlay); }

.einlass-filter-zeile { margin-bottom: 10px; }

.einlass-row { gap: 10px; }
.einlass-row .emp-meta { flex: 1 1 160px; }
.einlass-row-erschienen { background: var(--hover-overlay-strong); }
.einlass-row-ungeklaert { border-left: 3px solid var(--c-krank); }
.einlass-row-widerspruch { border-left: 3px solid var(--c-unentschuldigt); }

.einlass-badge {
  flex-shrink: 0;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--hover-overlay);
  color: var(--muted);
}
.einlass-badge-bestaetigt { background: rgba(5, 150, 105, 0.14); color: var(--c-anwesend); }
.einlass-badge-ungeklaert { background: rgba(217, 119, 6, 0.16); color: var(--c-krank); }
.einlass-badge-widerspruch { background: rgba(220, 38, 38, 0.14); color: var(--c-unentschuldigt); }

.einlass-row button[data-einlass-toggle] {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  background: var(--input-bg);
}
.einlass-row button.einlass-btn-einlassen { color: var(--c-anwesend); }
.einlass-row button.einlass-btn-zurueck { color: var(--muted); }
.einlass-row button[data-einlass-toggle]:hover { background: var(--hover-overlay); }

.einlass-hinweis-text {
  width: 100%;
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.einlass-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--hover-overlay);
  color: var(--muted);
}
.einlass-chip-ok { background: rgba(5, 150, 105, 0.14); color: var(--c-anwesend); }

.einlass-verteilung { display: flex; flex-direction: column; gap: 8px; }
.einlass-verteilung-zeile {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 2fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.einlass-verteilung-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.einlass-verteilung-balken {
  height: 8px;
  border-radius: 999px;
  background: var(--ring-track);
  overflow: hidden;
}
.einlass-verteilung-fuellung {
  display: block;
  height: 100%;
  background: var(--c-anwesend);
  border-radius: 999px;
}
.einlass-verteilung-zahl {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-weight: 600;
  color: var(--muted);
  min-width: 26px;
  text-align: right;
}

.einlass-pool-hinweis { margin: 6px 0 10px; }

/* Trennzeile in der Anwesenheits-Suche zwischen eigener Abteilung und Pool */
.suche-gruppe {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--input-bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.suche-item-pool .emp-funktion { color: var(--muted); }

/* ---------- Benutzerverwaltung: Bereiche & Passwort ---------- */

.user-rechte-block {
  width: 100%;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.user-rechte-kopf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.user-rechte-titel {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.user-vorlage,
#new-user-vorlage {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12.5px;
  background: var(--panel);
  color: var(--text);
  max-width: 100%;
}
.user-rechte-liste {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}
.bereich-checkbox { white-space: nowrap; }

.user-passwort-zeile {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.user-passwort-zeile input {
  flex: 1 1 160px;
  border: 1px solid var(--border) !important;
  background: var(--input-bg) !important;
  border-radius: 8px;
  padding: 6px 8px;
}
.user-passwort-zeile button {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--input-bg);
  color: var(--text) !important;
  cursor: pointer;
}
.user-passwort-zeile button:hover { background: var(--hover-overlay); }

@media (max-width: 700px) {
  .einlass-verteilung-zeile { grid-template-columns: 1fr auto; }
  .einlass-verteilung-balken { display: none; }
}

/* ---------- Einlass: Export ---------- */

.einlass-export-knoepfe {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 10px;
}
.einlass-export-knoepfe button {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.einlass-export-knoepfe button:hover { background: var(--hover-overlay); }

/* ---------- Benutzerverwaltung: Startreiter ---------- */

.user-startreiter-zeile {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.user-startreiter-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.user-startreiter,
#new-user-startreiter {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12.5px;
  background: var(--panel);
  color: var(--text);
  max-width: 100%;
}
