/* Pfad: /css/main.css */
/* KeyManager Pro — Globales Stylesheet */
/* Design: Behördlich-professionell, Schweizer Designsystem trifft SaaS */

/* Google Fonts werden per <link> in den HTML-Dateien geladen (non-blocking) */

/* ═══════════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════════ */
:root {
  --navy:       #1A2744;
  --navy-mid:   #2D4A6F;
  --navy-light: #3A5A8A;
  --blue:       #3A7BD5;
  --blue-light: #E8F0FE;
  --green:      #2D6A4F;
  --green-light:#E8F5E9;
  --orange:     #E65100;
  --orange-light:#FFF3E0;
  --red:        #C62828;
  --red-light:  #FFEBEE;
  --bg:         #F4F1EA;
  --card:       #FFFFFF;
  --border:     #EAE6DE;
  --text:       #1A2744;
  --text-muted: #8A8470;
  --text-light: #A09888;
  --gold:       #C9A84C;
  --gold-light: #FDF6EC;
  --black-light:#424242;
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:   16px;
  --space-lg:   24px;
  --space-xl:   40px;
  --space-2xl:  64px;
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.07);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.1);
  --shadow-xl:  0 20px 60px rgba(0,0,0,.15);
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', -apple-system, sans-serif;
  --transition:   all .2s ease;
  /* Akzentfarbe — wird per Theme überschrieben */
  --accent:        #2D6A4F;
  --accent-light:  #E8F5E9;
  --accent-hover:  #245A42;
}

/* ═══════════════════════════════════════════════
   FARBTHEMEN — Akzentfarbe
   ═══════════════════════════════════════════════ */
[data-theme="green"]  { --accent:#2D6A4F; --accent-light:#E8F5E9; --accent-hover:#245A42; }
[data-theme="blue"]   { --accent:#1565C0; --accent-light:#E3F2FD; --accent-hover:#0D47A1; }
[data-theme="purple"] { --accent:#7B1FA2; --accent-light:#F3E5F5; --accent-hover:#6A1B9A; }
[data-theme="teal"]   { --accent:#00695C; --accent-light:#E0F2F1; --accent-hover:#004D40; }
[data-theme="orange"] { --accent:#D84315; --accent-light:#FBE9E7; --accent-hover:#BF360C; }
[data-theme="slate"]  { --accent:#37474F; --accent-light:#ECEFF1; --accent-hover:#263238; }

/* ═══════════════════════════════════════════════
   NAVIGATIONSFARBE — Sidebar
   ═══════════════════════════════════════════════ */
[data-navcolor="navy"]   .sidebar { background: #1A2744; }
[data-navcolor="black"]  .sidebar { background: #111111; }
[data-navcolor="green"]  .sidebar { background: #1B4332; }
[data-navcolor="blue"]   .sidebar { background: #0D3063; }
[data-navcolor="purple"] .sidebar { background: #3E1060; }
[data-navcolor="slate"]  .sidebar { background: #263238; }
[data-navcolor="brown"]  .sidebar { background: #3E2723; }

/* ═══════════════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════════════ */
[data-mode="dark"] {
  --bg:           #0F1419;
  --card:         #1A2232;
  --border:       #2A3548;
  --text:         #D8E4F0;
  --text-muted:   #7A8FA6;
  --text-light:   #506070;
  --blue-light:   #1A2D50;
  --green-light:  #1B2D22;
  --orange-light: #2D1A0A;
  --red-light:    #2D1215;
  --gold-light:   #2A2010;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.3);
  --shadow-md:    0 4px 12px rgba(0,0,0,.4);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.5);
}
[data-mode="dark"] body          { background: var(--bg); color: var(--text); }
[data-mode="dark"] h1,
[data-mode="dark"] h2,
[data-mode="dark"] h3,
[data-mode="dark"] h4            { color: var(--text); }
[data-mode="dark"] .card         { background: var(--card); border-color: var(--border); }
[data-mode="dark"] .form__input,
[data-mode="dark"] .form__select,
[data-mode="dark"] .form__textarea {
  background: #111927;
  border-color: var(--border);
  color: var(--text);
}
[data-mode="dark"] .form__label  { color: var(--text-muted); }
[data-mode="dark"] .table th     { border-color: var(--border); color: var(--text-muted); }
[data-mode="dark"] .table td     { border-color: var(--border); color: var(--text); }
[data-mode="dark"] .table tbody tr:hover td { background: #1E2D42; }
[data-mode="dark"] .btn--outline { color: var(--text); border-color: var(--border); }
[data-mode="dark"] .btn--outline:hover { background: var(--border); }
[data-mode="dark"] .modal__box   { background: var(--card); border-color: var(--border); }
[data-mode="dark"] .modal__header { border-color: var(--border); }
[data-mode="dark"] .modal__footer { border-color: var(--border); }
[data-mode="dark"] .tabs__btn    { background: var(--card); border-color: var(--border); color: var(--text-muted); }
[data-mode="dark"] .tabs__btn.active { background: var(--accent); color: #fff; }
[data-mode="dark"] .tabs__panel  { background: transparent; }
[data-mode="dark"] .info-box     { background: var(--card); border-color: var(--border); }
[data-mode="dark"] .badge--gray  { background: #2A3548; color: var(--text-muted); }
[data-mode="dark"] .page-header__sub { color: var(--text-muted); }
[data-mode="dark"] .sidebar      { background: #080E17; }
[data-mode="dark"] .sidebar__link.active { background: #1A2D42; }
[data-mode="dark"] .topbar       { background: #080E17; border-color: var(--border); }
[data-mode="dark"] .settings-nav { background: var(--card); border-color: var(--border); }
[data-mode="dark"] .settings-nav__link:hover { background: var(--border); }
[data-mode="dark"] .settings-nav__link.active { background: var(--accent); color: #fff; }
[data-mode="dark"] select option { background: #1A2232; }

/* ═══════════════════════════════════════════════
   SCHRIFTGRÖSSE
   Nur body + Textelemente skalieren.
   html-root bleibt immer bei 16 px → rem-basierte
   Abstände (Padding, Radius, Shadow) bleiben stabil.
   ═══════════════════════════════════════════════ */
[data-fontsize="small"] body { font-size: 14px; }
[data-fontsize="large"]  body { font-size: 18px; }

/* Überschriften explizit skalieren (rem → proportional) */
[data-fontsize="small"] h1 { font-size: 2.19rem; }
[data-fontsize="small"] h2 { font-size: 1.53rem; }
[data-fontsize="small"] h3 { font-size: 1.09rem; }
[data-fontsize="small"] h4 { font-size: 0.96rem; }
[data-fontsize="large"]  h1 { font-size: 2.81rem; }
[data-fontsize="large"]  h2 { font-size: 1.97rem; }
[data-fontsize="large"]  h3 { font-size: 1.41rem; }
[data-fontsize="large"]  h4 { font-size: 1.24rem; }

/* Schaltflächen, Labels, Badges, Inputs skalieren mit body-Größe mit */
[data-fontsize="small"] .btn,
[data-fontsize="small"] .form__input,
[data-fontsize="small"] .form__select,
[data-fontsize="small"] .form__textarea,
[data-fontsize="small"] .form__label,
[data-fontsize="small"] .badge,
[data-fontsize="small"] .sidebar__link,
[data-fontsize="small"] .modal__title,
[data-fontsize="small"] td, [data-fontsize="small"] th { font-size: 0.8125rem; } /* 13px */

[data-fontsize="large"]  .btn,
[data-fontsize="large"]  .form__input,
[data-fontsize="large"]  .form__select,
[data-fontsize="large"]  .form__textarea,
[data-fontsize="large"]  .form__label,
[data-fontsize="large"]  .badge,
[data-fontsize="large"]  .sidebar__link,
[data-fontsize="large"]  .modal__title,
[data-fontsize="large"]  td, [data-fontsize="large"]  th { font-size: 1rem; } /* 16px */

/* ═══════════════════════════════════════════════
   KOMPAKT-MODUS
   ═══════════════════════════════════════════════ */
[data-compact="true"] .card          { padding: var(--space-md); }
[data-compact="true"] .table th,
[data-compact="true"] .table td      { padding: 7px 10px; }
[data-compact="true"] .sidebar__link { padding: 7px 12px; }
/* Modals: Kompakt-Modus greift hier NICHT — Dialoge behalten immer vollen Rand */
[data-compact="true"] .form__group   { margin-bottom: var(--space-sm); }
[data-compact="true"] .page-header   { padding: var(--space-md) 0; }

/* Akzentfarbe-Overrides (ersetzen --green überall) */
.btn--green          { background: var(--accent) !important; }
.btn--green:hover    { background: var(--accent-hover) !important; }
.btn--green-light    { background: var(--accent-light) !important; color: var(--accent) !important; }
.sidebar__link.active { background: var(--accent) !important; }
.table th.sort-asc,
.table th.sort-desc  { color: var(--accent) !important; }
.table th.sort-asc::after,
.table th.sort-desc::after { color: var(--accent) !important; }
.table th.sortable:hover   { color: var(--accent) !important; }
.filter-chip.active  { background: var(--accent) !important; border-color: var(--accent) !important; }
.badge--green        { background: var(--accent-light); color: var(--accent); }
.progress__bar       { background: var(--accent) !important; }

/* ═══════════════════════════════════════════════
   DARSTELLUNGS-EINSTELLUNGEN UI
   ═══════════════════════════════════════════════ */
.theme-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}
.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.mode-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 12px 12px;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  background: var(--bg);
}
.mode-card:hover  { border-color: var(--accent); }
.mode-card.active { border-color: var(--accent); background: var(--accent-light); }
.mode-card__preview {
  width: 100%;
  height: 52px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
  display: flex;
  gap: 4px;
}
.mode-card__preview-sidebar {
  width: 28%;
  height: 100%;
  border-radius: 4px 0 0 4px;
}
.mode-card__preview-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px;
}
.mode-card__preview-line {
  height: 6px;
  border-radius: 3px;
}
.mode-card__label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text);
}
.mode-card__sub {
  font-size: .68rem;
  color: var(--text-muted);
}
/* Light preview */
.mode-card--light .mode-card__preview { background: #F4F1EA; }
.mode-card--light .mode-card__preview-sidebar { background: #1A2744; }
.mode-card--light .mode-card__preview-line:nth-child(1) { background: #e0dbd4; width: 90%; }
.mode-card--light .mode-card__preview-line:nth-child(2) { background: #e8e3dc; width: 70%; }
.mode-card--light .mode-card__preview-line:nth-child(3) { background: var(--accent); width: 50%; }
/* Dark preview */
.mode-card--dark .mode-card__preview  { background: #0F1419; }
.mode-card--dark .mode-card__preview-sidebar { background: #080E17; }
.mode-card--dark .mode-card__preview-line:nth-child(1) { background: #2A3548; width: 90%; }
.mode-card--dark .mode-card__preview-line:nth-child(2) { background: #1A2232; width: 70%; }
.mode-card--dark .mode-card__preview-line:nth-child(3) { background: var(--accent); width: 50%; }
/* System preview */
.mode-card--system .mode-card__preview {
  background: linear-gradient(to right, #F4F1EA 50%, #0F1419 50%);
}
.mode-card--system .mode-card__preview-sidebar {
  background: linear-gradient(to bottom, #1A2744 50%, #080E17 50%);
}
.mode-card--system .mode-card__preview-line:nth-child(1) { background: #9E9E9E; width: 90%; }
.mode-card--system .mode-card__preview-line:nth-child(2) { background: #BDBDBD; width: 70%; }
.mode-card--system .mode-card__preview-line:nth-child(3) { background: var(--accent); width: 50%; }

.color-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: var(--transition);
  position: relative;
}
.color-swatch:hover    { transform: scale(1.15); }
.color-swatch.active   { border-color: var(--text); }
.color-swatch.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .75rem;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}

.fontsize-btns {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.fontsize-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
}
.fontsize-btn:hover  { border-color: var(--accent); }
.fontsize-btn.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  margin-bottom: var(--space-sm);
}
.toggle-row__info strong { font-size: .875rem; color: var(--text); display: block; }
.toggle-row__info span   { font-size: .75rem; color: var(--text-muted); }
.toggle-switch {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  position: relative;
  background: var(--border);
  transition: background .2s;
  flex-shrink: 0;
}
.toggle-switch.on { background: var(--accent); }
.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle-switch.on::after { left: 23px; }

/* ═══════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════ */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}
/* ── Seiten-Übergang ── */
/* WICHTIG: Kein transform hier verwenden! Sonst wird body zum
   Containing Block für position:fixed → Modals werden relativ
   zum Body (Dokument) positioniert statt zum Viewport. */
@keyframes km-page-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  animation: km-page-in 0.2s ease forwards;
}
img { max-width: 100%; display: block; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea {
  font-family: var(--font-body);
  font-size: inherit;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--navy);
}
h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

/* ═══════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}
.container--narrow {
  max-width: 480px;
}
.container--mid {
  max-width: 640px;
}

/* ═══════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════ */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card--hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card--navy {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.card--featured {
  border: 2px solid var(--gold);
  box-shadow: var(--shadow-md);
  transform: scale(1.03);
  position: relative;
}

/* ═══════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn--disabled {
  opacity: .5; cursor: not-allowed; pointer-events: none;
}
.btn--green   { background: var(--green); color: #fff; }
.btn--navy    { background: var(--navy); color: #fff; }
.btn--blue    { background: var(--blue); color: #fff; }
.btn--red     { background: var(--red); color: #fff; }
.btn--orange  { background: var(--orange); color: #fff; }
.btn--gold    { background: var(--gold); color: #fff; }
.btn--ghost   { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); }
.btn--ghost:hover { background: rgba(255,255,255,.1); }
.btn--outline { background: transparent; color: var(--navy); border: 1px solid var(--border); }
.btn--outline:hover { background: var(--bg); }
.btn--sm      { padding: 6px 14px; font-size: .8rem; }
.btn--lg      { padding: 14px 32px; font-size: 1rem; }
.btn--full    { width: 100%; }
.btn--icon    { padding: 8px; min-width: 36px; }
.btn--green-light { background: var(--green-light); color: var(--green); }
.btn--red-light   { background: var(--red-light); color: var(--red); }
.btn--blue-light  { background: var(--blue-light); color: var(--blue); }

/* Loading state */
.btn--loading {
  pointer-events: none;
  position: relative;
  color: transparent !important; /* Ausnahme: Loading-State muss Text verbergen */
}
.btn--loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════ */
.form__group {
  margin-bottom: var(--space-md);
}
.form__label {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: var(--space-xs);
}
.form__input,
.form__select,
.form__textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: .9rem;
  background: #FAFAF6;
  color: var(--text);
  transition: var(--transition);
}
.form__input:focus,
.form__select:focus,
.form__textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(58,123,213,.12);
}
.form__input--error {
  border-color: var(--red);
}
.form__error {
  font-size: .78rem;
  color: var(--red);
  margin-top: var(--space-xs);
  display: none;
}
.form__error.visible {
  display: block;
}
.form__hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}
.form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}
.form__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A8470' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.form__textarea {
  resize: vertical;
  min-height: 80px;
}
.form__checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  font-size: .875rem;
  cursor: pointer;
}
.form__checkbox input[type="checkbox"] {
  width: 18px; height: 18px;
  margin-top: 2px;
  accent-color: var(--green);
  cursor: pointer;
}

/* Password strength bar */
.pw-strength {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-top: var(--space-sm);
  overflow: hidden;
}
.pw-strength__bar {
  height: 100%;
  border-radius: 2px;
  width: 0;
  transition: width .3s, background .3s;
}
.pw-strength__label {
  font-size: .75rem;
  margin-top: var(--space-xs);
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge--green  { background: var(--green-light); color: var(--green); }
.badge--orange { background: var(--orange-light); color: var(--orange); }
.badge--red    { background: var(--red-light); color: var(--red); }
.badge--blue   { background: var(--blue-light); color: var(--blue); }
.badge--navy   { background: var(--navy); color: #fff; }
.badge--gold   { background: var(--gold-light); color: var(--gold); }
.badge--gray   { background: #F0ECE4; color: var(--text-muted); }
.badge--black  { background: #EEEEEE; color: var(--black-light); }

/* ═══════════════════════════════════════════════
   INFO TAGS
   ═══════════════════════════════════════════════ */
.tag {
  display: inline-block;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  margin: 2px;
}
.tag__label {
  font-size: .65rem;
  color: var(--text-light);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.tag__value {
  font-size: .8rem;
  color: var(--navy);
  font-weight: 700;
}
.tag--mono .tag__value {
  font-family: 'Courier New', monospace;
}

/* ═══════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
/* Sortierbare Spalten */
.table th.sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 22px;
  position: relative;
  transition: color .15s;
}
.table th.sortable:hover {
  color: var(--green);
}
.table th.sortable::after {
  content: '⇅';
  position: absolute;
  right: 6px;
  font-size: .75rem;
  opacity: .35;
  transition: opacity .15s;
}
.table th.sortable:hover::after { opacity: .7; }
.table th.sort-asc::after  { content: '▲'; opacity: 1; color: var(--green); }
.table th.sort-desc::after { content: '▼'; opacity: 1; color: var(--green); }
.table th.sort-asc,
.table th.sort-desc { color: var(--green); }
.table td {
  padding: 11px 14px;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:hover td {
  background: #FAF9F6;
}

/* ═══════════════════════════════════════════════
   MODAL
   Padding und max-width in em → skalieren proportional
   mit der gewählten Schriftgröße (Klein/Normal/Groß).
   ═══════════════════════════════════════════════ */
.modal__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  z-index: 1000;
  /* Overlay selbst scrollt wenn Modal größer als Viewport */
  overflow-y: auto;
  padding: 1em;
}
.modal__overlay.open {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* min-height: 100% kombiniert mit margin:auto am Box → vertikal zentriert wenn passt,
     scrollbar wenn größer */
  min-height: 100%;
}
.modal__box {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.5em;
  width: 100%;
  box-shadow: var(--shadow-xl);
  margin: auto 0;
  /* Modal wächst frei, Overlay scrollt — keine max-height-Begrenzung mehr nötig.
     Speichern-Buttons sind dadurch IMMER per Scroll erreichbar. */
}
/* Footer-Buttons werden klebrig am Modal-Boden – auch beim Scrollen sichtbar */
.modal__footer {
  position: sticky;
  bottom: -1.5em;
  background: var(--card);
  margin-bottom: -1.5em;
  padding-bottom: 1.5em;
  z-index: 2;
}
/* em-basierte max-width: Modal wächst/schrumpft mit Schriftgröße */
.modal__box--sm { max-width: min(27.5em, 95vw); }   /* ~440px bei Normal */
.modal__box--md { max-width: min(35em,   95vw); }   /* ~560px bei Normal */
.modal__box--lg { max-width: min(43.75em,95vw); }   /* ~700px bei Normal */
.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5em;
}
.modal__title {
  font-size: 1.15rem;
  font-weight: 800;
}
.modal__close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}
.modal__footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-top: 1.5em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: var(--space-lg);
}
.tabs__btn {
  flex: 1;
  padding: 9px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  transition: var(--transition);
}
.tabs__btn.active {
  background: var(--card);
  color: var(--navy);
  box-shadow: var(--shadow-sm);
}
.tabs__panel {
  display: none;
}
.tabs__panel.active {
  display: block;
}

/* ═══════════════════════════════════════════════
   STEPPER (Progress Steps)
   ═══════════════════════════════════════════════ */
.stepper {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-lg);
}
.stepper__step,
.step {
  flex: 1;
  text-align: center;
}
.stepper__bar,
.step-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-bottom: var(--space-xs);
  transition: background .3s;
}
.stepper__bar.done,
.step-bar.done {
  background: var(--green);
}
.stepper__label,
.step-label {
  font-size: .7rem;
  color: var(--text-light);
  font-weight: 500;
}
.stepper__label.active,
.step-label.active {
  color: var(--green);
  font-weight: 700;
}

/* ═══════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-sm);
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease;
  max-width: 380px;
}
.toast--success { background: var(--green); color: #fff; }
.toast--error   { background: var(--red); color: #fff; }
.toast--warning { background: var(--orange); color: #fff; }
.toast--info    { background: var(--blue); color: #fff; }
.toast--out { animation: toastOut .3s ease forwards; }
@keyframes toastIn  { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; transform:translateY(0); } to { opacity:0; transform:translateY(10px); } }

/* ═══════════════════════════════════════════════
   CODE INPUT (6-digit verification)
   ═══════════════════════════════════════════════ */
.code-input {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}
.code-input__field {
  width: 48px; height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FAFAF6;
  transition: var(--transition);
}
.code-input__field:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(58,123,213,.15);
}

/* ═══════════════════════════════════════════════
   APP SHELL — SIDEBAR
   ═══════════════════════════════════════════════ */
.app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 240px;
  height: 100vh;
  height: 100dvh; /* dynamische Viewport-Höhe (Browser-Toolbar berücksichtigt) */
  background: var(--navy);
  color: #C8D6E5;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform .3s;
  overflow: hidden;
  will-change: auto; /* sicherstellen dass kein Containing-Block Bug entsteht */
}
.sidebar__brand {
  flex: 0 0 auto;
  padding: var(--space-lg) var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-align: center;
}
.sidebar__logo {
  width: 64px; height: 64px;
  border-radius: var(--radius-md);
  object-fit: contain;
  margin: 0 auto var(--space-sm);
  background: rgba(255,255,255,.08);
  padding: 8px;
}
.sidebar__org-name {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
}
.sidebar__nav {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-md) var(--space-sm);
  /* Scrollbar in beiden Zuständen (ein-/ausgeklappt) verstecken — Scrolling bleibt möglich */
  scrollbar-width: none;       /* Firefox */
  -ms-overflow-style: none;    /* IE/Edge alt */
}
.sidebar__nav::-webkit-scrollbar {
  display: none;               /* Chrome/Safari/Edge neu */
  width: 0;
  height: 0;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #8EA4C0;
  font-weight: 600;
  font-size: .875rem;
  text-decoration: none;
  margin-bottom: 2px;
  transition: var(--transition);
}
.sidebar__link:hover {
  background: rgba(255,255,255,.06);
  color: #C8D6E5;
  text-decoration: none;
}
.sidebar__link.active {
  background: var(--navy-mid);
  color: #fff;
}
.sidebar__link-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}
/* Schritt B1: BETA-Kennzeichnung */
.km-beta-pill {
  display: inline-block;
  font-size: .56rem;
  font-weight: 800;
  letter-spacing: .5px;
  background: #f59e0b;
  color: #1a1a1a;
  padding: 1px 5px;
  border-radius: 6px;
  margin-left: 4px;
  vertical-align: middle;
  text-transform: uppercase;
}
.km-beta-badge {
  display: inline-block;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .6px;
  background: #f59e0b;
  color: #1a1a1a;
  padding: 2px 8px;
  border-radius: 8px;
  margin-left: 8px;
  vertical-align: middle;
  text-transform: uppercase;
}
.km-beta-banner {
  background: linear-gradient(135deg,#fef3c7,#fde68a);
  border: 1px solid #f59e0b;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .82rem;
  color: #92400e;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar__settings {
  flex: 0 0 auto;
  padding: var(--space-sm);
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ═══════════════════════════════════════════════
   Schritt 62z17: Globales Versions-Card in der Sidebar
   ═══════════════════════════════════════════════ */
.sidebar__version-card {
  flex: 0 0 auto;
  margin: var(--space-sm) var(--space-md) 0;
  padding: 10px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.sidebar__version-card:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(16,185,129,.35);
  transform: translateY(-1px);
}
.sidebar__version-card:active {
  transform: translateY(0);
}
.sidebar__version-card__icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(16,185,129,.12);
  border: 1px solid rgba(16,185,129,.30);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.sidebar__version-card__text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.sidebar__version-card__title {
  font-size: .82rem;
  color: #E0E7EF;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.sidebar__version-card__ver {
  font-size: .68rem;
  color: #10b981;
  font-family: 'SF Mono', Consolas, monospace;
  margin-top: 2px;
  letter-spacing: .02em;
}
.sidebar__version-card__arrow {
  color: rgba(200,214,229,.45);
  font-size: 1.05rem;
  flex-shrink: 0;
  transition: transform .15s, color .15s;
}
.sidebar__version-card:hover .sidebar__version-card__arrow {
  color: #10b981;
  transform: translateX(2px);
}

/* Eingeklappte Sidebar: nur Icon zeigen */
body.sidebar-collapsed .sidebar__version-card {
  margin: var(--space-sm) auto 0;
  padding: 8px;
  justify-content: center;
}
body.sidebar-collapsed .sidebar__version-card__text,
body.sidebar-collapsed .sidebar__version-card__arrow {
  display: none;
}
.sidebar__footer {
  flex: 0 0 auto;
  padding: var(--space-md);
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.sidebar__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--navy-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sidebar__user-name {
  font-size: .78rem;
  font-weight: 600;
  color: #C8D6E5;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__logout {
  font-size: .7rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
}
.sidebar__logout:hover { color: var(--red); }

/* App main area */
.app__main {
  flex: 1;
  margin-left: 240px;
  padding: var(--space-lg);
  background: var(--bg);
  min-height: 100vh;
  overflow-y: auto;
  transition: margin-left .25s ease;
}

/* ── Sidebar einklappbar (Teams-Style) ──
   .sidebar-collapsed auf <body> → Sidebar wird auf 76px reduziert.
   Icon zentriert + kleines Label darunter (wie Teams).
*/
body.sidebar-collapsed .sidebar { width: 76px; }
body.sidebar-collapsed .app__main { margin-left: 76px; }
body.sidebar-collapsed .sidebar__brand {
  padding: 12px 6px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
body.sidebar-collapsed .sidebar__logo {
  width: 44px; height: 44px;
  padding: 4px;
  margin: 0 auto 0;
}
body.sidebar-collapsed #sidebarFallback {
  width: 44px !important; height: 44px !important;
  font-size: 1.4rem !important;
  margin: 0 auto !important;
}
body.sidebar-collapsed .sidebar__org-name {
  display: none;
}
body.sidebar-collapsed .sidebar__nav {
  padding: 6px 4px;
  /* Scrollbar verstecken aber Scrolling erlauben */
  scrollbar-width: none;       /* Firefox */
  -ms-overflow-style: none;    /* IE/Edge alt */
}
body.sidebar-collapsed .sidebar__nav::-webkit-scrollbar {
  display: none;               /* Chrome/Safari */
  width: 0;
}
body.sidebar-collapsed .sidebar__settings {
  padding: 4px;
}
body.sidebar-collapsed .sidebar__link {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  padding: 8px 4px;
  text-align: center;
  position: relative;
  margin-bottom: 2px;
  border-radius: 8px;
  min-height: 56px;
}
body.sidebar-collapsed .sidebar__link-icon {
  font-size: 1.4rem;
  width: auto;
  line-height: 1;
}
/* Kleines Label DARUNTER (zweites span im Link) */
body.sidebar-collapsed .sidebar__link > span:not(.sidebar__link-icon) {
  font-size: .62rem;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
/* Aktiver Eintrag: kleiner farbiger Indikator-Balken links */
body.sidebar-collapsed .sidebar__link.active::before {
  content: '';
  position: absolute;
  left: -4px; top: 12px; bottom: 12px;
  width: 3px;
  background: var(--accent, #16a34a);
  border-radius: 0 3px 3px 0;
}
/* Unread-Badges etc. — neu positionieren (rechts oben am Icon, ÜBERLAPPEND).
   Wichtig: !important überschreibt die Inline-Styles aus setSidebarBadge() in main.js. */
body.sidebar-collapsed .sidebar__link {
  /* Overflow auf visible lassen, damit der Badge "raussteht" – aber Link selbst behält Box */
  overflow: visible;
}
body.sidebar-collapsed .sidebar__link-extra,
body.sidebar-collapsed .sidebar__link-badge,
body.sidebar-collapsed .sidebar__badge,
body.sidebar-collapsed .km-badge {
  position: absolute !important;
  top: 2px !important;
  right: 4px !important;
  left: auto !important;
  margin: 0 !important;
  font-size: .58rem !important;
  min-width: 16px !important;
  height: 16px !important;
  padding: 0 4px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 9px !important;
  background: #dc2626 !important;
  color: #fff !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  box-shadow: 0 0 0 2px var(--navy-deep, #1B4332) !important;
  z-index: 2 !important;
  /* Keine Breitenänderung am Link mehr */
  flex: 0 0 auto !important;
}
body.sidebar-collapsed .sidebar__footer {
  flex-direction: column;
  padding: 10px 6px 14px;
  gap: 6px;
  align-items: center;
}
/* Username weg, Abmelden bleibt sichtbar – als Icon */
body.sidebar-collapsed .sidebar__user-name {
  display: none !important;
}
body.sidebar-collapsed .sidebar__logout {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 32px;
  margin: 0;
  font-size: 0;
  color: #fff;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  transition: background .15s ease, color .15s ease;
}
body.sidebar-collapsed .sidebar__logout::before {
  content: '⎋';
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
}
body.sidebar-collapsed .sidebar__logout:hover {
  background: rgba(220, 38, 38, .15);
  border-color: rgba(220, 38, 38, .4);
}
body.sidebar-collapsed .sidebar__logout:hover::before {
  color: #ef4444;
}
/* Tooltip beim Hover (in beiden Modi) */
.sidebar__link[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: #1f2937;
  color: #fff;
  padding: 5px 9px;
  border-radius: 5px;
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  pointer-events: none;
}

/* Sidebar-Toggle-Button — fest oben, immer sichtbar */
.sidebar-toggle {
  position: fixed;
  top: 14px;
  left: 200px;
  width: 32px; height: 32px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 50%;
  cursor: pointer;
  z-index: 110;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  color: var(--text-muted, #6b7280);
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
  transition: all .25s ease;
}
.sidebar-toggle:hover {
  color: var(--text, #1f2937);
  border-color: var(--text-muted, #6b7280);
  transform: scale(1.05);
}
/* Eingebetteter Modus (Workspace-iframe): kein funktionsloser ☰-Toggle */
body.km-embed .sidebar-toggle { display: none !important; }
body.sidebar-collapsed .sidebar-toggle {
  /* Eingeklappt: Hamburger ganz oben mittig, ÜBER dem Logo – nicht überlappend.
     Sidebar = 76px, Button = 28px → (76-28)/2 = 24px für sauberes Zentrieren. */
  top: 8px;
  left: 24px;
  width: 28px; height: 28px;
  background: rgba(255,255,255,.08);
  color: #fff;
  border-color: rgba(255,255,255,.18);
  font-size: .95rem;
}
body.sidebar-collapsed .sidebar-toggle:hover {
  background: rgba(255,255,255,.15);
  transform: scale(1.06);
}
/* Brand-Bereich nach unten schieben, damit der Toggle Platz hat und nicht überlappt */
body.sidebar-collapsed .sidebar__brand {
  padding-top: 44px;
}
@media (max-width: 768px) {
  .sidebar-toggle { display: none; }
}

/* ── KONTEXT-MENÜ (Rechtsklick auf Sidebar-Link) ── */
.km-ctx-menu {
  position: fixed;
  background: #1f2937;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  padding: 4px;
  z-index: 99999;
  min-width: 220px;
  font-size: .85rem;
  color: #e5e7eb;
  animation: km-ctx-in .12s ease-out;
}
@keyframes km-ctx-in {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1); }
}
.km-ctx-menu__item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.km-ctx-menu__item:hover { background: rgba(255,255,255,.08); }
.km-ctx-menu__item--danger { color: #fca5a5; }
.km-ctx-menu__item--danger:hover { background: rgba(220,38,38,.18); }
.km-ctx-menu__sep {
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: 4px 6px;
}
.km-ctx-menu__icon { width: 18px; text-align: center; font-size: .95rem; }

/* ── LOSGELÖSTE MODULE ── */
.sidebar__detached-section {
  padding: 8px 6px;
  border-top: 1px dashed rgba(255,255,255,.12);
  margin-top: 4px;
}
.sidebar__detached-head {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: rgba(200,214,229,.55);
  padding: 4px 10px 6px;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
  user-select: none;
}
.sidebar__detached-head__toggle {
  font-size: .55rem;
  transition: transform .15s;
}
.sidebar__detached-list.collapsed { display: none; }
.sidebar__detached-section.is-collapsed .sidebar__detached-head__toggle {
  transform: rotate(-90deg);
}
.sidebar__detached-empty {
  font-size: .72rem;
  color: rgba(200,214,229,.4);
  font-style: italic;
  padding: 2px 12px;
}
/* ── LOSGELÖST-Bereich im eingeklappten Zustand ── */
body.sidebar-collapsed .sidebar__detached-section {
  padding: 6px 2px 4px;
  margin-top: 2px;
}
body.sidebar-collapsed .sidebar__detached-head {
  font-size: .56rem;
  letter-spacing: .2px;
  text-transform: none;    /* "Losgelöst" statt "LOSGELÖST" – schmaler */
  text-align: center;
  justify-content: center;
  padding: 2px 0 4px;
  gap: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.sidebar-collapsed .sidebar__detached-head > span:last-child {
  display: inline-block;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.sidebar-collapsed .sidebar__detached-head__toggle { display: none; }
/* Lange "Per Rechtsklick → Loslösen"-Hilfe wäre im 76px-Slot Lesemüll →
   durch kompaktes Mini-Icon "···" ersetzen, das beim Hover den Volltext zeigt. */
body.sidebar-collapsed .sidebar__detached-empty {
  font-size: 0;
  padding: 4px 0 2px;
  text-align: center;
  color: rgba(200,214,229,.35);
  position: relative;
  cursor: help;
}
body.sidebar-collapsed .sidebar__detached-empty::before {
  content: '⋯';
  font-size: 1rem;
  font-style: normal;
  line-height: 1;
  display: inline-block;
}
body.sidebar-collapsed .sidebar__detached-empty:hover::after {
  content: 'Per Rechtsklick → Loslösen';
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: #1f2937;
  color: #fff;
  padding: 5px 9px;
  border-radius: 5px;
  font-size: .76rem;
  font-weight: 600;
  font-style: normal;
  white-space: nowrap;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  pointer-events: none;
}
/* Losgelöste Links selbst: gleicher Look wie normale Sidebar-Links im
   collapsed-Mode (Icon + kleines Label darunter, nicht horizontal) */
body.sidebar-collapsed .sidebar__detached-list .sidebar__link {
  padding: 6px 4px;
  min-height: 50px;
}

/* ── INFO-MODAL für Modul-Infos ── */
.km-info-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 99998;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.km-info-box {
  background: #fff;
  color: #1f2937;
  border-radius: 12px;
  max-width: 520px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.km-info-box__head {
  background: linear-gradient(135deg, #1B4332, #2D6A4F);
  color: #fff;
  padding: 22px 24px;
  display: flex; align-items: center; gap: 14px;
  border-radius: 12px 12px 0 0;
}
.km-info-box__icon {
  font-size: 2.4rem;
  background: rgba(255,255,255,.15);
  border-radius: 12px;
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.km-info-box__title { margin: 0; font-size: 1.2rem; font-weight: 700; }
.km-info-box__sub   { margin: 4px 0 0; font-size: .82rem; opacity: .85; }
.km-info-box__body { padding: 22px 24px; }
.km-info-box__section { margin-bottom: 16px; }
.km-info-box__label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: #64748b; margin-bottom: 6px;
}
.km-info-box__text { font-size: .92rem; line-height: 1.5; color: #1f2937; }
.km-info-box__perm-list { list-style: none; padding: 0; margin: 0; }
.km-info-box__perm-list li {
  padding: 6px 10px;
  background: #f3f4f6;
  border-radius: 5px;
  margin-bottom: 4px;
  font-size: .85rem;
}
.km-info-box__foot {
  padding: 14px 24px;
  border-top: 1px solid #e5e7eb;
  display: flex; gap: 8px; justify-content: flex-end;
  background: #fafafa;
  border-radius: 0 0 12px 12px;
}

/* ═══════════════════════════════════════════════
   STANDARD-MODUL-KOPFZEILE
   Pattern für ALLE Module (Bestand & neu):
     <div class="page-header">
       <div>                                ← Titel + Beschreibung (links)
         <h2 class="page-header__title">…</h2>
         <p  class="page-header__sub">…</p>
       </div>
       <div class="flex gap-sm">            ← Action-Buttons (rechts)
         <button class="btn btn--outline btn--sm">Action 1</button>
         <button class="btn btn--outline btn--sm">Action 2</button>
         <button class="btn btn--green">+ Neu hinzufügen</button>   ← IMMER ZULETZT
       </div>
     </div>
   – Primary-Action (grün, „+ Neu…") steht im HTML immer am Ende
     → landet visuell ganz rechts.
   – Alle weiteren Aktions-Buttons (Export, Refresh, Import, …)
     stehen davor → links der Primary-Action.
   – Kopfzeile wird unten mit einer dezenten Linie vom Modul-Inhalt
     getrennt (border-bottom).
   ═══════════════════════════════════════════════ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-md);
  border-bottom: 1px solid var(--border);
}
.page-header__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
}
.page-header__sub {
  color: var(--text-muted);
  font-size: .875rem;
  margin-top: 2px;
}
/* Action-Container (zweiter, also letzter Direkt-Child der Kopfzeile):
   alle Buttons in einer Reihe, rechtsbündig, mit konsistentem Abstand.
   Greift unabhängig davon, ob der Container die Klasse ".flex" hat
   oder nicht — damit künftige Module die Konvention automatisch erben. */
.page-header > div:last-child:not(:first-child) {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  justify-content: flex-end;
  flex: 0 1 auto;
  min-width: 0;
}
/* Im Dark-Mode soll die Trennlinie nicht zu kontrastreich sein */
[data-mode="dark"] .page-header { border-bottom-color: var(--border); }

/* ═══════════════════════════════════════════════
   BUILDING CARDS GRID
   ═══════════════════════════════════════════════ */
.bld-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}
.bld-card {
  position: relative;
  cursor: pointer;
}
.bld-card__badge {
  position: absolute;
  top: 12px; right: 14px;
  font-size: .7rem;
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 600;
}
.bld-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--space-md);
}
.bld-card__icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.bld-card__name {
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 700;
  color: var(--navy);
}
.bld-card__addr {
  font-size: .78rem;
  color: var(--text-muted);
}

/* Progress bar (keys issued) */
.progress {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-top: var(--space-sm);
}
.progress__bar {
  height: 100%;
  border-radius: 2px;
  transition: width .3s;
}

/* KPI stat cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.kpi-card {
  display: flex;
  flex-direction: column;
}
.kpi-card__label {
  font-size: .65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
}
.kpi-card__value {
  font-size: 1.75rem;
  font-weight: 800;
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════
   EMOJI PICKER
   ═══════════════════════════════════════════════ */
.emoji-picker {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}
.emoji-picker__btn {
  width: 40px; height: 40px;
  font-size: 1.25rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: var(--transition);
}
.emoji-picker__btn:hover {
  border-color: var(--border);
}
.emoji-picker__btn.active {
  border-color: var(--gold);
  background: var(--gold-light);
}

/* ═══════════════════════════════════════════════
   CHIPS (Schlüssel-Vorschläge)
   ═══════════════════════════════════════════════ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip.active { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }

/* ═══════════════════════════════════════════════
   ACTION MENU (3-dot)
   ═══════════════════════════════════════════════ */
.action-menu {
  position: relative;
}
.action-menu__trigger {
  background: none;
  border: none;
  padding: 4px 8px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 4px;
}
.action-menu__trigger:hover { background: var(--bg); }
.action-menu__dropdown {
  display: none;
  position: absolute;
  right: 0; top: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 50;
  overflow: hidden;
}
.action-menu__dropdown.open {
  display: block;
}
.action-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 14px;
  font-size: .84rem;
  color: var(--text);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .1s;
}
.action-menu__item:hover { background: var(--bg); }
.action-menu__item--danger { color: var(--red); }

/* ═══════════════════════════════════════════════
   HERO SECTION (Landing)
   ═══════════════════════════════════════════════ */
.hero {
  background: var(--navy);
  color: #fff;
  padding: var(--space-2xl) 0;
  position: relative;
  overflow: hidden;
}
.hero__bg-pattern {
  position: absolute;
  inset: 0;
  opacity: .04;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 30L30 60L0 30z' fill='%23fff' fill-opacity='.1'/%3E%3C/svg%3E");
  background-size: 40px 40px;
}
.hero__content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: center;
  position: relative;
  z-index: 1;
}
.hero__headline {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: var(--space-md);
}
.hero__sub {
  font-size: 1.1rem;
  color: rgba(255,255,255,.7);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}
.hero__buttons {
  display: flex;
  gap: var(--space-md);
}

/* ═══════════════════════════════════════════════
   PRICING SECTION
   ═══════════════════════════════════════════════ */
.pricing-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
.pricing-toggle__label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
}
.pricing-toggle__label.active { color: var(--navy); }
.pricing-toggle__switch {
  width: 48px; height: 26px;
  border-radius: 13px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  border: none;
  transition: background .2s;
}
.pricing-toggle__switch.active { background: var(--green); }
.pricing-toggle__switch::after {
  content: '';
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 3px; left: 3px;
  transition: transform .2s;
}
.pricing-toggle__switch.active::after { transform: translateX(22px); }

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-md);
  align-items: flex-start;
}

/* ═══════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════ */
.login-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.login-page__brand {
  background: var(--navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}
.login-page__brand-logo {
  width: 120px; height: 120px;
  border-radius: var(--radius-lg);
  object-fit: contain;
  background: rgba(255,255,255,.08);
  padding: 16px;
  margin-bottom: var(--space-lg);
}
.login-page__brand-name {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: #fff;
  font-weight: 700;
  text-align: center;
}
.login-page__brand-sub {
  color: rgba(255,255,255,.5);
  font-size: .9rem;
  margin-top: var(--space-sm);
}
.login-page__form-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}
.login-page__form {
  width: 100%;
  max-width: 380px;
}

/* ═══════════════════════════════════════════════
   TRUST BADGES
   ═══════════════════════════════════════════════ */
.trust-badges {
  display: flex;
  justify-content: center;
  gap: var(--space-xl);
  padding: var(--space-xl) 0;
}
.trust-badge {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.trust-badge__icon {
  font-size: 1.2rem;
}

/* ═══════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════ */
.footer {
  background: var(--navy);
  color: rgba(255,255,255,.6);
  padding: var(--space-xl) 0;
}
.footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-xl);
}
.footer__brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: var(--space-sm);
}
.footer__heading {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.4);
  margin-bottom: var(--space-md);
}
.footer__link {
  display: block;
  color: rgba(255,255,255,.6);
  font-size: .85rem;
  margin-bottom: var(--space-sm);
  text-decoration: none;
}
.footer__link:hover { color: #fff; }

/* ═══════════════════════════════════════════════
   INLINE FORM (Lagerplatz schnell anlegen)
   ═══════════════════════════════════════════════ */
.inline-form {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
  padding: var(--space-md);
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
}
.inline-form .form__group { margin-bottom: 0; flex: 1; }

/* ═══════════════════════════════════════════════
   FILTER CHIPS
   ═══════════════════════════════════════════════ */
.filter-chips {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}
.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.filter-chip:hover { border-color: var(--blue); }
.filter-chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ═══════════════════════════════════════════════
   INFO BOX
   ═══════════════════════════════════════════════ */
.info-box {
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  line-height: 1.5;
}
.info-box--blue  { background: var(--blue-light); color: var(--navy); }
.info-box--green { background: var(--green-light); color: var(--green); }
.info-box--red   { background: var(--red-light); color: var(--red); }
.info-box--gold  { background: var(--gold-light); color: var(--navy); }

/* ═══════════════════════════════════════════════
   SETTINGS SIDEBAR
   ═══════════════════════════════════════════════ */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-lg);
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  transition: var(--transition);
}
.settings-nav__link:hover { background: var(--card); }
.settings-nav__link.active { background: var(--card); color: var(--navy); box-shadow: var(--shadow-sm); }

/* ═══════════════════════════════════════════════
   PERMISSIONS TABLE
   ═══════════════════════════════════════════════ */
.perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.perm-table th { padding: 8px 12px; font-size: .7rem; }
.perm-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.perm-table td:first-child { text-align: left; font-weight: 600; }
.perm-table input[type="radio"] {
  accent-color: var(--blue);
  width: 16px; height: 16px;
}

/* ═══════════════════════════════════════════════
   MOBILE TOPBAR (immer vorhanden, ab 768px sichtbar)
   ═══════════════════════════════════════════════ */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--navy);
  color: #fff;
  align-items: center;
  padding: 0 var(--space-md);
  z-index: 200;
  gap: var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar__hamburger {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar__hamburger:hover { background: rgba(255,255,255,.1); }
.topbar__title {
  font-weight: 700;
  font-size: .95rem;
  flex: 1;
}

/* Backdrop for mobile sidebar */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 149;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.open { display: block; }

/* ═══════════════════════════════════════════════
   LANDING PAGE MOBILE NAV
   ═══════════════════════════════════════════════ */
.lp-nav__mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.lp-nav__mobile-toggle:hover { background: rgba(255,255,255,.1); }
.lp-nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.lp-nav__drawer {
  display: flex;          /* always rendered, never display:none */
  position: fixed;
  top: 0; right: 0;
  width: 280px;
  height: 100vh;
  background: var(--navy);
  z-index: 300;
  flex-direction: column;
  padding: var(--space-xl) var(--space-lg);
  gap: var(--space-sm);
  box-shadow: -4px 0 24px rgba(0,0,0,.3);
  overflow-y: auto;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .3s cubic-bezier(.22,.68,0,1.2), visibility 0s linear .3s;
}
.lp-nav__drawer.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform .3s cubic-bezier(.22,.68,0,1.2), visibility 0s linear 0s;
}
.lp-nav__drawer-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.6);
  font-size: 1.4rem;
  cursor: pointer;
  align-self: flex-end;
  padding: 8px;
  margin-bottom: var(--space-md);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.lp-nav__drawer-close:hover { background: rgba(255,255,255,.08); }
.lp-nav__drawer a {
  display: block;
  color: rgba(255,255,255,.75);
  font-weight: 600;
  font-size: 1rem;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: var(--transition);
}
.lp-nav__drawer a:hover { background: rgba(255,255,255,.08); color: #fff; }
.lp-nav__drawer .btn {
  margin-top: var(--space-md);
  width: 100%;
  justify-content: center;
}
.lp-nav__backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 299;
}
.lp-nav__backdrop.open { display: block; }

/* ═══════════════════════════════════════════════
   TABLET — 1024px
   ═══════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .pricing-grid   { grid-template-columns: repeat(3, 1fr); }
  .bld-grid       { grid-template-columns: repeat(2, 1fr); }
  .hero__content  { grid-template-columns: 1fr; text-align: center; }
  .hero__buttons  { justify-content: center; }
  .hero__visual   { display: none; }
  .trust-badges   { gap: var(--space-lg); flex-wrap: wrap; justify-content: center; }
}

/* ═══════════════════════════════════════════════
   MOBILE — 768px
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── App Shell ── */
  .topbar { display: flex; }
  .app__main {
    margin-left: 0;
    padding: var(--space-md);
    padding-top: 72px;
    min-width: 0;
  }
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    z-index: 150;
  }
  .sidebar.open { transform: translateX(0); }

  /* ── Page Header ── */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
  }
  .page-header > div:last-child,
  .page-header > .flex {
    flex-wrap: wrap;
  }
  /* Auf Mobile: Action-Buttons starten von links (natürliche Leserichtung
     bei voller Zeilenbreite). Die rechtsbündige Anordnung auf dem Desktop
     bleibt davon unberührt. */
  .page-header > div:last-child:not(:first-child) {
    justify-content: flex-start;
  }
  .page-header__title { font-size: 1.25rem; }

  /* ── Cards ── */
  .card { padding: var(--space-md); }

  /* ── Tables: horizontal scroll with touch indicator ── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(-1 * var(--space-md));
    padding: 0 var(--space-md);
    border-radius: 0;
  }
  .card .table-wrap {
    margin: 0 calc(-1 * var(--space-md));
    padding: 0;
  }
  .table { min-width: 540px; font-size: .82rem; }
  .table th, .table td { padding: 9px 10px; }

  /* ── Modals: Bottom Sheet Stil ── */
  .modal__overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal__box {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
    width: 100%;
    max-width: 100% !important;
    padding: var(--space-lg) var(--space-md);
    overflow-y: auto;
  }
  /* Handle-Linie oben am Modal */
  .modal__box::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    margin: 0 auto var(--space-md);
  }
  .modal__footer {
    flex-direction: column-reverse;
    gap: var(--space-sm);
  }
  .modal__footer .btn { width: 100%; justify-content: center; }

  /* ── Forms ── */
  .form__row { grid-template-columns: 1fr; gap: var(--space-sm); }
  .form__input, .form__select, .form__textarea {
    font-size: 16px; /* Prevents iOS zoom */
    min-height: 44px;
  }

  /* ── Buttons: Touch-freundlich ── */
  .btn { min-height: 44px; }
  .btn--sm { min-height: 36px; }

  /* ── Action Menu: immer nach links öffnen wenn am Rand ── */
  .action-menu__dropdown {
    right: 0;
    left: auto;
    min-width: 180px;
    z-index: 60;
  }
  /* Letzter Column: overflow verhindern */
  .table td:last-child { overflow: visible; position: relative; }

  /* ── Inline Form: Stapeln ── */
  .inline-form {
    flex-direction: column;
    gap: var(--space-sm);
  }
  .inline-form .form__group { min-width: 0; }
  .inline-form .btn { width: 100%; }

  /* ── Filter Chips: horizontal scroll ── */
  .filter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .filter-chips::-webkit-scrollbar { display: none; }
  .filter-chip { flex-shrink: 0; }

  /* ── Settings Layout: Tabs oben ── */
  .settings-layout { grid-template-columns: 1fr; gap: var(--space-md); }
  .settings-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav__link {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 8px 14px;
    font-size: .8rem;
  }

  /* ── Building Grid ── */
  .bld-grid { grid-template-columns: 1fr; }

  /* ── KPI Grid ── */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-sm); }

  /* ── Flex-Between Stack ── */
  .flex-between {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  /* ── Login ── */
  .login-page { grid-template-columns: 1fr; }
  .login-page__brand { display: none; }
  .login-page__form-area { padding: var(--space-lg) var(--space-md); }

  /* ── Landing Page ── */
  .lp-nav__links { display: none !important; }
  .lp-nav__mobile-toggle { display: flex !important; }
  .lp-nav .container { position: relative; }
  .hero { padding: 60px 0 40px; }
  .hero__headline { font-size: 1.9rem; }
  .hero__sub { font-size: .95rem; }
  .hero__buttons { flex-direction: column; gap: var(--space-sm); align-items: stretch; }
  .hero__buttons .btn { width: 100%; justify-content: center; }
  .pricing-grid { grid-template-columns: 1fr; max-width: 400px; margin: 0 auto; }
  .card--featured { transform: none; }
  .footer__grid { grid-template-columns: 1fr; gap: var(--space-lg); }
  .trust-badges { flex-direction: column; align-items: center; gap: var(--space-md); padding: var(--space-lg) 0; }

  /* ── Changelog Tabelle: scroll ── */
  .cl-table { font-size: .78rem; }
  .cl-table th:nth-child(1),
  .cl-table td:nth-child(1) { display: none; } /* "Bereich" ausblenden */

  /* ── Landingpage: Animations-Freeze-Schutz ── */
  /* Elemente mit animation-fill-mode:both + delay können auf Mobile einfrieren */
  .anim-1, .anim-2, .anim-3, .anim-4,
  .reveal {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  /* ── Schriften ── */
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.35rem; }
  .container { padding: 0 var(--space-md); }

  /* ── Dash-Grid ── */
  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-sm); }
  .dash-card { padding: 14px 14px 12px; }
  .dash-card__value { font-size: 1.6rem; }
  .heute-grid { grid-template-columns: 1fr; gap: var(--space-sm); }
  .dash-two-col { grid-template-columns: 1fr; gap: var(--space-md); }
}

/* ═══════════════════════════════════════════════
   SMALL MOBILE — 480px
   ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
  .code-input__field { width: 40px; height: 48px; font-size: 1.2rem; }
  .container { padding: 0 var(--space-sm); }
  .app__main { padding: var(--space-sm); padding-top: 68px; }
  .card { padding: var(--space-sm) var(--space-md); }
  .page-header__title { font-size: 1.15rem; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-xs); }
  .dash-card { padding: 12px 10px; }
  .dash-card__value { font-size: 1.4rem; }
  .dash-card__icon { font-size: 1.2rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  /* Buttons wrappen statt überlaufen */
  .flex.gap-sm, .flex.gap-md { flex-wrap: wrap; }
  .hero__headline { font-size: 1.65rem; }
  .pricing-grid { max-width: 100%; }
}

/* ═══════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.hidden { display: none; }
.fw-700 { font-weight: 700; }

/* ═══════════════════════════════════════════════
   FAB — Floating Action Button (Mobile First)
   Pattern: <button class="km-fab" onclick="...">+</button>
   - Default: nur ab <=768px sichtbar (auf Desktop verstecken wir, weil dort
     der Header-Button reicht). Mit .km-fab--always immer sichtbar machen.
   ═══════════════════════════════════════════════ */
.km-fab {
  position: fixed;
  /* Auf Mobile sitzt die kmbot-Chat-Bubble auch unten rechts.
     Wir setzen den FAB drüber (~78px hoch), damit er nicht verdeckt wird. */
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 200;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  border: none;
  font-size: 1.7rem; line-height: 1;
  cursor: pointer;
  display: none;        /* default: auf Desktop verbergen */
  align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.28);
  transition: transform .12s, box-shadow .15s;
}
.km-fab:hover  { transform: scale(1.06); box-shadow: 0 8px 22px rgba(0,0,0,.32); }
.km-fab:active { transform: scale(.96); }
.km-fab--secondary { background: var(--navy); }
.km-fab--danger    { background: #C62828; }

/* FAB mit Label-Pille (nur auf >768px, falls --always) */
.km-fab__label {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.78); color: #fff;
  padding: 6px 12px; border-radius: 6px;
  font-size: .82rem; font-weight: 600; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
}
.km-fab:hover .km-fab__label { opacity: 1; }

@media (max-width: 768px) {
  .km-fab { display: inline-flex; }
}
.km-fab--always { display: inline-flex; }

/* ═══════════════════════════════════════════════
   STICKY SAVE FOOTER
   Pattern: <div class="km-sticky-footer"><button>Speichern</button></div>
   - In langen Modals oder Settings-Sektionen am unteren Rand sticky
   - Auf Mobile am Viewport-Bottom mit Safe-Area-Padding
   ═══════════════════════════════════════════════ */
.km-sticky-footer {
  position: sticky;
  bottom: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  z-index: 10;
  margin-top: var(--space-md);
}
.km-sticky-footer--left  { justify-content: flex-start; }
.km-sticky-footer--space { justify-content: space-between; }
@media (max-width: 768px) {
  .km-sticky-footer { padding-left: 12px; padding-right: 12px; }
  .km-sticky-footer .btn { flex: 1; min-height: 44px; }
  .km-sticky-footer .btn--outline { flex: 0 0 auto; }
}

/* ═══════════════════════════════════════════════
   MOBILE CARD LIST — Tabellen-Ersatz auf <=768px
   Pattern: <div class="km-mlist"><div class="km-mcard">…</div></div>
   ═══════════════════════════════════════════════ */
.km-mlist { display: flex; flex-direction: column; gap: 10px; }
.km-mcard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  cursor: pointer;
  transition: border-color .12s, transform .1s, box-shadow .15s;
}
.km-mcard:hover { border-color: var(--green); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.km-mcard__title { font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: 8px; }
.km-mcard__sub   { font-size: .8rem; color: var(--text-muted); }
.km-mcard__row   { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.km-mcard__row .lbl { color: var(--text-muted); min-width: 90px; }
.km-mcard__actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 4px; padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.km-mcard__actions .btn { flex: 1; min-height: 38px; font-size: .82rem; padding: 6px 10px; }

/* ═══════════════════════════════════════════════
   BOTTOM SHEET — Action-Sheet von unten (Mobile)
   Pattern: <div class="km-sheet" id="..."><div class="km-sheet__panel">…</div></div>
   ═══════════════════════════════════════════════ */
.km-sheet {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  z-index: 9500;
  align-items: flex-end;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.km-sheet.is-open { display: flex; }
.km-sheet__panel {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding: 8px 0 calc(12px + env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
  animation: km-sheet-up .22s ease;
}
@keyframes km-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.km-sheet__handle {
  width: 38px; height: 4px;
  background: rgba(0,0,0,.18);
  border-radius: 2px;
  margin: 6px auto 14px;
}
.km-sheet__title {
  font-weight: 700; font-size: 1rem;
  padding: 4px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.km-sheet__item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  font-size: .95rem; font-weight: 500;
  cursor: pointer;
  border: none; background: transparent;
  width: 100%; text-align: left; color: var(--text);
  min-height: 48px;
}
.km-sheet__item:hover, .km-sheet__item:active { background: rgba(0,0,0,.04); }
.km-sheet__item--danger { color: #C62828; }
.km-sheet__item__icon { font-size: 1.2rem; width: 28px; text-align: center; flex-shrink: 0; }
.km-sheet__cancel {
  margin: 10px 14px 0;
  padding: 14px;
  background: rgba(0,0,0,.04);
  border: none; border-radius: 12px;
  font-weight: 600; font-size: .95rem;
  cursor: pointer;
  color: var(--text);
}
.km-sheet__cancel:hover { background: rgba(0,0,0,.08); }
.mono { font-family: 'Courier New', monospace; }

/* ═══════════════════════════════════════════════
   ── Mobile-Optimierung (Runde 39) ──
   Nur mobile Feinschliff; Desktop bleibt unberührt.
   ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Toasts respektieren die Safe-Area auf Notch-iPhones,
     damit sie nicht unter der Hardware-Insel / Home-Indicator verschwinden. */
  .toast-container {
    right: calc(var(--space-md) + env(safe-area-inset-right));
    bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
  }
}

@media (max-width: 390px) {
  /* FAB auf sehr kleinen Phones kompakter und sicherer positionieren.
     Der 86px-Offset (kmbot-Bubble) ist hier oft zu hoch bzw. kollidiert
     mit Floating-Elementen – wir setzen den FAB knapp über die Safe-Area. */
  .km-fab {
    width: 48px; height: 48px;
    font-size: 1.4rem;
    bottom: calc(20px + env(safe-area-inset-bottom));
  }
  /* Kleine Buttons auf Mini-Screens etwas größer für besseren Touch-Komfort. */
  .btn--sm { min-height: 40px; }
}
