*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  background: #f5f7fa;
  color: #1a1a2e;
  min-height: 100vh;
}

body.admin-nav-open {
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────── */
.admin-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #1a1a2e;
  color: #fff;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
}
.admin-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #fff;
  transition: transform .18s ease, opacity .18s ease;
}
body.admin-nav-open .admin-menu-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
body.admin-nav-open .admin-menu-toggle span:nth-child(2) {
  opacity: 0;
}
body.admin-nav-open .admin-menu-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}
.admin-logo  {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #25ae7c;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}
.admin-logo img {
  display: block;
  width: 142px;
  height: auto;
  background: #fff;
  border-radius: 6px;
  padding: 4px 6px;
}
.admin-title { flex: 1; font-weight: 800; font-size: 18px; }

/* ── Layout ─────────────────────────────────────────────────────── */
.admin-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

.admin-nav {
  background: #fff;
  border-right: 1px solid #e8ecf0;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow: auto;
}
.admin-nav-backdrop {
  position: fixed;
  inset: 56px 0 0;
  background: rgba(15, 23, 42, 0.38);
  z-index: 89;
}

.tab-btn {
  background: none;
  border: none;
  text-align: left;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
}
.tab-btn:hover  { background: #f0f9f5; color: #25ae7c; }
.tab-btn.active { background: #e8f8f1; color: #1a9e6e; border-right: 3px solid #25ae7c; }

.admin-main {
  width: min(100%, 1360px);
  margin: 0;
  padding: 32px clamp(24px, 2vw, 40px) 88px;
}
.admin-footer {
  position: fixed;
  right: 24px;
  bottom: 16px;
  font-size: 13px;
  font-weight: 700;
}
.admin-footer a {
  color: #7a8494;
  text-decoration: none;
}
.admin-footer a:hover { color: #25ae7c; text-decoration: underline; }

/* ── Section ────────────────────────────────────────────────────── */
.tab-section.hidden { display: none; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.section-head h2 { font-size: 20px; font-weight: 800; flex: 1; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  padding: 8px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-primary { background: #25ae7c; color: #fff; border-color: #25ae7c; }
.btn-primary:hover { background: #1a9e6e; }
.btn-outline { background: transparent; color: #25ae7c; border-color: #25ae7c; }
.btn-outline:hover { background: #e8f8f1; }
.btn-danger  { background: #e74c3c; color: #fff; border-color: #e74c3c; font-size: 12px; padding: 5px 10px; }
.btn-danger:hover { background: #c0392b; }
.btn-reset   { background: #f39c12; color: #fff; border-color: #f39c12; font-size: 12px; padding: 5px 10px; }
.btn-reset:hover { background: #d68910; }

/* ── Form ───────────────────────────────────────────────────────── */
.form-card {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.form-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-col { display: flex; flex-direction: column; gap: 10px; }
.form-col label { font-size: 13px; font-weight: 700; color: #555; margin-top: 4px; }
.password-suggest {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 260px;
  min-width: 240px;
}
.password-suggest input {
  flex: 1;
  min-width: 0;
}

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  padding: 8px 12px;
  border: 1.5px solid #d0d7de;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: #1a1a2e;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #25ae7c;
}
select { cursor: pointer; }
.form-hint { font-size: 12px; color: #888; margin-top: 8px; }
.checkbox-row label,
.checkbox-list label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #555;
}
.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.filter-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-field label {
  font-size: 13px;
  font-weight: 700;
  color: #555;
}

.recommend-picker {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid #e8ecf0;
  border-radius: 16px;
  background: #f9fbfc;
}

.recommend-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.recommend-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.recommend-quick-card {
  padding: 14px;
  border: 1px solid #e8ecf0;
  border-radius: 14px;
  background: #fff;
}

.recommend-quick-card h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  color: #334155;
}

.recommend-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recommend-chip,
.recommend-chip-empty {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
}

.recommend-chip {
  padding: 0 12px;
  border: 1px solid #cfe7dc;
  background: #f2fbf6;
  color: #18794e;
  font-weight: 800;
  cursor: pointer;
}

.recommend-chip:hover {
  border-color: #25ae7c;
  background: #e7f8ef;
}

.recommend-chip-empty {
  color: #64748b;
}

.recommend-selected {
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: #fff;
}

.recommend-selected-empty {
  color: #64748b;
  font-weight: 700;
}

.recommend-selected-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.recommend-selected-copy {
  min-width: 0;
}

.recommend-selected-copy strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
  color: #0f172a;
}

.recommend-selected-copy span {
  color: #64748b;
  font-size: 13px;
}

.recommend-selected-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.recommend-results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #64748b;
  font-size: 13px;
}

.recommend-results-head strong {
  color: #0f172a;
  font-size: 14px;
}

.recommend-result-list {
  display: grid;
  gap: 10px;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 4px;
}

.recommend-result-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid #dbe3ea;
  border-radius: 16px;
  background: #fff;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}

.recommend-result-card:hover {
  border-color: #25ae7c;
  box-shadow: 0 8px 22px rgba(37, 174, 124, 0.12);
  transform: translateY(-1px);
}

.recommend-result-card.is-selected {
  border-color: #25ae7c;
  background: #f2fbf6;
}

.recommend-result-copy {
  min-width: 0;
}

.recommend-result-topline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  min-width: 0;
}

.recommend-result-icon {
  flex-shrink: 0;
  font-size: 16px;
}

.recommend-result-title {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
}

.recommend-result-path {
  color: #64748b;
  font-size: 13px;
}

.recommend-type-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: #e8f7f0;
  color: #18794e;
  font-size: 12px;
  font-weight: 900;
}

.recommend-empty {
  padding: 18px 16px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: #fff;
  color: #64748b;
  font-weight: 700;
}

.qr-dialog-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin: 18px 0;
}

.qr-preview-card {
  display: flex;
  justify-content: center;
}

.qr-preview {
  min-height: 260px;
  width: 100%;
  max-width: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  border: 1px solid #e8ecf0;
  border-radius: 16px;
  background: #f9fbfc;
  color: #64748b;
}

.qr-preview-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.qr-preview-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #64748b;
}

.qr-preview-name {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  color: #0f172a;
  word-break: break-word;
}

.qr-preview-stage {
  width: 100%;
  max-width: 220px;
}

.qr-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.qr-meta {
  gap: 8px;
}

.qr-meta input {
  width: 100%;
}

#qr-login-url {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.hidden { display: none !important; }

/* ── Tabellen ───────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e8ecf0;
  font-size: 14px;
}
.data-table th {
  background: #f5f7fa;
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid #e8ecf0;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafcfb; }

.history-wrong-list {
  margin: 0;
  padding-left: 18px;
}

.history-wrong-list .history-context {
  list-style: none;
  margin: 0 0 4px -18px;
  font-weight: 700;
}

.history-settings {
  margin-top: 6px;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.45;
}

.history-more {
  margin-top: 6px;
}

.history-more summary {
  cursor: pointer;
  color: #1f5d49;
  font-weight: 700;
}

.history-more[open] summary {
  margin-bottom: 6px;
}

.history-wrong-list-extra {
  margin-top: 0;
}

.history-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.history-delete-hint {
  margin-top: 8px;
  color: #b7791f;
  font-size: 12px;
}

.analytics-admin-panel {
  margin: 18px 0 22px;
}

.analytics-panel {
  display: grid;
  gap: 18px;
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: 16px;
  padding: 18px;
}

.analytics-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.analytics-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  justify-content: flex-end;
}

.analytics-toolbar h3 {
  margin: 0 0 4px;
}

.analytics-filter {
  display: grid;
  gap: 6px;
  min-width: min(260px, 100%);
  font-weight: 700;
}

.analytics-filter span {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.analytics-filter select {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid #d8dee6;
  background: #fff;
  color: #1f2933;
}

.analytics-zoom-controls {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.analytics-zoom-controls span {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.analytics-zoom-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-zoom-group strong {
  min-width: 48px;
  text-align: center;
  color: #1f2933;
}

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.analytics-kpi {
  background: #f7fafc;
  border: 1px solid #e8ecf0;
  border-radius: 14px;
  padding: 12px 14px;
}

.analytics-kpi span {
  display: block;
  color: #718096;
  font-size: 12px;
  margin-bottom: 4px;
}

.analytics-kpi strong {
  font-size: 16px;
}

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

.analytics-chart-card {
  border: 1px solid #e8ecf0;
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}

.analytics-chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}

.analytics-chart-head h4 {
  margin: 0;
  font-size: 15px;
}

.analytics-chart-head span,
.analytics-chart-warning,
.analytics-note,
.analytics-empty,
.analytics-loading {
  color: #718096;
  font-size: 13px;
}

.analytics-chart-warning {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff8ef;
  border: 1px solid #efdcc0;
}

.analytics-chart-svg {
  width: auto;
  max-width: none;
  height: auto;
  display: block;
}

.analytics-chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
}

.analytics-chart-shell {
  position: relative;
}

.analytics-chart-tooltip {
  position: fixed;
  z-index: 20;
  max-width: 260px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
  pointer-events: none;
}

.analytics-grid-line {
  stroke: #e8ecf0;
  stroke-width: 1;
}

.analytics-axis-line {
  stroke: #d8dee6;
  stroke-width: 1.2;
}

.analytics-axis-label {
  fill: #718096;
  font-size: 11px;
}

.analytics-active-line {
  stroke: rgba(15, 23, 42, 0.18);
  stroke-width: 1.5;
  pointer-events: none;
}

.analytics-active-dot {
  fill: var(--chart-accent, #25ae7c);
  stroke: #fff;
  stroke-width: 3;
  pointer-events: none;
}

.analytics-point-hit {
  cursor: pointer;
  outline: none;
}

.analytics-point-group:hover .analytics-point-dot {
  filter: drop-shadow(0 0 0.3rem rgba(15, 23, 42, 0.18));
}

.analytics-point-hit.is-active {
  stroke: rgba(15, 23, 42, 0.18);
  stroke-width: 1.5;
}

.badge-admin       { background: #fde8d8; color: #c0392b; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-einrichtung { background: #e8eefc; color: #2c5cc5; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-therapeut   { background: #fff2d9; color: #b26b00; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-lernende    { background: #e8f8f1; color: #1a9e6e; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-aktiv       { color: #1a9e6e; font-weight: 700; font-size: 12px; }
.badge-inaktiv     { color: #a94442; font-weight: 700; font-size: 12px; }
.badge-seen    { color: #888; font-size: 12px; }
.badge-unseen  { color: #e67e22; font-weight: 700; font-size: 12px; }
.badge-done    { color: #1a9e6e; font-weight: 700; font-size: 12px; }
.muted { color: #aaa; font-size: 13px; }

.btn-group { display: flex; gap: 6px; }

.v1-export-status {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f5f7fa;
  color: #5f6b7a;
  font-size: 13px;
  font-weight: 700;
}

.v1-export-status:empty { display: none; }
.v1-export-status.is-ready { background: #e8f8f1; color: #157a55; }
.v1-export-status.is-error { background: #fdeceb; color: #a94442; }

.v1-export-problems {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #f2c7c3;
  border-radius: 8px;
  background: #fff7f6;
  color: #8e3f38;
  font-size: 13px;
}

.v1-export-problems ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.v1-export-table-wrap { max-width: 720px; }

.v1-export-key-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

.v1-export-key-row input {
  flex: 1 1 420px;
  min-width: 260px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.v1-export-confirm {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 16px;
  font-size: 13px;
  font-weight: 700;
}

#btn-v1-export-download:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.module-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
}

.module-checks label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #455468;
}

.filter-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-field label {
  font-size: 12px;
  font-weight: 700;
  color: #667085;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.link-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.link-stack small {
  color: #64748b;
  font-size: 12px;
}

.limit-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #475467;
}

.limit-stack strong {
  color: #111827;
}

.login-link-copy {
  display: inline-flex;
  width: 100%;
  max-width: 100%;
  border: 1px solid #d6e0ea;
  border-radius: 6px;
  background: #f8fafc;
  color: #1f2937;
  font-family: "Courier New", monospace;
  font-size: 12px;
  padding: 7px 10px;
  cursor: pointer;
  text-align: left;
  word-break: break-all;
  transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.login-link-copy:hover {
  background: #eef6f3;
  border-color: #25ae7c;
}

.login-link-copy.copied {
  background: #dcfce7;
  border-color: #25ae7c;
  color: #166534;
  box-shadow: 0 0 0 2px rgba(37, 174, 124, 0.12);
}

.login-link-meta {
  display: block;
  margin-top: 6px;
  color: #64748b;
  font-size: 11px;
}

.login-link-meta code {
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}

.badge-admin { background: #fde8d8; color: #c0392b; }
.badge-einrichtung { background: #e7f0ff; color: #2453a6; }
.badge-therapeut { background: #fff1d8; color: #a15c00; }
.badge-lernende { background: #e8f8f1; color: #1a9e6e; }
.badge-aktiv { background: #e8f8f1; color: #1a9e6e; }
.badge-inaktiv { background: #f3f4f6; color: #6b7280; }

@media (max-width: 1040px) {
  .admin-header {
    gap: 12px;
    padding: 0 16px;
  }
  .admin-menu-toggle {
    display: inline-flex;
    flex-shrink: 0;
  }
  .admin-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .admin-nav {
    position: fixed;
    top: 56px;
    left: 0;
    width: min(320px, calc(100vw - 32px));
    height: calc(100vh - 56px);
    max-height: none;
    z-index: 90;
    border-right: 1px solid #e8ecf0;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
    transform: translateX(-100%);
    transition: transform .2s ease;
    overflow-y: auto;
  }
  body.admin-nav-open .admin-nav {
    transform: translateX(0);
  }
  body.admin-nav-open .admin-nav-backdrop.hidden {
    display: block !important;
  }
  .admin-main {
    width: 100%;
    padding: 24px 16px 88px;
  }

  .filter-toolbar {
    grid-template-columns: 1fr;
  }
  .recommend-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .recommend-quick-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .admin-logo img {
    width: 120px;
  }
  .admin-logo span {
    display: none;
  }
  .admin-title {
    font-size: 16px;
  }
  #btn-logout {
    padding: 8px 12px;
    font-size: 13px;
  }
  .recommend-toolbar {
    grid-template-columns: 1fr;
  }
  .recommend-result-card,
  .recommend-selected-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .recommend-selected-meta,
  .recommend-type-pill {
    align-self: flex-start;
  }
}

/* ── Navigation Editor ──────────────────────────────────────────── */
#nav-editor {
  width: 100%;
  height: 500px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  border: 1.5px solid #d0d7de;
  border-radius: 8px;
  resize: vertical;
  background: #1e1e2e;
  color: #cdd6f4;
}

/* ── Dialog ─────────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.dialog {
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 380px;
  width: 90%;
  text-align: center;
}
.dialog h3 { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.pw-box {
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 8px;
  padding: 14px 20px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .04em;
  margin: 12px 0;
}

/* ── Toast ──────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a2e;
  color: #fff;
  padding: 10px 22px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Aufgabe erstellen ──────────────────────────────────────────── */
.aufgabe-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 28px;
  align-items: start;
}
@media (max-width: 860px) {
  .aufgabe-grid { grid-template-columns: 1fr; }
}
.neues-thema-box {
  background: #f0fdf8;
  border: 1px solid #c8f0e0;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.neues-thema-box label { margin-top: 0 !important; }
.input-with-check { display: flex; align-items: center; gap: 8px; }
.input-with-check input { flex: 1; min-width: 0; }
#auf-titel-status { font-size: 12px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.field-readonly { background: #f5f7fa !important; color: #999 !important; font-family: monospace !important; font-size: 12px !important; }
#auf-dateiname { font-family: 'Courier New', monospace; font-size: 11px; color: #999; margin-top: -4px; }
.editor-col { display: flex; flex-direction: column; gap: 8px; }
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.editor-label { font-size: 13px; font-weight: 700; color: #555; }
#auf-editor {
  width: 100%;
  height: 520px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  border: 1.5px solid #d0d7de;
  border-radius: 8px;
  resize: vertical;
  background: #1e1e2e;
  color: #cdd6f4;
  tab-size: 2;
}
.btn-sm { padding: 5px 12px !important; font-size: 12px !important; }
.auf-save-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e8ecf0;
}
#auf-save-msg { font-size: 13px; font-weight: 600; color: #25ae7c; }

/* ── Nav View Toggle ────────────────────────────────────────────── */
.nav-view-toggle { display: flex; gap: 4px; }
.nav-view-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1.5px solid #d0d7de;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: all .15s;
}
.nav-view-btn.active { background: #25ae7c; border-color: #25ae7c; color: #fff; }
.nav-scan-card {
  margin-top: 18px;
}
.nav-candidate-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.nav-candidate-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fbfcfd;
}
.nav-candidate-copy {
  flex: 1;
  min-width: 0;
}
.nav-candidate-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.nav-candidate-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.nav-candidate-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.badge-nav-new {
  background: #e8f8f1;
  color: #1a9e6e;
}
.badge-nav-type {
  background: #eef2ff;
  color: #3743a5;
}
.nav-candidate-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  color: #475467;
  font-size: 13px;
}
.nav-candidate-meta code {
  padding: 2px 8px;
  border-radius: 999px;
  background: #eff3f7;
  color: #344054;
  font-size: 12px;
}
.nav-candidate-info {
  margin: 8px 0 0;
  color: #667085;
  font-size: 13px;
}

/* ── DnD Tree ───────────────────────────────────────────────────── */
#nav-dnd-tree {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: 12px;
  padding: 8px;
  min-height: 120px;
}

.dnd-item { position: relative; }
.dnd-fach { border-radius: 8px; margin-bottom: 6px; }
.dnd-thema { border-radius: 6px; margin-bottom: 2px; }
.dnd-seite { border-radius: 4px; margin-bottom: 2px; }

.dnd-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: inherit;
  position: relative;
  user-select: none;
}
.dnd-fach > .dnd-row  { background: #f0f9f5; }
.dnd-thema > .dnd-row { background: #f8f9fb; }
.dnd-seite > .dnd-row { background: transparent; }
.dnd-row:hover { background: #e8f8f1 !important; }

.dnd-handle {
  cursor: grab;
  color: #bbb;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
.dnd-handle:active { cursor: grabbing; }

.dnd-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.dnd-icon { flex-shrink: 0; }
.dnd-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.dnd-fach  > .dnd-row .dnd-title { font-weight: 800; font-size: 15px; }
.dnd-thema > .dnd-row .dnd-title { font-weight: 700; color: #444; }
.dnd-seite > .dnd-row .dnd-title { font-weight: 600; color: #666; font-size: 13px; }

.dnd-actions { display: flex; gap: 4px; flex-shrink: 0; }
.dnd-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.dnd-row:hover .dnd-btn { opacity: 1; }
.dnd-btn-add  { color: #1a7fc4; font-weight: 700; font-size: 11px !important; }
.dnd-btn-add:hover  { background: #e8f0fb; }
.dnd-btn-edit { color: #25ae7c; }
.dnd-btn-edit:hover { background: #e8f8f1; }
.dnd-btn-del  { color: #e74c3c; }
.dnd-btn-del:hover  { background: #fde8e8; }

.dnd-children { padding-left: 24px; }
.dnd-dragging { opacity: .35; }

.dnd-item.drop-before > .dnd-row::before,
.dnd-item.drop-after  > .dnd-row::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: #25ae7c;
  border-radius: 2px;
  pointer-events: none;
  z-index: 10;
}
.dnd-item.drop-before > .dnd-row::before { top: 0; }
.dnd-item.drop-after  > .dnd-row::after  { bottom: 0; }

/* ── Nav-Edit Dialog ────────────────────────────────────────────── */
.dialog-wide { max-width: 820px !important; width: min(92vw, 820px); }
.dialog-btns { display: flex; gap: 10px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.dialog-btns .btn { flex: 1 1 160px; }

.section-head-inline {
  align-items: flex-start;
}

.content-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) minmax(160px, .8fr) minmax(160px, .8fr);
  gap: 12px;
}

.content-search-wrap,
.content-filter-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.content-search-wrap label,
.content-filter-wrap label {
  font-size: 13px;
  font-weight: 700;
  color: #555;
}

.content-editor-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.content-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.editor-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .9fr);
  gap: 18px;
  align-items: start;
}

.preview-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#content-editor {
  width: 100%;
  height: 520px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  border: 1.5px solid #d0d7de;
  border-radius: 8px;
  resize: vertical;
  background: #1e1e2e;
  color: #cdd6f4;
  tab-size: 2;
}

.markdown-preview {
  min-height: 220px;
  max-height: 520px;
  overflow: auto;
  padding: 16px 18px;
  border: 1px solid #e8ecf0;
  border-radius: 8px;
  background: #fbfcfd;
  line-height: 1.6;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 0 0 12px;
  line-height: 1.25;
}

.markdown-preview p,
.markdown-preview ul,
.markdown-preview ol,
.markdown-preview blockquote,
.markdown-preview table {
  margin: 0 0 12px;
}

.markdown-preview ul,
.markdown-preview ol {
  padding-left: 20px;
}

.markdown-preview code {
  background: #eef2f6;
  padding: 1px 5px;
  border-radius: 5px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.markdown-preview pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
}

.markdown-preview pre code {
  background: transparent;
  padding: 0;
}

.markdown-preview table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-preview th,
.markdown-preview td {
  border: 1px solid #dfe5eb;
  padding: 8px 10px;
  text-align: left;
}

.markdown-preview blockquote {
  border-left: 3px solid #25ae7c;
  padding-left: 12px;
  color: #4f5a67;
}

@media (max-width: 980px) {
  .content-toolbar,
  .content-meta-grid,
  .editor-split {
    grid-template-columns: 1fr;
  }

  .content-editor-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 1200px) {
  .admin-main {
    width: min(100%, 1120px);
    padding-inline: 24px;
  }

  .aufgabe-grid {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    position: sticky;
    top: 56px;
    z-index: 95;
    flex-direction: row;
    gap: 8px;
    padding: 10px 16px;
    border-right: none;
    border-bottom: 1px solid #e8ecf0;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
  }

  .tab-btn {
    padding: 9px 12px;
    border-radius: 8px;
    flex: 0 0 auto;
  }

  .tab-btn.active {
    border-right: none;
    box-shadow: inset 0 -3px 0 #25ae7c;
  }

  .admin-main {
    width: min(100%, 960px);
    padding: 24px 18px 88px;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .form-row {
    align-items: stretch;
  }

  .form-row > * {
    flex: 1 1 180px;
  }
}

@media (max-width: 700px) {
  .admin-header {
    height: auto;
    min-height: 56px;
    padding: 10px 14px;
    flex-wrap: wrap;
    row-gap: 10px;
  }

  .admin-logo {
    gap: 8px;
    font-size: 13px;
  }

  .admin-logo img {
    width: 118px;
  }

  .admin-title {
    font-size: 16px;
    flex: 1 1 auto;
  }

  .admin-nav {
    top: 76px;
    padding: 8px 12px;
  }

  .admin-main {
    padding: 18px 12px 84px;
  }

  .section-head h2 {
    font-size: 18px;
  }

  .form-card {
    padding: 16px;
  }

  .filter-toolbar {
    grid-template-columns: 1fr;
  }

  .dialog,
  .dialog-wide {
    width: calc(100% - 24px);
    padding: 22px 18px;
  }

  #auf-editor,
  #content-editor,
  .markdown-preview {
    max-height: none;
  }

  #auf-editor,
  #content-editor {
    height: 340px;
  }

  .admin-footer {
    position: static;
    text-align: center;
    padding: 0 0 18px;
  }
}

/* Mobile Admin-Navigation: alte horizontale Tablet-Navigation bewusst überschreiben. */
@media (max-width: 1040px) {
  .admin-nav {
    position: fixed;
    top: 56px;
    left: 0;
    width: min(320px, calc(100vw - 32px));
    height: calc(100vh - 56px);
    max-height: none;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 16px 0;
    border-right: 1px solid #e8ecf0;
    border-bottom: none;
    overflow-x: hidden;
    overflow-y: auto;
    white-space: normal;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

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

  .tab-btn {
    width: 100%;
    flex: 0 0 auto;
    border-radius: 0;
    padding: 10px 20px;
    white-space: normal;
  }

  .tab-btn.active {
    border-right: 3px solid #25ae7c;
    box-shadow: none;
  }

  .nav-candidate-item,
  .nav-candidate-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-candidate-actions {
    width: 100%;
    flex-direction: column;
  }

  .nav-candidate-badges {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .qr-dialog-grid {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    top: 76px;
    height: calc(100vh - 76px);
  }

  .admin-nav-backdrop {
    inset: 76px 0 0;
  }
}
