* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1e2530;
  background: #f5f6f8;
  margin: 0;
  line-height: 1.6;
}

.page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 40px) 70px;
}
/* Fließtext-Blöcke schmal halten (Lesbarkeit), Tabelle/Karten dürfen breit sein */
.page > .lead,
.tabpane > .lead,
.hint { max-width: 900px; }

.page a { color: #1d4ed8; }

.back {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 0.9rem;
  text-decoration: none;
}

h1 { font-size: 1.6rem; margin: 8px 0 4px; }
h2 { font-size: 1.15rem; margin: 28px 0 8px; }
h3 { font-size: 1rem; margin: 18px 0 6px; }

.lead { color: #67707e; margin-top: 0; }

.hint {
  background: #fff8e6;
  border: 1px solid #f5d67a;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.9rem;
  margin: 16px 0;
}

.fill {
  background: #fde8e8;
  color: #9b1c1c;
  padding: 0 5px;
  border-radius: 3px;
  font-weight: 600;
}

table { border-collapse: collapse; width: 100%; font-size: 0.85rem; margin: 10px 0; }
th, td { border: 1px solid #dfe3e9; padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: #eef1f5; position: sticky; top: 0; }
.table-scroll { overflow-x: auto; }

code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }

.tag { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.tag-green { background: #dcfce7; color: #166534; }
.tag-yellow { background: #fef3c7; color: #92400e; }
.tag-red { background: #fee2e2; color: #991b1b; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0; }
.stat { background: #fff; border: 1px solid #dfe3e9; border-radius: 10px; padding: 12px 14px; }
.stat .n { font-size: 1.5rem; font-weight: 700; }
.stat .l { font-size: 0.8rem; color: #67707e; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.82rem; margin: 8px 0 16px; }

/* Reiter (Tabs) */
.tabs { display: flex; gap: 4px; margin: 16px 0 14px; border-bottom: 2px solid #dfe3e9; flex-wrap: wrap; }
.tab-btn {
  border: none; background: none; padding: 10px 16px; font-size: 0.95rem;
  font-weight: 600; color: #67707e; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab-btn.active { color: #1d4ed8; border-bottom-color: #1d4ed8; }
.tabpane[hidden] { display: none; }

/* Region-Badges (Konkurrenz) */
.reg { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 0.74rem; font-weight: 700; white-space: nowrap; }
.reg-lokal { background: #dcfce7; color: #166534; }
.reg-regional { background: #dbeafe; color: #1e40af; }
.reg-de { background: #fef3c7; color: #92400e; }
.reg-int { background: #e5e7eb; color: #374151; }

/* Aufklappbare Anbieter-Kacheln */
.src { background: #fff; border: 1px solid #dfe3e9; border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.src > summary {
  list-style: none; cursor: pointer; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; font-size: 0.95rem;
}
.src > summary::-webkit-details-marker { display: none; }
.src > summary::before { content: "▸"; color: #98a2b3; font-size: 0.8rem; transition: transform 0.15s; }
.src[open] > summary::before { transform: rotate(90deg); }
.src-name { font-weight: 700; flex: 1; }
.src-count { font-variant-numeric: tabular-nums; color: #67707e; font-size: 0.85rem; white-space: nowrap; }
.src-body { padding: 4px 14px 14px 32px; font-size: 0.85rem; color: #35404f; }
.src-body p { margin: 6px 0; }
.src-body a { word-break: break-all; }
.ministats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.ministat { background: #f5f6f8; border-radius: 8px; padding: 8px 10px; }
.ministat .n { font-size: 1.15rem; font-weight: 700; }
.ministat .l { font-size: 0.72rem; color: #67707e; }
.src-cats { color: #67707e; }
.src-region {
  font-size: 0.95rem; margin: 18px 0 8px; padding-bottom: 5px;
  border-bottom: 2px solid #dfe3e9; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.src-region span { font-size: 0.78rem; font-weight: 400; color: #98a2b3; }

/* Kreis-/Regionsgruppen: aufklappbar, Zustand bleibt im Browser gemerkt */
.src-group { margin-top: 18px; }
.src-group > summary.src-region {
  list-style: none; cursor: pointer; font-weight: 700; margin: 0 0 8px;
  transition: border-color 0.15s;
}
.src-group > summary.src-region::-webkit-details-marker { display: none; }
.src-group > summary.src-region::before {
  content: "▸"; color: #98a2b3; font-size: 0.8rem; transition: transform 0.15s;
}
.src-group[open] > summary.src-region::before { transform: rotate(90deg); }
.src-group > summary.src-region:hover { border-bottom-color: #98a2b3; }
.src-group > summary.src-region:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
/* Zugeklappt reicht der Abstand der Ueberschrift allein */
.src-group:not([open]) > summary.src-region { margin-bottom: 0; }

/* Termin-Eintragen-Formular */
.ev-form { background: #fff; border: 1px solid #dfe3e9; border-radius: 12px; padding: 16px; margin-bottom: 18px; }
.ev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.ev-f { display: flex; flex-direction: column; font-size: 0.82rem; font-weight: 600; color: #35404f; gap: 4px; }
.ev-f.ev-full { grid-column: 1 / -1; }
.ev-f input, .ev-f select, .ev-f textarea {
  border: 1px solid #dfe3e9; border-radius: 8px; padding: 8px 10px; font-size: 0.92rem;
  font-family: inherit; font-weight: 400; color: #1e2530; background: #fff;
}
.ev-f input:focus, .ev-f select:focus, .ev-f textarea:focus { outline: 2px solid #1d4ed8; outline-offset: -1px; border-color: #1d4ed8; }
.ev-hint { font-size: 0.72rem; font-weight: 400; color: #98a2b3; }
.ev-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ev-btn { border: 1px solid #dfe3e9; background: #fff; color: #1e2530; border-radius: 8px; padding: 9px 16px; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.ev-btn:hover { background: #eef1f5; }
.ev-btn.primary { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.ev-btn.primary:hover { background: #1a43b8; }
.ev-btn.danger { color: #991b1b; border-color: #f3c9c9; }
.ev-msg { margin: 10px 0 0; color: #166534; font-weight: 600; font-size: 0.88rem; }
.ev-msg[hidden] { display: none; }
.ev-draft { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border: 1px solid #dfe3e9; border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; font-size: 0.88rem; }
.ev-del { border: none; background: none; color: #b42318; font-size: 1rem; cursor: pointer; padding: 2px 6px; }
#ev-draft-wrap[hidden] { display: none; }
/* Im Backend-Betrieb sind Entwürfe/Download überflüssig */
.api-mode #ev-draft-wrap { display: none !important; }
.ev-addr-line { display: flex; gap: 8px; align-items: flex-start; }
.ev-addr-line .ev-ac { flex: 1; min-width: 0; }
.ev-hnr { width: 80px; flex: none; }
.ev-ac { position: relative; }
.ev-ac input { width: 100%; }
.ev-ac-list {
  list-style: none; margin: 2px 0 0; padding: 4px;
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  background: #fff; border: 1px solid #cbd5e1; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14); max-height: 240px; overflow-y: auto;
}
.ev-ac-list[hidden] { display: none; }
.ev-ac-list li { padding: 8px 10px; font-size: 0.88rem; font-weight: 400; border-radius: 6px; cursor: pointer; }
.ev-ac-list li:hover { background: #eef4ff; }
.ev-addr { display: block; font-size: 0.82rem; font-weight: 600; margin-top: 6px; }
.ev-addr[hidden] { display: none; }
.ev-addr.checking { color: #67707e; }
.ev-addr.ok { color: #166534; }
.ev-addr.bad { color: #b42318; }
@media (max-width: 620px) { .ev-grid { grid-template-columns: 1fr; } }

/* Termin-Tabelle (Alle Termine) */
.tbl-toolbar { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; flex-wrap: wrap; }
#tbl-search { flex: 1; min-width: 200px; border: 1px solid #dfe3e9; border-radius: 8px; padding: 9px 12px; font-size: 0.92rem; }
.tbl-count { font-size: 0.82rem; color: #67707e; white-space: nowrap; }
.tbl-wrap { max-height: 70vh; overflow: auto; border: 1px solid #dfe3e9; border-radius: 10px; }
table.tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.82rem; margin: 0; }
table.tbl th, table.tbl td { border: none; border-bottom: 1px solid #eef1f5; padding: 7px 10px; text-align: left; vertical-align: top; white-space: nowrap; }
table.tbl td.col-title, table.tbl td.col-address, table.tbl td.col-venue { white-space: normal; min-width: 150px; }
table.tbl thead th {
  position: sticky; top: 0; z-index: 2; background: #eef1f5; cursor: pointer; user-select: none;
  font-weight: 700; border-bottom: 2px solid #d3d9e0;
}
table.tbl thead th:hover { background: #e2e8f1; }
table.tbl thead th.sorted::after { content: " ▲"; font-size: 0.7em; color: #1d4ed8; }
table.tbl thead th.sorted.desc::after { content: " ▼"; }
table.tbl tbody tr:hover { background: #f7f9fc; }
table.tbl td.is-draft { background: #fffbeb; }
.tbl-act { border: none; background: none; cursor: pointer; font-size: 1rem; padding: 1px 4px; }
.tbl-act.edit { color: #1d4ed8; }
.tbl-act.del { color: #b42318; }
.tbl-lock { color: #98a2b3; }
.col-act { white-space: nowrap; }

/* Recherche-Landkarte (Choroplethen) */
.map-modes { display: flex; gap: 6px; margin: 6px 0 8px; flex-wrap: wrap; }
.mode-btn {
  border: 1px solid #cdd4de; background: #fff; color: #35404f;
  padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.mode-btn.active { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
#kreis-map {
  height: 480px; border: 1px solid #dfe3e9; border-radius: 10px;
  background: #eef2f7; z-index: 0;
}
.map-legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 2px; font-size: 0.8rem; }
.map-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.map-legend .lg i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.leaflet-tooltip { font-size: 0.8rem; line-height: 1.35; }

/* Automatische Aktualisierung + Quellenüberwachung */
.autoup-box { background: #f4f8ff; border: 1px solid #cfe0f7; border-radius: 12px; padding: 14px 16px; margin: 18px 0 6px; }
.autoup-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.autoup-head strong { font-size: 1rem; }
.autoup-state { font-size: 0.82rem; color: #45516a; }
.autoup-state.running { color: #1d4ed8; font-weight: 600; }
.autoup-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 4px; }
.autoup-field { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; font-weight: 600; color: #35404f; }
.autoup-field select { border: 1px solid #cbd5e1; border-radius: 8px; padding: 7px 10px; font-size: 0.9rem; font-weight: 400; background: #fff; }
.autoup-msg { font-size: 0.82rem; color: #166534; font-weight: 600; }
.autoup-note { font-size: 0.78rem; color: #67707e; margin: 8px 0 0; }

.srcmon { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px 14px; margin: 8px 0 4px; }
.srcmon-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; background: #fff; border: 1px solid #eef1f5; font-size: 0.85rem; }
.srcmon-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-ok { background: #22c55e; }
.dot-warn { background: #f59e0b; }
.dot-err { background: #ef4444; }
.dot-pc { background: #3b82f6; }
.srcmon-row .s-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srcmon-row .s-count { font-variant-numeric: tabular-nums; font-weight: 700; color: #1e2530; }
.srcmon-row .s-note { flex: none; font-size: 0.72rem; color: #8a94a6; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Meldungen (Freigabe) */
.meld-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 0.7rem; font-weight: 700; text-align: center; vertical-align: middle; }
.meld-card { background: #fff; border: 1px solid #dfe3e9; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; font-size: 0.9rem; }
.meld-kind { font-size: 0.72rem; font-weight: 700; color: #67707e; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.meld-card a { word-break: break-all; }
.meld-card p { margin: 6px 0 0; color: #35404f; }
.meld-contact { margin-top: 6px; font-size: 0.8rem; color: #67707e; }
.meld-meta { margin-top: 4px; font-size: 0.72rem; color: #98a2b3; }
.meld-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Postfach ---------- */
.mail-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .mail-layout { grid-template-columns: 1fr; } }

.mail-neu-btn { width: 100%; margin-bottom: 10px; }

.mail-liste { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; }
.mail-row { background: #fff; border: 1px solid #dfe3e9; border-radius: 8px; padding: 9px 11px; cursor: pointer; font-size: 0.85rem; text-align: left; width: 100%; }
.mail-row:hover { background: #f4f6f9; }
.mail-row.active { border-color: #1d4ed8; box-shadow: 0 0 0 1px #1d4ed8; }
.mail-row.unread .mail-row-betreff { font-weight: 700; }
.mail-row-von { color: #67707e; font-size: 0.78rem; }
.mail-row-betreff { margin: 2px 0; color: #1e2530; }
.mail-row-datum { color: #98a2b3; font-size: 0.72rem; }

.mail-lesen { background: #fff; border: 1px solid #dfe3e9; border-radius: 10px; padding: 16px; min-height: 200px; }
.mail-lesen-kopf { border-bottom: 1px solid #eef1f5; padding-bottom: 10px; margin-bottom: 10px; }
.mail-lesen-betreff { font-size: 1.05rem; font-weight: 700; margin: 0 0 4px; }
.mail-lesen-meta { color: #67707e; font-size: 0.82rem; }
.mail-lesen-text { white-space: pre-wrap; font-size: 0.9rem; color: #1e2530; }
.mail-lesen-frame { width: 100%; min-height: 320px; border: 1px solid #eef1f5; border-radius: 6px; }
.mail-lesen-btns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.mail-compose { display: flex; flex-direction: column; gap: 10px; }
.mail-compose label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; font-weight: 600; color: #35404f; }
.mail-compose input, .mail-compose textarea { border: 1px solid #dfe3e9; border-radius: 8px; padding: 9px 10px; font-size: 0.9rem; font-family: inherit; }
.mail-compose textarea { min-height: 220px; resize: vertical; }
.mail-fehler { color: #991b1b; font-size: 0.85rem; }

/* Ordner-Leiste */
.mail-ordner-liste { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.mail-ordner-btn { display: flex; align-items: center; justify-content: space-between; gap: 6px; background: #fff; border: 1px solid #dfe3e9; border-radius: 8px; padding: 7px 10px; font-size: 0.85rem; text-align: left; cursor: pointer; color: #35404f; }
.mail-ordner-btn:hover { background: #f4f6f9; }
.mail-ordner-btn.active { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.mail-ordner-btn.active .meld-badge { background: #fff; color: #1d4ed8; }

/* Anhänge (Leseansicht + beim Verfassen) */
.mail-anhaenge { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.mail-anhang-chip { display: inline-flex; align-items: center; gap: 5px; background: #f4f6f9; border: 1px solid #dfe3e9; border-radius: 999px; padding: 5px 10px; font-size: 0.8rem; color: #1e2530; text-decoration: none; }
.mail-anhang-chip span { color: #98a2b3; }
.mail-anhang-chip button { border: none; background: none; cursor: pointer; color: #991b1b; font-size: 0.85rem; padding: 0 0 0 2px; }
.mail-anhang-zeile { display: flex; flex-direction: column; gap: 8px; }
.mail-anhang-waehlen { display: inline-block; width: fit-content; cursor: pointer; }
.mail-anhang-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* WYSIWYG-Editor */
.mail-editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.mail-editor-btn { border: 1px solid #dfe3e9; background: #fff; border-radius: 6px; padding: 5px 10px; font-size: 0.85rem; cursor: pointer; min-width: 32px; }
.mail-editor-btn:hover { background: #eef1f5; }
.mail-editor {
  border: 1px solid #dfe3e9; border-radius: 8px; padding: 12px 14px; min-height: 220px;
  font-size: 0.95rem; line-height: 1.6; color: #1c2430; background: #fff; overflow-y: auto;
}
.mail-editor:focus { outline: 2px solid #1d4ed8; outline-offset: -1px; }
.mail-editor a { color: #0077b6; }

/* Besuchsstatistik */
.besucher-karten { display: flex; flex-wrap: wrap; gap: 12px; }
.besucher-karte { background: #f4f6f9; border: 1px solid #dfe3e9; border-radius: 10px; padding: 12px 18px; min-width: 140px; }
.besucher-zahl { font-size: 1.8rem; font-weight: 700; color: #0b3d91; }
.besucher-label { font-size: 0.8rem; color: #67707e; margin-top: 2px; }
.besucher-tabelle { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 0.88rem; }
.besucher-tabelle th { text-align: left; color: #67707e; font-weight: 600; font-size: 0.78rem; padding: 4px 8px; border-bottom: 1px solid #dfe3e9; }
.besucher-tabelle td { padding: 5px 8px; border-bottom: 1px solid #f0f2f5; position: relative; }
.besucher-balken { position: absolute; left: 0; top: 0; bottom: 0; background: #e6edff; z-index: 0; }
.besucher-zahl-zelle { position: relative; z-index: 1; font-variant-numeric: tabular-nums; }

/* Statistik-Reiter (Vorbild: Reiter "Statistik" bei GuideYourRide,
   besucher-aggregat.php/stats-admin.php) - Kopfzeile + Liniendiagramme +
   Funnel-Balken. Farben an unser Markenblau/-gold angelehnt statt GYRs Grün. */
.stats-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.stats-section { margin: 24px 0; }
.stats-section > h3, .stats-section > h4 { margin: 0 0 10px; }
.stats-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 860px) { .stats-grid2 { grid-template-columns: 1fr; } }

.lz-h4 { margin: 16px 0 4px; font-size: 0.86rem; font-weight: 700; color: #33404f; }
.lz-wrap { background: #fff; border: 1px solid #dfe3e9; border-radius: 10px; padding: 10px 12px 6px; margin-bottom: 6px; }
.lz-svg { display: block; width: 100%; height: auto; overflow: visible; }
.lz-grid { stroke: #e8eef5; stroke-width: 1; }
.lz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lz-area { opacity: .12; }
.lz-dot { opacity: 0; transition: opacity .15s; }
.lz-wrap:hover .lz-dot { opacity: 1; }
.lz-dot:hover { opacity: 1; r: 5; }
.lz-ylbl, .lz-xlbl { font-size: 10px; fill: #7b8794; font-family: inherit; }
.lz-ylbl { text-anchor: end; }
.lz-xlbl { text-anchor: middle; }
.lz-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 4px 2px 2px; }
.lz-leg { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: #55606e; font-weight: 600; }
.lz-leg i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

.funnel-row { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.funnel-lbl { width: 190px; flex: none; font-size: .82rem; font-weight: 600; color: #33404f; }
.funnel-bar { flex: 1 1 0; height: 16px; background: #eef3f9; border-radius: 6px; overflow: hidden; }
.funnel-bar i { display: block; height: 100%; background: linear-gradient(90deg, #3399d6, #0b3d91); border-radius: 6px; transition: width .3s; }
.funnel-val { width: 110px; flex: none; text-align: right; font-size: .82rem; color: #1a2634; }
.funnel-val small { color: #67707e; }
@media (max-width: 560px) {
  .funnel-lbl { width: 120px; font-size: .76rem; }
  .funnel-val { width: 88px; font-size: .76rem; }
}
