/* ============================================================================
   Trove — Admin Theme  (handgebaut, kein Framework)
   ========================================================================== */

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

  /* Brand */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;

  /* Neutrals (light) */
  --bg:        #f6f7fb;
  --surface:   #ffffff;
  --surface-2: #f9fafb;
  --border:    #e5e7eb;
  --text:      #111827;
  --text-2:    #6b7280;
  --text-3:    #9ca3af;

  --sidebar-bg:   #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-muted:#64748b;
  --sidebar-active-bg: rgba(99,102,241,.18);
  --sidebar-active-text: #ffffff;

  --success: #10b981;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --info:    #3b82f6;

  --radius:   12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14);

  --sidebar-w: 260px;
  --topbar-h: 64px;

  /* Diagramm-Palette (Analyse). Beide Modi sind ausgewählt, nicht umgerechnet:
     die Dunkel-Werte sind dieselben Farbtöne, für die dunkle Fläche gestuft.
     Die REIHENFOLGE ist die Absicherung gegen Farbfehlsichtigkeit — Nachbarn
     sind maximal getrennt. Slots deshalb strikt der Reihe nach vergeben und
     niemals im Kreis wiederverwenden; ab zwei Reihen gehört eine Legende dazu,
     damit die Zuordnung nicht allein an der Farbe hängt.
     Geprüft mit dem Validator gegen --surface #ffffff bzw. #111827. */
  --viz-1: #2a78d6;
  --viz-2: #1baf7a;
  --viz-3: #eda100;
  --viz-4: #008300;
  --viz-5: #4a3aa7;
  --viz-6: #e34948;
  --viz-7: #e87ba4;
  --viz-8: #eb6834;
}

:root[data-theme="dark"] {
  --viz-1: #3987e5;
  --viz-2: #199e70;
  --viz-3: #c98500;
  --viz-4: #008300;
  --viz-5: #9085e9;
  --viz-6: #e66767;
  --viz-7: #d55181;
  --viz-8: #d95926;
}

:root[data-theme="dark"] {
  --bg:        #0b1120;
  --surface:   #111827;
  --surface-2: #0f1626;
  --border:    #1f2937;
  --text:      #f3f4f6;
  --text-2:    #9ca3af;
  --text-3:    #6b7280;
  --sidebar-bg:   #0a0f1d;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.45);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
h1,h2,h3,h4 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
/* Das hidden-Attribut muss gewinnen: Klassen wie .badge oder .btn setzen display
   und schlagen damit die display:none-Regel des Browsers — ausgeblendete Elemente
   blieben sonst sichtbar (der „In Arbeit"-Badge über dem Fortschrittsbalken). */
[hidden] { display: none !important; }

/* ── App-Shell ───────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; overflow: hidden; }

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 22px;
  color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.02em;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar__brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: grid; place-items: center; color: #fff; font-weight: 800;
  box-shadow: 0 4px 12px rgba(79,70,229,.5);
}
.brandmark { flex: none; border-radius: 27%; box-shadow: 0 4px 12px rgba(79,70,229,.5); }
.sidebar__section { padding: 18px 14px 6px; color: var(--sidebar-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 6px 12px 20px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 2px 0; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500; cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.nav-item .ic { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-item .badge-count { margin-left: auto; font-size: 11px; background: var(--brand-600);
  color: #fff; border-radius: 999px; padding: 1px 7px; }
.sidebar__foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }

/* ── Main ────────────────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; min-height: 0; }
.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
  /* Nicht schrumpfen: .topbar sitzt in der Flex-Spalte .main; auf fullHeight-Seiten
     (.content--fill) presste die hohe Content-Spalte den Kopf sonst von 64→43 px
     zusammen → Topbar je Menüpunkt unterschiedlich hoch. flex:none pinnt die Höhe. */
  flex: none;
}
.topbar__title { font-size: 16px; font-weight: 650; }
.topbar__spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px; color: var(--text-2); min-width: 260px;
}
.search input { border: 0; background: transparent; outline: none; color: var(--text); width: 100%; font-size: 13px; }

/* Globale Live-Suche: breiteres Feld, das beim Fokus noch etwas wächst, mit
   aufklappendem Ergebnis-Dropdown darunter. */
.search--global { position: relative; min-width: 340px; transition: min-width .15s ease; }
.search--global:focus-within { min-width: 420px; border-color: var(--brand-500, #6366f1); }
.gsr {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: min(70vh, 560px); overflow-y: auto; padding: 6px;
}
.gsr.is-loading { opacity: .6; }
.gsr__group { padding: 2px 0; }
.gsr__group + .gsr__group { border-top: 1px solid var(--border); margin-top: 2px; padding-top: 4px; }
.gsr__grouphd { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); padding: 6px 10px 2px; }
.gsr .sresult { padding: 8px 10px; border: 0; gap: 10px; }
/* feine graue Trennlinie zwischen den Treffern (nicht vor dem ersten je Gruppe) */
.gsr .sresult + .sresult { border-top: 1px solid var(--border); }
.gsr .sresult:hover, .gsr .sresult.is-active { background: var(--surface-2); border-radius: 8px; }
.gsr .sresult:hover + .sresult, .gsr .sresult.is-active + .sresult { border-top-color: transparent; }
.gsr__all { display: block; text-align: center; padding: 9px; margin-top: 4px; border-top: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--brand-600); border-radius: 0 0 8px 8px; }
.gsr__all:hover, .gsr__all.is-active { background: var(--surface-2); }
.gsr__empty { padding: 18px; text-align: center; color: var(--text-2); font-size: 13px; }

/* Treffer-Zeile (Ergebnisseite UND Live-Dropdown). */
.sresults { display: flex; flex-direction: column; }
.sresult { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--border); color: var(--text); }
.sresult:first-child { border-top: 0; }
.sresult:hover { background: var(--surface-2); }
.sresult__ico { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px;
  background: var(--surface-2); color: var(--text-2); }
.sresult__ico svg { width: 18px; height: 18px; }
.sresult__ico .cmark { width: 30px; height: 30px; }
.sresult__body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.sresult__title { font-weight: 600; }
.sresult__sub { color: var(--text-2); }
.sresult__meta { flex: none; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.avatar { width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; display: grid; place-items: center; font-weight: 700; }

/* Status-LEDs in der Kopfleiste (Graph-DB / LLM) */
.sysleds { display: flex; align-items: center; gap: 14px; }
.sysled { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600;
  color: var(--text-2); cursor: default; user-select: none; }
.sysled__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none;
  transition: background .2s, box-shadow .2s; }
.sysled.is-up .sysled__dot { background: var(--success); }
.sysled.is-down .sysled__dot { background: var(--danger); }

/* Mandanten-Zeichen: Logo oder Anfangsbuchstabe (views/_tenantMark.php).
   Abgerundetes Quadrat statt Kreis — ein Kreis würde breite Wort-Logos
   an beiden Enden abschneiden. */
.tmark { flex: none; border-radius: 22%; display: grid; place-items: center; overflow: hidden; }
/* contain, nicht cover: das ganze Logo soll zu sehen sein, auch wenn es quer ist. */
.tmark--img { object-fit: contain; background: var(--surface-2); }
.tmark--initial { background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; font-weight: 700; letter-spacing: -.01em; user-select: none; }
/* In der dunklen Seitenleiste braucht ein Logo mit weißer Schrift etwas Fläche. */
.sidebar .tmark--img { background: rgba(255,255,255,.08); }

.logo-up { display: flex; gap: 14px; align-items: flex-start; }
.logo-up__ctl { flex: 1; min-width: 0; }

/* Kontakt-Zeichen (views/_contactMark.php): Person rund, Firma eckig — die Form
   trennt die beiden Arten schon ohne Beschriftung. */
.cmark { flex: none; display: grid; place-items: center; color: #fff; user-select: none;
  box-shadow: 0 2px 6px rgba(16,24,40,.18); }
/* Person: runde Scheibe, violetter Verlauf. Firma: abgerundetes Quadrat, blauer
   Verlauf — Form und Farbe trennen die Arten auch ohne Symbol. */
.cmark--person { border-radius: 50%; background: linear-gradient(135deg, #8b5cf6, #6366f1); }
.cmark--company { border-radius: 26%; background: linear-gradient(135deg, #0ea5e9, #0369a1); }
.cmark svg { opacity: .95; }

/* ── Hover-Vorschau (web/js/thumbpop.js) ──────────────────────────────────
   Jedes Element mit data-lg zeigt nach kurzem Verweilen das verlinkte Bild.
   pointer-events:none — das Popup folgt der Maus und darf nichts blockieren. */
/* Lupen-Zeiger nur, wenn die Vorschau auch kommt — sonst verspricht er etwas,
   das der abgeschaltete Zustand nicht hält. */
body[data-thumbpop="on"] [data-lg] { cursor: zoom-in; }
.thumbpop { position: fixed; z-index: 9999; padding: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 34px rgba(0,0,0,.3);
  pointer-events: none; }
/* Bildvorschauen bleiben „durchlässig" (sonst flackern sie unter der Maus). Die
   Kartenfassung dagegen MUSS Ereignisse annehmen — nur so lässt sich im Mailtext
   blättern. Die Klasse setzt das Skript, solange eine Karte sichtbar ist. */
.thumbpop--card { pointer-events: auto; }

/* ── Gerendertes Markdown (Entwürfe, Assistent) ───────────────────────────── */
.md-out { font-size: 14px; line-height: 1.7; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 10px; padding: 20px; color: var(--text); }
.md-out > :first-child { margin-top: 0; }
.md-out > :last-child { margin-bottom: 0; }
.md-out p { margin: 0 0 12px; }
.md-out h1, .md-out h2, .md-out h3, .md-out h4 { margin: 20px 0 10px; line-height: 1.3; font-weight: 650; }
.md-out h1 { font-size: 19px; }
.md-out h2 { font-size: 17px; }
.md-out h3 { font-size: 15.5px; }
.md-out h4 { font-size: 14.5px; }
.md-out ul, .md-out ol { margin: 0 0 12px; padding-left: 22px; }
.md-out li { margin: 3px 0; }
.md-out blockquote { margin: 0 0 12px; padding: 2px 14px; border-left: 3px solid var(--border);
    color: var(--text-2); }
.md-out code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.md-out pre { margin: 0 0 12px; padding: 12px 14px; overflow-x: auto; background: var(--surface);
    border: 1px solid var(--border); border-radius: 8px; }
.md-out pre code { border: 0; padding: 0; background: none; }
.md-out table { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-size: 13px; }
.md-out th, .md-out td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; }
.md-out th { background: var(--surface); font-weight: 600; }
.md-out hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.md-out a { color: var(--brand-600); }
/* Höhe kommt aus dem Profil des Benutzers: das Layout setzt --thumbpop-p am body
   als blanke Zahl (Anteil der Bildschirmhöhe in %). Vorschauen sind Dokumentseiten,
   also hochkant — die Höhe ist das Maß, die Breite folgt dem Seitenverhältnis.
   max-width ist nur ein Notnagel für querformatige Bilder, damit sie nicht aus dem
   Fenster laufen. Der Rückfallwert greift nur ohne Layout. */
/* Kartenfassung der Hover-Vorschau (E-Mails): Kopf mit Betreff/Absender/Datum,
   darunter der Mailtext. Bewusst großzügig — hier soll man wirklich lesen können,
   nicht nur erahnen. Der Verlauf am unteren Rand zeigt an, dass es weitergeht. */
.thumbpop__card { width: 520px; max-width: calc(100vw - 32px); }
/* Kopf mit etwas Gewicht, danach beginnt der Text unmittelbar. */
.thumbpop__head { padding: 4px 2px 11px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.thumbpop__title { font-size: 15px; font-weight: 650; color: var(--text); line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumbpop__meta { margin-top: 5px; font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
/* Scrollbar: im Popover soll das Rad im Mailtext blättern. overscroll-behavior
   verhindert, dass die Seite mitscrollt, sobald das Ende erreicht ist — sonst
   würde das Popover ausgerechnet beim Weiterdrehen zugehen. */
.thumbpop__text { max-height: 340px; overflow-y: auto; overscroll-behavior: contain;
    padding: 0 8px 2px 2px; font-size: 13.5px; line-height: 1.6; color: var(--text-2);
    white-space: pre-wrap; overflow-wrap: anywhere; }
.thumbpop__text::-webkit-scrollbar { width: 8px; }
.thumbpop__text::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.thumbpop__text::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
.thumbpop img { display: block; border-radius: 4px;
  max-height: calc(var(--thumbpop-p, 60) * 1vh);
  max-width: 92vw; }

.content { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 28px 32px; width: 100%; max-width: none; }

/* ── Vollhöhen-Pane ──────────────────────────────────────────────────────────
   Ein einzelnes Pane füllt den Content-Bereich bis zum unteren Bildschirmrand
   und bekommt bei Überlauf einen eigenen Scrollbalken. Seite opt-in via
   $this->params['fullHeight'] = true (Layout setzt .content--fill) und markiert
   das Pane mit .pane (i. d. R. am .card). Nicht bei mehreren Panes verwenden –
   dort scrollt jede Spalte selbst. */
.content--fill { display: flex; flex-direction: column; overflow: hidden; }
.content--fill > * { flex: none; }
.content--fill > .pane { flex: 1 1 auto; min-height: 0; }
.pane.card { display: flex; flex-direction: column; overflow: hidden; }
.pane.card > .card__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.content--fill > .pane:not(.card) { overflow-y: auto; }

/* Feste Mindesthöhe → jeder Seitenkopf ist gleich hoch, egal ob mit/ohne
   Untertitel oder Aktionen. align-items:flex-end hält Titel und Buttons unten bündig. */
/* FESTE Höhe auf jeder Seite — sonst „springt" der Inhalt beim Wechsel der
   Menüpunkte. Zentriert, kein Umbruch der Aktionen, Untertitel einzeilig.
   Bewusst mit `.content `-Präfix (höhere Spezifität): das geteilte yii2kit-Widget
   bringt sein EIGENES pagehead.css (min-height:63px, flex-end, wrap) mit, das die
   nackten .page-head-Regeln sonst überschriebe. So gewinnt Troves Fassung überall —
   auf Widget- UND handgebauten Köpfen — ohne die geteilte Bibliothek zu ändern. */
.content .page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px;
    gap: 16px; flex-wrap: nowrap; height: 64px; min-height: 0; }
.content .page-head h1 { font-size: 22px; }
/* Titelblock (Widget: .page-head__main; handgebaut: nacktes erstes <div>).
   Vertikal zentriert; kürzt statt zu wachsen. */
.content .page-head__main, .content .page-head > div:not([class]):first-child { min-width: 0; min-height: 0;
    display: flex; flex-direction: column; justify-content: center; }
/* Zeichen/Avatar links neben dem Titelblock. */
.page-head__lead { display: flex; align-items: center; gap: 12px; min-width: 0; }
/* Zurück-Link über der Überschrift — soll die Kopfhöhe nicht aufblähen. */
.page-head__back { line-height: 1.3; margin-bottom: 2px; }
.content .page-head__actions { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; flex: none; }
/* Detailseiten mit reichhaltigem Kopf (Zurück-Link, Chips, Statistik) sind KEINE
   Menüpunkte — sie dürfen höher sein und ihren Untertitel umbrechen. */
.content .page-head--free { height: auto; min-height: 64px; align-items: flex-start; flex-wrap: wrap; }
.content .page-head--free .sub { white-space: normal; overflow: visible; }
/* Abschnitts-Icon vor der Überschrift (zentral per Layout eingesetzt). Inline —
   damit h1 mit .truncate weiter sauber kürzt. */
.page-head__ico { width: 22px; height: 22px; flex: none; margin-right: 9px;
    color: var(--brand-600); vertical-align: -4px; }
/* Untertitel einzeilig: ein umbrechender Untertitel würde den Kopf höher machen. */
.content .page-head .sub { color: var(--text-2); font-size: 13px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card__head { padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__head h3 { font-size: 15px; margin: 0; display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
/* Titel-Symbol: dezent (Sekundärfarbe), fest, links vor dem Titeltext. Die
   Symbole kommen aus app\widgets\Badge::icon($name, 'card-title__ico'). */
.card-title__ico { width: 17px; height: 17px; flex: none; color: var(--brand-600, #4f46e5); }
.card__body { padding: 20px; }

.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* Stat tiles */
.stat { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 6px; }
.stat__top { display: flex; align-items: center; justify-content: space-between; }
.stat__label { color: var(--text-2); font-size: 12.5px; font-weight: 550; }
.stat__value { font-size: 28px; font-weight: 720; letter-spacing: -.02em; }
.stat__icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand-600); }
:root[data-theme="dark"] .stat__icon { background: rgba(99,102,241,.15); }
.stat__delta { font-size: 12px; font-weight: 600; }
.stat__delta.up { color: var(--success); }
.stat__delta.down { color: var(--danger); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600; line-height: 1;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  transition: background .12s, border-color .12s, box-shadow .12s; white-space: nowrap; }

/* ── Listen: Icon-Aktionen + anklickbare Zeilen (app-weit einheitlich) ──────
   In Tabellen Aktionen als Icon-Buttons (.iact) statt Text; fehlende Aktionen
   bekommen einen leeren Platzhalter (.iact--empty), damit die Icons spaltenweise
   untereinander stehen. Eine Zeile mit data-href öffnet ihr Ziel (web/js/row-open.js). */
.row-acts { display: inline-flex; gap: 2px; justify-content: flex-end; }
.iact { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px;
  color: var(--text-2); flex: none; }
.iact:hover { background: var(--surface-2); color: var(--text); }
.iact svg { width: 16px; height: 16px; }
.iact--danger:hover { color: var(--danger); }
.iact--empty { pointer-events: none; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover > td { background: var(--surface-2); }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 2px 6px rgba(79,70,229,.35); }
.btn-primary:hover { background: var(--brand-700); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; }
/* Symbol im Badge: „flex: none" verhindert, dass es in engen Tabellenspalten
   zusammengequetscht wird, während der Text umbricht. */
.badge__ico { width: 13px; height: 13px; flex: none; }
/* In Buttons etwas größer — 13px (Badge-Maß) wirkt neben 13.5px-Text zu zart. */
.btn .badge__ico { width: 15px; height: 15px; }
/* Jedes Symbol in einem Button bekommt eine Größe — auch ein blankes <svg>
   (Badge::icon(name, '') liefert kein badge__ico und wäre sonst größenlos). */
.btn svg { width: 15px; height: 15px; flex: none; }
.badge-gray   { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge-green  { background: rgba(16,185,129,.12); color: #059669; }
.badge-amber  { background: rgba(245,158,11,.14); color: #b45309; }
.badge-red    { background: rgba(239,68,68,.12); color: #dc2626; }

/* Toggle-Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch__input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track { position: relative; width: 44px; height: 24px; border-radius: 999px; background: var(--border); transition: background .18s ease; flex: none; }
.switch__thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s ease; }
.switch__input:checked + .switch__track { background: var(--success); }
.switch__input:checked + .switch__track .switch__thumb { transform: translateX(20px); }
.switch__input:focus-visible + .switch__track { box-shadow: 0 0 0 3px rgba(16,185,129,.35); }
.switch__text { font-weight: 600; font-size: 14px; }

/* Tabs (wiederverwendbar) */
.ftabs__nav { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin: 0 0 20px; }
.ftabs__tab { display: inline-flex; align-items: center; gap: 7px; appearance: none; border: 0; background: transparent;
    padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text-2); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0; }
.ftabs__tab:hover { color: var(--text); background: var(--surface-2); }
.ftabs__tab.is-active { color: var(--text); border-bottom-color: var(--brand-600, #4f46e5); }
.ftabs__ico { width: 15px; height: 15px; flex: none; }
.ftabs__pane { display: none; }
.ftabs__pane.is-active { display: block; }
.badge-blue   { background: rgba(59,130,246,.12); color: #2563eb; }
.badge-indigo { background: var(--brand-50); color: var(--brand-700); }
.dot { width: 7px; height: 7px; border-radius: 50%; }

/* ── Mandanten-Umschalter (Topbar) ────────────────────────────────────────
   Ersetzt das <select>: zeigt Logo und die Verschachtelung von Unter-Mandanten,
   was ein natives Auswahlfeld nicht kann. */
.tswitch { position: relative; }
.tswitch__btn { display: inline-flex; align-items: center; gap: 8px; min-width: 200px; max-width: 280px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
/* Der Name schiebt den Pfeil nach rechts, statt daneben zu kleben — sonst wirkt
   der Knopf bei kurzen Namen wie „Admin" halbleer. */
.tswitch__btn .tswitch__name { flex: 1; text-align: left; }
.tswitch__btn:hover { background: var(--surface-2); }
.tswitch__name { font-size: 13px; font-weight: 600; }
.tswitch__caret { color: var(--text-3); flex: none; }
.tswitch__menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 260px; max-width: 340px; max-height: 60vh; overflow-y: auto;
  padding: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.tswitch__item { display: flex; align-items: center; gap: 9px; padding: 7px 12px;
  border-radius: var(--radius-sm); color: var(--text); font-size: 13.5px; }
.tswitch__item:hover { background: var(--surface-2); }
.tswitch__item.is-active { background: var(--brand-50, #eef2ff); color: var(--brand-700, #4338ca); font-weight: 600; }
:root[data-theme="dark"] .tswitch__item.is-active { background: rgba(99,102,241,.18); color: #a5b4fc; }
.tswitch__item .tswitch__name { flex: 1; min-width: 0; font-weight: 500; }
.tswitch__item.is-active .tswitch__name { font-weight: 600; }
.tswitch__branch { color: var(--text-3); flex: none; font-size: 12px; margin-right: -2px; }
.tswitch__check { color: var(--brand-600, #4f46e5); flex: none; }

/* ── Kontakt-Marke mit Vorschau ───────────────────────────────────────────
   Namens-Marke, die beim Überfahren eine kleine Kontaktkarte zeigt und beim
   Klick zum Kontakt führt (views/document/_senderChip.php). */
.cchip { position: relative; display: inline-block; }
.cchip__link { text-decoration: none; }
.cchip__pop { position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: 272px; padding: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); color: var(--text);
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .12s, transform .12s; }
/* Den 8px-Spalt zwischen Marke und Karte überbrücken: ohne diese unsichtbare
   Fläche reißt der Hover ab, sobald die Maus in die Karte wandern will — genau
   das ließ die Karte „verschwinden", bevor man die Kopier-Symbole erreichte. */
.cchip__pop::before { content: ''; position: absolute; top: -8px; left: 0; right: 0; height: 8px; }
/* Erst nach kurzem Verweilen — sonst blitzt die Karte bei jedem Vorbeiziehen auf.
   Auch beim Tastatur-Fokus zeigen (Erreichbarkeit). */
.cchip:hover .cchip__pop, .cchip:focus-within .cchip__pop {
  opacity: 1; visibility: visible; transform: translateY(0); transition-delay: .15s; }
.cchip__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
  text-decoration: none; color: inherit; border-radius: var(--radius-sm); }
.cchip__head:hover { color: inherit; }
.cchip__id { min-width: 0; display: flex; flex-direction: column; }
.cchip__name { font-weight: 650; font-size: 14px; line-height: 1.2; }
.cchip__kind { color: var(--brand-600, #4f46e5); font-size: 11.5px; font-weight: 600; }
.cchip__rows { display: flex; flex-direction: column; }
.cchip__row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2);
  min-width: 0; padding: 3px 4px; border-radius: 6px; }
.cchip__row:hover { background: var(--surface-2); }
.cchip__ico { flex: none; width: 15px; text-align: center; opacity: .8; }
.cchip__row > .truncate { flex: 1; }
/* Kopier-Symbol rechts: standardmäßig zurückhaltend, tritt beim Überfahren der
   Zeile hervor. Auf Touch (kein Hover) dauerhaft sichtbar. */
.cchip__copy { flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text-3); opacity: 0; transition: opacity .12s, color .12s, background .12s; }
.cchip__row:hover .cchip__copy, .cchip__copy:focus-visible { opacity: 1; }
.cchip__copy:hover { background: var(--surface); color: var(--brand-600, #4f46e5); }
.cchip__copy.is-copied { opacity: 1; color: var(--success, #10b981); }
@media (hover: none) { .cchip__copy { opacity: 1; } }

/* ── Facetten (Filter-Chips) ──────────────────────────────────────────────
   Genutzt von der Dokumentliste (Typ) und vom Quellenkatalog (Status). Als <a>
   oder <button> verwendbar; „is-active" markiert die gewählte Facette. */
.facets { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.facet { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; }
.facet:hover { background: var(--surface-2); color: var(--text); }
.facet.is-active { background: var(--brand-50, #eef2ff); color: var(--brand-700, #4338ca); border-color: var(--brand-500, #6366f1); }
:root[data-theme="dark"] .facet.is-active { background: rgba(99,102,241,.18); color: #a5b4fc; }
.facet__n { font-size: 11px; opacity: .7; }
/* Unterpunkte (Dateitypen unter „Dokumente") — leiser, kleiner, als Kind erkennbar. */
.facet--sub { font-weight: 500; font-size: 11.5px; padding: 4px 9px; border-style: dashed; }

/* ── Ansichts-Umschalter Liste/Karten ─────────────────────────────────────── */
.viewtoggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex: none; }
.viewtoggle__btn { display: grid; place-items: center; width: 34px; height: 32px; color: var(--text-2); background: var(--surface); cursor: pointer; }
.viewtoggle__btn + .viewtoggle__btn { border-left: 1px solid var(--border); }
.viewtoggle__btn:hover { background: var(--surface-2); color: var(--text); }
.viewtoggle__btn.is-active { background: var(--brand-50, #eef2ff); color: var(--brand-700, #4338ca); }
:root[data-theme="dark"] .viewtoggle__btn.is-active { background: rgba(99,102,241,.18); color: #a5b4fc; }
.viewtoggle__btn svg { width: 16px; height: 16px; }

/* ── Dokumente als Karten ─────────────────────────────────────────────────── */
.dcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; padding: 2px; }
.dcard { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--surface); color: var(--text); cursor: pointer; transition: box-shadow .12s, border-color .12s; }
.dcard:hover { box-shadow: var(--shadow-md); border-color: var(--brand-500, #6366f1); }
/* Platzhalter-Karte beim Nachladen (Infinite-Scroll, Kartenansicht). */
.dcard--loading { align-items: center; justify-content: center; gap: 10px; min-height: 220px;
  border-style: dashed; cursor: default; color: var(--text-3); }
.dcard--loading:hover { box-shadow: none; border-color: var(--border); }
.dcard__spin { width: 26px; height: 26px; border: 3px solid var(--border);
  border-top-color: var(--brand-500, #6366f1); border-radius: 50%; animation: dcardspin .7s linear infinite; }
.dcard__loadtxt { font-size: 12px; }
@keyframes dcardspin { to { transform: rotate(360deg); } }
/* Thumb trägt die Lupe: leichter grauer Rahmen, Zoom-Cursor nur hier. */
.dcard__thumb { position: relative; height: 150px; display: grid; place-items: center; background: var(--surface-2);
  overflow: hidden; margin: 8px 8px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.dcard__thumb[data-lg] { cursor: zoom-in; }
.dcard__thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.dcard__thumb .thumb__ext { font-size: 22px; font-weight: 800; color: var(--text-3); }
.dcard__type { position: absolute; top: 8px; left: 8px; }
.dcard__body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dcard__title { display: flex; align-items: center; gap: 7px; font-weight: 600; min-width: 0; }
/* Titel ist ein echter Link (neuer Tab / Strg-Klick / Barrierefreiheit), sieht aber
   aus wie der Titeltext — die ganze Karte bleibt zusätzlich per row-open klickbar. */
.dcard__link { color: inherit; text-decoration: none; }
.dcard__link:hover { text-decoration: underline; }
.dcard__meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.dcard__meta svg { width: 13px; height: 13px; }
.dcard__sum { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dcard__foot { margin-top: 2px; }

/* Dokumentdatum-Zeile in der Listenansicht */
.doc-date { display: inline-flex; align-items: center; gap: 4px; margin-top: 1px; }
.doc-date svg { width: 13px; height: 13px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3); font-weight: 600; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
/* Spaltenköpfe per Drag & Drop umsortieren (colmenu.js / document-Liste). */
.table th.th-drag { cursor: grab; }
.table th.th-drag:active { cursor: grabbing; }
.table th.th-dragging { opacity: .4; background: var(--brand-100, #e0e7ff); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .muted { color: var(--text-2); }

/* ── Pager ───────────────────────────────────────────────────────────────────
   ACHTUNG beim Anpassen: Hier läuft yii\widgets\LinkPager, NICHT yii\bootstrap5\LinkPager.
   Nur letzterer rendert Bootstrap-Markup (li.page-item > a.page-link) — der hier
   erzeugt stattdessen:
       ul.pagination > li[.first|.prev|.active|.disabled|.next|.last] > a
   mit KLASSENLOSEM <a>; deaktivierte Buttons haben gar kein <a>, sondern ein <span>.
   Regeln müssen daher am li ansetzen. Das Theme bringt kein Bootstrap mit — ohne
   diese Regeln steht da eine Aufzählung mit Punkten. Gilt für jede Seite mit
   LinkPager (Dokumente, Audit), deshalb hier und nicht je Seite. */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.pagination li { display: block; }
.pagination li > a,
.pagination li > span {
  display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 600; line-height: 1; text-decoration: none;
  transition: background .12s, color .12s, border-color .12s;
}
.pagination li > a:hover { background: var(--surface-2); color: var(--text); }
.pagination li.active > a,
.pagination li.active > span { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
/* Deaktiviert (erste/letzte Seite): sichtbar da, aber erkennbar tot.
   Yii rendert hier ein <span> statt <a> — daher beide Varianten. */
.pagination li.disabled > a,
.pagination li.disabled > span { opacity: .45; pointer-events: none; }

/* ── Analyse: Filterleiste, Diagramme, Kennzahlen ────────────────────────── */
.afilter { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin: 0 0 20px;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.afilter__f { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.afilter__l { font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.afilter .input { height: 34px; font-size: 13px; padding: 4px 8px; }
.afilter__act { flex-direction: row; align-items: center; gap: 10px; min-width: 0; padding-bottom: 7px; }

/* Feste Höhe: Chart.js braucht einen Container mit Höhe, sonst wächst die
   Zeichenfläche bei maintainAspectRatio:false endlos. */
.chartbox { position: relative; height: 260px; }
.chartbox canvas { display: block; }

.kpi { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
/* KPI-Kachel mit Symbol oben rechts — dezent getönt, gleiche Bildsprache wie
   die Karten-Titel (app\widgets\Badge). Label/Wert brauchen rechts etwas Luft,
   damit sie nicht unter das Symbol laufen. */
.kpi-card { position: relative; }
.kpi-card .card__body { padding-right: 64px; }
.kpi-card__ico { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: 10px;
  background: var(--surface-2); color: var(--brand-600, #4f46e5); }
.kpi-card__ico svg { width: 19px; height: 19px; }
/* Leichte KPI-Fläche ohne eigenen Kartenrahmen — für Kacheln, die schon in
   einer Karte liegen (z. B. der Kostenvergleich). */
.kpi-tile { position: relative; padding-right: 44px; }
.kpi-tile__ico { position: absolute; top: 0; right: 0; width: 32px; height: 32px;
  display: grid; place-items: center; border-radius: 9px;
  background: var(--surface-2); color: var(--brand-600, #4f46e5); }
.kpi-tile__ico svg { width: 17px; height: 17px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }

/* kartik CheckboxX: Label rechts neben der Box statt darunter
   (überschreibt .form-group label{display:block}). */
.cbx-container { vertical-align: middle; }
label.cbx-label,
.form-group label.cbx-label {
  display: inline-block; margin: 0 0 0 8px; vertical-align: middle;
  font-size: 14px; font-weight: 400; color: var(--text); cursor: pointer;
}
/* Toggle-Switch: inline-flex gegen .form-group label{display:block} durchsetzen,
   sonst steht der Knopf über dem Text. */
.form-group label.switch { display: inline-flex; margin: 0; }
.input, textarea.input, select.input {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 13px; outline: none; transition: border-color .12s, box-shadow .12s; }
.input:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
:root[data-theme="dark"] .input:focus { box-shadow: 0 0 0 3px rgba(99,102,241,.25); }
.help-block { color: var(--danger); font-size: 12.5px; margin-top: 5px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }

/* ── Auth ────────────────────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth__hero {
  background: radial-gradient(1200px 600px at 20% 10%, #312e81 0%, #0f172a 55%, #020617 100%);
  color: #e2e8f0; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth__hero .brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; color: #fff; }
.auth__hero .brand .logo { width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700)); display: grid; place-items: center; font-weight: 800; }
.auth__hero h2 { font-size: 34px; line-height: 1.2; color: #fff; max-width: 440px; letter-spacing: -.02em; }
.auth__hero p { color: #94a3b8; max-width: 420px; font-size: 15px; }
.auth__hero .feat { display: flex; align-items: center; gap: 10px; margin: 10px 0; color: #cbd5e1; }
.auth__hero .feat .tick { width: 22px; height: 22px; border-radius: 50%; background: rgba(99,102,241,.25);
  color: #a5b4fc; display: grid; place-items: center; font-size: 12px; }
.auth__panel { display: grid; place-items: center; padding: 40px; background: var(--bg); }
.auth__card { width: 100%; max-width: 380px; }
.auth__card h1 { font-size: 24px; }
.auth__card .lead { color: var(--text-2); margin-bottom: 26px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth__hero { display: none; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.mt-0{margin-top:0}.mb-0{margin-bottom:0}
.mt-1{margin-top:4px}.mb-1{margin-bottom:4px}
.mt-2{margin-top:8px}.mb-2{margin-bottom:8px}
.mt-3{margin-top:12px}.mb-3{margin-bottom:12px}
.mt-4{margin-top:20px}.mb-4{margin-bottom:20px}
.mt-5{margin-top:28px}.mb-5{margin-bottom:28px}
.text-2 { color: var(--text-2); } .text-sm { font-size: 12.5px; } .fw-600 { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: rgba(239,68,68,.1); color: #b91c1c; border: 1px solid rgba(239,68,68,.25); }
.alert-success { background: rgba(16,185,129,.1); color: #047857; border: 1px solid rgba(16,185,129,.25); }
.empty { text-align: center; color: var(--text-3); padding: 40px 20px; }
.flag { width: 20px; height: 15px; border-radius: 2px; object-fit: cover; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.10); }

/* ── Section-Header-Widget (Icon + Label + Linie nach rechts) ─────────────── */
.section-head { display: flex; align-items: center; gap: 10px; margin: 22px 0 14px; }
.section-head:first-child { margin-top: 0; }
.section-head__icon { width: 26px; height: 26px; border-radius: 7px; background: var(--brand-50);
  color: var(--brand-600); display: grid; place-items: center; flex: none; }
.section-head__icon svg { width: 15px; height: 15px; }
:root[data-theme="dark"] .section-head__icon { background: rgba(99,102,241,.15); }
.section-head__label { font-size: 13px; font-weight: 650; color: var(--text); letter-spacing: .02em; white-space: nowrap; }
.section-head__line { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }
.section-head__hint { white-space: nowrap; }
.geo-item { display: flex; align-items: center; gap: 7px; }

/* ── Einheitliche Control-Höhe (TextInput = Select2 = Button) ─────────────── */
:root { --control-h: 42px; }
input.input, select.input { height: var(--control-h); }
.btn { min-height: var(--control-h); }
.search { min-height: var(--control-h); }

/* ── Select2 an das eigene Theme angepasst ───────────────────────────────── */
.select2-container { line-height: normal; }
.select2-container--default .select2-selection--single {
  height: var(--control-h);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: normal;
  padding-left: 13px;
  padding-right: 28px;
  color: var(--text);
  font-size: 14px;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--text-3); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 100%; right: 8px; }
.select2-container--default .select2-selection--single .select2-selection__arrow b { border-color: var(--text-2) transparent transparent; }
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b { border-color: transparent transparent var(--text-2); }
.select2-container--default .select2-selection--single .select2-selection__clear { color: var(--text-3); font-weight: 700; margin-right: 18px; }

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
:root[data-theme="dark"] .select2-container--default.select2-container--focus .select2-selection--single,
:root[data-theme="dark"] .select2-container--default.select2-container--open .select2-selection--single {
  box-shadow: 0 0 0 3px rgba(99,102,241,.25);
}

.select2-container--default .select2-dropdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.select2-container--default .select2-results__option {
  color: var(--text);
  padding: 9px 13px;
  font-size: 13.5px;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--brand-600); color: #fff; }
.select2-container--default .select2-results__option[aria-selected=true] { background: var(--surface-2); color: var(--text); }
.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 8px 11px;
}

/* ── Geoblocking ─────────────────────────────────────────────────────────── */
.geo-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.geo-layout--single { grid-template-columns: minmax(0, 1fr); }
.geo-layout--settings { grid-template-columns: minmax(0, 1fr) 340px; }
.geo-side, .geo-tenants { position: sticky; top: 20px; }
.geo-tenants { padding: 0; overflow: hidden; }
.geo-tenants__filter { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.geo-tenants__filter .geo-tenant-search { flex: 1 1 auto; min-width: 0; }
.geo-tenants__filter .geo-tenant-status { flex: 0 0 auto; width: auto; }
.geo-tenants__empty { padding: 16px; }
.geo-tenants__list { display: flex; flex-direction: column; max-height: calc(100vh - 220px); overflow: auto; }
.geo-tenant { display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.geo-tenant:hover { background: var(--surface-2); }
.geo-tenant.is-active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--brand-600); }
.geo-tenant__body { display: flex; flex-direction: column; min-width: 0; }
.geo-tenant__name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.geo-tenant__status { font-size: 11.5px; }
.geo-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--text-3); }
.geo-dot--on { background: var(--success); }
.geo-dot--warn { background: var(--warning); }
.geo-dot--off { background: var(--text-3); }
.geo-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); }
.geo-badge--on { color: var(--success); }
.geo-badge--warn { color: var(--warning); }
.geo-result { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; }
.geo-picker__toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .geo-layout, .geo-layout--settings { grid-template-columns: minmax(0, 1fr); }
  .geo-side, .geo-tenants { position: static; }
  .geo-tenants__list { max-height: 260px; }
}

/* ── Mandanten-Leiste (Master-Detail auf Admin-Seiten) ────────────────────── */
.tenant-view { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.tenant-view--single { grid-template-columns: minmax(0, 1fr); }
.tenant-detail { min-width: 0; }
.tenant-rail { position: sticky; top: 20px; padding: 0; overflow: hidden; }
.tenant-rail__filter { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.tenant-rail__filter .input { width: 100%; }
.tenant-rail__list { display: flex; flex-direction: column; max-height: calc(100vh - 220px); overflow: auto; }
.tenant-rail__item { display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.tenant-rail__item:hover { background: var(--surface-2); }
.tenant-rail__item.is-active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--brand-600); }
.tenant-rail__body { display: flex; flex-direction: column; min-width: 0; }
.tenant-rail__name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tenant-rail__sub { font-size: 11.5px; }
.tenant-rail__empty { padding: 16px; }
@media (max-width: 860px) {
  .tenant-view { grid-template-columns: minmax(0, 1fr); }
  .tenant-rail { position: static; }
  .tenant-rail__list { max-height: 260px; }
}

/* ── Modal (global, wiederverwendbar via app\widgets\Modal) ───────────────── */
.modal { position: fixed; inset: 0; z-index: 1000; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 23, 42, .55); }
.modal.is-open { display: flex; animation: modalFade .12s ease; }
.modal__dialog { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 520px; max-width: 100%; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; animation: modalPop .14s ease; }
.modal__dialog--sm { width: 420px; }
.modal__dialog--lg { width: 760px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; background: var(--sidebar-bg); color: #fff;
  border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.modal__head h3 { font-size: 16px; margin: 0; color: #fff; }
.modal__close { border: 0; background: transparent; cursor: pointer; color: rgba(255, 255, 255, .7);
  font-size: 24px; line-height: 1; width: 34px; height: 34px; border-radius: 8px; }
.modal__close:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.modal__body { padding: 20px; overflow: auto; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── Info-Zeilen (Label ↔ Wert, z. B. Profil-Übersicht) ───────────────────── */
.info-row { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.info-row:last-child { border-bottom: 0; }
.info-row__label { color: var(--text-2); }
.info-row__value { font-weight: 600; text-align: right; }

/* ── Spalten-Menü (Dokument- und Kontaktliste) ─────────────────────────────── */
.colmenu { position: relative; }
.colmenu__panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); padding: 6px; min-width: 210px; }
.colmenu__hint { font-size: 11px; padding: 2px 9px 6px; }
.colmenu__list { list-style: none; margin: 0; padding: 0; }
.colmenu__item { display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 6px;
    font-size: 13px; white-space: nowrap; user-select: none; }
.colmenu__item:hover { background: var(--surface-2); }
.colmenu__item.is-dragging { opacity: .5; background: var(--surface-2); }
.colmenu__grip { cursor: grab; color: var(--text-3); font-size: 13px; line-height: 1; }
.colmenu__lbl { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; }
.colmenu__lbl input { width: 15px; height: 15px; accent-color: var(--brand-500, #6366f1); cursor: pointer; }
