:root {
    color-scheme: light;
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-2: #eef1f4;
    --surface-3: #e5e9ef;
    --text: #17202a;
    --muted: #667085;
    --border: #d7dde4;
    --accent: #b42318;
    --accent-hover: #8f1c14;
    --accent-text: #ffffff;
    --success: #15803d;
    --danger-bg: #fff1f0;
    --danger-text: #9f1c13;
    --success-bg: #ecfdf3;
    --success-text: #087a3d;
    --shadow: 0 12px 34px rgba(16, 24, 40, .08);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1f2630;
    --surface-3: #252e39;
    --text: #f4f6f8;
    --muted: #9aa4b2;
    --border: #303844;
    --accent: #c84747;
    --accent-hover: #df5c5c;
    --accent-text: #ffffff;
    --success: #4ade80;
    --danger-bg: #3a1719;
    --danger-text: #ffb4b4;
    --success-bg: #10321f;
    --success-text: #9ce6b4;
    --shadow: 0 12px 34px rgba(0, 0, 0, .25);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        color-scheme: dark;
        --bg: #0d1117;
        --surface: #161b22;
        --surface-2: #1f2630;
        --surface-3: #252e39;
        --text: #f4f6f8;
        --muted: #9aa4b2;
        --border: #303844;
        --accent: #c84747;
        --accent-hover: #df5c5c;
        --accent-text: #ffffff;
        --success: #4ade80;
        --danger-bg: #3a1719;
        --danger-text: #ffb4b4;
        --success-bg: #10321f;
        --success-text: #9ce6b4;
        --shadow: 0 12px 34px rgba(0, 0, 0, .25);
    }
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
    min-height: 78px;
    padding: 12px clamp(16px, 3vw, 34px);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
}
.brand { color: var(--text); text-decoration: none; display: grid; gap: 2px; }
.brand strong { font-size: clamp(1.15rem, 3vw, 1.65rem); }
.eyebrow {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip {
    display: grid;
    line-height: 1.15;
    text-align: right;
}
.user-chip span { font-weight: 700; font-size: .9rem; }
.user-chip small { color: var(--muted); text-transform: capitalize; }

.theme-control {
    display: flex;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}
.theme-control button {
    border: 0;
    background: transparent;
    color: var(--text);
    min-width: 40px;
    padding: 8px 10px;
    border-radius: 7px;
    cursor: pointer;
}
.theme-control button.active { background: var(--surface); box-shadow: var(--shadow); }

.app-shell {
    width: min(1280px, calc(100% - 28px));
    margin: 24px auto 56px;
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 22px;
}
.main-nav {
    align-self: start;
    position: sticky;
    top: 102px;
    display: grid;
    gap: 6px;
}
.main-nav a,
.nav-logout button {
    width: 100%;
    border: 0;
    text-align: left;
    text-decoration: none;
    color: var(--muted);
    background: transparent;
    padding: 11px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 650;
}
.main-nav a:hover,
.nav-logout button:hover { background: var(--surface-2); color: var(--text); }
.main-nav a.active { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.nav-logout { margin: 8px 0 0; border-top: 1px solid var(--border); padding-top: 8px; }

.content { min-width: 0; }
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin: 0 0 18px;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(1.55rem, 4vw, 2.15rem); }
h2 { margin-bottom: 8px; font-size: 1.12rem; }
p { color: var(--muted); }

.card, .status-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}
.card { padding: 20px; margin-bottom: 18px; }
.status-card {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 18px;
}
.status-line { display: flex; align-items: center; gap: 9px; margin-top: 7px; }
.status-dot {
    width: 11px; height: 11px; border-radius: 999px; background: var(--success);
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 18%, transparent);
}
.pill, .self-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 11px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-weight: 700;
}
.self-badge { padding: 2px 7px; font-size: .7rem; margin-left: 7px; color: var(--muted); }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }

.empty-state {
    min-height: 160px;
    margin-top: 14px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    display: grid;
    place-content: center;
    text-align: center;
    gap: 6px;
    color: var(--muted);
}
.empty-state strong { color: var(--text); }

.primary, .secondary, .primary-link {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 750;
    cursor: pointer;
}
.primary, .primary-link {
    background: var(--accent);
    color: var(--accent-text);
}
.primary:hover, .primary-link:hover { background: var(--accent-hover); }
.primary-link { display: inline-block; text-decoration: none; }
.secondary {
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.secondary:hover { background: var(--surface-3); }
button:disabled { opacity: .55; cursor: not-allowed; }

.auth-shell {
    width: min(440px, calc(100% - 28px));
    margin: clamp(48px, 9vw, 100px) auto;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: clamp(22px, 5vw, 34px);
    box-shadow: var(--shadow);
}
.auth-title { margin-bottom: 22px; }
.auth-title h1 { margin-top: 4px; }
.form-stack { display: grid; gap: 15px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .86rem; font-weight: 650; }
input, select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text);
    padding: 9px 11px;
    outline: none;
}
input:focus, select:focus {
    border-color: color-mix(in srgb, var(--accent) 65%, var(--border));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.alert {
    border-radius: 10px;
    padding: 11px 13px;
    margin-bottom: 15px;
    border: 1px solid transparent;
}
.alert.error { background: var(--danger-bg); color: var(--danger-text); }
.alert.success { background: var(--success-bg); color: var(--success-text); }

.user-create-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr .75fr 1.2fr auto;
    gap: 12px;
    align-items: end;
}
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form select { width: 110px; }
.password-form input { min-width: 170px; }
.switch-label { display: flex; align-items: center; grid-template-columns: none; gap: 6px; white-space: nowrap; }
.switch-label input { width: auto; min-height: auto; }
code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 5px;
    color: var(--text);
}
.simple-page { width: min(720px, calc(100% - 28px)); margin: 70px auto; }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .main-nav {
        position: static;
        display: flex;
        overflow-x: auto;
        padding-bottom: 2px;
    }
    .main-nav a, .nav-logout button { white-space: nowrap; width: auto; }
    .nav-logout { margin: 0 0 0 auto; border: 0; padding: 0; }
    .user-create-grid { grid-template-columns: 1fr 1fr; }
    .user-create-grid .primary { width: 100%; }
}
@media (max-width: 720px) {
    .topbar { align-items: flex-start; padding: 10px 14px; }
    .topbar-actions { gap: 7px; }
    .user-chip { display: none; }
    .theme-control button { min-width: 36px; padding: 7px 8px; }
    .app-shell { width: min(100% - 18px, 1280px); margin-top: 14px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .page-head { align-items: stretch; flex-direction: column; }
    .page-head .primary { width: 100%; }
    .status-card { align-items: flex-start; flex-direction: column; }
    .user-create-grid { grid-template-columns: 1fr; }
    .card { padding: 16px; }
}


textarea{width:100%;border:1px solid var(--border);border-radius:9px;background:var(--surface-2);color:var(--text);padding:9px 11px;resize:vertical}
.calendar-card{overflow:hidden}.calendar-toolbar{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:12px;margin-bottom:14px}.calendar-toolbar h2{text-align:center;margin:0;text-transform:capitalize}
.calendar-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));border-top:1px solid var(--border);border-left:1px solid var(--border)}
.cal-weekday{padding:9px;text-align:center;color:var(--muted);font-size:.72rem;font-weight:800;text-transform:uppercase;border-right:1px solid var(--border);border-bottom:1px solid var(--border)}
.cal-day{min-height:112px;padding:8px;border-right:1px solid var(--border);border-bottom:1px solid var(--border);background:var(--surface)}
.cal-day.outside{background:var(--surface-2)}.cal-day.today{box-shadow:inset 0 0 0 2px var(--accent)}.cal-number{display:inline-flex;font-weight:800;font-size:.84rem;margin-bottom:6px}
.cal-events{display:grid;gap:4px}.cal-event{width:100%;border:0;border-radius:6px;padding:5px 6px;background:color-mix(in srgb,var(--accent) 16%,var(--surface-2));color:var(--text);text-align:left;font-size:.75rem;font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}
.booking-list{display:grid;margin-top:12px}.booking-row{border:0;border-top:1px solid var(--border);background:transparent;color:var(--text);padding:13px 4px;display:flex;justify-content:space-between;gap:16px;text-align:left;cursor:pointer}.booking-row:first-child{border-top:0}.booking-row span:last-child{text-align:right}.booking-row small,.next-booking span{display:block;color:var(--muted);margin-top:3px}
.event-dialog{width:min(680px,calc(100% - 24px));border:1px solid var(--border);border-radius:16px;background:var(--surface);color:var(--text);padding:0;box-shadow:var(--shadow)}.event-dialog::backdrop{background:rgba(0,0,0,.58);backdrop-filter:blur(3px)}.event-dialog form{padding:22px}.modal-head{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:18px}.icon-button{border:0;background:var(--surface-2);color:var(--text);border-radius:8px;width:38px;height:38px;font-size:1.4rem;cursor:pointer}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}.form-grid .wide{grid-column:1/-1}.modal-actions{display:grid;grid-template-columns:auto 1fr auto auto;gap:10px;margin-top:20px}.danger{color:var(--danger-text)}
@media(max-width:720px){.calendar-card{padding:10px}.cal-weekday{padding:6px 2px}.cal-day{min-height:72px;padding:5px}.cal-number{font-size:.75rem}.cal-event{font-size:0;width:9px;height:9px;padding:0;border-radius:50%;background:var(--accent)}.cal-events{display:flex;flex-wrap:wrap}.cal-events small{display:none}.booking-row{flex-direction:column}.booking-row span:last-child{text-align:left}.form-grid{grid-template-columns:1fr}.form-grid .wide{grid-column:auto}.modal-actions{grid-template-columns:1fr 1fr}.modal-actions span{display:none}.modal-actions button{width:100%}}


.access-card h2{margin-top:5px}.copy-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:9px}.copy-row input{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.hint{font-size:.83rem;margin:9px 0 14px}.access-data{display:grid;gap:0;margin:16px 0}.access-data div{display:grid;grid-template-columns:130px minmax(0,1fr);gap:12px;padding:10px 0;border-bottom:1px solid var(--border)}.access-data dt{font-weight:750;color:var(--muted)}.access-data dd{margin:0;overflow-wrap:anywhere}.alert.info{background:var(--surface-2);color:var(--text);border-color:var(--border)}
@media(max-width:720px){.copy-row{grid-template-columns:1fr}.access-data div{grid-template-columns:1fr;gap:4px}}


/* Release 0.5.0 - Dashboard / Kalender UX */

.vehicle-overview{
    display:grid;
    grid-template-columns:minmax(0,1.5fr) minmax(210px,.8fr) minmax(180px,.65fr);
    gap:14px;
    margin-bottom:18px;
}
.status-panel,.mini-panel{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:16px;
    box-shadow:var(--shadow);
}
.status-panel{
    padding:20px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    border-left:4px solid var(--success);
}
.status-panel.blocked{
    border-left-color:var(--accent);
}
.vehicle-status{
    display:flex;
    align-items:center;
    gap:10px;
    margin:8px 0 6px;
    font-size:1.15rem;
}
.status-dot.blocked{
    background:var(--accent);
    box-shadow:0 0 0 5px color-mix(in srgb,var(--accent) 18%,transparent);
}
.status-panel p{
    margin:0;
}
.vehicle-mark{
    border:1px solid var(--border);
    border-radius:12px;
    background:var(--surface-2);
    padding:12px 14px;
    font-weight:850;
    letter-spacing:.05em;
    white-space:nowrap;
}
.mini-panel{
    padding:18px;
}
.next-booking,.month-summary{
    display:grid;
    gap:4px;
    margin-top:8px;
}
.next-booking strong,.month-summary strong{
    font-size:1.05rem;
}
.month-summary strong{
    font-size:2rem;
    line-height:1;
}
.next-booking span,.next-booking small,.month-summary span{
    color:var(--muted);
}
.calendar-toolbar{
    grid-template-columns:1fr auto 1fr;
}
.calendar-toolbar-side{
    display:flex;
    align-items:center;
    gap:10px;
}
.calendar-toolbar-side:last-child{
    justify-content:flex-end;
}
.calendar-nav{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:10px;
}
.calendar-nav h2{
    min-width:180px;
    text-align:center;
}
.square-button{
    min-width:40px;
    padding:9px 12px;
    font-size:1.15rem;
}
.calendar-legend{
    color:var(--muted);
    font-size:.75rem;
}
.calendar-legend span{
    display:inline-flex;
    align-items:center;
    gap:5px;
    white-space:nowrap;
}
.legend-dot,.booking-category{
    width:9px;
    height:9px;
    border-radius:999px;
    display:inline-block;
    flex:0 0 auto;
}
.cal-day{
    position:relative;
    transition:background .12s ease;
}
[data-can-write="1"] .cal-day:not(.outside){
    cursor:pointer;
}
[data-can-write="1"] .cal-day:not(.outside):hover{
    background:color-mix(in srgb,var(--surface-2) 70%,var(--surface));
}
.cal-day-head{
    display:flex;
    justify-content:space-between;
    align-items:center;
}
.day-count{
    min-width:20px;
    height:20px;
    display:inline-grid;
    place-items:center;
    border-radius:999px;
    background:var(--surface-2);
    color:var(--muted);
    font-size:.68rem;
    font-weight:800;
}
.cal-event{
    border-left:3px solid var(--accent);
    background:var(--surface-2);
}
.cal-event span{
    opacity:.7;
    margin-right:4px;
}
.category-ausbildung{--category:#2f7dcb}
.category-dienst{--category:#7b61c9}
.category-jugendfeuerwehr{--category:#d88916}
.category-einsatzbereitschaft{--category:#bd3f3f}
.category-sonstiges{--category:#6f7a86}
.legend-dot.category-ausbildung,
.booking-category.category-ausbildung{background:#2f7dcb}
.legend-dot.category-dienst,
.booking-category.category-dienst{background:#7b61c9}
.legend-dot.category-jugendfeuerwehr,
.booking-category.category-jugendfeuerwehr{background:#d88916}
.legend-dot.category-einsatzbereitschaft,
.booking-category.category-einsatzbereitschaft{background:#bd3f3f}
.legend-dot.category-sonstiges,
.booking-category.category-sonstiges{background:#6f7a86}
.cal-event.category-ausbildung{border-left-color:#2f7dcb}
.cal-event.category-dienst{border-left-color:#7b61c9}
.cal-event.category-jugendfeuerwehr{border-left-color:#d88916}
.cal-event.category-einsatzbereitschaft{border-left-color:#bd3f3f}
.cal-event.category-sonstiges{border-left-color:#6f7a86}
.booking-row{
    align-items:center;
    border-radius:10px;
    padding:13px 10px;
}
.booking-row:hover{
    background:var(--surface-2);
}
.booking-main{
    display:flex;
    align-items:center;
    gap:11px;
    min-width:0;
}
.booking-main>span{
    min-width:0;
}
.booking-main strong{
    display:block;
    overflow:hidden;
    text-overflow:ellipsis;
}
.booking-time{
    flex:0 0 auto;
}
.role-hint{
    color:var(--muted);
    font-size:.78rem;
}
.event-meta{
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:8px 12px;
    padding:10px 12px;
    margin-bottom:14px;
    border:1px solid var(--border);
    border-radius:10px;
    background:var(--surface-2);
    color:var(--muted);
    font-size:.8rem;
}
.category-pill{
    display:inline-flex;
    align-items:center;
    padding:4px 8px;
    border-radius:999px;
    color:var(--text);
    background:var(--surface);
    border:1px solid var(--border);
    font-weight:750;
}
.toast{
    position:fixed;
    right:20px;
    bottom:20px;
    z-index:100;
    max-width:min(420px,calc(100% - 40px));
    padding:12px 15px;
    border:1px solid var(--border);
    border-radius:11px;
    background:var(--surface);
    color:var(--text);
    box-shadow:var(--shadow);
    font-weight:700;
}
.toast.success{
    border-left:4px solid var(--success);
}
.toast.error{
    border-left:4px solid var(--accent);
}

@media(max-width:980px){
    .vehicle-overview{
        grid-template-columns:1fr 1fr;
    }
    .status-panel{
        grid-column:1/-1;
    }
    .calendar-toolbar{
        grid-template-columns:auto 1fr;
        gap:10px;
    }
    .calendar-toolbar-side:last-child{
        display:none;
    }
    .calendar-nav{
        justify-self:end;
    }
}
@media(max-width:720px){
    .vehicle-overview{
        grid-template-columns:1fr;
    }
    .status-panel{
        grid-column:auto;
    }
    .vehicle-mark{
        align-self:flex-start;
    }
    .calendar-toolbar{
        grid-template-columns:1fr;
    }
    .calendar-toolbar-side{
        order:2;
    }
    .calendar-toolbar-side .secondary{
        width:100%;
    }
    .calendar-nav{
        order:1;
        width:100%;
        justify-self:stretch;
        display:grid;
        grid-template-columns:auto 1fr auto;
    }
    .calendar-nav h2{
        min-width:0;
    }
    .booking-row{
        gap:8px;
    }
    .booking-time{
        width:100%;
        padding-left:20px;
    }
    .role-hint{
        display:none;
    }
    .toast{
        right:10px;
        bottom:10px;
        max-width:calc(100% - 20px);
    }
}


/* Release 0.6.0 - breiteres Layout & mehrtägige Termine */

.app-shell{
    width:min(1520px,calc(100% - 30px));
    grid-template-columns:170px minmax(0,1fr);
    gap:20px;
}

.content{
    width:100%;
}

.vehicle-overview{
    grid-template-columns:minmax(0,1.7fr) minmax(240px,.85fr) minmax(210px,.65fr);
}

.calendar-card{
    padding:18px;
}

.cal-day{
    min-height:124px;
    padding:7px;
    overflow:visible;
}

.cal-events{
    gap:5px;
}

.cal-event{
    min-height:26px;
    display:flex;
    align-items:center;
    gap:5px;
    padding:5px 7px;
    line-height:1.15;
    border-left-width:4px;
    overflow:hidden;
}

.cal-event .event-time{
    flex:0 0 auto;
    font-size:.68rem;
    font-weight:850;
    opacity:.72;
}

.cal-event .event-title{
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    font-size:.76rem;
    font-weight:800;
}

.cal-event.multiday-start{
    margin-right:-8px;
    border-top-right-radius:2px;
    border-bottom-right-radius:2px;
    padding-right:13px;
}

.cal-event.multiday-middle{
    margin-left:-8px;
    margin-right:-8px;
    border-left-width:0;
    border-radius:0;
    padding-left:12px;
    padding-right:12px;
}

.cal-event.multiday-end{
    margin-left:-8px;
    border-left-width:0;
    border-top-left-radius:2px;
    border-bottom-left-radius:2px;
    padding-left:12px;
}

.cal-event.multiday-middle .event-title,
.cal-event.multiday-end .event-title{
    font-weight:750;
}

.event-time-continuation{
    opacity:.45 !important;
}

.more-events{
    display:block;
    padding:2px 5px;
    color:var(--muted);
    font-size:.68rem;
    font-weight:700;
}

.booking-row{
    min-height:66px;
}

.booking-time{
    min-width:210px;
}

@media(min-width:1500px){
    .cal-day{
        min-height:136px;
    }

    .cal-event .event-title{
        font-size:.8rem;
    }
}

@media(max-width:1100px){
    .app-shell{
        grid-template-columns:155px minmax(0,1fr);
    }

    .vehicle-overview{
        grid-template-columns:1fr 1fr;
    }

    .status-panel{
        grid-column:1/-1;
    }
}

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

@media(max-width:720px){
    .app-shell{
        width:min(100% - 14px,1520px);
    }

    .calendar-card{
        padding:9px;
    }

    .cal-day{
        min-height:78px;
        padding:4px;
    }

    .cal-event{
        min-height:12px;
        width:auto;
        height:12px;
        padding:0;
        border-radius:4px;
        border-left-width:0;
        font-size:0;
    }

    .cal-event .event-time,
    .cal-event .event-title{
        display:none;
    }

    .cal-event.multiday-start{
        margin-right:-5px;
        border-top-right-radius:0;
        border-bottom-right-radius:0;
    }

    .cal-event.multiday-middle{
        margin-left:-5px;
        margin-right:-5px;
        border-radius:0;
    }

    .cal-event.multiday-end{
        margin-left:-5px;
        border-top-left-radius:0;
        border-bottom-left-radius:0;
    }

    .booking-time{
        min-width:0;
    }
}


/* Release 0.6.2 - Responsive Layout Fix / Desktop ohne Herauszoomen */

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

.topbar {
    min-height: 64px;
}

.app-shell {
    width: min(1380px, calc(100% - 24px));
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.main-nav {
    top: 82px;
}

.page-head {
    align-items: center;
    margin-bottom: 14px;
}

.page-head h1 {
    font-size: clamp(1.4rem, 2.4vw, 1.9rem);
}

.page-head p {
    margin-bottom: 0;
}

.vehicle-overview {
    grid-template-columns: minmax(0, 1.55fr) minmax(220px, .9fr) minmax(170px, .6fr);
    gap: 12px;
}

.status-panel,
.mini-panel {
    min-width: 0;
}

.status-panel {
    padding: 16px;
}

.mini-panel {
    padding: 16px;
}

.calendar-card {
    padding: 14px;
}

.calendar-toolbar {
    margin-bottom: 10px;
}

.calendar-grid {
    width: 100%;
    table-layout: fixed;
}

.cal-weekday {
    padding: 7px 4px;
}

.cal-day {
    min-width: 0;
    min-height: 96px;
    padding: 5px;
}

.cal-events {
    min-width: 0;
}

.cal-event {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.cal-event .event-title {
    flex: 1 1 auto;
    min-width: 0;
}

.cal-event.multiday-start,
.cal-event.multiday-middle,
.cal-event.multiday-end {
    margin-left: 0;
    margin-right: 0;
    border-radius: 6px;
}

.booking-list {
    gap: 2px;
}

.booking-row {
    min-height: 58px;
    padding: 10px 8px;
}

.booking-time {
    min-width: 190px;
}

/* Tablet */
@media (max-width: 1180px) {
    .app-shell {
        width: min(100% - 18px, 1180px);
        grid-template-columns: 135px minmax(0, 1fr);
        gap: 12px;
    }

    .vehicle-overview {
        grid-template-columns: 1.35fr .9fr;
    }

    .vehicle-overview .mini-panel:last-child {
        grid-column: 1 / -1;
    }

    .calendar-legend {
        display: none;
    }

    .cal-day {
        min-height: 88px;
    }
}

/* Mobile / iPhone */
@media (max-width: 720px) {
    body {
        font-size: 14px;
    }

    .topbar {
        min-height: 58px;
        padding: 8px 10px;
        align-items: center;
    }

    .brand {
        gap: 0;
    }

    .brand .eyebrow {
        font-size: .56rem;
    }

    .brand strong {
        font-size: 1rem;
        line-height: 1.1;
    }

    .theme-control {
        padding: 2px;
        border-radius: 8px;
    }

    .theme-control button {
        min-width: 32px;
        padding: 6px 7px;
        font-size: .76rem;
    }

    .app-shell {
        width: calc(100% - 12px);
        margin: 8px auto 20px;
        display: block;
    }

    .main-nav {
        display: none;
    }

    .content {
        width: 100%;
    }

    .page-head {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin-bottom: 10px;
    }

    .page-head > div {
        display: none;
    }

    .page-head .booking-button {
        width: 100%;
        min-height: 40px;
        margin: 0;
    }

    .vehicle-overview {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 10px;
    }

    .status-panel {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        padding: 12px;
        min-height: 82px;
    }

    .status-panel .eyebrow,
    .mini-panel .eyebrow {
        font-size: .58rem;
    }

    .vehicle-status {
        font-size: .92rem;
        margin: 5px 0 3px;
    }

    .status-panel p {
        font-size: .75rem;
        line-height: 1.35;
    }

    .vehicle-mark {
        font-size: .75rem;
        padding: 8px 9px;
    }

    .mini-panel {
        padding: 11px;
        min-height: 116px;
    }

    .mini-panel h2,
    .next-booking strong {
        font-size: .9rem;
    }

    .next-booking span,
    .next-booking small,
    .month-summary span {
        font-size: .7rem;
        line-height: 1.3;
    }

    .month-summary strong {
        font-size: 1.55rem;
    }

    .calendar-card {
        padding: 8px;
        border-radius: 12px;
        margin-bottom: 10px;
    }

    .calendar-toolbar {
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 6px;
        align-items: center;
        margin-bottom: 8px;
    }

    .calendar-toolbar-side {
        display: contents;
    }

    .calendar-toolbar-side:first-child .secondary {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        min-height: 34px;
        padding: 6px 8px;
        font-size: .76rem;
    }

    .calendar-nav {
        grid-column: 1 / -1;
        grid-row: 1;
        display: grid;
        grid-template-columns: 36px 1fr 36px;
        gap: 6px;
        width: 100%;
    }

    .calendar-nav h2 {
        min-width: 0;
        font-size: .95rem;
        margin: 0;
    }

    .square-button {
        min-width: 34px;
        height: 34px;
        padding: 0;
    }

    .calendar-legend {
        display: none !important;
    }

    .calendar-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        font-size: 11px;
        border-color: var(--border);
    }

    .cal-weekday {
        padding: 6px 1px;
        font-size: .56rem;
        letter-spacing: .02em;
    }

    .cal-day {
        min-height: 54px;
        padding: 3px;
        overflow: hidden;
    }

    .cal-number {
        font-size: .62rem;
        margin-bottom: 2px;
    }

    .day-count {
        min-width: 15px;
        height: 15px;
        font-size: .55rem;
    }

    .cal-events {
        display: grid;
        gap: 2px;
        width: 100%;
    }

    /* Termin auf iOS sichtbar: statt Mini-Punkt ein echter Balken */
    .cal-event {
        width: 100%;
        min-height: 16px;
        height: auto;
        padding: 2px 3px;
        border: 0;
        border-left: 3px solid var(--accent);
        border-radius: 4px;
        display: flex;
        align-items: center;
        background: color-mix(in srgb, var(--surface-3) 78%, var(--surface));
        font-size: .56rem;
        line-height: 1.05;
        overflow: hidden;
    }

    .cal-event .event-time {
        display: inline;
        flex: 0 0 auto;
        font-size: .54rem;
        font-weight: 850;
        opacity: .8;
    }

    .cal-event .event-title {
        display: block;
        flex: 1 1 auto;
        min-width: 0;
        font-size: .54rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .cal-event.multiday-start,
    .cal-event.multiday-middle,
    .cal-event.multiday-end {
        margin: 0;
        min-height: 16px;
        border-radius: 4px;
    }

    .cal-event.multiday-middle .event-time,
    .cal-event.multiday-middle .event-title {
        display: none;
    }

    .cal-event.multiday-middle::after {
        content: "↔";
        display: block;
        width: 100%;
        text-align: center;
        font-weight: 900;
        font-size: .62rem;
        opacity: .8;
    }

    .cal-event.multiday-end .event-title {
        display: none;
    }

    .cal-event.category-ausbildung,
    .cal-event.category-dienst,
    .cal-event.category-jugendfeuerwehr,
    .cal-event.category-einsatzbereitschaft,
    .cal-event.category-sonstiges {
        background: color-mix(in srgb, var(--surface-3) 82%, var(--surface));
    }

    .cal-event.category-ausbildung { border-left-color: #2f7dcb; }
    .cal-event.category-dienst { border-left-color: #7b61c9; }
    .cal-event.category-jugendfeuerwehr { border-left-color: #d88916; }
    .cal-event.category-einsatzbereitschaft { border-left-color: #bd3f3f; }
    .cal-event.category-sonstiges { border-left-color: #6f7a86; }

    .more-events {
        font-size: .52rem;
        padding: 0 2px;
    }

    .card:not(.calendar-card) {
        padding: 12px;
    }

    .section-head h2 {
        font-size: 1rem;
    }

    .booking-row {
        min-height: 0;
        padding: 9px 4px;
        gap: 5px;
    }

    .booking-main {
        align-items: flex-start;
    }

    .booking-main strong {
        font-size: .82rem;
    }

    .booking-main small,
    .booking-time,
    .booking-time small {
        font-size: .68rem;
        line-height: 1.35;
    }

    .booking-time {
        padding-left: 20px;
    }

    .event-dialog {
        width: calc(100% - 12px);
        max-height: calc(100vh - 20px);
        overflow-y: auto;
        border-radius: 12px;
    }

    .event-dialog form {
        padding: 14px;
    }

    .modal-actions {
        position: sticky;
        bottom: 0;
        background: var(--surface);
        padding-top: 10px;
    }
}

/* Sehr kleine iPhones */
@media (max-width: 390px) {
    .vehicle-overview {
        grid-template-columns: 1fr;
    }

    .status-panel {
        grid-column: auto;
    }

    .mini-panel {
        min-height: 0;
    }

    .calendar-grid {
        font-size: 10px;
    }

    .cal-day {
        min-height: 50px;
    }
}


/* Release 0.7.0 - iOS/PWA UI */

.brand{
    display:flex;
    align-items:center;
    gap:10px;
}
.brand-icon{
    width:38px;
    height:38px;
    flex:0 0 auto;
    border-radius:9px;
    box-shadow:0 4px 16px rgba(0,0,0,.22);
}
.brand-copy{
    display:grid;
    gap:1px;
}

@media (max-width: 720px) {
    body{
        padding-bottom:calc(10px + env(safe-area-inset-bottom));
    }

    .topbar{
        position:sticky;
        top:0;
        min-height:calc(60px + env(safe-area-inset-top));
        padding:
            calc(7px + env(safe-area-inset-top))
            calc(10px + env(safe-area-inset-right))
            7px
            calc(10px + env(safe-area-inset-left));
        background:color-mix(in srgb,var(--surface) 97%,transparent);
        box-shadow:0 1px 0 var(--border);
    }

    .brand{
        gap:8px;
        min-width:0;
    }

    .brand-icon{
        width:34px;
        height:34px;
        border-radius:8px;
    }

    .brand-copy{
        min-width:0;
    }

    .brand strong{
        font-size:.96rem;
        white-space:nowrap;
    }

    .topbar-actions{
        flex:0 0 auto;
    }

    .theme-control button{
        min-width:30px;
        padding:6px 6px;
    }

    .app-shell{
        width:100%;
        margin:0;
        padding:
            8px
            calc(8px + env(safe-area-inset-right))
            14px
            calc(8px + env(safe-area-inset-left));
    }

    .page-head{
        margin:0 0 8px;
    }

    .page-head .booking-button{
        min-height:42px;
        border-radius:11px;
        font-size:.86rem;
        box-shadow:0 6px 18px color-mix(in srgb,var(--accent) 22%,transparent);
    }

    .vehicle-overview{
        gap:7px;
        margin-bottom:8px;
    }

    .status-panel{
        min-height:74px;
        padding:10px 11px;
        border-radius:12px;
    }

    .status-panel p{
        font-size:.70rem;
    }

    .vehicle-mark{
        display:none;
    }

    .mini-panel{
        min-height:100px;
        padding:10px;
        border-radius:12px;
    }

    .next-booking strong{
        font-size:.86rem;
    }

    .next-booking span,
    .next-booking small,
    .month-summary span{
        font-size:.66rem;
    }

    .calendar-card{
        padding:7px;
        border-radius:12px;
        margin-bottom:8px;
    }

    .calendar-toolbar{
        margin-bottom:6px;
    }

    .calendar-toolbar-side:first-child .secondary{
        min-height:32px;
    }

    .calendar-grid{
        border-radius:8px;
        overflow:hidden;
    }

    .cal-weekday{
        min-height:25px;
        display:grid;
        place-items:center;
        padding:3px 1px;
        background:var(--surface-2);
    }

    .cal-day{
        min-height:58px;
        padding:2px;
    }

    .cal-day-head{
        min-height:15px;
    }

    .cal-number{
        font-size:.60rem;
    }

    .cal-events{
        margin-top:1px;
        gap:1px;
    }

    .cal-event{
        min-height:18px;
        padding:2px 3px;
        border-radius:3px;
        background:color-mix(in srgb,var(--accent) 17%,var(--surface-2));
    }

    .cal-event .event-time{
        display:inline;
        font-size:.52rem;
    }

    .cal-event .event-title{
        display:block;
        font-size:.52rem;
    }

    .cal-event.multiday-start{
        border-top-right-radius:0;
        border-bottom-right-radius:0;
    }

    .cal-event.multiday-middle{
        border-radius:0;
    }

    .cal-event.multiday-end{
        border-top-left-radius:0;
        border-bottom-left-radius:0;
    }

    .card:not(.calendar-card){
        border-radius:12px;
    }

    .booking-list{
        margin-top:6px;
    }

    .booking-row{
        border-radius:8px;
        padding:8px 3px;
    }

    .event-dialog{
        margin:auto 6px 6px;
        width:calc(100% - 12px);
        max-width:none;
        max-height:calc(100dvh - 12px - env(safe-area-inset-top));
        border-radius:18px 18px 12px 12px;
    }

    .event-dialog::backdrop{
        background:rgba(0,0,0,.72);
    }

    .event-dialog form{
        padding:14px 12px calc(12px + env(safe-area-inset-bottom));
    }

    .form-grid{
        gap:10px;
    }

    input,select,textarea{
        min-height:44px;
        font-size:16px;
    }

    textarea{
        min-height:90px;
    }
}

@media (max-width: 390px) {
    .brand-icon{
        width:31px;
        height:31px;
    }

    .brand strong{
        font-size:.88rem;
    }

    .vehicle-overview{
        grid-template-columns:1fr 1fr;
    }

    .status-panel{
        grid-column:1/-1;
    }

    .mini-panel{
        min-height:92px;
    }

    .cal-day{
        min-height:55px;
    }

    .cal-event{
        min-height:17px;
    }
}

html.is-standalone .topbar{
    backdrop-filter:blur(18px);
}


/* Release 0.7.1 - iOS Kalender deutlich sichtbar */

/* Echte Cache-Busting-URLs werden ab diesem Release serverseitig erzeugt. */

@media (max-width: 720px) {
    /* Header: kein Überlappen mehr */
    .topbar{
        display:grid;
        grid-template-columns:minmax(0,1fr) auto;
        gap:8px;
        align-items:center;
    }

    .brand{
        min-width:0;
        width:100%;
        gap:7px;
    }

    .brand-icon{
        width:32px;
        height:32px;
    }

    .brand-copy{
        min-width:0;
        overflow:hidden;
    }

    .brand .eyebrow{
        display:block;
        font-size:.52rem;
        line-height:1;
        margin-bottom:3px;
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;
    }

    .brand strong{
        display:flex;
        align-items:baseline;
        min-width:0;
        font-size:.88rem;
        line-height:1.05;
        white-space:nowrap;
        overflow:hidden;
    }

    .brand-vehicle,
    .brand-separator,
    .brand-callsign{
        flex:0 0 auto;
    }

    .brand-separator{
        display:none;
    }

    .brand-callsign{
        margin-left:5px;
        font-size:.74rem;
        color:var(--muted);
    }

    .topbar-actions{
        min-width:max-content;
    }

    .theme-control{
        flex-wrap:nowrap;
    }

    /* Mehr nutzbare Höhe für den Kalender */
    .calendar-card{
        padding:7px 6px 8px;
    }

    .calendar-grid{
        width:100%;
        overflow:visible;
    }

    .cal-weekday{
        min-height:24px;
        font-size:.57rem;
        font-weight:850;
    }

    .cal-day{
        position:relative;
        min-height:66px;
        padding:3px 2px;
        overflow:hidden;
        background:var(--surface);
    }

    .cal-day.has-events{
        background:
            linear-gradient(
                180deg,
                color-mix(in srgb,var(--surface-2) 78%,transparent) 0%,
                var(--surface) 58%
            );
    }

    /* belegte Tage müssen schon ohne Lesen auffallen */
    .cal-day.has-events::after{
        content:"";
        position:absolute;
        inset:auto 3px 2px 3px;
        height:3px;
        border-radius:999px;
        background:var(--accent);
        opacity:.95;
        pointer-events:none;
    }

    .cal-day.day-category-ausbildung::after{ background:#2f8ee5; }
    .cal-day.day-category-dienst::after{ background:#8b6fe8; }
    .cal-day.day-category-jugendfeuerwehr::after{ background:#e39a23; }
    .cal-day.day-category-einsatzbereitschaft::after{ background:#e14a4a; }
    .cal-day.day-category-sonstiges::after{ background:#85919e; }

    .cal-day.has-events .day-count{
        background:var(--text);
        color:var(--surface);
        opacity:.9;
    }

    .cal-events{
        display:grid;
        gap:2px;
        width:100%;
        margin-top:2px;
        position:relative;
        z-index:2;
    }

    /* Kein dunkler Mini-Punkt mehr: echter kontrastreicher Terminblock */
    .cal-event{
        width:100%;
        min-width:0;
        min-height:20px;
        height:auto;
        padding:3px 4px;
        display:flex;
        align-items:center;
        gap:3px;
        border:0;
        border-radius:5px;
        color:#fff;
        box-shadow:0 1px 4px rgba(0,0,0,.28);
        font-weight:800;
        line-height:1;
    }

    .cal-event .event-time{
        display:inline-block;
        flex:0 0 auto;
        color:#fff;
        opacity:1;
        font-size:.54rem;
        font-weight:900;
        letter-spacing:-.02em;
    }

    .cal-event .event-title{
        display:block;
        flex:1 1 auto;
        min-width:0;
        color:#fff;
        font-size:.54rem;
        font-weight:850;
        overflow:hidden;
        text-overflow:ellipsis;
        white-space:nowrap;
    }

    .cal-event.category-ausbildung{
        background:#236fbd;
        border-left:0;
    }

    .cal-event.category-dienst{
        background:#7658c9;
        border-left:0;
    }

    .cal-event.category-jugendfeuerwehr{
        background:#b8750d;
        border-left:0;
    }

    .cal-event.category-einsatzbereitschaft{
        background:#b93131;
        border-left:0;
    }

    .cal-event.category-sonstiges{
        background:#596775;
        border-left:0;
    }

    /* Mehrtägige Belegung: gleiche kräftige Farbe auf jedem beteiligten Tag */
    .cal-event.multiday-start{
        border-top-right-radius:1px;
        border-bottom-right-radius:1px;
    }

    .cal-event.multiday-middle{
        border-radius:1px;
    }

    .cal-event.multiday-end{
        border-top-left-radius:1px;
        border-bottom-left-radius:1px;
    }

    .cal-event.multiday-middle .event-time{
        font-size:0;
    }

    .cal-event.multiday-middle .event-time::after{
        content:"↔";
        font-size:.62rem;
        color:#fff;
    }

    /* Der Titel bleibt auch auf Fortsetzungs-Tagen sichtbar. */
    .cal-event.multiday-middle .event-title,
    .cal-event.multiday-end .event-title{
        display:block;
    }

    .cal-day.today{
        box-shadow:inset 0 0 0 2px #e54848;
    }

    /* Übersicht darunter nicht verschwenden */
    .card:not(.calendar-card){
        margin-bottom:8px;
    }

    .booking-row{
        background:color-mix(in srgb,var(--surface-2) 45%,transparent);
        margin-bottom:3px;
    }
}

/* iPhone 16 Pro / ähnliche Breiten: Zellen bewusst größer */
@media (min-width: 391px) and (max-width: 440px) {
    .cal-day{
        min-height:70px;
    }

    .cal-event{
        min-height:21px;
    }

    .cal-event .event-time,
    .cal-event .event-title{
        font-size:.56rem;
    }
}

/* Sehr schmale iPhones: Termin bleibt trotzdem Balken statt Punkt */
@media (max-width: 390px) {
    .cal-day{
        min-height:62px;
    }

    .cal-event{
        min-height:19px;
        padding:3px 3px;
    }

    .cal-event .event-time,
    .cal-event .event-title{
        font-size:.51rem;
    }
}


/* Release 0.9.0 - Bedienung / Live-Sync / Rollen */

.role-overview{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:10px;
    margin-bottom:14px;
}
.role-overview>div{
    display:grid;
    gap:3px;
    padding:12px 14px;
    border:1px solid var(--border);
    border-radius:12px;
    background:var(--surface);
}
.role-overview span{
    color:var(--muted);
    font-size:.78rem;
}

.refresh-button{
    min-width:38px;
    padding-inline:10px;
    font-size:1rem;
}
.refresh-button:disabled{
    opacity:.55;
}

.live-state{
    display:inline-flex !important;
    align-items:center;
    gap:5px;
    padding:4px 7px;
    border:1px solid var(--border);
    border-radius:999px;
    background:var(--surface-2);
}
.live-state>i{
    width:7px;
    height:7px;
    border-radius:999px;
    background:var(--success);
}
.live-state small{
    color:var(--muted);
    font-variant-numeric:tabular-nums;
}
.live-state[data-state="loading"]>i{
    background:#d39a28;
    animation:livePulse .8s infinite alternate;
}
.live-state[data-state="error"]>i{
    background:var(--accent);
}
@keyframes livePulse{
    from{opacity:.35}
    to{opacity:1}
}

.quick-duration{
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:7px;
    padding:10px;
    border:1px solid var(--border);
    border-radius:10px;
    background:var(--surface-2);
}
.quick-duration>span{
    margin-right:auto;
    color:var(--muted);
    font-size:.78rem;
    font-weight:750;
}
.quick-duration button{
    padding:7px 10px;
    min-height:34px;
}

.alert.success{
    border-color:color-mix(in srgb,var(--success) 50%,var(--border));
    background:color-mix(in srgb,var(--success) 9%,var(--surface));
}

@media(max-width:720px){
    .role-overview{
        grid-template-columns:1fr;
        gap:6px;
    }

    .calendar-toolbar-side:first-child{
        display:grid;
        grid-template-columns:1fr 40px;
        gap:6px;
    }

    .calendar-toolbar-side:first-child .secondary{
        width:auto;
    }

    .calendar-toolbar-side:first-child .refresh-button{
        display:block;
        grid-column:2;
        grid-row:2;
    }

    .calendar-toolbar-side:first-child [data-today]{
        grid-column:1;
        grid-row:2;
    }

    .quick-duration{
        display:grid;
        grid-template-columns:repeat(4,1fr);
        gap:5px;
    }

    .quick-duration>span{
        grid-column:1/-1;
        margin-right:0;
    }

    .quick-duration button{
        width:100%;
        min-width:0;
        padding-inline:4px;
        font-size:.72rem;
    }
}
