:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1d2228;
  --muted: #6b7280;
  --border: #dfe3e8;
  --accent: #20252b;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: inherit; }
.topbar { min-height: 72px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }
.logo-placeholder { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; letter-spacing: .04em; }
nav { display: flex; gap: 8px; flex-wrap: wrap; }
nav a { text-decoration: none; padding: 9px 12px; border-radius: 9px; }
nav a:hover { background: #f0f2f4; }
.container { width: min(1180px, calc(100% - 32px)); margin: 32px auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.login { width: min(460px, 100%); margin: 8vh auto 0; }
h1, h2, h3 { margin-top: 0; }
.muted { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .92rem; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #cfd5dc; border-radius: 9px; background: #fff; color: var(--text); padding: 10px 12px; font: inherit; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(32,37,43,.18); border-color: #7d8792; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn { appearance: none; border: 0; border-radius: 9px; padding: 10px 15px; background: var(--accent); color: #fff; text-decoration: none; font: inherit; font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn.secondary { background: #59636e; }
.btn.light { background: #eef1f4; color: var(--text); }
.flash { padding: 11px 13px; border-radius: 9px; margin-bottom: 16px; background: #eef1f4; }
.flash.error { background: #fef3f2; border: 1px solid #fecdca; color: var(--danger); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .88rem; color: var(--muted); }
footer { padding: 24px; color: var(--muted); text-align: center; font-size: .88rem; }
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; align-items: flex-start; flex-direction: column; }
  .container { width: min(100% - 20px, 1180px); margin: 20px auto; }
  .card { padding: 16px; }
  .login { margin-top: 4vh; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}

/* Dashboard / Kalenderkarten */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.grid {
  display: grid;
  gap: 18px;
}
.dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.calendar-card {
  display: block;
  min-height: 140px;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.calendar-card:hover {
  transform: translateY(-2px);
  border-color: #c8ced6;
  box-shadow: 0 10px 30px rgba(0,0,0,.09);
}
.calendar-card h2 {
  margin-bottom: 10px;
}
.calendar-card p {
  margin-bottom: 0;
}
.event {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.event:last-child {
  border-bottom: 0;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef1f4;
  font-size: .82rem;
  font-weight: 650;
}
.attendance-summary {
  padding-top: 4px;
}

@media (max-width: 760px) {
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .calendar-card {
    min-height: auto;
  }
}

/* V1.6: Tabellen, Rollen und Kalenderansichten */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-wrap table { min-width: 980px; }
.center { text-align: center; }
.badge.ok { background: #ecfdf3; color: #067647; }
.badge.danger { background: #fef3f2; color: #b42318; }
.check-row { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.check-row label, .check-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.check-row input, .check-label input, .role-card input { width: auto; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.role-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; background: #fff; }
.role-card span { display: flex; flex-direction: column; gap: 3px; }
.role-card small { color: var(--muted); }
.view-switch { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.calendar-toolbar { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 0 0 16px; }
.calendar-toolbar strong { min-width: 150px; text-align: center; }
.edit-card { margin-bottom: 18px; }
.calendar-scroll { overflow-x: auto; padding-bottom: 4px; }
.month-calendar { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); min-width: 1050px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.calendar-weekday { padding: 10px 12px; background: #eef1f4; font-size: .82rem; font-weight: 750; text-align: center; color: var(--muted); }
.calendar-day { min-height: 142px; padding: 9px; background: var(--surface); min-width: 0; }
.calendar-day.outside-month { background: #fafbfc; color: #9aa1aa; }
.calendar-day-number { font-weight: 750; margin-bottom: 7px; }
.event-tile { display: flex; flex-direction: column; gap: 2px; padding: 7px 8px; margin-bottom: 6px; border: 1px solid #d8dde3; border-radius: 8px; background: #f7f8fa; text-decoration: none; color: var(--text); }
.event-tile span { font-size: .76rem; color: var(--muted); }
.event-tile strong { font-size: .86rem; line-height: 1.18; overflow-wrap: anywhere; }
.event-tile small { color: var(--muted); line-height: 1.2; overflow-wrap: anywhere; }
.event-tile:hover { border-color: #aeb6bf; background: #f0f2f4; }
.event-tile.roomy { padding: 10px; margin-bottom: 9px; }
.week-calendar { display: grid; grid-template-columns: repeat(7, minmax(170px, 1fr)); min-width: 1190px; gap: 10px; }
.week-day { min-height: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.week-day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-bottom: 9px; margin-bottom: 9px; border-bottom: 1px solid var(--border); }
.week-day-head span { color: var(--muted); font-size: .88rem; }
.list-stack { display: grid; gap: 16px; }
.event-detail { scroll-margin-top: 16px; }
.event-detail h2 { margin-bottom: 6px; }
.event-address { margin-top: 6px; }
.signup-actions { margin: 16px 0; }
.no-list { margin-top: 6px; }
.delete-form { margin-top: 16px; }

@media (max-width: 760px) {
  .view-switch { width: 100%; }
  .view-switch .btn { flex: 1 1 0; }
  .calendar-toolbar { justify-content: space-between; }
  .role-grid { grid-template-columns: 1fr; }
  .month-calendar { grid-template-columns: repeat(7, 138px); min-width: 966px; }
  .calendar-day { min-height: 120px; }
  .week-calendar { grid-template-columns: repeat(7, 160px); min-width: 1120px; }
}

/* V1.9 consolidated – Rollenmatrix + vorbereitete Slot-Kalender */

.role-editor-card .role-section {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #e3e7ec;
}
.role-section-head {
    margin-bottom: 14px;
}
.role-section-head h3 {
    margin: 0 0 4px;
}
.calendar-role-matrix {
    border: 1px solid #dce1e7;
    border-radius: 12px;
    overflow: hidden;
}
.calendar-role-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 150px 150px;
    align-items: center;
    min-height: 54px;
    border-top: 1px solid #e7eaee;
}
.calendar-role-row:first-child {
    border-top: 0;
}
.calendar-role-row > div {
    padding: 12px 14px;
    min-width: 0;
}
.calendar-role-header {
    background: #f6f7f9;
    font-weight: 700;
}
.calendar-role-name {
    font-weight: 700;
}
.role-toggle {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 36px;
    cursor: pointer;
}

.slot-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 0 0 14px;
    font-size: .92rem;
}
.slot-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.slot-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0,0,0,.12);
}
.slot-free {
    background: #dff3e5;
}
.slot-occupied {
    background: #dce9ff;
}
.slot-blocked {
    background: #e4e6e9;
}

.slot-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin: 5px 0 7px;
    text-decoration: none;
    font-size: .76rem;
    line-height: 1.2;
}
.slot-summary span {
    padding: 3px 6px;
    border-radius: 999px;
    white-space: nowrap;
}
.slot-summary-free {
    background: #e4f6e9;
    color: #215a31;
}
.slot-summary-occupied {
    background: #e6efff;
    color: #284e86;
}
.slot-summary-blocked {
    background: #eceef1;
    color: #59616b;
}

.slot-week {
    display: grid;
    gap: 14px;
}
.slot-day-card {
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 14px;
    overflow: hidden;
}
.slot-day-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 13px 15px;
    background: #f7f8fa;
    border-bottom: 1px solid #e5e8ec;
}
.slot-day-head > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.slot-day-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}
.slot-day-actions form {
    margin: 0;
}
.btn.compact {
    min-height: 34px;
    padding: 6px 10px;
    font-size: .84rem;
}
.slot-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 8px;
    padding: 12px;
}
.prepared-slot {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border: 1px solid #e0e4e8;
    border-radius: 10px;
}
.prepared-slot.is-free {
    background: #f0faf3;
    border-color: #cce7d3;
}
.prepared-slot.is-occupied {
    background: #f1f6ff;
    border-color: #ceddf4;
}
.prepared-slot.is-blocked {
    background: #f1f2f4;
    border-color: #d9dde2;
}
.prepared-slot-time {
    font-size: .82rem;
    font-weight: 700;
    white-space: nowrap;
}
.prepared-slot-content {
    min-width: 0;
    text-decoration: none;
    color: inherit;
}
.prepared-slot-content strong,
.prepared-slot-content small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}
.prepared-slot-content small {
    margin-top: 2px;
    color: #667085;
    white-space: nowrap;
}
.prepared-slot-actions {
    display: flex;
    gap: 5px;
    align-items: center;
}
.prepared-slot-actions form,
.prepared-slot-action {
    margin: 0;
}
.slot-action-button {
    border: 1px solid #cfd5dc;
    border-radius: 8px;
    background: #fff;
    color: #344054;
    padding: 5px 8px;
    font: inherit;
    font-size: .78rem;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.slot-action-button.primary {
    border-color: #9fb7da;
    background: #eef4fd;
    color: #234d86;
}

@media (max-width: 720px) {
    .calendar-role-row {
        grid-template-columns: minmax(0, 1fr) 112px 112px;
    }
    .calendar-role-row > div {
        padding: 10px;
    }
    .slot-day-head {
        align-items: flex-start;
        flex-direction: column;
    }
    .slot-day-actions {
        justify-content: flex-start;
    }
    .slot-list {
        grid-template-columns: 1fr;
    }
    .prepared-slot {
        grid-template-columns: auto minmax(0, 1fr);
    }
    .prepared-slot-actions,
    .prepared-slot-action {
        grid-column: 1 / -1;
        justify-self: stretch;
    }
    .prepared-slot-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .slot-action-button {
        width: 100%;
        text-align: center;
    }
}


/* V1.10 – direkte Kalenderbedienung + Wochen-Zeitband */
.calendar-day-clickable { cursor: pointer; }
.calendar-day-clickable:hover { outline: 1px solid #c7d2df; outline-offset: -1px; }
.slot-week-toolbar { margin: 0 0 8px; }
.slot-week-scroll { overflow-x: auto; border: 1px solid #dfe3e8; border-radius: 12px; background: #fff; }
.slot-week-grid {
    min-width: 1120px;
    display: grid;
    grid-template-columns: 78px repeat(7, minmax(145px, 1fr));
}
.slot-week-corner,
.slot-week-dayhead {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #f6f7f9;
    border-bottom: 1px solid #dfe3e8;
}
.slot-week-corner {
    left: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border-right: 1px solid #dfe3e8;
}
.slot-week-dayhead {
    min-height: 74px;
    padding: 8px;
    text-align: center;
    border-right: 1px solid #e6e9ed;
}
.slot-week-dayhead strong,
.slot-week-dayhead span { display: block; }
.slot-week-daytools { display: flex; justify-content: center; gap: 4px; margin-top: 5px; }
.slot-week-daytools form { margin: 0; }
.slot-week-daytools button,
.slot-week-inline-action button {
    border: 1px solid #cfd5dc;
    background: #fff;
    border-radius: 6px;
    padding: 3px 5px;
    font: inherit;
    font-size: .7rem;
    cursor: pointer;
}
.slot-week-time {
    position: sticky;
    left: 0;
    z-index: 3;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fb;
    border-right: 1px solid #dfe3e8;
    border-bottom: 1px solid #e8ebef;
    font-size: .82rem;
    font-weight: 700;
}
.slot-week-time span { font-size: .68rem; font-weight: 400; color: #667085; }
.slot-week-cell {
    position: relative;
    min-height: 52px;
    padding: 6px 7px;
    border-right: 1px solid #e8ebef;
    border-bottom: 1px solid #e8ebef;
    overflow: hidden;
}
.slot-week-cell.is-free { background: #f0faf3; cursor: pointer; }
.slot-week-cell.is-occupied { background: #f1f6ff; }
.slot-week-cell.is-blocked { background: #f0f1f3; }
.slot-week-cell.is-outside { background: #fafafa; color: #98a2b3; }
.slot-week-state { font-size: .75rem; color: #667085; }
.slot-week-event { display: block; color: inherit; text-decoration: none; min-width: 0; }
.slot-week-event strong { display: block; font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-week-event small { display: block; font-size: .68rem; color: #667085; }
.slot-week-continuation { font-size: 1rem; color: #667085; }
.slot-week-inline-action { position: absolute; right: 3px; bottom: 3px; margin: 0; }
.slot-week-inline-action button { padding: 2px 4px; font-size: .65rem; }
@media (max-width: 720px) {
    .slot-week-grid { min-width: 980px; grid-template-columns: 64px repeat(7, minmax(130px,1fr)); }
    .slot-week-time { font-size: .75rem; }
}

/* Admin-Bereich */
.admin-grid .dashboard-card {
    text-decoration: none;
    color: inherit;
}
.admin-grid .dashboard-card strong,
.admin-grid .dashboard-card span {
    display: block;
}
.admin-grid .dashboard-card span {
    margin-top: 6px;
    color: #667085;
}


/* Admin-Kacheln */
.admin-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.admin-card {
    position: relative;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 18px;
    border: 1px solid #dfe3e8;
    border-radius: 16px;
    background: #fff;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}

.admin-card:hover {
    border-color: #c8d1dc;
}

.admin-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #f1f3f6;
    font-weight: 800;
    font-size: 1.05rem;
}

.admin-card h2 {
    margin: 0 0 4px;
    font-size: 1.05rem;
}

.admin-card p {
    margin: 0;
    color: #667085;
    font-size: .9rem;
    line-height: 1.4;
}

.admin-card-arrow {
    font-size: 1.7rem;
    line-height: 1;
    color: #98a2b3;
}

@media (max-width: 560px) {
    .admin-card {
        grid-template-columns: 44px minmax(0, 1fr);
    }

    .admin-card-icon {
        width: 44px;
        height: 44px;
    }

    .admin-card-arrow {
        display: none;
    }
}


/* V1.18 – aktive Tage der Slot-Kalender */
.active-days-card { margin-bottom: 18px; }
.active-day-add { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 14px; }
.active-day-add .field { min-width: 220px; margin: 0; }
.active-day-list { display: flex; flex-wrap: wrap; gap: 8px; }
.active-day-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 9px 7px 11px; border: 1px solid #d8dee6; border-radius: 999px; background: #f7f8fa; }
.active-day-chip form { margin: 0; }
.active-day-chip button { border: 0; background: transparent; padding: 0 3px; font-size: 1rem; line-height: 1; cursor: pointer; color: #667085; }
.slot-inactive-day { margin: 5px 0 7px; padding: 4px 6px; border-radius: 7px; background: #f1f2f4; color: #7b8490; font-size: .76rem; text-align: center; }


/* V1.20 Dashboard-Tourenkarte */
.dashboard-map-card { margin-bottom: 18px; }
.dashboard-map-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    margin-bottom: 12px;
}
.dashboard-map-head h2 { margin: 0 0 4px; }
.dashboard-map-date {
    display: flex;
    align-items: end;
    gap: 8px;
    flex-wrap: wrap;
}
.dashboard-map-date label { font-weight: 700; }
.dashboard-map-date input[type="date"] { min-height: 40px; }
.tour-map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 10px;
    font-size: .9rem;
}
.tour-map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tour-map-legend i {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,.28);
}
.tour-map {
    height: 520px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #dfe3e8;
    background: #eef1f4;
}
.dashboard-map-note { margin: 10px 0 0; }
.route-arrow-wrapper {
    background: transparent;
    border: 0;
}
.route-arrow {
    display: block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 22px;
    font-weight: 900;
    transform-origin: 50% 50%;
    text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
}
.map-popup strong {
    display: block;
    margin-bottom: 4px;
}
.map-popup-calendar {
    margin-top: 5px;
    font-size: .84rem;
    font-weight: 700;
}
@media (max-width: 720px) {
    .dashboard-map-head {
        align-items: stretch;
        flex-direction: column;
    }
    .dashboard-map-date { align-items: stretch; }
    .dashboard-map-date input[type="date"] { flex: 1 1 180px; }
    .tour-map { height: 380px; }
}


/* V1.22 Feinschliff Tourenkarte */
.dashboard-map-head {
    align-items: center;
}

.dashboard-map-date {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.dashboard-map-date label {
    margin: 0;
    white-space: nowrap;
}

.dashboard-map-date input[type="date"] {
    width: 185px;
    min-height: 40px;
    margin: 0;
}

.dashboard-map-date .btn {
    min-height: 40px;
    margin: 0;
    white-space: nowrap;
}

/* Leaflet-Layercontrol kompakter und ruhiger */
.tour-map .leaflet-control-layers {
    border: 1px solid rgba(0,0,0,.14);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
    background: rgba(255,255,255,.94);
    font-size: 13px;
}

.tour-map .leaflet-control-layers-expanded {
    padding: 8px 10px;
    min-width: 0;
}

.tour-map .leaflet-control-layers-list {
    margin: 0;
}

.tour-map .leaflet-control-layers-base,
.tour-map .leaflet-control-layers-overlays {
    display: grid;
    gap: 4px;
}

.tour-map .leaflet-control-layers-separator {
    margin: 6px 0;
    border-top-color: rgba(0,0,0,.10);
}

.tour-map .leaflet-control-layers label {
    margin: 0;
    display: block;
    line-height: 1.15;
    white-space: nowrap;
    cursor: pointer;
}

.tour-map .leaflet-control-layers label > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tour-map .leaflet-control-layers input {
    margin: 0;
    transform: scale(.9);
}

@media (max-width: 720px) {
    .dashboard-map-head {
        align-items: stretch;
    }

    .dashboard-map-date {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
    }

    .dashboard-map-date input[type="date"] {
        width: 100%;
        min-width: 0;
    }

    .tour-map .leaflet-control-layers {
        font-size: 12px;
    }

    .tour-map .leaflet-control-layers-expanded {
        padding: 7px 8px;
    }
}


/* V1.27 Mobile Kalender: Monatsansicht vollständig im Viewport */
@media (max-width: 760px) {
    .calendar-scroll {
        width: 100%;
        max-width: 100%;
    }

    .calendar-scroll:has(.month-calendar) {
        overflow-x: hidden;
    }

    .month-calendar {
        width: 100%;
        min-width: 0;
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }

    .calendar-weekday {
        min-width: 0;
        padding: 7px 1px;
        font-size: .72rem;
    }

    .calendar-day {
        min-width: 0;
        min-height: 82px;
        padding: 4px 3px;
        overflow: hidden;
    }

    .calendar-day-number {
        margin-bottom: 3px;
        font-size: .78rem;
    }

    .month-calendar .event-tile {
        gap: 0;
        padding: 3px 2px;
        margin-bottom: 3px;
        border-radius: 5px;
        overflow: hidden;
    }

    .month-calendar .event-tile span {
        display: block;
        font-size: .58rem;
        line-height: 1.08;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .month-calendar .event-tile strong {
        display: block;
        font-size: .64rem;
        line-height: 1.08;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .month-calendar .event-tile small {
        display: none;
    }

    .month-calendar .slot-summary {
        gap: 1px;
        margin-bottom: 3px;
    }

    .month-calendar .slot-summary span {
        display: block;
        padding: 1px 2px;
        font-size: .55rem;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .month-calendar .slot-inactive-day {
        font-size: .56rem;
        line-height: 1.05;
    }
}


/* V1.28 Dashboard mobile Feinschliff */
.dashboard-map-date {
    min-width: 0;
}

.dashboard-map-date input[type="date"] {
    box-sizing: border-box;
    max-width: 100%;
}

.tour-map .leaflet-control-layers {
    max-width: calc(100% - 24px);
}

.tour-map .leaflet-control-layers-toggle {
    width: 34px;
    height: 34px;
    background-size: 20px 20px;
}

@media (max-width: 720px) {
    .dashboard-map-head {
        gap: 12px;
    }

    .dashboard-map-date {
        width: 100%;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 7px;
    }

    .dashboard-map-date label {
        min-width: 0;
        margin: 0;
        white-space: nowrap;
    }

    .dashboard-map-date input[type="date"] {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100%;
        margin: 0;
        padding-left: 10px;
        padding-right: 8px;
    }

    .dashboard-map-date .btn {
        min-width: 0;
        margin: 0;
        padding-left: 12px;
        padding-right: 12px;
        white-space: nowrap;
    }

    .tour-map-legend {
        gap: 8px 12px;
        margin-bottom: 8px;
        font-size: .82rem;
    }

    .tour-map .leaflet-control-layers-expanded {
        max-width: 210px;
        padding: 7px 8px;
    }

    .tour-map .leaflet-control-layers label {
        font-size: 12px;
    }
}


/* V1.29 Tagesansicht */
.day-calendar { width: 100%; min-width: 0; }
.day-event-list { display: grid; gap: 10px; }
.day-event-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-decoration: none;
    color: var(--text);
}
.day-event-card:hover { border-color: #aeb6bf; background: #f7f8fa; }
.day-event-time { font-size: .82rem; color: var(--muted); }
.day-event-card small { color: var(--muted); }

.slot-day-grid {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}
.slot-day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: #eef1f4;
}
.slot-day-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    min-height: 48px;
    border-bottom: 1px solid var(--border);
}
.slot-day-row:last-child { border-bottom: 0; }
.slot-day-time {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12px 8px;
    font-size: .82rem;
    font-weight: 750;
    color: var(--muted);
    background: #fafbfc;
    border-right: 1px solid var(--border);
}
.slot-day-content { min-width: 0; padding: 6px 8px; }
.slot-day-content .event-tile { margin: 0; }
.slot-day-free,
.slot-day-free-text,
.slot-day-occupied,
.slot-day-blocked {
    display: flex;
    align-items: center;
    min-height: 34px;
    padding: 0 8px;
    border-radius: 7px;
    font-size: .82rem;
}
.slot-day-free {
    color: inherit;
    text-decoration: none;
    border: 1px dashed #c7d2df;
    background: #fafbfc;
}
.slot-day-free:hover { background: #f0f3f6; }
.slot-day-free-text, .slot-day-occupied { color: var(--muted); }
.slot-day-occupied { background: #f3f4f6; }
.slot-day-blocked { color: #8a5a00; background: #fff5d9; }
.slot-day-empty { padding: 18px; color: var(--muted); }

@media (max-width: 760px) {
    .slot-day-row { grid-template-columns: 58px minmax(0, 1fr); }
    .slot-day-time { padding-left: 4px; padding-right: 4px; }
    .day-event-card { padding: 12px; }
}


/* V1.30 LayerControl Ausrichtung */
.tour-map .leaflet-control-layers-expanded {
    width: auto;
    min-width: 158px;
    max-width: 220px;
}

.tour-map .leaflet-control-layers-base,
.tour-map .leaflet-control-layers-overlays {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.tour-map .leaflet-control-layers label {
    display: block;
    width: 100%;
    margin: 0;
    padding: 3px 0;
    white-space: nowrap;
}

.tour-map .leaflet-control-layers label > span {
    display: grid;
    grid-template-columns: 16px max-content;
    align-items: center;
    column-gap: 5px;
    width: max-content;
    max-width: 100%;
    white-space: nowrap;
}

.tour-map .leaflet-control-layers input[type="radio"],
.tour-map .leaflet-control-layers input[type="checkbox"] {
    position: static;
    width: 14px;
    height: 14px;
    min-width: 14px;
    margin: 0;
    padding: 0;
    transform: none;
}

.tour-map .leaflet-control-layers-separator {
    margin: 5px 0;
}

@media (max-width: 720px) {
    .tour-map .leaflet-control-layers-expanded {
        min-width: 154px;
        max-width: 200px;
    }

    .tour-map .leaflet-control-layers label > span {
        grid-template-columns: 15px max-content;
        column-gap: 4px;
    }

    .tour-map .leaflet-control-layers input[type="radio"],
    .tour-map .leaflet-control-layers input[type="checkbox"] {
        width: 13px;
        height: 13px;
        min-width: 13px;
    }
}


/* V1.31 Layerbutton zentrieren */
.tour-map .leaflet-control-layers-toggle {
    display: block;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: 20px 20px;
}

.tour-map .leaflet-control-layers:not(.leaflet-control-layers-expanded) {
    width: 34px;
    height: 34px;
    min-width: 34px;
    max-width: 34px;
    padding: 0;
    overflow: hidden;
}

@media (max-width: 720px) {
    .tour-map .leaflet-control-layers-toggle,
    .tour-map .leaflet-control-layers:not(.leaflet-control-layers-expanded) {
        width: 34px;
        height: 34px;
        min-width: 34px;
        max-width: 34px;
    }
}


/* V1.32 LayerControl Toggle final korrigiert */
.tour-map .leaflet-control-layers {
    box-sizing: border-box;
}

.tour-map .leaflet-control-layers:not(.leaflet-control-layers-expanded) {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.tour-map .leaflet-control-layers-toggle {
    display: block !important;
    width: 36px !important;
    height: 36px !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    background-position: 50% 50% !important;
    background-repeat: no-repeat !important;
    background-size: 22px 22px !important;
}

/* Leaflets Retina-Regel darf das Icon nicht wieder verschieben/vergrößern */
.leaflet-retina .tour-map .leaflet-control-layers-toggle {
    background-size: 22px 22px !important;
}

@media (max-width: 720px) {
    .tour-map .leaflet-control-layers:not(.leaflet-control-layers-expanded),
    .tour-map .leaflet-control-layers-toggle {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
    }
}


/* V1.33 Adressbestätigung + Slot-History */
.address-check-row { display:flex; gap:8px; align-items:center; }
.address-check-row input { flex:1 1 auto; min-width:0; }
.address-check-row .btn { flex:0 0 auto; white-space:nowrap; }
.address-result { margin-top:10px; padding:10px 12px; border:1px solid var(--border); border-radius:10px; background:#f7f8fa; display:flex; align-items:center; justify-content:space-between; gap:12px; }
.address-result[hidden] { display:none; }
.address-result strong { display:block; margin-top:2px; }
.event-address-map { height:300px; margin-top:10px; border:1px solid var(--border); border-radius:12px; overflow:hidden; background:#eef1f4; }
.address-status { margin:7px 0 0; font-size:.86rem; }
.slot-history-panel { margin-top:18px; padding-top:16px; border-top:1px solid var(--border); }
.slot-history-panel h3 { margin:0 0 10px; }
.slot-history-list { display:grid; gap:7px; }
.slot-history-item { padding:9px 10px; border:1px solid var(--border); border-radius:9px; background:#fafbfc; }
.slot-history-meta { display:flex; justify-content:space-between; gap:10px; margin-bottom:3px; font-size:.78rem; color:var(--muted); }
.slot-history-item small { display:block; margin-top:3px; color:var(--muted); }
@media (max-width:720px) {
  .address-check-row { display:grid; grid-template-columns:minmax(0,1fr) auto; }
  .address-result { align-items:stretch; flex-direction:column; }
  .event-address-map { height:250px; }
  .slot-history-meta { flex-direction:column; gap:1px; }
}


/* V1.34 Adresskarten-Fehlerdarstellung */
.map-load-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 20px;
    text-align: center;
    color: var(--muted);
    background: #f7f8fa;
}


/* V1.35 LayerControl im Hausbesuch + Slot-Reservierung */
.event-address-map .leaflet-control-layers {
    border: 1px solid rgba(0,0,0,.14);
    border-radius: 9px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    background: rgba(255,255,255,.96);
    font-size: 12px;
}

.event-address-map .leaflet-control-layers-expanded {
    width: auto;
    min-width: 142px;
    max-width: 180px;
    padding: 7px 9px;
}

.event-address-map .leaflet-control-layers-base,
.event-address-map .leaflet-control-layers-overlays {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.event-address-map .leaflet-control-layers label {
    display: block;
    width: 100%;
    margin: 0;
    padding: 3px 0;
    line-height: 1.2;
    white-space: nowrap;
}

.event-address-map .leaflet-control-layers label > span {
    display: grid;
    grid-template-columns: 15px max-content;
    align-items: center;
    column-gap: 5px;
    width: max-content;
    white-space: nowrap;
}

.event-address-map .leaflet-control-layers input[type="radio"],
.event-address-map .leaflet-control-layers input[type="checkbox"] {
    position: static;
    width: 13px;
    height: 13px;
    min-width: 13px;
    margin: 0;
    padding: 0;
    transform: none;
}

.event-address-map .leaflet-control-layers-separator {
    margin: 5px 0;
}

.event-address-map .leaflet-control-layers:not(.leaflet-control-layers-expanded) {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    max-width: 34px !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.event-address-map .leaflet-control-layers-toggle {
    display: block !important;
    width: 34px !important;
    height: 34px !important;
    margin: 0 !important;
    padding: 0 !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 20px 20px !important;
}

.leaflet-retina .event-address-map .leaflet-control-layers-toggle {
    background-size: 20px 20px !important;
}

.slot-reservation-status {
    display: flex;
    align-items: baseline;
    gap: 8px 12px;
    flex-wrap: wrap;
    margin: 0 0 14px;
    padding: 9px 11px;
    border: 1px solid #cdd8e3;
    border-radius: 9px;
    background: #f6f9fb;
    font-size: .84rem;
}

.slot-reservation-status span {
    color: var(--muted);
}

.slot-reservation-status.ok {
    border-color: #bcd7c4;
    background: #f4faf6;
}

.slot-reservation-status.error {
    border-color: #e3bcbc;
    background: #fff5f5;
}

.slot-reservation-status.error span {
    color: #8a3030;
}

@media (max-width: 720px) {
    .event-address-map .leaflet-control-layers-expanded {
        min-width: 138px;
        max-width: 170px;
    }

    .slot-reservation-status {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }
}


/* V1.36 Löschen-Button + Termin-Ersteller in History */
.btn.danger {
    background: #c62828;
    border-color: #c62828;
    color: #fff;
}

.btn.danger:hover {
    background: #a81f1f;
    border-color: #a81f1f;
    color: #fff;
}

.btn.danger:focus {
    outline: 2px solid rgba(198, 40, 40, .25);
    outline-offset: 2px;
}

.slot-history-creator {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f7f8fa;
    font-size: .84rem;
}

.slot-history-creator span {
    color: var(--muted);
}

@media (max-width: 720px) {
    .slot-history-creator {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }
}


/* V1.42 Mehrere 20-Minuten-Slots als ein Hausbesuch */
.slot-week-cell.event-part {
    position: relative;
    background: #eaf2ff;
}

.slot-week-cell.event-part.event-start:not(.event-end),
.slot-week-cell.event-part.event-continuation:not(.event-end) {
    border-bottom-color: transparent;
}

.slot-week-cell.event-part.event-continuation,
.slot-week-cell.event-part.event-middle {
    padding-top: 0;
    padding-bottom: 0;
}

.slot-week-cell.event-part.event-start {
    box-shadow: inset 3px 0 0 #8098b3, inset -1px 0 0 #d8e3ef;
}

.slot-week-cell.event-part.event-continuation {
    box-shadow: inset 3px 0 0 #8098b3, inset -1px 0 0 #d8e3ef;
}

.slot-week-cell.event-part.event-end {
    box-shadow: inset 3px 0 0 #8098b3, inset -1px 0 0 #d8e3ef, inset 0 -1px 0 #c9d7e5;
}

.slot-week-event {
    height: 100%;
}

.slot-week-continuation {
    display: block;
    min-height: 100%;
}

/* Tagesansicht: derselbe Hausbesuch läuft optisch durch alle belegten Slots. */
.slot-day-row.event-part .slot-day-content {
    background: #eef4ff;
    border-left: 3px solid #8098b3;
}

.slot-day-row.event-part.event-start:not(.event-end) {
    border-bottom-color: transparent;
}

.slot-day-row.event-part.event-continuation:not(.event-end) {
    border-bottom-color: transparent;
}

.slot-day-row.event-part.event-continuation .slot-day-content {
    padding-top: 0;
    padding-bottom: 0;
}

.slot-day-row.event-part.event-continuation .slot-day-time {
    border-bottom-color: var(--border);
}

.slot-day-continuation {
    min-height: 100%;
    border-radius: 0;
    background: transparent;
    text-decoration: none;
}

.slot-day-row.event-part.event-end .slot-day-content {
    box-shadow: inset 0 -1px 0 #c9d7e5;
}


/* V1.43 Gesamtübersicht der drei Hausbesuchsgruppen */
.overview-section-head {
    margin-bottom: 10px;
}

.overview-date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 10px 0 8px;
}

.overview-date-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.overview-date-form input[type="date"] {
    min-width: 150px;
}

.overview-day-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    min-width: 40px;
    padding-left: 0;
    padding-right: 0;
    font-size: 1.35rem;
    line-height: 1;
}

.overview-day-title {
    margin: 0 0 12px;
    text-align: center;
    font-weight: 800;
    font-size: 1rem;
}

.combined-calendar-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.combined-calendar {
    width: 100%;
    min-width: 820px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.combined-calendar th,
.combined-calendar td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.combined-calendar tr:last-child > * {
    border-bottom: 0;
}

.combined-calendar tr > *:last-child {
    border-right: 0;
}

.combined-calendar thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 10px;
    background: #f7f8fa;
    text-align: center;
    font-size: .9rem;
}

.combined-time-head {
    width: 82px;
}

.combined-group-head.group-oberdorf {
    border-top: 4px solid #d62828;
}

.combined-group-head.group-unterdorf {
    border-top: 4px solid #f2c94c;
}

.combined-group-head.group-fahrend {
    border-top: 4px solid #d000b8;
}

.combined-time-cell {
    width: 82px;
    padding: 10px 7px;
    background: #fafbfc;
    text-align: center;
    vertical-align: top;
}

.combined-time-cell strong,
.combined-time-cell span {
    display: block;
}

.combined-time-cell strong {
    font-size: .8rem;
}

.combined-time-cell span {
    margin-top: 1px;
    font-size: .68rem;
    color: var(--muted);
}

.combined-slot {
    height: 52px;
    padding: 6px 8px;
    vertical-align: middle;
    text-align: center;
    font-size: .8rem;
}

.combined-slot.free {
    background: #f4faf6;
    color: #4d6f58;
}

.combined-slot.blocked {
    background: #fff5d9;
    color: #8a5a00;
}

.combined-slot.inactive,
.combined-slot.no-permission {
    background: #f5f6f7;
    color: #98a2b3;
}

.combined-slot.occupied {
    padding: 0;
    vertical-align: top;
}

.combined-slot.occupied.group-oberdorf {
    background: #fff0f0;
    border-left: 4px solid #d62828;
}

.combined-slot.occupied.group-unterdorf {
    background: #fffbea;
    border-left: 4px solid #d7ad00;
}

.combined-slot.occupied.group-fahrend {
    background: #fff0fc;
    border-left: 4px solid #d000b8;
}

.combined-event {
    display: flex;
    min-height: 100%;
    height: 100%;
    box-sizing: border-box;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 8px 10px;
    color: inherit;
    text-decoration: none;
    text-align: left;
}

.combined-event:hover {
    background: rgba(255,255,255,.42);
}

.combined-event span {
    font-size: .7rem;
    color: var(--muted);
}

.combined-event strong {
    font-size: .82rem;
    line-height: 1.2;
}

.combined-event small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: .7rem;
}

@media (max-width: 720px) {
    .overview-date-nav {
        gap: 6px;
    }

    .overview-date-form {
        min-width: 0;
        flex: 1 1 auto;
    }

    .overview-date-form input[type="date"] {
        min-width: 0;
        width: 100%;
    }

    .overview-date-form .btn {
        display: none;
    }

    .combined-calendar {
        min-width: 720px;
    }
}


/* V1.44 Dashboard-Kalender sauber gruppiert */
.dashboard-calendar-section {
    margin-top: 22px;
}

.dashboard-calendar-section + .dashboard-calendar-section {
    margin-top: 30px;
}

.dashboard-section-title {
    margin: 0 0 10px;
}

.dashboard-section-title h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: #344054;
}

.calendar-card-overview {
    border-width: 2px;
}

@media (max-width: 720px) {
    .dashboard-calendar-section {
        margin-top: 18px;
    }

    .dashboard-calendar-section + .dashboard-calendar-section {
        margin-top: 24px;
    }
}
