:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #002D5B;
  --primary-dark: #001a38;
  --accent: #00AEEF;
  --border: #d1d5db;
  --error: #b91c1c;
  --ok: #166534;
  --warn: #92400e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }

.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.75rem 1.25rem 0.85rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  gap: 0.65rem;
}

.topbar-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.topbar-brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
}

.brand-icon { width: 36px; height: 36px; object-fit: contain; }
.brand-logo { max-height: 48px; max-width: 220px; object-fit: contain; }

.nav-toggle {
  display: none !important;
  flex-shrink: 0;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.main-nav a.menu-btn,
.main-nav button.menu-btn {
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
}

.main-nav a.menu-btn.primary,
.main-nav a.menu-btn.is-active,
.main-nav button.menu-btn.primary,
.main-nav button.menu-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.main-nav a.menu-btn-logout:hover {
  border-color: var(--error);
  color: var(--error);
}

.nav-group {
  position: relative;
}

.nav-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-caret {
  font-size: 0.7rem;
  opacity: 0.85;
}

.nav-dropdown {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  min-width: 13.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 0.35rem;
  z-index: 40;
  display: grid;
  gap: 0.15rem;
}

.nav-dropdown[hidden] {
  display: none !important;
}

.nav-dropdown-item {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
}

.nav-dropdown-item:hover,
.nav-dropdown-item.is-active {
  background: #eef5fb;
  color: var(--primary);
}

.nav-group.is-active > .nav-group-toggle {
  border-color: var(--primary);
}

@media (max-width: 900px) {
  .nav-toggle {
    display: inline-flex !important;
  }

  .main-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .main-nav.is-open {
    display: flex;
  }

  .main-nav a.menu-btn,
  .main-nav button.menu-btn {
    width: 100%;
    justify-content: space-between;
    text-align: left;
  }

  .nav-group {
    width: 100%;
  }

  .nav-dropdown {
    position: static;
    box-shadow: none;
    border-radius: 8px;
    margin-top: 0.25rem;
    background: #f8fafc;
  }
}

.container {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1rem 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card { width: min(420px, calc(100vw - 2rem)); }

h1, h2 { margin-top: 0; }
.muted { color: var(--muted); }
.error { color: var(--error); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

.form-grid, .filter-form {
  display: grid;
  gap: 1rem;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
}

.form-grid > .full,
.form-grid label.full {
  grid-column: 1 / -1;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.form-row > label {
  flex: 1 1 220px;
  margin: 0;
}

.form-row > .btn {
  flex: 0 0 auto;
  align-self: flex-end;
  height: 2.5rem;
  margin-bottom: 0;
}

.filter-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
}

label.checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.65rem;
  grid-column: 1 / -1;
  padding: 0.35rem 0;
}

label.checkbox-row input[type="checkbox"] {
  width: auto;
  min-width: 1.1rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.article-list-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.article-list-tools .article-search {
  flex: 1 1 220px;
  max-width: 360px;
}

.abc-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.abc-filter button {
  min-width: 2rem;
  padding: 0.35rem 0.45rem;
  font-size: 0.85rem;
}

.abc-filter button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

input, select, textarea, button, .btn { font: inherit; }

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
}

textarea { min-height: 90px; }

.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.btn.primary, button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn:disabled, button:disabled,
.btn.primary:disabled, button.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.primary:hover, button.primary:hover { background: var(--primary-dark); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.form-submit-row {
  margin-top: 1rem;
}

.form-submit-row .btn {
  min-height: 2.5rem;
  height: 2.5rem;
  padding-top: 0;
  padding-bottom: 0;
}

.doc-toolbar-actions > .btn,
.doc-toolbar-actions > a.btn,
.doc-toolbar-actions form.inline-form .btn,
.doc-toolbar-actions form.inline-form button,
.doc-toolbar-actions form.doc-send-form .btn,
.doc-toolbar-actions form.doc-send-form button {
  min-height: 2.5rem;
  height: 2.5rem;
  padding-top: 0;
  padding-bottom: 0;
  box-sizing: border-box;
}

.doc-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.doc-toolbar-title {
  margin: 0;
}

.doc-toolbar-actions {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  width: 100%;
}

.doc-toolbar-actions > .btn,
.doc-toolbar-actions > a.btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.doc-toolbar-actions form.doc-send-form,
.doc-toolbar-actions form.inline-form {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 0.4rem;
  margin: 0 !important;
  padding: 0;
  width: auto !important;
  max-width: none !important;
  flex: 0 0 auto;
}

.doc-toolbar-actions form.doc-send-form input[type="email"] {
  width: 14rem !important;
  min-width: 11rem !important;
  max-width: 14rem !important;
  flex: 0 0 14rem;
  margin: 0 !important;
}

.doc-toolbar-actions form.inline-form .btn,
.doc-toolbar-actions form.inline-form button,
.doc-toolbar-actions form.doc-send-form .btn,
.doc-toolbar-actions form.doc-send-form button {
  flex: 0 0 auto;
  width: auto !important;
  white-space: nowrap;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th { font-size: 0.85rem; color: var(--muted); }

.num { text-align: right; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: #e8f7fc;
  color: var(--primary);
}

.badge.danger { background: #fee2e2; color: var(--error); }
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.warn { background: #ffedd5; color: var(--warn); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.stat-link {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.stat-link:hover {
  border-color: var(--primary);
  background: #f3f8fc;
  box-shadow: 0 1px 0 rgba(0, 45, 91, 0.06);
}

.stat-link:hover .muted {
  color: var(--primary);
}

.stat {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.stat strong { display: block; font-size: 1.35rem; margin-top: 0.25rem; }

.site-footer {
  max-width: 1200px;
  margin: 0 auto 2rem;
  padding: 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.portal-footer {
  width: 100%;
  max-width: none;
  justify-content: center;
  text-align: center;
  margin: 2rem 0 2rem;
}

.portal-footer p {
  margin: 0;
  width: 100%;
  text-align: center;
}

.portal-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}

.portal-login-card {
  max-width: 420px;
  margin: 2.5rem auto;
}

.portal-login-card .login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.portal-login-card .brand-icon-lg {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
}

.permissions-block {
  grid-column: 1 / -1;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 1.5rem;
  margin-top: 0.75rem;
}

.permission-item {
  display: grid;
  grid-template-columns: 1.1rem 1fr;
  gap: 0.65rem;
  align-items: center;
  margin: 0;
  font-size: 0.95rem;
}

.permission-item input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}

.permission-item span {
  line-height: 1.3;
}

@media (max-width: 700px) {
  .permissions-grid {
    grid-template-columns: 1fr;
  }
}

.thumb-cell {
  width: 52px;
  vertical-align: middle;
}

.table-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
  background: #f8fafc;
}

.table-thumb-empty {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: #f8fafc;
}

.file-upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 0.75rem 0 1rem;
}

.file-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.85rem;
}

.file-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.file-thumb-link {
  flex: 0 0 auto;
}

.file-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.file-doc-icon {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  background: #e8f7fc;
}

.file-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.file-meta strong {
  word-break: break-word;
  font-size: 0.9rem;
}

@media (max-width: 800px) {
  .file-upload-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: #fff; }
  .container { margin: 0; max-width: none; }
  .card { border: none; box-shadow: none; padding: 0; }
  .topbar, nav, .flash { display: none !important; }
  .bom-tree-table tr[hidden] { display: none !important; }
}

.print-only { display: none; }

.doc-letterhead-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 64px;
}

.doc-logo {
  max-height: 64px;
  max-width: 280px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.doc-letterhead-line {
  margin-top: 0.65rem;
  border-bottom: 2px solid #002D5B;
}

.doc-signature {
  margin: 1.5rem 0 1rem;
  max-width: 280px;
}

.doc-signature-img {
  display: block;
  max-width: 240px;
  max-height: 90px;
  object-fit: contain;
  background: #fff;
}

.qm-footer-signature-img {
  display: inline-block;
  max-height: 28px;
  max-width: 90px;
  width: auto;
  height: auto;
  object-fit: contain;
  vertical-align: middle;
}

.qm-doc-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.65rem;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

.qm-doc-meta-signer {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.bom-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  min-width: 1.5rem;
  padding: 0;
  margin-right: 0.35rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--primary);
}

.bom-toggle-spacer {
  display: inline-block;
  width: 1.5rem;
  min-width: 1.5rem;
  margin-right: 0.35rem;
}

.bom-name {
  vertical-align: middle;
}

.bom-tree-table .bom-row[data-depth="0"] > td:first-child {
  font-weight: 500;
}

.bom-tree-table .bom-row[data-depth]:not([data-depth="0"]) > td:first-child {
  border-left: 2px solid #c5d4e3;
}

.qm-doc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin: 0 0 1rem;
}

.qm-doc-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  margin-left: auto;
}

.qm-doc-toolbar-version {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.85rem;
  margin: 0;
  margin-left: auto;
}

.qm-doc-toolbar-version .qm-doc-version-input {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  flex: 0 0 auto;
  white-space: nowrap;
}

.qm-doc-toolbar-version .qm-doc-version-input input {
  width: 3.5rem;
  min-width: 3.5rem;
}

.qm-doc-toolbar-version .checkbox-row {
  margin: 0;
  flex: 0 0 auto;
  white-space: nowrap;
}

.qm-doc-toolbar > .btn,
.qm-doc-toolbar-version > .btn,
.qm-doc-toolbar-actions > .btn,
.qm-approval-panel-actions .btn {
  flex: 0 0 auto;
  min-height: 2.5rem;
  height: 2.5rem;
  padding-top: 0;
  padding-bottom: 0;
  box-sizing: border-box;
}

.qm-approval-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  background: #f4f7fb;
  border: 1px solid #d5dde8;
  border-radius: 8px;
}

.qm-approval-panel-status {
  margin: 0;
  color: #3a4553;
  line-height: 1.45;
}

.qm-approval-panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.qm-approval-panel-actions form,
.qm-approval-grant {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.85rem;
  width: auto;
  max-width: 100%;
}

.qm-approval-grant .qm-doc-version-input {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  flex: 0 0 auto;
  white-space: nowrap;
}

.qm-approval-grant .qm-doc-version-input input[type="date"] {
  width: 11rem;
  min-width: 11rem;
  max-width: 11rem;
  flex: 0 0 11rem;
}

.qm-approval-proxy-hint {
  margin: 0;
  flex: 1 1 14rem;
  line-height: 1.4;
}

/* QM-Dokument: Anweisung wie Ausdruck bearbeiten */
.qm-paper-editor {
  grid-column: 1 / -1;
}

.qm-paper-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.qm-paper-toolbar button {
  min-width: 2rem;
}

.qm-paper {
  background: #fff;
  border: 1px solid #c8d0da;
  border-radius: 4px;
  padding: 1.1rem 1.25rem 1.4rem;
  box-shadow: 0 1px 2px rgba(0, 45, 91, 0.06);
}

.qm-paper .doc-letterhead {
  margin-bottom: 0.75rem;
}

.qm-paper-title {
  margin: 0.75rem 0 0.25rem;
  font-size: 1.2rem;
  color: #002D5B;
}

.qm-paper-sub {
  margin: 0 0 0.75rem;
  color: #445;
  font-size: 0.92rem;
}

.qm-instruction-edit {
  min-height: 12rem;
  outline: none;
  border: 1px dashed #b8c4d2;
  border-radius: 3px;
  padding: 0.55rem 0.65rem;
  background: #fbfdff;
}

.qm-instruction-edit:focus {
  border-color: #002D5B;
  background: #fff;
}

.qm-instruction-edit:empty:before {
  content: attr(data-placeholder);
  color: #8896a6;
}

.qm-paper .qm-doc-meta-footer {
  margin-top: 1.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid #bbb;
  pointer-events: none;
}

.qm-paper .qm-doc-meta-pages {
  display: none;
}

.qm-instruction {
  font-size: 14px;
  line-height: 1.45;
}

.qm-instruction p,
.qm-instruction-edit p {
  margin: 0.5rem 0;
}

.qm-instruction ol,
.qm-instruction ul,
.qm-instruction-edit ol,
.qm-instruction-edit ul {
  margin: 0.5rem 0 0.5rem 1.25rem;
  padding: 0;
}

.qm-instruction-locked {
  border-style: solid;
  background: #fff;
  cursor: default;
}

.qm-version-table .qm-row-current td {
  background: #eef4fa;
}

.qm-diff {
  background: #f7f9fb;
  border: 1px solid #d5dde6;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  overflow: auto;
  max-height: 22rem;
  font-size: 0.85rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.qm-diff-add {
  color: #0b6b2e;
  background: #e6f6eb;
  display: block;
}

.qm-diff-del {
  color: #8a1f1f;
  background: #fdebec;
  display: block;
}

.qm-diff-same {
  color: #445;
  display: block;
}

.qm-diff-meta .qm-diff-add,
.qm-diff-meta .qm-diff-del {
  display: inline;
  padding: 0 0.2rem;
}

/* Benachrichtigungs-Popup */
.erp-notif-modal {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 20, 40, 0.45);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.erp-notif-dialog {
  background: #fff;
  border-radius: 10px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  padding: 1.25rem 1.35rem 1.1rem;
  box-shadow: 0 12px 40px rgba(0, 45, 91, 0.22);
}

.erp-notif-dialog h2 {
  margin: 0 0 0.85rem;
  font-size: 1.15rem;
}

.erp-notif-item {
  padding: 0.75rem 0;
  border-top: 1px solid #e4e9ef;
}

.erp-notif-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.qm-approval-request select {
  min-width: 12rem;
  max-width: 18rem;
}

/* Seitenhilfe */
.page-help {
  margin: 0 0 1rem;
}

.page-help-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  background: #f3f7fb;
  border: 1px solid #d5dde8;
  border-radius: 8px;
}

.page-help-intro {
  margin: 0;
  flex: 1 1 16rem;
  color: #3a4553;
  line-height: 1.45;
  font-size: 0.95rem;
}

.page-help-open {
  flex: 0 0 auto;
  align-self: center;
}

.page-help-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 20, 40, 0.4);
}

.page-help-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 9001;
  width: min(28rem, 100vw);
  height: 100vh;
  background: #fff;
  box-shadow: -8px 0 28px rgba(0, 45, 91, 0.18);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.page-help-panel[hidden],
.page-help-overlay[hidden] {
  display: none !important;
}

.page-help-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid #d5dde8;
  background: #f7fafc;
}

.page-help-panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
}

.page-help-panel-body {
  padding: 1rem 1.15rem 1.5rem;
  overflow: auto;
  flex: 1 1 auto;
  line-height: 1.5;
  color: #2c3540;
}

.page-help-panel-body h3 {
  margin: 1.1rem 0 0.4rem;
  font-size: 1rem;
  color: #002d5b;
}

.page-help-panel-body h3:first-child {
  margin-top: 0;
}

.page-help-panel-body p,
.page-help-panel-body ul,
.page-help-panel-body ol {
  margin: 0 0 0.65rem;
}

.page-help-panel-body ul,
.page-help-panel-body ol {
  padding-left: 1.25rem;
}

.page-help-preview {
  border: 1px solid #d5dde8;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: #fafbfc;
  max-height: 22rem;
  overflow: auto;
}

.page-help-editor-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 900px) {
  .page-help-editor-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}


/* Immobilien-Suche Erg?nzungen */
.topbar-user { display: flex; align-items: center; gap: 0.75rem; }
.login-brand { text-align: center; margin-bottom: 0.75rem; }
.source-fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
}
.source-fieldset legend { padding: 0 0.35rem; color: var(--muted); }
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 1rem;
  margin-top: 0.35rem;
}
.source-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0.75rem 0 1.25rem;
  font-size: 0.92rem;
}
.results-list { display: grid; gap: 0.85rem; }
.result-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: #fff;
}
.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.35rem;
}
.result-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #eef5fb;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-soft {
  background: #f3f4f6;
  color: #374151;
  font-weight: 500;
}
.result-price { color: var(--primary); white-space: nowrap; font-size: 1.05rem; }
.result-price-muted { color: var(--muted); font-weight: 600; }
.result-item h3 { margin: 0.25rem 0 0.55rem; font-size: 1.05rem; line-height: 1.35; }
.result-facts {
  list-style: none;
  margin: 0 0 0.55rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  font-size: 0.92rem;
}
.result-facts li {
  margin: 0;
  color: var(--text);
}
.fact-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-right: 0.25rem;
}
.result-snippet {
  margin: 0 0 0.75rem;
  color: #374151;
  line-height: 1.45;
  font-size: 0.95rem;
}
.result-actions { margin: 0; }
.site-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}
label { display: grid; gap: 0.35rem; font-size: 0.92rem; }
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

/* Suchformular: mehrere Felder nebeneinander + Radiuskarte */
.search-form {
  display: block;
}

.search-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem 1rem;
  align-items: start;
}

.search-form-grid > label {
  min-width: 0;
  margin: 0;
}

.search-form-grid > .search-map-panel,
.search-form-grid > .search-span-full {
  grid-column: 1 / -1;
}

.search-map-panel {
  display: grid;
  gap: 0.65rem;
  margin: 0.15rem 0 0.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem 0.85rem;
  background: #f8fafc;
}

.search-map-summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  list-style: none;
  padding: 0.15rem 0;
}

.search-map-summary::-webkit-details-marker {
  display: none;
}

.search-map-summary::before {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  margin-right: 0.4em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  vertical-align: 0.15em;
  transition: transform 0.15s ease;
}

.search-map-panel:not([open]) .search-map-summary::before {
  transform: rotate(-45deg);
  vertical-align: 0.05em;
}

.search-map-hint {
  font-weight: 500;
  font-size: 0.85em;
}

.title-mobile {
  display: none;
}

.search-map {
  width: 100%;
  height: 280px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #e8eef4;
  z-index: 0;
}

.search-map-controls {
  display: grid;
  gap: 0.35rem;
}

.radius-slider-label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
}

.radius-slider-label input[type="range"] {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--accent);
}

.search-map-status {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.35;
  min-height: 1.2em;
}

.search-map-status.error {
  color: var(--error);
}

.search-submit-row {
  margin-top: 1rem;
}

.search-submit-btn {
  min-width: 8rem;
}

.search-form .source-fieldset {
  margin-top: 1rem;
}

.source-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
}

@media (max-width: 900px) {
  .search-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Smartphone */
@media (max-width: 640px) {
  .container {
    margin: 0.5rem auto;
    padding: 0 0.6rem 5.5rem;
  }

  .card,
  .search-card {
    padding: 0.85rem 0.75rem;
    border-radius: 10px;
  }

  .brand-icon {
    width: 28px;
    height: 28px;
  }

  .topbar {
    padding: 0.5rem 0.7rem;
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .topbar-bar {
    gap: 0.45rem;
  }

  .topbar-brand {
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
  }

  .topbar-title {
    font-size: 0.88rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-user {
    flex-shrink: 0;
    gap: 0.35rem;
    width: auto;
    flex-wrap: nowrap;
  }

  .topbar-user-name {
    display: none;
  }

  .topbar-user .menu-btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.82rem;
  }

  .title-desktop {
    display: none;
  }

  .title-mobile {
    display: inline;
  }

  .search-card h1 {
    font-size: 1.2rem;
    margin: 0 0 0.3rem;
  }

  .search-intro {
    font-size: 0.84rem;
    margin-bottom: 0.75rem;
    line-height: 1.35;
  }

  /* 2 Spalten: kuerzere Scrollstrecke als 1 Spalte */
  .search-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem 0.65rem;
  }

  .search-form-grid > label {
    font-size: 0.78rem;
    gap: 0.28rem;
  }

  .search-form-grid input,
  .search-form-grid select {
    padding: 0.5rem 0.55rem;
    font-size: 1rem; /* verhindert iOS-Zoom */
    min-height: 2.55rem;
  }

  .search-map-panel {
    padding: 0.45rem 0.55rem 0.55rem;
  }

  .search-map-summary {
    font-size: 0.92rem;
    min-height: 2.4rem;
    display: flex;
    align-items: center;
  }

  .search-map {
    height: 190px;
    margin-top: 0.4rem;
  }

  .source-fieldset {
    padding: 0.55rem 0.65rem;
    margin-top: 0.75rem;
  }

  .source-checks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.45rem;
  }

  .checkbox-inline {
    margin: 0;
    font-size: 0.8rem;
    min-height: 2.35rem;
    gap: 0.35rem;
  }

  .checkbox-inline input {
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
  }

  .search-submit-row {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    margin: 0;
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
    background: rgba(244, 246, 248, 0.96);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  }

  .search-submit-btn {
    width: 100%;
    min-height: 2.85rem;
    font-size: 1.05rem;
  }

  .source-status {
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.84rem;
  }

  .result-item {
    padding: 0.8rem 0.75rem;
  }

  .result-meta {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .result-price {
    font-size: 1.12rem;
    white-space: normal;
  }

  .result-item h3 {
    font-size: 0.98rem;
  }

  .result-facts {
    gap: 0.3rem 0.7rem;
    font-size: 0.86rem;
  }

  .result-snippet {
    font-size: 0.86rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .result-actions .btn {
    width: 100%;
    min-height: 2.55rem;
    justify-content: center;
  }

  .site-footer {
    font-size: 0.78rem;
    padding: 0.65rem 0.4rem;
    margin-top: 1.25rem;
  }

  .leaflet-control-zoom a {
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
  }
}

@media (max-width: 380px) {
  .search-form-grid {
    grid-template-columns: 1fr;
  }

  .source-checks {
    grid-template-columns: 1fr;
  }
}
