/* ============================================================
   Alpha Power Tool — Main Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');
@import url('variables.css');

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font-sans); }
input, select, textarea { font-family: var(--font-sans); }

/* ============================================================
   Layout
   ============================================================ */
.apt-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   Sidebar — ausklappbar mit Pin-Funktion
   ============================================================ */
.apt-sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  border-right: 0.5px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.25s ease, width 0.25s ease;
  z-index: 200;
  /* --sb-text-2/3/4 kommen aus variables.css (je Palette definiert) */
}

/* Overlay (Mobile) */
.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
}
.sb-overlay.active { display: block; }

/* Mobile/Desktop-Modus wird per JS über die kleinere Bildschirmseite bestimmt
   (Klasse html.viewport-mobile, siehe base.html <head>) statt reiner Breite —
   ein Handy im Querformat bleibt so zuverlässig im Mobile-Drawer-Modus. */

/* Mobile: Sidebar als Drawer von links */
html.viewport-mobile .apt-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width) !important;
  transform: translateX(-100%);
  box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  /* Aus dem Flex-Flow nehmen */
  flex-shrink: 0;
  margin-right: -220px;
}
html.viewport-mobile .apt-layout.sb-open .apt-sidebar {
  transform: translateX(0);
}
html.viewport-mobile .apt-layout.sb-open .sb-overlay {
  display: block;
}
html.viewport-mobile .apt-main {
  width: 100%;
  min-width: 0;
}
/* Topbar auf Mobile: genug Platz für Hamburger */
html.viewport-mobile .apt-topbar {
  padding: 0 12px;
  gap: 8px;
}

/* Desktop/Tablet: Sidebar kollabierbar, aber kein Overlay */
html:not(.viewport-mobile) .apt-layout.sb-collapsed .apt-sidebar {
  width: 0;
  border-right: none;
  overflow: hidden;
}
/* Pinned = immer sichtbar, kein Collapse */
html:not(.viewport-mobile) .apt-layout.sb-pinned .apt-sidebar {
  transform: none !important;
  width: var(--sidebar-width) !important;
}

.apt-sidebar::-webkit-scrollbar { width: 3px; }
.apt-sidebar::-webkit-scrollbar-track { background: transparent; }
.apt-sidebar::-webkit-scrollbar-thumb { background: var(--tint-4); border-radius: 3px; }

.sidebar-logo {
  padding: 18px 18px 14px;
  border-bottom: 0.5px solid var(--color-border);
  flex-shrink: 0;
  text-align: center;
}
.sidebar-logo-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sidebar-logo-sub {
  font-size: 10px;
  color: var(--sb-text-4);
  margin-top: 2px;
}

/* ── Suche (⌘K / Strg+K) ──────────────────────────────────────── */
.sb-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 10px 4px;
  padding: 7px 9px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--sb-text-3);
  font-size: 11.5px;
  cursor: pointer;
  transition: var(--transition);
}
.sb-search:hover { border-color: var(--color-border-hover); color: var(--sb-text-2); }
.sb-search i { font-size: 13px; flex-shrink: 0; }
.sb-search span { flex: 1; }
.sb-kbd {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--sb-text-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}

/* ── Favoriten (jetzt Teil von "Übersicht & Favoriten", kein eigener Block mehr) ── */
.sb-fav-empty {
  font-size: 11px;
  color: var(--sb-text-4);
  padding: 6px 8px;
  font-style: italic;
}

.sidebar-section {
  padding: 10px 10px 4px;
}
.sidebar-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--sb-text-3);
  padding: 5px 8px;
  margin-bottom: 2px;
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}
.sidebar-section-label:hover { background: var(--tint-1); color: var(--sb-text-2); }
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  color: var(--sb-text-3);
  font-size: 12.5px;
  margin-bottom: 1px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}
.sidebar-item:hover {
  background: var(--tint-2);
  color: var(--sb-text-2);
}
.sidebar-item.active {
  background: var(--color-accent-dim);
  color: var(--color-accent);
}
.sidebar-item i { font-size: 15px; flex-shrink: 0; }
.sidebar-item .itemtext { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Farbige Icon-Chips je Modul — nutzt die längst vorhandenen --color-mod-*-Töne,
   die vorher im Menü gar nicht verwendet wurden. Farbe kommt als Inline-Style
   (style="--chip:...") direkt am .sb-chip-Element in base.html. */
.sb-chip {
  width: 21px;
  height: 21px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--chip-bg, var(--tint-3));
}
.sb-chip i { font-size: 13px; color: var(--chip-fg, var(--sb-text-2)); }
.sidebar-item.active .sb-chip { background: var(--color-accent-mid) !important; }
.sidebar-item.active .sb-chip i { color: var(--color-accent) !important; }

/* Anpinnen-Stern je Menüpunkt (Favoriten) */
.sb-star {
  opacity: 0;
  font-size: 13px !important;
  color: var(--sb-text-4) !important;
  flex-shrink: 0;
  transition: var(--transition);
  padding: 2px;
}
.sidebar-item:hover .sb-star { opacity: .7; }
.sb-star:hover { opacity: 1 !important; color: var(--color-accent) !important; }
.sb-star.pinned { opacity: 1; color: var(--color-accent) !important; }

/* Sichtbarer, aber noch nicht verlinkter Menüpunkt (z.B. "Verträge" — bewusst nicht
   ausgeblendet, Umsetzung folgt). Kein <a>, daher kein hover/active-Zustand nötig. */
.sidebar-item-soon { opacity: .62; cursor: default; }
.sb-soon-badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--color-warning);
  background: var(--color-warning-dim);
  border-radius: 999px;
  padding: 1px 7px;
  flex-shrink: 0;
}

/* Einklappbares Menü */
.sb-chev {
  font-size: 12px;
  color: var(--sb-text-4);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.sidebar-section[data-sb].sb-collapsed .sb-chev {
  transform: rotate(-90deg);
}
/* ⚠️ Hier stand `max-height: 500px`. Das schneidet einen Block ohne jede
   Warnung hart ab, sobald er höher wird — der Superadmin-Block lag mit elf
   Einträgen knapp darunter. `grid-template-rows: 1fr → 0fr` klappt dieselbe
   Animation, aber ohne Deckel und ohne JavaScript. */
.sb-items {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}
.sb-items > * { min-height: 0; }
.sidebar-section[data-sb].sb-collapsed .sb-items {
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
}

/* ── Ebenen des Menüs ──────────────────────────────────────────────────────
   Module / Einstellungen / Admin liegen im selben Menü und werden getauscht,
   statt ein zweites Navigationsband aufzumachen. Welche Ebene offen ist,
   entscheidet der Server (siehe base.html) — der Klick schaltet nur um. */
.sb-ebene { display: none; }
.sb-ebene.aktiv { display: block; }

.sb-ebene-zurueck {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 10px 2px;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--sb-text-3);
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}
.sb-ebene-zurueck:hover { background: var(--tint-1); color: var(--sb-text-2); }

.sb-fuss-punkt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  margin-top: 2px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--sb-text-2);
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}
.sb-fuss-punkt:hover { background: var(--tint-2); }
.sb-fuss-punkt.aktiv { background: var(--color-accent-dim); color: var(--color-accent-text); }
.sb-fuss-chev { margin-left: auto; font-size: 13px; opacity: 0.4; }
.sb-fuss-punkt.aktiv .sb-fuss-chev { opacity: 0.8; }

/* Der Standard-Chip für Verwaltungspunkte — ersetzt den bis 08/2026
   wiederholten Inline-Stil `--chip-bg:var(--color-surface-3)`. */
.sb-chip-neutral { --chip-bg: var(--color-surface-3); }

/* Handy: Touch-Ziele ≥44px */
@media (max-width: 768px) {
  .sb-fuss-punkt, .sb-ebene-zurueck { min-height: 44px; }
}

.sidebar-divider {
  height: 0.5px;
  background: var(--color-border);
  margin: 8px 14px;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 10px;
  border-top: 0.5px solid var(--color-border);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover { background: var(--tint-2); }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--color-accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-accent);
  flex-shrink: 0;
}
.user-name { font-size: 12px; color: var(--sb-text-2); }
.user-role { font-size: 10px; color: var(--sb-text-4); }

/* ── Kommandopalette (⌘K / Strg+K) ───────────────────────────────
   App-weites Overlay, durchsucht alle aktuell im Menü gerenderten
   .sidebar-item-Links (rollenabhängig — zeigt also nur, was der
   jeweilige Benutzer ohnehin sehen darf). */
.cmdk-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 500;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.cmdk-overlay.open { display: flex; }
.cmdk-box {
  width: 480px;
  max-width: 90vw;
  background: var(--color-surface);
  border: 1px solid var(--color-border-hover);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.cmdk-box input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border);
  padding: 14px 16px;
  color: var(--color-text);
  font-size: 13.5px;
  font-family: var(--font-sans);
  outline: none;
}
.cmdk-box input::placeholder { color: var(--color-text-4); }
.cmdk-results { max-height: 320px; overflow-y: auto; padding: 6px; }
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: var(--color-text-2);
  cursor: pointer;
}
.cmdk-item i { font-size: 14px; opacity: .85; flex-shrink: 0; }
.cmdk-item:hover, .cmdk-item.sel { background: var(--color-accent-dim); color: var(--color-accent); }
.cmdk-item .cmdk-grp { margin-left: auto; font-size: 10px; color: var(--color-text-4); }
.cmdk-empty { padding: 18px; font-size: 12px; color: var(--color-text-4); text-align: center; }

/* ============================================================
   Main Content Area
   ============================================================ */
.apt-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Hamburger-Button */
.sb-toggle-btn {
  background: none;
  border: none;
  color: var(--color-text-2);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sb-toggle-btn:hover { color: var(--color-accent); background: var(--tint-3); }
html.viewport-mobile .sb-toggle-btn {
  font-size: 24px;
  padding: 8px 10px;
  color: var(--color-text);
  min-width: 40px;
  min-height: 40px;
  justify-content: center;
}

/* Pin-Button in Sidebar-Logo */
.sidebar-logo { position: relative; }
.sb-pin-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  color: var(--color-text-4);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: none; /* nur Desktop */
  transition: color var(--transition);
}
.sb-pin-btn:hover { color: var(--color-accent); }
.sb-pin-btn.pinned { color: var(--color-accent); }
html:not(.viewport-mobile) .sb-pin-btn { display: flex; align-items: center; }

/* ============================================================
   Topbar
   ============================================================ */
.apt-topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 0.5px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-3);
  flex-shrink: 0;
}
.topbar-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.lang-select {
  background: var(--color-surface-2);
  border: 0.5px solid var(--color-border);
  color: var(--color-accent);
  font-size: 11px;
  font-family: var(--font-sans);
  padding: 5px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.lang-select:hover { border-color: var(--color-accent-mid); }

/* Farbschema-Schalter — steht links neben der Sprachauswahl */
.theme-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 26px; padding: 0;
  background: var(--color-surface-2);
  border: 0.5px solid var(--color-border);
  color: var(--color-accent-text);
  border-radius: var(--radius-md);
  cursor: pointer; flex-shrink: 0;
  transition: border-color var(--transition), color var(--transition);
}
.theme-btn i { font-size: 15px; }
.theme-btn:hover { border-color: var(--color-accent-mid); }
.theme-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
/* Auf dem Handy das Touch-Mindestmaß des Projekts einhalten */
html.viewport-mobile .theme-btn { width: 44px; height: 40px; }

/* ============================================================
   Content
   ============================================================ */
.apt-content {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
  background: var(--color-surface);
}
.apt-content::-webkit-scrollbar { width: 4px; }
.apt-content::-webkit-scrollbar-thumb { background: var(--tint-4); border-radius: 4px; }

/* ============================================================
   Section Labels
   ============================================================ */
.section-label {
  font-size: 9px;
  color: var(--color-text-4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

/* ============================================================
   App Cards / Kacheln
   ============================================================ */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.app-card {
  background: var(--color-surface-2);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: block;
}
.app-card:hover {
  border-color: var(--color-border-hover);
  background: var(--color-surface-3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.app-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.app-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
  font-size: 17px;
}
.app-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 2px;
}
.app-desc {
  font-size: 10px;
  color: var(--color-text-4);
  line-height: 1.4;
}
.app-badge {
  display: inline-block;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  margin-top: var(--space-2);
}
.badge-active { background: var(--color-accent-dim); color: var(--color-accent); }
.badge-soon   { background: var(--tint-2); color: var(--color-text-4); }
.badge-beta   { background: var(--color-info-dim); color: var(--color-info); }

/* ============================================================
   Stats Cards
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.stat-card {
  background: var(--color-surface-2);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.stat-label {
  font-size: 9px;
  color: var(--color-text-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-1);
}
.stat-value {
  font-size: 22px;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.2;
}
.stat-sub {
  font-size: 10px;
  color: var(--color-accent);
  margin-top: 3px;
  opacity: 0.8;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  border: none;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary {
  background: var(--color-accent);
  color: #000000;
}
.btn-primary:hover { background: #d4df00; box-shadow: 0 0 12px rgba(200,211,0,0.3); }
.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text-2);
  border: 0.5px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-surface-3); color: var(--color-text); }
.btn-danger {
  background: var(--color-danger-dim);
  color: var(--color-danger);
  border: 0.5px solid rgba(216,90,48,0.2);
}
.btn-danger:hover { background: rgba(216,90,48,0.2); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 13px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: var(--space-4); }
.form-label {
  display: block;
  font-size: 11px;
  color: var(--color-text-3);
  margin-bottom: var(--space-2);
  font-weight: 500;
}
.form-input {
  width: 100%;
  background: var(--color-surface-2);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 13px;
  font-family: var(--font-sans);
  padding: 9px 12px;
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--color-accent-mid); }
.form-input::placeholder { color: var(--color-text-4); }
.form-select {
  width: 100%;
  background: var(--color-surface-2);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 13px;
  font-family: var(--font-sans);
  padding: 9px 12px;
  outline: none;
  cursor: pointer;
}
.form-select:focus { border-color: var(--color-accent-mid); }

/* ============================================================
   Tables
   ============================================================ */
.apt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.apt-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 9px;
  font-weight: 500;
  color: var(--color-text-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 0.5px solid var(--color-border);
}
.apt-table td {
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--color-border);
  color: var(--color-text-2);
}
.apt-table tr:hover td { background: var(--tint-1); }
.apt-table tr:last-child td { border-bottom: none; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--color-surface-2);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

/* ============================================================
   Badges / Status
   ============================================================ */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 8px; border-radius: var(--radius-sm); }
.status-dot { width: 5px; height: 5px; border-radius: var(--radius-full); }
.status-active  { background: var(--color-success-dim); color: var(--color-success); }
.status-pending { background: var(--color-warning-dim); color: var(--color-warning); }
.status-error   { background: var(--color-danger-dim);  color: var(--color-danger);  }

/* ============================================================
   KI Chat Widget (Global)
   ============================================================ */
.ai-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 46px;
  height: 46px;
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(200,211,0,0.4);
  transition: all var(--transition);
  z-index: 100;
  font-size: 20px;
  color: #000;
}
.ai-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(200,211,0,0.5);
}
.ai-chat-panel {
  position: fixed;
  bottom: 82px;
  right: 24px;
  width: 340px;
  height: 440px;
  background: var(--color-sidebar);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  display: none;
}
.ai-chat-panel.open { display: flex; }
.ai-chat-header {
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-chat-avatar {
  width: 28px;
  height: 28px;
  background: var(--color-accent-dim);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--color-accent);
}
.ai-chat-title { font-size: 12px; font-weight: 500; color: var(--color-text); }
.ai-chat-sub { font-size: 10px; color: var(--color-text-4); }
.ai-chat-close { margin-left: auto; background: none; border: none; color: var(--color-text-3); font-size: 18px; cursor: pointer; }
.ai-chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-msg { max-width: 85%; font-size: 12px; line-height: 1.5; padding: 9px 12px; border-radius: var(--radius-lg); }
.ai-msg-user { background: var(--color-accent-dim); color: var(--color-text); align-self: flex-end; border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg); }
.ai-msg-bot { background: var(--color-surface-2); color: var(--color-text-2); align-self: flex-start; border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px; }
.ai-chat-input-row {
  padding: 12px;
  border-top: 0.5px solid var(--color-border);
  display: flex;
  gap: 8px;
}
.ai-chat-input {
  flex: 1;
  background: var(--color-surface-2);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 8px 12px;
  outline: none;
  resize: none;
}
.ai-chat-input:focus { border-color: var(--color-accent-mid); }
.ai-send-btn {
  width: 32px;
  height: 32px;
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-md);
  color: #000;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-end;
}

/* ============================================================
   Alerts / Notifications
   ============================================================ */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 12px;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.alert-success { background: var(--color-success-dim); color: var(--color-success); border: 0.5px solid rgba(29,158,117,0.2); }
.alert-warning { background: var(--color-warning-dim); color: var(--color-warning); border: 0.5px solid rgba(186,117,23,0.2); }
.alert-danger  { background: var(--color-danger-dim);  color: var(--color-danger);  border: 0.5px solid rgba(216,90,48,0.2); }
.alert-info    { background: var(--color-info-dim);    color: var(--color-info);    border: 0.5px solid rgba(55,138,221,0.2); }

/* ============================================================
   Utilities
   ============================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-auto { margin-top: auto; }
.text-accent { color: var(--color-accent); }
.text-muted { color: var(--color-text-3); }
.text-sm { font-size: 11px; }
.text-xs { font-size: 10px; }
.font-medium { font-weight: 500; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   Arbeitsliste (.wl-*) — gemeinsames Bauteil für Mail-Pilot-Briefing und die
   Kästen der PM-Startseite.

   Beide zeigten dasselbe: eine nach Dringlichkeit gruppierte Liste von Dingen,
   die auf eine Entscheidung warten. Die Stile lagen doppelt inline in
   briefing.html (.mp-briefing-*) und woche.html (.pw-karte) und waren dadurch
   fürs jeweils andere Modul unerreichbar.

   Der Breakpoint ist bewusst 768px statt der früheren 600px des Briefings —
   als gemeinsames Bauteil muss es der Projektkonvention folgen.
   ═════════════════════════════════════════════════════════════════════════ */

.wl-kopf {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  margin: 18px 0 8px; color: var(--color-text-2b);
}
.wl-kopf:first-child { margin-top: 0; }
.wl-kopf.warn { color: var(--color-err-text); }
.wl-count {
  background: var(--color-surface); color: var(--color-text-4b); font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 8px; text-transform: none; letter-spacing: 0;
  margin-left: auto;
}
.wl-liste { background: var(--color-card); border: 1px solid var(--color-surface); border-radius: 6px; overflow: hidden; }
.wl-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--color-card-2); text-decoration: none;
  transition: background .1s;
}
.wl-item:last-child { border-bottom: none; }
.wl-item:hover { background: var(--color-sidebar); }
.wl-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.wl-item-main strong { color: var(--color-text-1b); font-size: 13px; }
.wl-betreff { color: var(--color-text-2b); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-zsf { color: var(--color-text-5); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-zeit { color: var(--color-text-5); font-size: 11px; white-space: nowrap; flex-shrink: 0; }
.wl-leer { text-align: center; padding: 40px 20px; }
.wl-aktionen { display: flex; gap: 6px; flex-shrink: 0; }
.wl-btn {
  background: var(--color-surface); border: 1px solid var(--color-surface-3); color: var(--color-text-3b); cursor: pointer;
  border-radius: 6px; padding: 5px 9px; font-size: 11px; line-height: 1;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.wl-btn:hover { border-color: var(--color-accent-text); color: var(--color-accent-text); }
.wl-btn[disabled] { opacity: .5; cursor: default; }
.wl-mehr { font-size: 11px; color: var(--color-text-5); margin-top: 6px; }

@media (max-width: 768px) {
  .wl-zeit { display: none; }
  .wl-item { flex-wrap: wrap; }
  .wl-btn { padding: 9px 12px; font-size: 12px; }   /* Touch-Ziel */
}


/* ── Logo je Farbschema ───────────────────────────────────────────────────
   Zwei Dateien statt einer Umfärbung: das Logo ist mehrfarbig (Fingerabdruck
   grau, „brand.eu" lime, Rest schwarz bzw. weiß) — ein CSS-Filter träfe alle
   Teile gleich und zerstörte die Marke. */
.sidebar-logo img { max-width: 138px; width: 100%; height: auto; display: block; margin: 0 auto 8px; }
.sidebar-logo .logo-fuer-hell { display: none; }
:root[data-theme="hell"] .sidebar-logo .logo-fuer-dunkel { display: none; }
:root[data-theme="hell"] .sidebar-logo .logo-fuer-hell   { display: block; }
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .sidebar-logo .logo-fuer-dunkel { display: none; }
  :root[data-theme="auto"] .sidebar-logo .logo-fuer-hell   { display: block; }
}

/* ── Reklamations-Ablauf (Zeitleiste) ──────────────────────────────────────
   Genutzt von der Reklamations-Detailseite und vom Reklamations-Reiter der
   Kundenkartei — deshalb zentral hier statt in einem der beiden Templates. */
.rk-ablauf { display:flex; flex-direction:column; gap:2px; }
.rk-ablauf-zeile { display:flex; gap:12px; align-items:flex-start; padding:6px 0; position:relative; }
.rk-ablauf-zeile:not(:last-child)::before {
  content:''; position:absolute; left:13px; top:34px; bottom:-6px; width:1px;
  background:var(--color-surface-3);
}
.rk-ablauf-marke {
  width:27px; height:27px; border-radius:50%; border:1px solid; flex:0 0 auto;
  display:flex; align-items:center; justify-content:center; font-size:14px;
  background:var(--color-card); position:relative; z-index:1;
}
.rk-ablauf-inhalt { flex:1; min-width:0; padding-top:3px; }
.rk-ablauf-kopf { display:flex; gap:10px; align-items:baseline; flex-wrap:wrap; }
.rk-ablauf-text { font-size:13px; color:var(--color-text-1b); font-weight:600; }
.rk-ablauf-zeit { font-size:11px; color:var(--color-text-5); white-space:nowrap; }
.rk-ablauf-detail { font-size:12px; color:var(--color-text-3b); margin-top:2px; white-space:pre-wrap; word-break:break-word; }
.rk-ablauf-user { font-size:11px; color:var(--color-text-5); margin-top:2px; }

/* ── Art einer PM-Aufgabe: Farbe je Art ────────────────────────────────────
   Die Grundfarbe kommt als `--pm-art-farbe` aus PmBoardTyp.farbe. Fläche und
   Rahmen bleiben in beiden Designs dezent; im hellen Design wird der Text
   abgedunkelt, weil ein mittelheller Farbton auf Weiß sonst unlesbar ist
   (dieselbe Überlegung wie beim Akzent in variables.css). Ohne Farbe
   (Altbestand) greift überall der bisherige Akzent-Look. */
.pm-art-chip {
  font-size: 10px; padding: 2px 7px; border-radius: 6px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
  background: color-mix(in srgb, var(--pm-art-farbe, #c8d300) 14%, transparent);
  color: var(--pm-art-farbe, var(--color-accent-text));
  border: 1px solid color-mix(in srgb, var(--pm-art-farbe, #c8d300) 30%, transparent);
}
.pm-art-chip i { font-size: 12px; }
:root[data-theme="hell"] .pm-art-chip {
  color: color-mix(in srgb, var(--pm-art-farbe, #666d00) 62%, #000);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .pm-art-chip {
    color: color-mix(in srgb, var(--pm-art-farbe, #666d00) 62%, #000);
  }
}

/* ── Hülle des Admin-Bereichs (admin/shell.html) ───────────────────────────
   Bewusst hier und nicht in der Vorlage: Die Modul-Einstellungsseiten, die in
   die Hülle umgezogen sind, belegen `extra_css` mit ihrem eigenen CSS. Läge
   das Hüllen-CSS dort, verschwände es bei genau diesen Seiten. */
.ab-inhalt { max-width: 1100px; }

.ab-pfad { display: flex; align-items: center; gap: 6px; font-size: 12px;
           color: var(--color-text-4b); margin-bottom: var(--space-2); }
.ab-pfad a { color: var(--color-text-3b); text-decoration: none; }
.ab-pfad a:hover { color: var(--color-accent-text); }

.ab-kopf { margin-bottom: var(--space-5); padding-bottom: var(--space-4);
           border-bottom: 0.5px solid var(--color-border); }
.ab-kopf h1 { font-size: 21px; font-weight: 600; color: var(--color-text); margin: 0 0 5px; }
.ab-kopf p { font-size: 13px; color: var(--color-text-3b); margin: 0;
             max-width: 62ch; line-height: 1.5; }

@media (max-width: 768px) {
  .ab-kopf h1 { font-size: 18px; }
}
