/* ============================================================
   ZAS Dashboard — Redesign v2 (2026-04-24)
   Sidebar-Layout, eckig, professionell, business-like.
   ============================================================ */

/* ---- Design Tokens ---- */
:root {
  /* Farben */
  --color-bg: #f5f6f8;
  --color-panel: #ffffff;
  --color-panel-alt: #fafbfc;
  --color-border: #e4e6eb;
  --color-border-strong: #d1d5db;
  --color-text: #1a1a2e;
  --color-text-muted: #6b7280;
  --color-text-subtle: #9ca3af;

  /* Sidebar */
  --sidebar-bg: #1a1a2e;
  --sidebar-bg-alt: #242440;
  --sidebar-border: #2c2c4a;
  --sidebar-text: #e5e7eb;
  --sidebar-text-muted: #9ca3af;
  --sidebar-hover: #2d2d4f;
  --sidebar-active: #0f766e;
  --sidebar-active-text: #ffffff;

  /* Accent (Teal) */
  --accent: #0f766e;
  --accent-hover: #0c5e57;
  --accent-light: #14b8a6;
  --accent-soft: #ccfbf1;
  --accent-bg: #f0fdfa;

  /* States */
  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-success: #059669;
  --color-success-bg: #ecfdf5;
  --color-info: #2563eb;
  --color-info-bg: #eff6ff;

  /* Maße */
  --sidebar-width: 260px;
  --sidebar-width-mobile: 280px;
  --radius: 2px;
  --radius-lg: 4px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-sidebar: 2px 0 8px rgba(0, 0, 0, 0.06);

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Consolas', 'Monaco', monospace;

  /* Transitions */
  --transition: 150ms ease;
}

/* ---- Reset ---- */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.25;
}
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }
h5 { font-size: 14px; }

p { margin: 0; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

.hidden {
  display: none !important;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-subtle);
  margin-bottom: 4px;
}

.section-copy {
  color: var(--color-text-muted);
  font-size: 14px;
  line-height: 1.55;
}

/* ============================================================
   LOGIN VIEW
   ============================================================ */
.screen-login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  /* keine backdrop-filter / blur — iOS Safari Bug */
}

.login-panel {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  padding: 40px 32px;
  border: 1px solid var(--color-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  margin: 0 auto 16px;
  letter-spacing: -0.02em;
}

.login-logo-img {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  object-fit: contain;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-text);
}

.login-slogan {
  color: var(--color-text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-footer {
  margin-top: 24px;
  text-align: center;
  color: var(--color-text-subtle);
  font-size: 12px;
}

/* ============================================================
   APP SHELL (Sidebar + Content)
   ============================================================ */
.screen-app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-sidebar);
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 72px;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: #fff;
  padding: 4px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  min-width: 0;
  flex: 1;
}

.sidebar-product {
  color: var(--sidebar-text);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-company {
  color: var(--sidebar-text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-badge {
  margin: 12px 16px 0;
  padding: 8px 12px;
  background: var(--sidebar-bg-alt);
  border-left: 3px solid var(--accent);
  color: var(--sidebar-text);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-badge-super {
  border-left-color: #fbbf24;
}

.sidebar-badge-dot {
  width: 8px;
  height: 8px;
  background: #fbbf24;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sidebar-impersonate {
  margin: 12px 16px 0;
  padding: 10px 12px;
  background: rgba(251, 191, 36, 0.1);
  border-left: 3px solid #fbbf24;
}

.sidebar-impersonate-label {
  color: #fbbf24;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.sidebar-impersonate-name {
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.sidebar-impersonate-exit {
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid #fbbf24;
  color: #fbbf24;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.sidebar-impersonate-exit:hover {
  background: #fbbf24;
  color: #1a1a2e;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--sidebar-text-muted);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.nav-item.active {
  background: var(--sidebar-bg-alt);
  color: var(--sidebar-active-text);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item.active .nav-icon {
  opacity: 1;
  color: var(--accent-light);
}

.nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
  position: relative;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
  min-height: 44px;
}

.sidebar-user:hover {
  background: var(--sidebar-hover);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user-text {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 40px;
}

.sidebar-logout:hover {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}

/* ---- Profile Menu (popup above sidebar user) ---- */
.profile-menu {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  margin-bottom: 4px;
  background: #fff;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 50;
}

.profile-menu button {
  display: flex;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
}

.profile-menu button:hover {
  background: var(--color-bg);
}

.profile-menu-info {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 6px;
}

/* ---- Mobile Topbar ---- */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--sidebar-border);
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.mobile-nav-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--sidebar-border);
  cursor: pointer;
}

.mobile-nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
  transition: transform var(--transition);
}

.mobile-topbar-title {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
}

/* ---- Backdrop for mobile nav ---- */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 35;
}

body.nav-open .nav-backdrop {
  display: block;
}

/* ============================================================
   WORKSPACE (Content Area)
   ============================================================ */
.workspace {
  padding: 24px 32px 40px;
  min-width: 0;
  max-width: 100%;
}

.content-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.content-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}

.content-subtitle {
  color: var(--color-text-muted);
  font-size: 13px;
}

/* ---- Panels ---- */
.panel {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  padding: 20px;
  margin-bottom: 16px;
}

.panel-filter-banner {
  padding: 0;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.panel-header-compact {
  margin-bottom: 0;
  padding: 12px 20px;
  background: var(--color-panel-alt);
  border-bottom: 1px solid var(--color-border);
}

.filter-banner-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}

.filter-banner-body {
  padding: 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filter-banner-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-banner-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-subtle);
}

.toggle-arrow {
  font-size: 10px;
  transition: transform var(--transition);
}

.filter-banner-toggle[aria-expanded="true"] .toggle-arrow {
  transform: rotate(180deg);
}

/* ---- Section tabs ---- */
.section-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 16px;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.section-tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 44px;
}

.section-tab:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.section-tab.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

.section-tab-action {
  margin-left: auto;
  margin-right: 12px;
  border-right: none !important;
}

/* ---- Form elements ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.input, input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="url"], input[type="number"], input[type="date"],
input[type="time"], input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.45;
  min-height: 44px;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

select {
  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 fill='%236b7280' d='M6 8L2 4h8z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-subtle);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  background: transparent;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  min-height: 44px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: #fff;
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg);
  border-color: var(--color-text-muted);
}

.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-small {
  padding: 7px 12px;
  font-size: 13px;
  min-height: 36px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

.icon-btn-close {
  font-size: 22px;
  line-height: 1;
}

/* ---- Toolbar rows ---- */
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-row-end {
  justify-content: flex-end;
}

.toolbar-row-compact {
  gap: 8px;
}

/* ---- Forms ---- */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---- Stats grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.stats-grid-compact {
  gap: 8px;
}

.stat-card {
  padding: 14px;
  background: #fff;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.stat-card.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 0 0 1px var(--accent);
}

.stat-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.stat-card-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
}

.stat-card-sub {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ---- Filters grid ---- */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.filters-grid-compact .field-search {
  grid-column: span 2;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-shell {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 12px 14px;
  background: var(--color-panel-alt);
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--color-panel-alt);
}

.data-table tr.row-selected td {
  background: var(--accent-bg);
}

.sort-btn {
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.sort-btn-arrow {
  opacity: 0.5;
  font-size: 10px;
}

.sort-btn.sorted .sort-btn-arrow {
  opacity: 1;
  color: var(--accent);
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-status-neu { background: var(--color-info-bg); color: var(--color-info); }
.badge-status-in_bearbeitung { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-status-erledigt { background: var(--color-success-bg); color: var(--color-success); }
.badge-priority-high { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-priority-normal { background: var(--color-bg); color: var(--color-text-muted); }
.badge-priority-low { background: var(--color-panel-alt); color: var(--color-text-subtle); }

/* ============================================================
   MANDANTEN-CARDS (super-admin tenants)
   ============================================================ */
.tenant-card {
  border: 1px solid var(--color-border);
  padding: 16px 20px;
  margin-bottom: 12px;
  background: #fff;
  transition: border-color var(--transition);
}

.tenant-card:hover {
  border-color: var(--accent);
}

.tenant-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tenant-card-name {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
}

.tenant-card-slug {
  font-size: 12px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.tenant-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tenant-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-muted);
}

.tenant-card-stat strong {
  color: var(--color-text);
  font-weight: 700;
}

/* ============================================================
   USAGE GRID (super-admin)
   ============================================================ */
.usage-filter-bar {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid var(--color-border);
  width: fit-content;
}

.range-btn {
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
}

.range-btn:last-child {
  border-right: none;
}

.range-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.range-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.stats-filter-bar {
  display: flex;
  gap: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  width: fit-content;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.usage-card {
  background: #fff;
  border: 1px solid var(--color-border);
  padding: 20px;
}

.usage-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--accent);
}

.usage-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  color: var(--color-text-muted);
}

.usage-card-row:last-child {
  border-bottom: none;
}

.usage-card-value {
  font-weight: 700;
  color: var(--color-text);
  font-size: 15px;
}

/* ============================================================
   ADMIN OVERVIEW (super-admin dashboard)
   ============================================================ */
.admin-overview {
  display: grid;
  gap: 16px;
}

.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.admin-kpi {
  background: #fff;
  border: 1px solid var(--color-border);
  padding: 18px;
  border-left: 3px solid var(--accent);
}

.admin-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.admin-kpi-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.admin-kpi-sub {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ============================================================
   SPLIT LAYOUTS (editor panels)
   ============================================================ */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.split-layout-wide {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.side-panel,
.editor-panel {
  min-width: 0;
}

/* ---- Stack list ---- */
.stack-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stack-list-item {
  display: flex;
  padding: 12px;
  background: var(--color-panel-alt);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.stack-list-item:hover {
  background: #fff;
  border-color: var(--color-border);
}

.stack-list-item.active {
  background: var(--accent-bg);
  border-color: var(--accent);
}

/* ---- Template list / Vorlagen (Fix #4) ---- */
.template-group {
  border: 1px solid var(--color-border);
  margin-bottom: 8px;
  background: var(--color-panel);
}

.template-group-header {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 10px 14px;
  background: var(--color-panel-alt);
  border: none;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  text-align: left;
  min-height: 44px;
}

.template-group.collapsed .template-group-header {
  border-bottom: none;
}

.template-group-label {
  flex: 1;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.template-group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--color-border);
  color: var(--color-text);
}

.template-group-chevron {
  font-size: 10px;
  color: var(--color-text-muted);
  transition: transform var(--transition);
}

.template-group.collapsed .template-group-chevron {
  transform: rotate(-90deg);
}

.template-group-body {
  display: flex;
  flex-direction: column;
}

.template-group.collapsed .template-group-body {
  display: none;
}

.stack-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}

.stack-item:last-child {
  border-bottom: none;
}

.stack-item:hover {
  background: var(--color-panel-alt);
}

.stack-item.active {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

.stack-item-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text);
}

.stack-item-title-row strong {
  font-weight: 600;
}

.stack-item-meta {
  font-size: 11px;
  color: var(--color-text-muted);
}

.pill-channel {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--sidebar-bg);
  color: #fff;
}

/* ---- Data table tweaks (Fix #6) ---- */
.data-table th {
  font-size: 11px;
  padding: 10px 12px;
}

.data-table td {
  padding: 10px 12px;
  font-size: 13px;
  vertical-align: middle;
}

.data-table td[data-label="Status"],
.data-table td[data-label="Aktionen"],
.data-table td[data-label="Aktion"] {
  white-space: nowrap;
}

.data-table td[data-label="Anmeldename"],
.data-table td[data-label="Name"] {
  font-weight: 500;
}

.action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.action-stack .btn-small {
  white-space: nowrap;
}

/* Sidebar-Produkt-Name Ellipse falls Tenant-Name lang */
.sidebar-product,
.sidebar-company {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  background: #fff;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-card-wide {
  max-width: 920px;
}

.modal-card-dialog {
  max-width: 440px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-root {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-info);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  color: var(--color-text);
  animation: slideIn 200ms ease;
}

.toast-success { border-left-color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-warn { border-left-color: var(--color-warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state h5 {
  color: var(--color-text);
  font-size: 16px;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
}

/* ============================================================
   BRANDING PREVIEW
   ============================================================ */
.branding-preview {
  padding: 24px;
  background: var(--color-panel-alt);
  border: 1px dashed var(--color-border-strong);
}

.branding-preview-mark {
  width: 80px;
  height: 80px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 28px;
  margin-bottom: 12px;
}

.branding-preview-name {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 2px;
}

.branding-preview-slogan {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ============================================================
   RESPONSIVE / MOBILE
   ============================================================ */
@media (max-width: 900px) {
  .screen-app {
    grid-template-columns: 1fr;
  }

  .mobile-topbar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: var(--sidebar-width-mobile);
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform var(--transition);
    z-index: 45;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .workspace {
    padding: 16px 16px 32px;
  }

  .content-title {
    font-size: 18px;
  }

  .split-layout,
  .split-layout-wide {
    grid-template-columns: 1fr;
  }

  .filters-grid-compact .field-search {
    grid-column: span 1;
  }

  .section-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .section-tab {
    flex-shrink: 0;
  }

  .panel {
    padding: 16px;
  }

  .toast-root {
    top: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }

  .login-panel {
    padding: 28px 20px;
  }
}

@media (max-width: 480px) {
  .data-table th,
  .data-table td {
    padding: 10px 8px;
    font-size: 12px;
  }

  .btn {
    padding: 10px 14px;
    font-size: 13px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   iOS SAFARI FIXES
   Login-Felder funktionieren dort — kein backdrop-filter: blur!
   ============================================================ */
@supports (-webkit-touch-callout: none) {
  input, select, textarea {
    font-size: 16px; /* verhindert Auto-Zoom auf iOS */
  }
  .login-panel input {
    -webkit-appearance: none;
    appearance: none;
    background: #fff !important;
    color: var(--color-text) !important;
  }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .sidebar, .mobile-topbar, .btn, .section-tabs, .panel-header button,
  .nav-backdrop {
    display: none !important;
  }
  .workspace { padding: 0; }
  .panel { border: 1px solid #000; box-shadow: none; page-break-inside: avoid; }
}

/* ============================================================
   UTILITY: Accordion
   ============================================================ */
.accordion {
  border: 1px solid var(--color-border);
  margin-bottom: 8px;
}

.accordion-header {
  padding: 12px 16px;
  background: var(--color-panel-alt);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.accordion-body {
  padding: 16px;
  border-top: 1px solid var(--color-border);
}

/* ============================================================
   UTILITY: Key-Value data list
   ============================================================ */
.data-list {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 16px;
  font-size: 14px;
}

.data-list dt {
  color: var(--color-text-muted);
  font-weight: 500;
}

.data-list dd {
  margin: 0;
  color: var(--color-text);
  font-weight: 500;
}

@media (max-width: 600px) {
  .data-list {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }
  .data-list dt {
    margin-top: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
}

/* ============================================================
   Template variable panel — collapsible, grouped, compact chips
   ============================================================ */
.variable-panel {
  padding: 0;
  overflow: hidden;
}

.variable-panel-header {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  text-align: left;
  min-height: 44px;
  transition: background var(--transition);
}

.variable-panel-header:hover {
  background: var(--color-panel-alt);
}

.variable-panel-title {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.variable-panel-title strong {
  font-weight: 600;
}

.variable-panel-meta {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.variable-panel-chevron {
  font-size: 11px;
  color: var(--color-text-muted);
  transition: transform var(--transition);
}

.variable-panel.is-collapsed .variable-panel-chevron {
  transform: rotate(-90deg);
}

.variable-panel-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 14px 12px;
  border-top: 1px solid var(--color-border);
}

.variable-panel.is-collapsed .variable-panel-body {
  display: none;
}

.variable-panel-body .helper-copy {
  margin: 10px 0 4px;
}

.variable-group-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.variable-group {
  border: 1px solid var(--color-border);
  background: var(--color-panel-alt);
}

.variable-group-header {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  text-align: left;
  min-height: 36px;
  transition: background var(--transition);
}

.variable-group-header:hover {
  background: var(--color-panel);
}

.variable-group-label {
  flex: 1;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.variable-group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--color-border);
  color: var(--color-text);
}

.variable-group-chevron {
  font-size: 10px;
  color: var(--color-text-muted);
  transition: transform var(--transition);
}

.variable-group.is-collapsed .variable-group-chevron {
  transform: rotate(-90deg);
}

.variable-group-body {
  padding: 4px 10px 10px;
  background: var(--color-panel);
  border-top: 1px solid var(--color-border);
}

.variable-group.is-collapsed .variable-group-body {
  display: none;
}

.variable-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 6px;
}

.variable-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 5px 10px;
  background: var(--color-panel-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: 12px;
  line-height: 1.3;
  color: var(--color-text);
  cursor: grab;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.variable-chip:hover {
  background: var(--accent-bg);
  border-color: var(--accent-light);
}

.variable-chip:active {
  cursor: grabbing;
}

.variable-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.variable-chip-face {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variable-chip-back {
  display: none;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}

.variable-chip.is-flipped {
  background: var(--accent-bg);
  border-color: var(--accent);
}

.variable-chip.is-flipped .variable-chip-front {
  display: none;
}

.variable-chip.is-flipped .variable-chip-back {
  display: inline-block;
}

.variable-chip:not(.has-description) .variable-chip-front {
  font-style: italic;
  color: var(--color-text-muted);
}

/* ============================================================
   Message history
   ============================================================ */
.message-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-item {
  padding: 12px;
  background: var(--color-panel-alt);
  border-left: 3px solid var(--color-border);
  font-size: 13px;
}

.message-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

/* ============================================================
   Contacts view
   ============================================================ */
.contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
}

.contact-row:last-child { border-bottom: none; }

.contact-avatar {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

.contact-calls {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  text-align: right;
}

.contact-calls strong { color: var(--color-text); font-weight: 700; }

/* ============================================================
   PRAXIS-EINSTELLUNGEN / USER + ROLE EDITOR (2026-04-26)
   ============================================================ */

.user-mgmt-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
  align-items: flex-start;
}

@media (max-width: 1100px) {
  .user-mgmt-grid {
    grid-template-columns: 1fr;
  }
}

.data-table-tight th,
.data-table-tight td {
  padding: 9px 10px;
  font-size: 13px;
  vertical-align: middle;
  word-break: break-word;
}

.data-table-tight th {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  background: var(--color-panel-alt);
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}

.data-table-tight td {
  border-bottom: 1px solid var(--color-border);
}

.data-table-tight tr:last-child td {
  border-bottom: none;
}

.data-table-tight .table-actions-cell,
.data-table-tight .action-stack {
  white-space: normal;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 2px;
  white-space: nowrap;
}

.pill-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.pill-muted {
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.pill-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

/* Permissions list (Rolleneditor) — read as list, not as a tight checkbox grid */
.permissions-list {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.permission-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 4px 12px;
  align-items: start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition);
}

.permission-item:last-child {
  border-bottom: none;
}

.permission-item:hover {
  background: var(--color-panel-alt);
}

.permission-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.permission-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.permission-help {
  grid-column: 2;
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* Profile grid (Praxis-Einstellungen → Profil) */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.profile-info {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 4px 0;
}

.profile-info > div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

.profile-info > div:last-child {
  border-bottom: none;
}

.profile-info-label {
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Force-Password modal cannot be dismissed by clicking the backdrop */
#forcePasswordModal .modal-backdrop {
  cursor: not-allowed;
}

/* Sidebar nav-icon "€" should look like the others */
.sidebar-nav .nav-item .nav-icon {
  font-feature-settings: 'tnum' 1;
}

/* === Tenant-Edit Page (full-page mit Tabs) === */
.tenant-edit-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.tenant-edit-title .eyebrow {
  margin: 0;
}

.tenant-edit-title h2 {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
}

.tenant-edit-tab {
  display: block;
}

.tenant-edit-tab.hidden {
  display: none;
}

.section-tabs.section-tabs-sub {
  margin-top: 16px;
  margin-bottom: 8px;
  background: var(--color-surface-soft, #faf7f1);
  padding: 6px;
  border-radius: 10px;
}
