/* ==========================================================================
   MARKENTRIX OS — Komponenten
   Übernimmt die bewährten Klassen aus der Kommandozentrale (kpi-tile,
   status-pill, data-table, dt-card, cred-card, toast …) unverändert im
   Look und erweitert sie um die Shell-Komponenten (Sidebar, Topbar,
   Modal, Drawer, Kanban, Kalender, Command-Palette, Formulare).
   ========================================================================== */

/* ---------------------------------------------------------------- Sidebar */
.sidebar {
  grid-area: sidebar;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: var(--z-sidebar);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: var(--sp-4) var(--sp-4);
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex: none;
  white-space: nowrap;
}
.sidebar-brand .brand-wordmark { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.sidebar-brand .brand-sub { font-size: 10.5px; color: var(--text-muted); margin-top: 1px; }
.app-shell.sidebar-collapsed .brand-text { display: none; }

.sidebar-toggle {
  margin-left: auto; flex: none;
  background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm);
  width: 26px; height: 26px; color: var(--text-muted); display: flex; align-items: center; justify-content: center;
}
.app-shell.sidebar-collapsed .sidebar-toggle { margin-left: 0; }
.sidebar-toggle:hover { color: var(--text-primary); border-color: var(--border-strong); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-2); }
.sidebar-group { margin-bottom: var(--sp-2); }
.sidebar-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
  padding: var(--sp-3) var(--sp-3) var(--sp-1);
  white-space: nowrap;
}
.app-shell.sidebar-collapsed .sidebar-group-label { opacity: 0; height: 4px; padding: 0; overflow: hidden; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px var(--sp-3); border-radius: var(--r-sm);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  white-space: nowrap; position: relative; margin-bottom: 2px;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-item .nav-ico { flex: none; width: 18px; height: 18px; opacity: 0.85; }
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 4px; bottom: 4px; width: 3px;
  background: var(--bar-hue); border-radius: 0 3px 3px 0;
}
.nav-item .nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700; background: rgba(230,103,103,0.18);
  color: var(--status-critical); border-radius: var(--r-pill); padding: 1px 7px; min-width: 18px; text-align: center;
}
.app-shell.sidebar-collapsed .nav-item .nav-label,
.app-shell.sidebar-collapsed .nav-item .nav-badge { display: none; }
.app-shell.sidebar-collapsed .nav-item { justify-content: center; }
.app-shell.sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: var(--sp-2); }

.sidebar-footer { border-top: 1px solid var(--border); padding: var(--sp-3); flex: none; }
.role-chip {
  display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 9px;
  white-space: nowrap; overflow: hidden;
}

/* ---------------------------------------------------------------- Topbar */
.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--border);
  background: var(--page);
  position: sticky; top: 0; z-index: var(--z-topbar);
  min-width: 0;
}
.hamburger { display: none; background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm); width: 34px; height: 34px; color: var(--text-secondary); align-items: center; justify-content: center; flex: none; }
@media (max-width: 900px) { .hamburger { display: flex; } }

.global-search {
  flex: 1 1 320px; max-width: 460px; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 8px 12px; color: var(--text-muted);
}
.global-search input {
  flex: 1; background: none; border: none; color: var(--text-primary); min-width: 0;
}
.global-search input::placeholder { color: var(--text-muted); }
.global-search kbd {
  font-size: 10.5px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-family: inherit;
}
.topbar-spacer { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-2); flex: none; }

.range-select {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 8px 10px; font-size: 12.5px; color: var(--text-secondary);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

#syncBadge { width: auto; padding: 6px 12px; }
#profileBtn { padding: 4px 8px 4px 4px; }

/* ---- Topbar auf Smartphones (≤640px) ----
   Suchfeld-Platzhalter, Zeitraum-Label und alle Button-Beschriftungen
   passen auf einem Handy-Bildschirm nicht gleichzeitig neben die Icons.
   Ohne diese Anpassung werden rechte Topbar-Elemente — u. a. der
   Profil-Button, über den man sich abmeldet — aus dem sichtbaren
   Bereich gedrängt (durch overflow-x:hidden unsichtbar statt scrollbar),
   ohne dass ein einfacher „gibt es horizontalen Scroll"-Test das erkennt).
   Muss NACH den obigen Basis-Regeln stehen, da bei gleicher Spezifität die
   spätere Regel im Stylesheet gewinnt (nicht die Reihenfolge der @media-
   Blöcke). */
@media (max-width: 640px) {
  .topbar { gap: 5px; padding: 0 var(--sp-2); }
  .global-search { flex: 0 0 auto; max-width: none; padding: 8px; }
  .global-search input, .global-search kbd { display: none; }
  .range-select { max-width: 74px; padding: 8px 4px; font-size: 11px; }
  .topbar-right { gap: 3px; }
  #syncBadge span, #createBtn span, #profileName { display: none; }
  #syncBadge, #createBtn { padding: 8px; }
  #profileBtn { padding: 4px; }
}

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border-radius: var(--r-md); padding: 8px 14px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--bar-hue); border-color: var(--bar-hue); color: #05121A; }
.btn-primary:hover { filter: brightness(1.08); color: #05121A; }
.btn-danger { background: transparent; border-color: rgba(230,103,103,0.4); color: var(--status-critical); }
.btn-danger:hover { background: rgba(230,103,103,0.1); border-color: var(--status-critical); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-1); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; border-radius: var(--r-sm); }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--r-md); position: relative; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.icon-btn-badge {
  position: absolute; top: -4px; right: -4px; background: var(--status-critical); color: #fff;
  font-size: 9.5px; font-weight: 700; border-radius: 999px; min-width: 15px; height: 15px;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--page);
}

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #28C7F7, #8B5CF6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; color: #05121A;
}

/* ------------------------------------------------------------- Dropdowns */
.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-md); min-width: 240px; z-index: var(--z-dropdown);
  opacity: 0; transform: translateY(-6px) scale(0.98); pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  padding: var(--sp-2);
}
.dropdown.open .dropdown-panel { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--r-sm); font-size: 12.5px; color: var(--text-secondary); background: none; border: none;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--text-primary); }
.dropdown-sep { height: 1px; background: var(--gridline); margin: 6px 4px; }
.dropdown-header { font-size: 11px; text-transform: uppercase; color: var(--text-muted); padding: 6px 10px 4px; letter-spacing: 0.04em; }

.notif-panel { width: 340px; max-height: 420px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 10px; border-radius: var(--r-sm); align-items: flex-start; }
.notif-item:hover { background: var(--surface-2); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; }
.notif-dot.info { background: var(--bar-hue); }
.notif-dot.warn { background: var(--status-warning); }
.notif-dot.critical { background: var(--status-critical); }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.notif-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.notif-item.unread { background: rgba(40,199,247,0.05); }

/* ------------------------------------------------------------------ Karten */
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-5);
}
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); gap: var(--sp-3); }
.card-title-row h2 { margin: 0; }
.card-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 34px 10px; }

/* -------------------------------------------------------------------- KPI */
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--sp-3); }
.kpi-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-4); cursor: pointer; text-align: left;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.kpi-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.kpi-label { font-size: 11.5px; color: var(--text-muted); margin-bottom: 8px; }
.kpi-value { font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-value.good { color: var(--status-good-text); }
.kpi-value.warning { color: var(--status-warning); }
.kpi-value.critical { color: var(--status-critical); }
.kpi-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; margin-top: 6px; }
.kpi-delta.up { color: var(--status-good-text); }
.kpi-delta.down { color: var(--status-critical); }
.kpi-delta.flat { color: var(--text-muted); }
.kpi-updated { font-size: 10.5px; color: var(--text-muted); margin-top: 6px; }

/* --------------------------------------------------------------- Status */
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.status-pill.good { background: rgba(12,163,12,0.14); color: var(--status-good-text); }
.status-pill.warning { background: rgba(250,178,25,0.14); color: var(--status-warning); }
.status-pill.critical { background: rgba(230,103,103,0.16); color: var(--status-critical); }
.status-pill.info { background: rgba(40,199,247,0.14); color: var(--status-info); }
.status-pill.muted { background: rgba(184,192,204,0.18); color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.status-dot.good { background: var(--status-good); }
.status-dot.warning { background: var(--status-warning); }
.status-dot.critical { background: var(--status-critical); }
.status-dot.muted { background: var(--baseline); }

/* ---------------------------------------------------------------- Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gridline); margin-bottom: var(--sp-5); overflow-x: auto; }
.tab-btn { background: none; border: none; padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab-btn.active { color: var(--text-primary); border-bottom-color: var(--bar-hue); }
.tab-btn:hover { color: var(--text-primary); }

/* View-switcher (Tabelle/Karten/Kanban/Kalender) */
.view-switch { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.view-switch button { border: none; background: none; color: var(--text-muted); font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 7px; }
.view-switch button.active { background: var(--surface-2); color: var(--text-primary); }

/* ------------------------------------------------------------- Toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-4); }
.search-input, .filter-select {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 8px 12px; font-size: 13px; color: var(--text-primary);
}
.search-input { flex: 1 1 220px; min-width: 160px; }
.search-input::placeholder { color: var(--text-muted); }
.results-count { font-size: 12px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* --------------------------------------------------------------- Tabelle */
table.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); padding: 8px; border-bottom: 1px solid var(--gridline); white-space: nowrap; }
table.data-table td { padding: 10px 8px; border-bottom: 1px solid var(--gridline); vertical-align: middle; }
table.data-table tbody tr { cursor: pointer; transition: background var(--dur-fast) var(--ease); }
table.data-table tbody tr:hover { background: var(--surface-2); }
table.data-table tr:last-child td { border-bottom: none; }
.cell-primary { font-weight: 600; color: var(--text-primary); }
.cell-sub { color: var(--text-muted); font-size: 11.5px; margin-top: 1px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini-btn { border: 1px solid var(--border); background: transparent; color: var(--text-secondary); border-radius: var(--r-sm); padding: 5px 9px; font-size: 11.5px; cursor: pointer; white-space: nowrap; }
.mini-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }

/* Health / Score bar */
.health-bar { width: 64px; height: 6px; border-radius: 999px; background: var(--bar-hue-track); overflow: hidden; display: inline-block; vertical-align: middle; }
.health-bar-fill { height: 100%; border-radius: 999px; }

/* ------------------------------------------------------------- Karten-Grid */
.record-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: var(--sp-3); }
.record-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); cursor: pointer; border-left: 3px solid var(--baseline); transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.record-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.record-card.good { border-left-color: var(--status-good); }
.record-card.warning { border-left-color: var(--status-warning); }
.record-card.critical { border-left-color: var(--status-critical); }
.record-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.record-name { font-weight: 700; font-size: 13.5px; }
.record-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.record-meta-row { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; color: var(--text-muted); margin-top: 10px; }

/* ------------------------------------------------------------------ Kanban */
.kanban-board { display: flex; gap: var(--sp-3); overflow-x: auto; padding-bottom: var(--sp-2); align-items: flex-start; }
.kanban-col { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); width: 272px; flex: none; display: flex; flex-direction: column; max-height: calc(100vh - 260px); }
.kanban-col-head { display: flex; align-items: center; gap: 8px; padding: var(--sp-3) var(--sp-3) var(--sp-2); border-bottom: 1px solid var(--gridline); flex: none; }
.kanban-col-title { font-weight: 700; font-size: 12.5px; flex: 1; }
.kanban-col-count { font-size: 11px; color: var(--text-muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.kanban-col-sum { font-size: 10.5px; color: var(--text-muted); padding: 0 var(--sp-3) var(--sp-2); flex: none; }
.kanban-col-body { padding: var(--sp-2); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-col-body.drag-over { background: rgba(40,199,247,0.06); outline: 1px dashed var(--bar-hue); outline-offset: -4px; border-radius: var(--r-sm); }
.kanban-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 11px; cursor: grab; font-size: 12px; }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card-title { font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.kanban-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: var(--text-muted); font-size: 11px; margin-top: 8px; }
/* Tastatur-/Screenreader-Alternative zu Drag & Drop: unauffällig, aber immer bedienbar */
.kanban-move { display: block; margin-top: 8px; }
.kanban-move select {
  width: 100%; background: var(--surface-raised); color: var(--text-secondary); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 10.5px; padding: 4px 6px; cursor: pointer;
}
.kanban-move select:hover { color: var(--text-primary); border-color: var(--border-strong); }

/* ----------------------------------------------------------------- Kalender */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--gridline); border: 1px solid var(--gridline); border-radius: var(--r-md); overflow: hidden; }
.cal-dow { background: var(--surface-1); text-align: center; font-size: 10.5px; color: var(--text-muted); padding: 6px; text-transform: uppercase; }
.cal-cell { background: var(--page); min-height: 92px; padding: 6px; font-size: 11px; }
.cal-cell.other-month { opacity: 0.35; }
.cal-cell.today { background: rgba(40,199,247,0.06); }
.cal-daynum { font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.cal-event { background: var(--surface-2); border-left: 2px solid var(--bar-hue); border-radius: 4px; padding: 2px 5px; margin-bottom: 3px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-event.warning { border-left-color: var(--status-warning); }
.cal-event.critical { border-left-color: var(--status-critical); }

/* -------------------------------------------------------------- Funnel/Bars */
.funnel-row { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 12px; }
.funnel-label { color: var(--text-secondary); }
.funnel-track { background: var(--bar-hue-track); border-radius: 4px; height: 14px; overflow: hidden; }
.funnel-fill { background: var(--bar-hue); height: 100%; border-radius: 4px; min-width: 2px; }
.funnel-fill.lost { background: var(--text-muted); }
.funnel-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }

/* -------------------------------------------------------------- Empty/Skeleton */
.empty-state { text-align: center; color: var(--text-muted); font-size: 13px; padding: 48px 16px; }
.empty-state .empty-ico { width: 40px; height: 40px; margin: 0 auto 12px; opacity: 0.5; }
.empty-state .empty-action { margin-top: 14px; }
.skeleton { background: linear-gradient(90deg, var(--surface-1) 25%, var(--surface-2) 37%, var(--surface-1) 63%); background-size: 400% 100%; animation: skel 1.4s ease infinite; border-radius: var(--r-sm); }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* -------------------------------------------------------------------- Formulare */
.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.field .hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.field .field-error { font-size: 11.5px; color: var(--status-critical); margin-top: 5px; display: none; }
.field.invalid .field-error { display: block; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--status-critical); }
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 9px 11px; color: var(--text-primary);
}
.field textarea { resize: vertical; min-height: 72px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); }
.checkbox-row input { width: auto; }

/* --------------------------------------------------------------------- Modal */
.modal-overlay, .drawer-overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-5);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-base) var(--ease);
}
.modal-overlay.open, .drawer-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-lg);
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.98); transition: transform var(--dur-base) var(--ease);
}
.modal-overlay.open .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5) var(--sp-5) var(--sp-3); border-bottom: 1px solid var(--gridline); }
.modal-body { padding: var(--sp-5); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--gridline); }
.modal-close { background: none; border: none; color: var(--text-muted); width: 30px; height: 30px; border-radius: var(--r-sm); }
.modal-close:hover { color: var(--text-primary); background: var(--surface-2); }

/* --------------------------------------------------------------------- Drawer */
.drawer-overlay { justify-content: flex-end; padding: 0; }
.drawer {
  background: var(--surface-raised); border-left: 1px solid var(--border);
  width: 100%; max-width: 560px; height: 100%; overflow-y: auto; box-shadow: var(--shadow-lg);
  transform: translateX(16px); transition: transform var(--dur-base) var(--ease);
}
.drawer-overlay.open .drawer { transform: none; }
.drawer-head { position: sticky; top: 0; background: var(--surface-raised); z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5); border-bottom: 1px solid var(--gridline); }
.drawer-title { font-size: 17px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; }
.drawer-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.drawer-body { padding: var(--sp-5); }
.drawer-section { margin-bottom: var(--sp-6); }
.drawer-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: var(--sp-3); }
.kv-row { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 7px 0; border-bottom: 1px solid var(--gridline); font-size: 12.5px; }
.kv-row:last-child { border-bottom: none; }
.kv-key { color: var(--text-muted); }
.kv-val { color: var(--text-primary); font-weight: 500; text-align: right; }

/* --------------------------------------------------------------------- Toast */
.toast-stack { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; z-index: var(--z-toast); max-width: 360px; }
.toast {
  background: var(--surface-raised); border: 1px solid var(--border); border-left: 3px solid var(--bar-hue);
  color: var(--text-primary); padding: 12px 14px; border-radius: var(--r-md); font-size: 12.5px;
  box-shadow: var(--shadow-md); display: flex; gap: 10px; align-items: flex-start;
  animation: toast-in var(--dur-base) var(--ease);
}
.toast.success { border-left-color: var(--status-good); }
.toast.error { border-left-color: var(--status-critical); }
.toast.warning { border-left-color: var(--status-warning); }
.toast .toast-msg { flex: 1; line-height: 1.4; }
.toast .toast-close { background: none; border: none; color: var(--text-muted); flex: none; }
.toast .toast-action {
  background: none; border: none; color: var(--bar-hue); flex: none; font-weight: 700;
  font-size: 12px; padding: 0 2px; text-decoration: underline; text-underline-offset: 2px;
}
.toast .toast-action:hover { color: var(--text-primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------- Confirm-Dialog */
.confirm-modal .modal-body { display: flex; gap: 12px; }
.confirm-ico { width: 38px; height: 38px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; }
.confirm-ico.warning { background: rgba(250,178,25,0.14); color: var(--status-warning); }
.confirm-ico.critical { background: rgba(230,103,103,0.16); color: var(--status-critical); }
.confirm-ico.info { background: rgba(40,199,247,0.14); color: var(--status-info); }

/* --------------------------------------------------------- Command Palette */
.palette-overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-palette);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh;
  opacity: 0; pointer-events: none; transition: opacity var(--dur-fast) var(--ease);
}
.palette-overlay.open { opacity: 1; pointer-events: auto; }
.palette {
  width: 100%; max-width: 580px; background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden;
  transform: translateY(-8px); transition: transform var(--dur-fast) var(--ease);
}
.palette-overlay.open .palette { transform: none; }
.palette-input-row { display: flex; align-items: center; gap: 10px; padding: var(--sp-4); border-bottom: 1px solid var(--gridline); }
.palette-input-row input { flex: 1; background: none; border: none; font-size: 15px; color: var(--text-primary); }
.palette-results { max-height: 360px; overflow-y: auto; padding: var(--sp-2); }
.palette-group-label { font-size: 10.5px; text-transform: uppercase; color: var(--text-muted); padding: 8px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); font-size: 13px; color: var(--text-secondary); }
.palette-item .palette-item-sub { color: var(--text-muted); font-size: 11px; margin-left: auto; }
.palette-item.active { background: var(--surface-2); color: var(--text-primary); }
.palette-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 12.5px; }
.palette-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--gridline); font-size: 10.5px; color: var(--text-muted); }
.palette-foot kbd { border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; margin-right: 4px; }

/* -------------------------------------------------------------- Banners/Help */
.help-note { background: var(--surface-1); border: 1px solid var(--border); border-left: 3px solid var(--cat-1); border-radius: var(--r-md); padding: 12px 14px; font-size: 12.5px; color: var(--text-secondary); margin-bottom: var(--sp-5); line-height: 1.55; }
.help-note strong { color: var(--text-primary); }
.banner { border: 1px solid var(--border); border-left: 3px solid var(--status-warning); background: var(--surface-1); border-radius: var(--r-md); padding: 12px 14px; font-size: 12.5px; color: var(--text-secondary); margin-bottom: var(--sp-5); line-height: 1.55; }
.banner strong { color: var(--text-primary); }
.banner.info { border-left-color: var(--status-info); }

/* Sparkline / mini chart canvas wrapper */
.chart-wrap { position: relative; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 11.5px; color: var(--text-secondary); }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }

@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
  .modal { max-width: 96vw; }
  .drawer { max-width: 100vw; }
}

/* ------------------------------------------------------- Login/Registrierung */
.auth-screen {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  background: var(--page); padding: var(--sp-5);
}
.auth-screen[hidden] { display: none; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: var(--sp-7) var(--sp-6);
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: var(--sp-6); }
.auth-logo .brand-wordmark { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16px; color: var(--text-primary); }
.auth-logo .brand-sub { font-size: 11px; color: var(--text-muted); }
.auth-card h1 { font-size: 19px; margin: 0 0 var(--sp-5); }
.auth-error { background: rgba(230,103,103,0.12); border: 1px solid rgba(230,103,103,0.35); color: var(--status-critical); font-size: 12.5px; border-radius: var(--r-sm); padding: 9px 11px; margin-bottom: var(--sp-4); line-height: 1.5; }
.auth-info { background: rgba(40,199,247,0.10); border: 1px solid rgba(40,199,247,0.30); color: var(--text-secondary); font-size: 12.5px; border-radius: var(--r-sm); padding: 9px 11px; margin-bottom: var(--sp-4); line-height: 1.5; }
.auth-switch { display: block; width: 100%; text-align: center; margin-top: var(--sp-5); background: none; border: none; color: var(--bar-hue); font-size: 12.5px; cursor: pointer; padding: 4px; }
.auth-switch:hover { text-decoration: underline; }
