:root {
  --bg: #f3f4f6;
  --sidebar-bg: #1f2937;
  --sidebar-text: #e5e7eb;
  --sidebar-active: #374151;
  --accent: #f59e0b;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --card: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
.hidden { display: none !important; }

/* ===== Login ===== */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1f2937 0%, #111827 100%);
}
.login-card {
  background: var(--card); padding: 40px 36px; border-radius: 14px;
  text-align: center; width: 380px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-logo { height: 40px; margin-bottom: 14px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.btn-ms { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; }
.ms-icon { font-weight: 600; }
.link-btn {
  background: none; border: none; color: var(--muted); font-size: 12px;
  cursor: pointer; margin-top: 14px; text-decoration: underline;
}
.admin-form { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.admin-form input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.login-error { color: #dc2626; font-size: 13px; margin-top: 12px; }

/* ===== App-Layout ===== */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 240px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: width .18s ease;
}
.sidebar.collapsed { width: 64px; }

.sidebar-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px; min-height: 56px;
}
.collapse-btn {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--sidebar-text); padding: 4px 8px; border-radius: 6px; flex-shrink: 0;
}
.collapse-btn:hover { background: var(--sidebar-active); }
.logo { height: 26px; width: auto; transition: opacity .12s; }
.sidebar.collapsed .logo { display: none; }

.nav { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overflow-x: hidden; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border: none; background: none; color: var(--sidebar-text);
  border-radius: 8px; cursor: pointer; font-size: 14px; text-align: left;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--sidebar-active); }
.nav-item.active { background: var(--sidebar-active); font-weight: 600; }
.nav-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-logo { width: 22px; height: 22px; object-fit: contain; flex-shrink: 0; }
.nav-label { opacity: 1; transition: opacity .12s; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }

.sidebar-foot { padding: 8px; border-top: 1px solid #374151; display: flex; flex-direction: column; gap: 2px; }
.nav-settings { color: #9ca3af; }
.user-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  color: var(--sidebar-text); font-size: 13px; overflow: hidden; white-space: nowrap;
}
.user-name { overflow: hidden; text-overflow: ellipsis; }
.nav-logout { color: #9ca3af; }
.sidebar.collapsed .user-row { justify-content: center; padding: 10px 0; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.content { flex: 1; min-height: 0; overflow: hidden; }

/* Inhalt, der scrollen darf (Startseite, Einstellungen) */
.scroll-body { height: 100%; overflow-y: auto; padding: 24px; }

/* Module: iframe füllt den Bereich komplett — kein Doppel-Scroll */
.module-frame { width: 100%; height: 100%; border: none; display: block; background: #fff; }

/* ===== Buttons ===== */
.btn {
  padding: 9px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 500;
}
.btn-primary { background: var(--accent); color: #111827; }
.btn-primary:hover { background: #d97706; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== Module-Karten ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 22px; cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.08); }
.card-icon { font-size: 30px; }
.card-logo { height: 30px; width: auto; }
.cell-logo { height: 20px; width: auto; }
.cell-icon { font-size: 16px; }
.card-label { font-weight: 600; margin-top: 10px; }
.card-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.welcome { margin-bottom: 24px; }
.welcome h2 { font-size: 20px; margin-bottom: 4px; }
.welcome p { color: var(--muted); font-size: 14px; }

.placeholder {
  background: var(--card); border: 1px dashed var(--border); border-radius: 12px;
  padding: 48px; text-align: center; color: var(--muted);
}
.placeholder h3 { color: var(--text); margin-bottom: 8px; }

/* ===== Einstellungen ===== */
.settings-section {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; margin-bottom: 20px;
}
.settings-section h3 { font-size: 16px; margin-bottom: 12px; }
.settings-section p.hint { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }

.badge { padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-viewer { background: #e0f2fe; color: #075985; }

.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.inline-form input, .inline-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.inline-form input[type="text"], .inline-form input[type="email"] { min-width: 200px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.suggest { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.suggest button { background: none; border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 12px; cursor: pointer; margin: 2px; }
.suggest button:hover { background: var(--bg); }

/* ===== Modal (Modul bearbeiten) ===== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 999; padding: 20px;
}
.modal-box {
  background: var(--card); border-radius: 14px; padding: 24px;
  width: 640px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.modal-box h3 { margin-bottom: 16px; font-size: 17px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.field textarea { min-height: 320px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ===== Zugriff-Matrix ===== */
.matrix-scroll { overflow-x: auto; }
table.access-table { min-width: 100%; border-collapse: collapse; font-size: 13px; }
table.access-table th, table.access-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap;
}
table.access-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: none; }
.emp-name { min-width: 200px; }
.emp-name .hint { margin-top: 2px; font-weight: 400; }
.access-cell { width: 18px; height: 18px; cursor: pointer; accent-color: #f59e0b; }
table.access-table th:not(:first-child) { text-align: center; }
table.access-table td:not(:first-child) { text-align: center; }
