/* ============================================================
   STPS.Mapping — Design System (STPS.Mapping.WebPortal)
   Übernommen aus STPS.OutputSolution. Hell + Dunkel, Poppins + JetBrains Mono.

   DIES IST DIE EINZIGE QUELLE. Der Styleguide unter /styleguide.html liest genau diese
   Datei — er kann also nicht gegenüber der Anwendung driften.

   REGELN (siehe docs/ui-ux-designkonzept.md, Abschnitt 8):
   - Farben ausschließlich über Tokens. Kein #hex, kein rgba() ausserhalb der
     Token-Blöcke.
   - Keine var(--x, #fallback)-Fallbacks auf Literale — die sehen im Hell-Theme
     korrekt aus und kippen erst im Dark-Theme auf.
   - Jeder neue Farbwert entsteht als Token-Paar (:root + [data-theme="dark"]).
   - Bewusst themenunabhängige Stellen tragen einen Kommentar mit Begründung.
   ============================================================ */

/* ------------------------------------------------------------
   1. Tokens — HELL
   ------------------------------------------------------------ */
:root {
  /* Marke */
  --color-primary:        #2e3862;
  --color-primary-hover:  #232b4d;
  --color-primary-soft:   #eef0f7;
  --color-primary-ring:   rgba(46, 56, 98, 0.22);
  --color-accent:         #ff6136;
  --color-accent-hover:   #f04a1f;
  --color-accent-soft:    #fff1ec;

  /* Flächen */
  --color-bg-app:         #f8fafc;
  --color-bg-subtle:      #f1f5f9;
  --color-surface:        #ffffff;
  --color-surface-hover:  #f8fafc;
  --color-border:         #e2e8f0;
  --color-border-strong:  #cbd5e1;

  /* Text — vierstufige Hierarchie:
     primary = Werte · secondary = Fließtext/Zellen · muted = Labels/Meta · faint = Platzhalter */
  --color-text-primary:   #0f172a;
  --color-text-secondary: #334155;
  --color-text-muted:     #64748b;
  --color-text-faint:     #94a3b8;

  /* Semantische Status — Dreier-Set je Status:
     Vollton (Ränder/Icons/Balken/gefüllte Buttons), -bg (Fläche), -text (Vordergrund auf -bg).
     Zusätzlich -soft (noch schwächerer Tint für Kacheln/Log-Zeilen) und -border. */
  --color-success:        #1e7d50;
  --color-success-bg:     #d8efe1;
  --color-success-text:   #0f5436;
  --color-success-soft:   #eef8f2;
  --color-success-border: #a7d9c0;

  --color-warning:        #d97706;
  --color-warning-bg:     #fef3c7;
  --color-warning-text:   #92400e;
  --color-warning-soft:   #fffbeb;
  --color-warning-border: #fcd34d;

  --color-danger:         #dc2626;
  --color-danger-bg:      #fee2e2;
  --color-danger-text:    #991b1b;
  --color-danger-soft:    #fef5f5;
  --color-danger-border:  #fecaca;

  --color-info:           #2563eb;
  --color-info-bg:        #dbeafe;
  --color-info-text:      #1e40af;
  --color-info-soft:      #eff6ff;
  --color-info-border:    #bfdbfe;

  --color-neutral-bg:     #f1f5f9;
  --color-neutral-text:   #475569;

  /* Overlays (Dialog-Backdrop, Drawer-Scrim) */
  --color-scrim:          rgba(15, 23, 42, 0.32);
  --color-backdrop:       rgba(15, 23, 42, 0.45);

  /* Kategoriale Palette für Diagramme — bewusst getrennt von den Statusfarben.
     Die Farbe eines Schlüssels ergibt sich aus seiner Position in einer festen,
     kanonischen Reihenfolge, nie aus dem Rang unter den gerade sichtbaren Werten. */
  --chart-1: #3987e5;
  --chart-2: #d95926;
  --chart-3: #199e70;
  --chart-4: #c98500;
  --chart-5: #d55181;
  --chart-6: #008300;
  --chart-7: #9085e9;
  --chart-8: #e66767;
  --chart-other: #94a3b8;   /* Grau bedeutet immer genau eines: zusammengefasst. */

  /* Schatten */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);

  /* Radien */
  --radius-card:  12px;
  --radius-input: 8px;
  --radius-btn:   8px;
  --radius-pill:  9999px;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  64px;

  /* Schrift */
  --font-ui:   'Poppins', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ------------------------------------------------------------
   2. Tokens — DUNKEL
   Achtung auf die Umkehr: --color-bg-app ist HIER dunkler als --color-surface.
   Karten heben sich also durch Helligkeit ab, genau umgekehrt zum Hell-Theme.
   Genau deshalb dürfen Flächen nie als Literal gesetzt werden.
   ------------------------------------------------------------ */
html[data-theme="dark"] {
  --color-primary:        #6e7aae;   /* heller statt dunkler — dunkles Blau auf dunklem Grund verschwindet */
  --color-primary-hover:  #8a96c4;
  --color-primary-soft:   rgba(110, 122, 174, 0.16);
  --color-primary-ring:   rgba(110, 122, 174, 0.32);
  --color-accent:         #ff8b69;
  --color-accent-hover:   #ffa787;
  --color-accent-soft:    rgba(255, 97, 54, 0.16);

  --color-bg-app:         #0a0f14;
  --color-bg-subtle:      #0f172a;
  --color-surface:        #111827;
  --color-surface-hover:  #1f2937;
  --color-border:         #1f2937;
  --color-border-strong:  #334155;

  --color-text-primary:   #f1f5f9;
  --color-text-secondary: #cbd5e1;
  --color-text-muted:     #94a3b8;
  --color-text-faint:     #64748b;

  --color-success:        #10b981;
  --color-success-bg:     rgba(16, 185, 129, 0.14);
  --color-success-text:   #6ee7b7;
  --color-success-soft:   rgba(16, 185, 129, 0.07);
  --color-success-border: rgba(16, 185, 129, 0.38);

  --color-warning:        #f59e0b;
  --color-warning-bg:     rgba(245, 158, 11, 0.14);
  --color-warning-text:   #fcd34d;
  --color-warning-soft:   rgba(245, 158, 11, 0.07);
  --color-warning-border: rgba(245, 158, 11, 0.38);

  --color-danger:         #ef4444;
  --color-danger-bg:      rgba(239, 68, 68, 0.14);
  --color-danger-text:    #fca5a5;
  --color-danger-soft:    rgba(239, 68, 68, 0.07);
  --color-danger-border:  rgba(239, 68, 68, 0.38);

  --color-info:           #3b82f6;
  --color-info-bg:        rgba(59, 130, 246, 0.14);
  --color-info-text:      #93c5fd;
  --color-info-soft:      rgba(59, 130, 246, 0.07);
  --color-info-border:    rgba(59, 130, 246, 0.38);

  --color-neutral-bg:     rgba(148, 163, 184, 0.12);
  --color-neutral-text:   #cbd5e1;

  --color-scrim:          rgba(0, 0, 0, 0.5);
  --color-backdrop:       rgba(0, 0, 0, 0.6);

  /* Kategoriale Palette: aufgehellt, damit sie auf #0a0f14 trägt.
     Reihenfolge bleibt identisch — sonst wechseln Serien beim Theme-Wechsel die Farbe. */
  --chart-1: #60a5fa;
  --chart-2: #fb8b5c;
  --chart-3: #34d399;
  --chart-4: #fbbf24;
  --chart-5: #f472b6;
  --chart-6: #4ade80;
  --chart-7: #a5b4fc;
  --chart-8: #fca5a5;
  --chart-other: #64748b;

  /* Deutlich kräftiger — sonst verschwindet die Tiefenwirkung auf dunklem Grund. */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.45), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);

  color-scheme: dark;
}

/* ------------------------------------------------------------
   3. Basis
   ------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;               /* Dichte statt Luft — Zielgruppe sind Fachanwender */
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.mono { font-family: var(--font-mono); }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 10px; border: 2px solid var(--color-bg-app); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-faint); }

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   4. App-Shell — CSS-Grid mit benannten Bereichen.
   Kein position:fixed, keine Scroll-Synchronisation: nur .app-content scrollt.
   ------------------------------------------------------------ */
.app-shell {
  --sidebar-w-current: var(--sidebar-w);
  display: grid;
  grid-template-columns: var(--sidebar-w-current) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
  height: 100vh;
  background: var(--color-bg-app);
  transition: grid-template-columns 0.16s ease-out;
}
/* Der Collapse-Zustand hängt am Shell-Container, nicht an der Sidebar — damit können Regeln
   überall im CSS darauf reagieren, auch aus Dateien, die zur Sidebar gar nicht gehören. Die
   Breite ist eine lokale Custom-Property, damit der Übergang animierbar bleibt. */
.app-shell[data-sidebar-collapsed="true"] { --sidebar-w-current: 64px; }

.app-content { grid-area: content; overflow: auto; position: relative; }

/* --- Sidebar --- */
.app-sidebar {
  grid-area: sidebar;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;    /* damit Labels während des Einklappens nicht überstehen */
}
.sidebar-brand {
  padding: 18px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-brand-full { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.sidebar-brand-mark { display: none; align-items: center; justify-content: center; }
.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 8px 12px; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--color-border); font-size: 10.5px; color: var(--color-text-faint); }

.ds-nav-section {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  padding: 0 12px;
  margin: 18px 0 6px;
}
.ds-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 1px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  user-select: none;
}
.ds-nav-item:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.ds-nav-icon { width: 16px; height: 16px; flex: 0 0 auto; color: var(--color-text-muted); }

/* Aktiv = drei Signale: Tönung, Textfarbe, Marker links. Auch bei reduziertem Kontrast eindeutig. */
.ds-nav-item-active { background: var(--color-primary-soft); color: var(--color-primary); }
.ds-nav-item-active .ds-nav-icon { color: var(--color-primary); }
.ds-nav-item-active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 18px;
  background: var(--color-primary);
  border-radius: 2px;
}

.sidebar-toggle {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--color-text-muted);
  padding: 4px;
  border-radius: var(--radius-input);
  cursor: pointer;
  line-height: 0;
  display: grid;
  place-items: center;
}
.sidebar-toggle:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.sidebar-toggle-icon { transition: transform 0.16s ease-out; }

/* Collapsed-Regeln stehen global, weil die Marke am .app-shell hängt. */
.app-shell[data-sidebar-collapsed="true"] .sidebar-brand { flex-direction: column; padding: 14px 0; gap: 8px; }
.app-shell[data-sidebar-collapsed="true"] .sidebar-brand-full { display: none; }
.app-shell[data-sidebar-collapsed="true"] .sidebar-brand-mark { display: flex; }
.app-shell[data-sidebar-collapsed="true"] .sidebar-toggle { margin-left: 0; }
.app-shell[data-sidebar-collapsed="true"] .sidebar-toggle-icon { transform: rotate(180deg); }
.app-shell[data-sidebar-collapsed="true"] .ds-nav-section { display: none; }
.app-shell[data-sidebar-collapsed="true"] .ds-nav-label { display: none; }
.app-shell[data-sidebar-collapsed="true"] .ds-nav-item { justify-content: center; }
.app-shell[data-sidebar-collapsed="true"] .sidebar-footer { display: none; }

/* --- Topbar --- */
.app-topbar {
  grid-area: topbar;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--color-text-muted);
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bc-link { color: var(--color-text-muted); padding: 4px 6px; border-radius: 4px; }
.bc-link:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.bc-sep { color: var(--color-text-faint); font-size: 11px; user-select: none; }
.bc-current { color: var(--color-text-primary); font-weight: 500; padding: 4px 6px; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-bg-subtle);
  color: var(--color-text-secondary);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: border-color 0.1s;
  font-family: inherit;
}
.avatar:hover { border-color: var(--color-border-strong); }

/* Dropdowns über native <details>/<summary> — kein JS-Zustand, kein Outside-Click-Handler,
   Escape und Fokus funktionieren nativ. */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown[open] > .dropdown-menu { display: block; }
.dropdown:not([open]) > .dropdown-menu { display: none; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  animation: dd-in 0.12s ease-out;
}
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-text-primary);
  cursor: pointer;
  user-select: none;
}
.dropdown-item:hover { background: var(--color-surface-hover); }
.dropdown-separator { height: 1px; background: var(--color-border); margin: 6px 4px; }

/* --- Seiten-Container --- */
.page { max-width: 1400px; margin: 0 auto; padding: 28px 32px 80px; }  /* 80px unten: darunter sitzt der Toaster */
.page-wide { max-width: none; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  margin: 0;
}
/* Fokus nach Navigation wird programmatisch auf die h1 gesetzt; der Ring soll dabei nur
   bei echter Tastaturnavigation sichtbar sein. */
.page-title:focus:not(:focus-visible) { outline: none; }
.page-subtitle { font-size: 13.5px; color: var(--color-text-muted); margin: 4px 0 0; }

/* ------------------------------------------------------------
   5. ds-card
   ------------------------------------------------------------ */
.ds-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-xs);
}
.ds-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
/* 14px/600: Die Karte ist ein Behälter, keine Überschrift. */
.ds-card-header h2, .ds-card-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.005em;
}
.ds-card-body { padding: 20px; }

/* ------------------------------------------------------------
   6. ds-btn — Varianten setzen Variablen, nicht Eigenschaften.
   Hover/Fokus/Disabled/Active sind einmal auf der Basisklasse definiert und
   gelten für jede künftige Variante automatisch.
   ------------------------------------------------------------ */
.ds-btn {
  --btn-bg: var(--color-surface);
  --btn-fg: var(--color-text-primary);
  --btn-border: var(--color-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.05s;
  white-space: nowrap;
  user-select: none;
}
.ds-btn:hover:not(:disabled)  { background: var(--color-surface-hover); }
.ds-btn:active:not(:disabled) { transform: translateY(0.5px); }
.ds-btn:focus-visible { outline: 2px solid var(--color-primary-ring); outline-offset: 2px; }
.ds-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ds-btn-primary { --btn-bg: var(--color-primary); --btn-fg: #ffffff; --btn-border: var(--color-primary); }
/* bewusst weiß: Text auf vollflächiger Markenfarbe — die Fläche themed bereits selbst. */
.ds-btn-primary:hover:not(:disabled) { --btn-bg: var(--color-primary-hover); --btn-border: var(--color-primary-hover); }

.ds-btn-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--color-text-secondary); }
.ds-btn-ghost:hover:not(:disabled) { background: var(--color-surface-hover); }

/* Outline — Löschen ist nicht der Normalfall. */
.ds-btn-danger { --btn-bg: var(--color-surface); --btn-fg: var(--color-danger); --btn-border: var(--color-border); }
.ds-btn-danger:hover:not(:disabled) { --btn-bg: var(--color-danger-bg); --btn-border: var(--color-danger); }

/* Gefüllt — nur für eindeutige Ja/Nein-Entscheidungen. */
.ds-btn-success      { --btn-bg: var(--color-success); --btn-fg: #ffffff; --btn-border: var(--color-success); }
.ds-btn-danger-solid { --btn-bg: var(--color-danger);  --btn-fg: #ffffff; --btn-border: var(--color-danger); }
/* bewusst weiß (beide): Text auf vollflächiger Statusfarbe. */
.ds-btn-success:hover:not(:disabled) {
  --btn-bg: color-mix(in oklab, var(--color-success) 86%, #000);
  --btn-border: color-mix(in oklab, var(--color-success) 86%, #000);
}
.ds-btn-danger-solid:hover:not(:disabled) {
  --btn-bg: color-mix(in oklab, var(--color-danger) 86%, #000);
  --btn-border: color-mix(in oklab, var(--color-danger) 86%, #000);
}

.ds-btn-lg    { height: 42px; padding: 0 18px; font-size: 14px; }
.ds-btn-sm    { height: 30px; padding: 0 10px; font-size: 12px; }
.ds-btn-block { width: 100%; }
.ds-btn-icon  { width: 36px; padding: 0; }

/* ------------------------------------------------------------
   7. Eingaben
   ------------------------------------------------------------ */
.ds-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}
.ds-label-hint { color: var(--color-text-muted); font-weight: 400; }
.ds-field-hint { margin-top: 6px; font-size: 11.5px; color: var(--color-text-muted); }

.ds-input, .ds-select, .ds-textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  transition: border-color 0.12s, box-shadow 0.12s;
  outline: none;
}
.ds-textarea { height: auto; padding: 10px 12px; min-height: 80px; resize: vertical; line-height: 1.5; }
.ds-input:focus, .ds-select:focus, .ds-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}
.ds-input::placeholder, .ds-textarea::placeholder { color: var(--color-text-faint); }
.ds-input:disabled, .ds-select:disabled, .ds-textarea:disabled {
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  cursor: not-allowed;
}
/* Select-Pfeil als inline-SVG-Data-URI — kein Icon-Font, kein Bild-Request.
   Der Pfeil kann nicht themen (Data-URI), ist aber in beiden Themes ein neutrales Grau. */
.ds-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
/* Kompakte Variante für dichte Filter-/Toolbar-Zeilen. */
.ds-input-sm, .ds-select-sm { height: 26px; padding: 2px 6px; font-size: 11.5px; }
.ds-select-sm { padding-right: 26px; background-position: right 8px center; }

.ds-checkbox, .ds-radio { accent-color: var(--color-primary); width: 15px; height: 15px; }

.ds-field { margin-bottom: 16px; }
.ds-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* ------------------------------------------------------------
   8. ds-badge — Basisklasse IST die neutrale Variante.
   Die Zuordnung Status → Ton gehört im Code an genau eine Stelle, nicht ins Markup.
   ------------------------------------------------------------ */
.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  height: 22px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-pill);
  background: var(--color-neutral-bg);
  color: var(--color-neutral-text);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.ds-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.ds-badge-success { background: var(--color-success-bg); color: var(--color-success-text); }
.ds-badge-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.ds-badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger-text); }
.ds-badge-info    { background: var(--color-info-bg);    color: var(--color-info-text); }

/* ------------------------------------------------------------
   9. ds-alert
   ------------------------------------------------------------ */
.ds-alert {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-input);
  background: var(--color-neutral-bg);
  color: var(--color-text-secondary);
  font-size: 13px;
  border: 1px solid transparent;
}
.ds-alert-info    { background: var(--color-info-bg);    color: var(--color-info-text); }
.ds-alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.ds-alert-danger  { background: var(--color-danger-bg);  color: var(--color-danger-text); }
.ds-alert-success { background: var(--color-success-bg); color: var(--color-success-text); }

/* ------------------------------------------------------------
   10. ds-table — kein Zebra-Streifen; Hover und Trennlinien reichen.
   ------------------------------------------------------------ */
.ds-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ds-table thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  white-space: nowrap;
}
.ds-table thead th.is-sortable { cursor: pointer; user-select: none; }
.ds-table thead th.is-sortable:hover { color: var(--color-text-primary); }
.ds-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  vertical-align: middle;
}
/* Nur die Leitspalte wird hochgezogen. */
.ds-table tbody td.is-lead { color: var(--color-text-primary); font-weight: 500; }
.ds-table tbody tr { transition: background 0.1s; }
.ds-table tbody tr:hover { background: var(--color-surface-hover); cursor: pointer; }
/* Zeilen ohne Detailseite: Hover-Tönung ja, Hand-Cursor nein — ein Zeiger ohne Ziel ist ein
   leeres Versprechen. */
.ds-table tbody tr.is-static:hover { cursor: default; }
.ds-table tbody tr:last-child td { border-bottom: 0; }

/* Link in einer Tabellenzelle. Ohne Unterstreichung im Ruhezustand — eine Tabelle voller
   unterstrichener Namen ist unruhig; der Hover macht die Klickbarkeit deutlich genug. */
.table-link { color: inherit; }
.table-link:hover { color: var(--color-primary); text-decoration: underline; }

/* Aktionen am Zeilenende. Rechtsbündig, damit sie über alle Zeilen eine Kante bilden. */
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

/* Zeile, die Aufmerksamkeit braucht (z. B. Quelle ohne Ziel). Bewusst -soft und nicht -bg:
   über eine ganze Tabelle wäre der kräftige Tint zu laut, und die Badges in der Statusspalte
   müssen sich noch davon abheben. */
.ds-table tbody tr.is-unmapped { background: var(--color-warning-soft); }
.ds-table tbody tr.is-unmapped:hover { background: var(--color-warning-bg); }

/* Technischer Bezeichner in einer Zelle — Quellschlüssel, Zielschlüssel, IDs. */
.ds-key {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--color-bg-subtle);
  color: var(--color-text-primary);
  font-size: 12px;
}

/* Mehrzeiliger Rohtext: JSON-Metadaten, Stacktraces. */
.code-block {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-input);
  background: var(--color-bg-subtle);
  color: var(--color-text-secondary);
  font-size: 11.5px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ------------------------------------------------------------
   10b. Wiederkehrende Seitenbausteine
   ------------------------------------------------------------ */

/* Titelzeile einer Detailseite: Überschrift plus Statusträger auf einer Grundlinie. */
.detail-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* Filter-/Suchleiste im Kartenkopf. */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  min-width: 0;
}
.toolbar-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--color-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

/* Zwei gleichwertige Karten nebeneinander; unter 1000px untereinander. */
.detail-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  align-items: start;
}

/* Eingabe mit angehängter Aktion (Kopieren, Öffnen, Anzeigen). Der Button behält seine
   Eigenbreite, das Feld nimmt den Rest. */
.input-with-action {
  display: flex;
  gap: 8px;
}
.input-with-action > .ds-input { flex: 1 1 auto; min-width: 0; }
.input-with-action > .ds-btn { flex: 0 0 auto; height: 38px; }

/* Anmeldeflächen ohne Shell (EmptyLayout): Kundenzugang, Login, Passwort-Reset.
   Eine gemeinsame Hülle, damit die Seiten nicht einzeln auseinanderlaufen. */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--color-bg-app);
}
.auth-box { width: 100%; max-width: 380px; }
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  text-align: center;
}
.auth-brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.auth-brand-accent { color: var(--color-accent); }
.auth-brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--color-text-primary);
}
.auth-brand-sub { font-size: 12.5px; color: var(--color-text-muted); }
.auth-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--color-text-muted);
}
/* Überschrift in der Anmeldekarte. 18px statt der 22px einer Seitenüberschrift: die Karte
   ist schmal, und der Satz darunter trägt die eigentliche Information. */
.auth-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--color-text-primary);
}
.auth-title:focus:not(:focus-visible) { outline: none; }
.auth-lead {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.auth-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
  font-size: 12.5px;
}
.auth-links a { color: var(--color-primary); }
.auth-links a:hover { text-decoration: underline; }

/* Kundenbereich: keine Sidebar, nur eine schlanke Kopfleiste. Steht global, weil sich
   Mapping-Liste und Editor sie teilen (Regel 10). */
.customer-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.customer-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.customer-brand-svg { flex: 0 0 auto; color: var(--color-primary); }
.customer-brand-accent { color: var(--color-accent); }
.customer-project {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.customer-topbar-right { display: flex; align-items: center; gap: 10px; }
.customer-topbar form { display: inline; margin: 0; }
/* Quittung des Sofortspeicherns. Bewusst nur Text und keine Statusfarbe: „gespeichert" ist
   der Normalfall und soll nicht wie eine Erfolgsmeldung aufblinken. */
.save-status {
  font-size: 11.5px;
  color: var(--color-text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* Begruendung, warum das Werkzeug einen Wunsch abgelehnt hat. Steht direkt unter dem Status
   des Eintrags, weil sie nur dort etwas erklaert - als eigene Spalte waere sie in fast jeder
   Zeile leer. */
.entry-reject {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--color-warning-text, var(--color-text-muted));
  max-width: 260px;
}

/* Schmaler als das interne Portal: der Kundenbereich zeigt Listen, keine Datentabellen. */
.customer-page { max-width: 860px; }

/* Rückfrage direkt im Fluss, wenn ein modaler Dialog zu viel wäre — der Nutzer soll den
   Zustand sehen, über den er entscheidet. */
.confirm-inline { align-items: center; flex-wrap: wrap; }
.confirm-inline-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* Formularspalte. Ersetzt das row/col-Raster des Identity-Scaffoldings: Anmelde- und
   Profilformulare brauchen keine Rasterspalten, sondern eine begrenzte Zeilenlänge. */
.form-column { max-width: 520px; }

/* Untermenü des Profilbereichs. Der aktive Marker der Sidebar sitzt bei -12px Padding;
   hier gibt es keins, deshalb rückt er auf 0. */
.manage-nav {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.manage-nav .ds-nav-item-active::before { left: 0; }

/* Wertpaare in Detailkarten: Label oben klein, Wert darunter. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px 24px;
}
.field-value {
  margin-top: 2px;
  font-size: 13px;
  color: var(--color-text-primary);
}
.ds-table .num { font-family: var(--font-mono); font-size: 12px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* Filterzeile: sitzt im <thead>, damit Filter dort stehen, wo die Spalte ist. */
.ds-table-filter-row th { padding: 6px 16px; background: var(--color-bg-subtle); border-bottom: 1px solid var(--color-border); }
.ds-table-filter-input, .ds-table-filter-select {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.ds-table-filter-input::placeholder { color: var(--color-text-muted); }
.ds-table-filter-input:focus, .ds-table-filter-select:focus { border-color: var(--color-primary); }
.ds-table-filter-select {
  appearance: none;
  padding-right: 24px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* Pager — rendert nichts, wenn ohnehin alles auf eine Seite passt (Logik im Code). */
.ds-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-muted);
}
.ds-pager-nav { display: flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------
   11. Leerzustände — zweistufig.
   ------------------------------------------------------------ */
/* Noch nichts angelegt: Karte, zentriert, nennt den Weg nach vorn. */
.ds-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
}
.ds-empty-title { font-size: 14px; font-weight: 600; color: var(--color-text-primary); margin: 0 0 6px; }
.ds-empty-icon { color: var(--color-text-faint); margin-bottom: 12px; }
/* Filter treffen nichts: Zeile über alle Spalten — Tabelle samt Filterzeile bleibt stehen. */
.ds-table-empty td { padding: 32px 16px; text-align: center; color: var(--color-text-muted); font-size: 12.5px; }

/* ------------------------------------------------------------
   12. Native <dialog> — aktive Sekundäraufgaben (Editoren, Wizards, Bestätigungen)
   ------------------------------------------------------------ */
dialog.ds-dialog {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  color: var(--color-text-primary);
  padding: 0;
  box-shadow: var(--shadow-lg);
  max-width: min(92vw, 1100px);
  max-height: 88vh;
  overflow: hidden;
}
/* WICHTIG: Browser-Default für ein geschlossenes <dialog> ist display:none.
   Ein pauschales display:flex würde auch geschlossene Dialoge sichtbar machen. */
dialog.ds-dialog[open] { display: flex; flex-direction: column; }
dialog.ds-dialog::backdrop { background: var(--color-backdrop); backdrop-filter: blur(2px); }

.ds-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
}
.ds-dialog-header h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text-primary); letter-spacing: -0.005em; }
.ds-dialog-body { padding: 20px; overflow: auto; flex: 1 1 auto; }
.ds-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
}
.ds-dialog-close, .ds-drawer-close, .ds-toast-close, .ds-banner-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px;
  border-radius: var(--radius-input);
  line-height: 0;
}
.ds-dialog-close:hover, .ds-drawer-close:hover, .ds-toast-close:hover, .ds-banner-close:hover {
  background: var(--color-surface-hover);
  color: var(--color-text-primary);
}

/* ------------------------------------------------------------
   13. Drawer — passive Inspektion (Verlauf, Rohdaten, Stacktrace)
   ------------------------------------------------------------ */
.ds-drawer-shell { position: fixed; inset: 0; pointer-events: none; z-index: 900; }
.ds-drawer-scrim { position: absolute; inset: 0; background: var(--color-scrim); opacity: 0; transition: opacity 0.16s ease-out; }
.ds-drawer {
  position: absolute;
  top: 0; right: 0;
  height: 100%;
  width: min(420px, 90vw);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.18s ease-out;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}
.ds-drawer-shell.ds-drawer-open { pointer-events: auto; }
.ds-drawer-shell.ds-drawer-open .ds-drawer-scrim { opacity: 1; }
.ds-drawer-shell.ds-drawer-open .ds-drawer { transform: translateX(0); }
.ds-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
}
.ds-drawer-header h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text-primary); }
.ds-drawer-body { padding: 16px 20px; overflow: auto; flex: 1 1 auto; }

/* ------------------------------------------------------------
   14. Toaster — Ergebnis einer gerade ausgelösten Aktion (5s, unten rechts)
   ------------------------------------------------------------ */
.ds-toaster {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1100;
  pointer-events: none;
}
.ds-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--color-text-primary);
  pointer-events: auto;
  animation: toast-in 0.16s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.ds-toast-msg { flex: 1; line-height: 1.4; }
.ds-toast-success { border-left: 3px solid var(--color-success); }
.ds-toast-success > svg:first-of-type { color: var(--color-success); }
.ds-toast-warning { border-left: 3px solid var(--color-warning); }
.ds-toast-warning > svg:first-of-type { color: var(--color-warning); }
.ds-toast-danger  { border-left: 3px solid var(--color-danger); }
.ds-toast-danger  > svg:first-of-type { color: var(--color-danger); }
.ds-toast-info    { border-left: 3px solid var(--color-info); }
.ds-toast-info    > svg:first-of-type { color: var(--color-info); }

/* ------------------------------------------------------------
   15. Banner — Zustand der Seite, den der Nutzer kennen muss, bevor er handelt
   ------------------------------------------------------------ */
.ds-banner-stack { display: flex; flex-direction: column; gap: 6px; padding: 12px 24px 0; }
.ds-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  font-size: 12.5px;
  color: var(--color-text-primary);
  background: var(--color-surface);
}
.ds-banner-msg { flex: 1; line-height: 1.4; }
.ds-banner-action {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-primary);
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  background: var(--color-surface);
}
.ds-banner-action:hover { background: var(--color-surface-hover); }
.ds-banner-info    { border-left: 3px solid var(--color-info); }
.ds-banner-info    > svg:first-of-type { color: var(--color-info); }
.ds-banner-success { border-left: 3px solid var(--color-success); }
.ds-banner-success > svg:first-of-type { color: var(--color-success); }
.ds-banner-warning { border-left: 3px solid var(--color-warning); }
.ds-banner-warning > svg:first-of-type { color: var(--color-warning); }
.ds-banner-danger  { border-left: 3px solid var(--color-danger); }
.ds-banner-danger  > svg:first-of-type { color: var(--color-danger); }

/* ------------------------------------------------------------
   16. KPI-Kacheln
   ------------------------------------------------------------ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}
.kpi-card--info    { border-left-color: var(--color-info); }
.kpi-card--primary { border-left-color: var(--color-primary); }
.kpi-card--success { border-left-color: var(--color-success); }
.kpi-card--danger  { border-left-color: var(--color-danger); }
.kpi-icon {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--color-neutral-bg);
  color: var(--color-neutral-text);
}
.kpi-card--info    .kpi-icon { background: var(--color-info-bg);      color: var(--color-info-text); }
.kpi-card--primary .kpi-icon { background: var(--color-primary-soft); color: var(--color-primary); }
.kpi-card--success .kpi-icon { background: var(--color-success-bg);   color: var(--color-success-text); }
.kpi-card--danger  .kpi-icon { background: var(--color-danger-bg);    color: var(--color-danger-text); }
.kpi-body { min-width: 0; }
.kpi-label { font-size: 12px; font-weight: 500; color: var(--color-text-muted); }
.kpi-value {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;   /* damit Zahlen beim Live-Update nicht zappeln */
}
.kpi-hint { font-size: 11.5px; color: var(--color-text-faint); }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ------------------------------------------------------------
   17. Fortschritt, Spinner, Stepper
   ------------------------------------------------------------ */
.progress { position: relative; height: 8px; background: var(--color-bg-subtle); border-radius: var(--radius-pill); overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-primary); border-radius: var(--radius-pill); transition: width 0.4s ease-out; }
.progress-fill.indeterminate { width: 35% !important; animation: progress-indet 1.4s ease-in-out infinite; }
/* Zähler unter dem Balken (z. B. „118 / 240"). tabular-nums, damit er beim Aktualisieren
   nicht zappelt. */
.progress-caption {
  margin-top: 4px;
  font-size: 11px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
/* Fortschritt unter 100 % bleibt neutral-primär; erst diese Modifier färben ihn. */
.progress-fill.is-warning { background: var(--color-warning); }
.progress-fill.is-danger  { background: var(--color-danger); }
.progress-fill.is-success { background: var(--color-success); }
@keyframes progress-indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ds-stepper {
  display: flex;
  align-items: flex-start;
  padding: 16px 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}
.ds-step { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; text-align: center; }
/* Verbindungslinie hinter den Kreisen. */
.ds-step:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 15px;          /* vertikale Mitte des 32px-Kreises minus Linienstärke */
  right: 50%; left: -50%;
  height: 2px;
  background: var(--color-border);
  z-index: 0;
}
.ds-step.is-done::before, .ds-step.is-active::before {
  background: color-mix(in srgb, var(--color-success) 55%, var(--color-border));
}
.ds-step-circle {
  position: relative; z-index: 1;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  background: var(--color-bg-subtle);
  border: 2px solid var(--color-border);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.ds-step-label { font-size: 12px; color: var(--color-text-muted); line-height: 1.25; padding: 0 4px; }
.ds-step.is-done .ds-step-circle { background: var(--color-success); border-color: var(--color-success); color: #fff; }
/* bewusst weiß: Häkchen/Nummer auf vollflächiger Statusfarbe. */
.ds-step.is-done .ds-step-label { color: var(--color-text-secondary); }
.ds-step.is-active .ds-step-circle {
  background: var(--color-info);
  border-color: var(--color-info);
  color: #fff;   /* bewusst weiß: siehe oben */
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-info) 18%, transparent);
}
.ds-step.is-active .ds-step-label { color: var(--color-text-primary); font-weight: 600; }
@media (max-width: 640px) { .ds-step-label { font-size: 10.5px; } }

/* ------------------------------------------------------------
   18. Kleinteile
   ------------------------------------------------------------ */
.ds-meta-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.search-box { position: relative; flex: 1; max-width: 320px; }
.search-box input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.search-box input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-ring); }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); }

/* Kunden-/Fremdlogos sind typischerweise dunkel auf transparent und im Dark-Theme unlesbar.
   invert flippt die Helligkeit, hue-rotate dreht den mitinvertierten Farbton näherungsweise
   zurück. Grenze: ein bereits helles Logo wird dadurch dunkel — dann gehört ein zweiter
   Upload „Logo (dunkel)" her, kein schlauerer Filter. */
html[data-theme="dark"] .tenant-logo { filter: invert(1) hue-rotate(180deg); }

/* ------------------------------------------------------------
   19. Bewegung — knapp bemessen, und auf Wunsch gar nicht.
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------
   20. Blazor
   Alles ab hier ist framework-spezifisch und hat im portablen Teil des Systems nichts
   verloren. Die Klassennamen gibt Blazor vor, sie sind nicht frei wählbar.
   ------------------------------------------------------------ */

/* EditForm-Validierung. Blazor setzt .valid/.invalid selbst auf das Eingabefeld. */
.valid.modified:not([type=checkbox]) {
  border-color: var(--color-success);
}
.invalid {
  border-color: var(--color-danger);
}
.invalid:focus {
  box-shadow: 0 0 0 3px var(--color-danger-bg);
}
.validation-message {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--color-danger);
}
.validation-errors {
  margin: 0 0 16px;
  padding: 12px 14px;
  list-style: none;
  border-radius: var(--radius-input);
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  font-size: 13px;
}

/* Fehleranzeige des Frameworks. Bewusst als Banner unten, nicht als Toast: der Zustand ist
   nicht das Ergebnis einer Nutzeraktion und darf sich nicht nach 5s selbst wegblenden. */
#blazor-error-ui {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 2000;
  padding: 10px 16px;
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  border-top: 1px solid var(--color-danger);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
}
#blazor-error-ui .reload {
  margin-left: 8px;
  font-weight: 600;
  color: var(--color-danger);
  text-decoration: underline;
  cursor: pointer;
}
#blazor-error-ui .dismiss {
  float: right;
  cursor: pointer;
  padding: 0 4px;
}

/* Verbindungsverlust-Overlay des Frameworks. Die Einblendung ist um 0.4s verzögert, damit
   kurze Aussetzer unsichtbar bleiben — ein sofort aufpoppendes Overlay macht eine stabile
   Anwendung nervös. */
.components-reconnect-show,
.components-reconnect-failed,
.components-reconnect-rejected {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: grid;
  place-items: center;
  background: var(--color-backdrop);
  backdrop-filter: blur(2px);
  color: var(--color-text-primary);
  font-size: 13px;
  animation: reconnect-in 0.2s ease-out 0.4s both;
}
@keyframes reconnect-in { from { opacity: 0; } to { opacity: 1; } }
