/* ============================================================
   Dispo – Stylesheet
   Dark/Light über CSS-Variablen, Mobile-First, responsive.
   ============================================================ */

/* ---- Lokale Schrift (Inter) ---- */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/inter-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/inter-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/inter-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/inter-700.woff2') format('woff2');
}

/* ---- Design-Tokens ---- */
:root {
    --bg:          #f4f6fb;
    --surface:     #ffffff;
    --surface-2:   #f8fafc;
    --border:      #e3e8f0;
    --text:        #1e2430;
    --text-muted:  #64748b;
    --primary:     #2563eb;
    --primary-600: #1d4ed8;
    --primary-fg:  #ffffff;
    --danger:      #dc2626;
    --danger-bg:   #fee2e2;
    --success:     #16a34a;
    --success-bg:  #dcfce7;
    --warn:        #f59e0b;
    --shadow:      0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-lg:   0 10px 30px rgba(15, 23, 42, .18);
    --radius:      12px;
    --radius-sm:   8px;
    --sidebar-w:   232px;
    --topbar-h:    60px;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
    --bg:          #0f141c;
    --surface:     #171e2a;
    --surface-2:   #1e2735;
    --border:      #2a3547;
    --text:        #e6ecf5;
    --text-muted:  #94a3b8;
    --primary:     #3b82f6;
    --primary-600: #2563eb;
    --primary-fg:  #ffffff;
    --danger:      #ef4444;
    --danger-bg:   #3b1d1d;
    --success:     #22c55e;
    --success-bg:  #14321f;
    --shadow:      0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg:   0 12px 34px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; line-height: 1.25; }
a { color: var(--primary); text-decoration: none; }
.muted { color: var(--text-muted); }
small.muted { font-size: .8rem; }

.icon { width: 20px; height: 20px; flex: 0 0 auto; stroke-width: 2; vertical-align: middle; }

/* ============================================================
   App-Layout
   ============================================================ */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas: "brand top" "side main";
    min-height: 100vh;
}

.topbar {
    grid-area: top;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar-spacer { flex: 1; }

.brand {
    grid-area: brand;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.25rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.brand-icon { width: 26px; height: 26px; color: var(--primary); }

.sidebar {
    grid-area: side;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem .75rem;
    overflow-y: auto;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.sidebar a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar a:hover { background: var(--surface-2); color: var(--text); }
.sidebar a.active { background: var(--primary); color: var(--primary-fg); }
.sidebar a.active .icon { color: var(--primary-fg); }

.content {
    grid-area: main;
    padding: 1.5rem;
    overflow-x: hidden;
    position: relative;
}

/* Topbar-Elemente */
.nav-toggle { display: none; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); }

.user-box { display: flex; align-items: center; gap: .6rem; }
.user-name { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
.badge { font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; font-weight: 600; }
.badge-ro { background: var(--warn); color: #3a2a00; }

/* Theme-Toggle: Sonne/Mond je nach Theme */
#themeToggle .icon-moon { display: none; }
[data-theme="dark"] #themeToggle .icon-sun { display: none; }
[data-theme="dark"] #themeToggle .icon-moon { display: inline; }

/* ============================================================
   Seitenkopf, Karten
   ============================================================ */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 1.5rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.card + .card { margin-top: 1.25rem; }
.card-narrow { max-width: 560px; }
.card-title { font-size: 1.1rem; margin-bottom: 1rem; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .55rem .95rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .35rem .55rem; font-size: .85rem; }
.btn-icon { padding: .4rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ============================================================
   Tabellen
   ============================================================ */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data-table th, .data-table td {
    text-align: left;
    padding: .7rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    font-weight: 600;
}
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .loading, .data-table .empty { text-align: center; color: var(--text-muted); padding: 2rem; }
.col-actions { text-align: right; white-space: nowrap; }
.pre-line { white-space: pre-line; }
.cell-sub { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }
.created-info {
    display: flex; align-items: center; gap: .4rem;
    margin: 0 0 .25rem; font-size: .85rem;
    padding: .5rem .7rem; background: var(--surface-2);
    border-radius: var(--radius-sm);
}
.created-info .icon { width: 16px; height: 16px; }

/* Schreibgeschütztes Detail-Modal */
.detail-grid { margin: 0; }
.detail-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 1rem;
    padding: .6rem .2rem;
    border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt { color: var(--text-muted); font-weight: 600; font-size: .85rem; }
.detail-row dd { margin: 0; }
.notes-content { line-height: 1.5; }
.notes-content p { margin: 0 0 .5rem; }
.notes-content ul, .notes-content ol { margin: .3rem 0; padding-left: 1.3rem; }
@media (max-width: 520px) {
    .detail-row { grid-template-columns: 1fr; gap: .15rem; }
}
.row-actions { display: inline-flex; gap: .35rem; justify-content: flex-end; }

/* Status-Pills */
.pill { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.pill-active, .pill-confirmed { background: var(--success-bg); color: var(--success); }
.pill-inactive, .pill-cancelled { background: var(--danger-bg); color: var(--danger); }
.pill-maintenance, .pill-request { background: rgba(245, 158, 11, .18); color: var(--warn); }
.pill-ro { background: rgba(245, 158, 11, .18); color: var(--warn); }
.pill-full { background: rgba(37, 99, 235, .15); color: var(--primary); }

/* Fahrzeug-Thumbnail mit Hover-Zoom */
.thumb {
    width: 54px; height: 40px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: zoom-in;
}

/* Frei schwebende Bildvorschau beim Hover (nicht vom Tabellen-Overflow beschnitten) */
.thumb-preview {
    position: fixed;
    z-index: 2000;
    pointer-events: none;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    display: none;
}
.thumb-preview img {
    display: block;
    max-width: 260px;
    max-height: 260px;
    border-radius: 6px;
}
.thumb-empty {
    width: 54px; height: 40px; border-radius: 6px;
    border: 1px dashed var(--border);
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}

/* ============================================================
   Formulare
   ============================================================ */
.form-grid { display: flex; flex-direction: column; gap: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid label, .login-form label { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; }
.form-grid label > span, .login-form label > span { font-size: .85rem; color: var(--text-muted); }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="time"], input[type="file"], select, textarea {
    width: 100%;
    padding: .55rem .65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}
input:disabled, select:disabled { opacity: .6; }
.check-row { flex-direction: row !important; align-items: center; gap: .5rem; }
.check-row input { width: auto; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: .5rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; margin: 0; }
legend { font-size: .85rem; color: var(--text-muted); padding: 0 .4rem; }
.hint { font-size: .82rem; color: var(--text-muted); }
.duration-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .6rem .8rem;
    font-weight: 600;
}

/* Fahrer-Mehrfachauswahl (Chips) */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; min-height: 1.6rem; align-items: center; }
.chips-empty { font-size: .85rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .25rem .3rem .25rem .6rem;
    background: rgba(37, 99, 235, .12); color: var(--primary);
    border-radius: 999px; font-size: .85rem; font-weight: 600;
}
.chip-x {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border: none; border-radius: 50%;
    background: rgba(37, 99, 235, .18); color: var(--primary);
    font-size: 1rem; line-height: 1; cursor: pointer; padding: 0;
}
.chip-x:hover { background: var(--primary); color: #fff; }

/* Etappen (Segmente) im Buchungsformular */
.seg-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem 1rem; margin: 0; }
.seg-row legend { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .85rem; color: var(--text); padding: 0 .4rem; }
.seg-del { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: none; background: transparent; color: var(--danger); cursor: pointer; border-radius: 6px; }
.seg-del:hover { background: var(--danger-bg); }
.seg-del .icon { width: 15px; height: 15px; }
#addStop { align-self: flex-start; }
.seg-view { padding: .25rem 0; }
.seg-view + .seg-view { border-top: 1px dashed var(--border); }

/* Kalender-Event-Inhalt: Kennzeichen fett */
.fc-ev { font-size: .8rem; line-height: 1.2; padding: 1px 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-ev b { font-weight: 700; }
/* Tageszahl in der Monatsansicht links statt rechts */
.fc .fc-daygrid-day-top { flex-direction: row; }

/* ============================================================
   Fahrzeug-Timeline (Fahrzeugplan)
   ============================================================ */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .45rem .8rem; border: none; background: var(--surface);
    color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer;
}
.view-toggle button + button { border-left: 1px solid var(--border); }
.view-toggle button.active { background: var(--primary); color: #fff; }
.view-toggle .icon { width: 16px; height: 16px; }

.tl-toolbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tl-nav { display: inline-flex; gap: .3rem; }
.tl-title { font-weight: 600; font-size: 1.05rem; }
.tl-scroll { overflow-x: auto; }

.tl { --leftw: 150px; min-width: calc(var(--leftw) + var(--n) * 34px); font-size: .8rem; }
.tl-head { display: grid; grid-template-columns: var(--leftw) 1fr; position: sticky; top: 0; z-index: 2; }
.tl-corner { background: var(--surface-2); border: 1px solid var(--border); padding: .4rem .6rem; font-weight: 600; display: flex; align-items: flex-end; }
.tl-days { display: grid; grid-template-columns: repeat(var(--n), 1fr); }
.tl-day { border: 1px solid var(--border); border-left: none; padding: .25rem 0; text-align: center; line-height: 1.1; color: var(--text-muted); }
.tl-day span { display: block; font-size: .68rem; }
.tl-day.tl-we { background: var(--surface-2); }
.tl-day.tl-today { background: rgba(37, 99, 235, .14); color: var(--primary); font-weight: 700; }

.tl-group { background: var(--surface-2); border: 1px solid var(--border); border-top: none; padding: .3rem .6rem; font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.tl-row { display: grid; grid-template-columns: var(--leftw) 1fr; }
.tl-veh { border: 1px solid var(--border); border-top: none; padding: .4rem .6rem; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.tl-veh .tl-plate { font-size: .72rem; color: var(--text-muted); }
.tl-track {
    position: relative; border: 1px solid var(--border); border-top: none; border-left: none; min-height: 40px;
    background-image: repeating-linear-gradient(to right, var(--border) 0, var(--border) 1px, transparent 1px, transparent calc(100% / var(--n)));
}
.tl-bar {
    position: absolute; top: 5px; bottom: 5px; border-radius: 5px; padding: 0 .4rem;
    display: flex; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    cursor: pointer; color: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.tl-bar.tl-confirmed { background: #16a34a; }
.tl-bar.tl-request   { background: #eab308; color: #3a2e00; }
.tl-bar.tl-cancelled { background: #dc2626; }
.tl-bar:hover { filter: brightness(1.06); z-index: 3; }
.tl-bar[data-can="1"] { cursor: grab; }
.tl-bar.tl-dragging { cursor: grabbing; opacity: .85; z-index: 5; box-shadow: var(--shadow-lg); }

/* ============================================================
   Alerts / Toasts
   ============================================================ */
.alert { padding: .7rem .9rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 500; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-list { margin: .3rem 0 0; padding-left: 1.1rem; }

.toast-wrap {
    position: fixed;
    top: calc(var(--topbar-h) + 12px);
    right: 18px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: min(92vw, 380px);
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: .7rem .9rem;
    animation: toast-in .2s ease;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 4vh 1rem;
    z-index: 90;
    overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    animation: modal-in .18s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 1.25rem; }

/* ============================================================
   Login-Seite
   ============================================================ */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 1rem;
    background: linear-gradient(135deg, var(--bg), var(--surface-2));
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 100%; max-width: 380px;
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand .brand-icon { color: var(--primary); }
.login-brand h1 { margin: .5rem 0 0; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }

/* ============================================================
   Filterleiste (Kalender)
   ============================================================ */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
}
.filter-field { display: flex; flex-direction: column; gap: .3rem; min-width: 200px; }
.filter-field label {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .8rem; color: var(--text-muted); font-weight: 600;
}
.filter-field label .icon { width: 16px; height: 16px; }
.filter-bar #filterReset { margin-bottom: 1px; }
@media (max-width: 560px) {
    .filter-field { min-width: 100%; }
    .filter-bar #filterReset { width: 100%; }
}

/* ============================================================
   Kalender-Anpassungen
   ============================================================ */
#calendar { min-height: 60vh; }
.fc { --fc-border-color: var(--border); --fc-page-bg-color: var(--surface); font-family: var(--font); }
.fc .fc-toolbar-title { font-size: 1.2rem; }
.fc .fc-button {
    background: var(--surface-2); border-color: var(--border); color: var(--text);
    text-transform: capitalize; font-weight: 500;
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--border); }
.fc .fc-daygrid-day.fc-day-today, .fc .fc-timegrid-col.fc-day-today { background: rgba(37, 99, 235, .08); }
.fc-event { cursor: pointer; border: none; }

/* ============================================================
   Quill-Anpassungen (Dark-Mode-tauglich)
   ============================================================ */
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--border); }
.ql-container.ql-snow { border-bottom-left-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.ql-toolbar.ql-snow { border-top-left-radius: var(--radius-sm); border-top-right-radius: var(--radius-sm); background: var(--surface-2); }
.ql-editor { min-height: 130px; color: var(--text); }
[data-theme="dark"] .ql-snow .ql-stroke { stroke: var(--text-muted); }
[data-theme="dark"] .ql-snow .ql-fill { fill: var(--text-muted); }
[data-theme="dark"] .ql-snow .ql-picker { color: var(--text-muted); }
[data-theme="dark"] .ql-editor.ql-blank::before { color: var(--text-muted); }
.notes-view { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.notes-view p { margin: 0; }

/* ============================================================
   Statistik / Dashboard
   ============================================================ */
.stat-filter { align-items: flex-end; }
.stat-presets { display: flex; gap: .4rem; flex-wrap: wrap; margin-left: auto; }

/* KPI-Kacheln */
.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
}
.stat-tile-val { font-size: 1.7rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.stat-tile-lbl { margin-top: .35rem; font-weight: 600; font-size: .9rem; }
.stat-tile-sub { color: var(--text-muted); font-size: .8rem; margin-top: .1rem; }

/* Karten-Raster */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}
.stat-card { padding: 1.25rem; }
.stat-card-title { font-size: 1rem; margin: 0 0 1rem; }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; flex: 0 0 auto; }
.donut circle { transition: stroke-dasharray .4s ease; }
.donut-center { fill: var(--text); font-size: 24px; font-weight: 700; text-anchor: middle; }
.donut-sub { fill: var(--text-muted); font-size: 10px; text-anchor: middle; text-transform: uppercase; letter-spacing: .06em; }
.donut-legend { display: flex; flex-direction: column; gap: .5rem; flex: 1; min-width: 140px; }
.lg-row { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .9rem; }
.lg-dot { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.lg-val { margin-left: auto; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Horizontale Auslastungs-Balken */
.hbars { display: flex; flex-direction: column; gap: .9rem; }
.hbar-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.hbar-label { font-weight: 600; font-size: .9rem; }
.hbar-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: .25rem 0 .2rem; }
.hbar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s ease; }
.hbar-sub { font-size: .78rem; color: var(--text-muted); }
.hbar-note { margin: .9rem 0 0; font-size: .85rem; }

/* Säulen-Diagramm (Monat / Wochentag) */
.col-chart { display: flex; align-items: flex-end; gap: .5rem; height: 170px; padding-top: 1rem; }
.col-item { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.col-val { font-size: .72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-bottom: .2rem; }
.col-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.col-bar { width: 70%; max-width: 42px; background: var(--primary); border-radius: 4px 4px 0 0; transition: height .4s ease; }
.col-x { margin-top: .35rem; font-size: .75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Ranglisten (Ziele / Strecken) */
.rank-list { display: flex; flex-direction: column; gap: .55rem; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto; align-items: center; gap: .6rem; }
.rank-label { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.rank-bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.rank-count { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Flotte / TÜV-Erinnerungen */
.rem-group + .rem-group { margin-top: 1rem; }
.rem-group h4 { margin: 0 0 .5rem; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.rem-row { display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: .4rem; }
.rem-row .icon { width: 18px; height: 18px; flex: 0 0 auto; }
.rem-label { font-weight: 500; }
.rem-meta { margin-left: auto; font-size: .82rem; color: var(--text-muted); white-space: nowrap; }
.rem-critical { background: var(--danger-bg); }
.rem-critical .icon, .rem-critical .rem-meta { color: var(--danger); }
.rem-warning .icon, .rem-warning .rem-meta { color: var(--warn); }

/* ============================================================
   Responsive – Mobile
   ============================================================ */
@media (max-width: 820px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: var(--topbar-h) 1fr;
        grid-template-areas: "top" "main";
    }
    /* Mobiler Kopf: Menü-Button und Logo fließen nebeneinander in der Topbar */
    .topbar { padding: 0 1rem; gap: .5rem; }
    .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 38px; height: 38px; flex: 0 0 auto;
        border: 1px solid var(--border); background: var(--surface);
        color: var(--text); border-radius: var(--radius-sm); cursor: pointer;
    }
    .nav-toggle:hover { background: var(--surface-2); }
    .brand {
        position: static; height: auto; padding: 0;
        border: none; background: transparent; font-size: 1.05rem;
    }
    .sidebar {
        position: fixed;
        top: var(--topbar-h); bottom: 0; left: 0;
        width: 78%; max-width: 300px;
        transform: translateX(-100%);
        transition: transform .22s ease;
        z-index: 45;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: none; }
    .content { padding: 1rem; }
    .form-row { grid-template-columns: 1fr; }
    .user-name { display: none; }   /* Benutzer-Icon+Name mobil ausblenden (ohne Funktion); Logout bleibt */
    .sidebar-backdrop {
        position: fixed; inset: var(--topbar-h) 0 0 0;
        background: rgba(0,0,0,.4); z-index: 44;
    }

    /* Kalender-Toolbar mobil untereinander stapeln */
    .fc .fc-toolbar.fc-header-toolbar {
        flex-direction: column;
        align-items: center;
        gap: .6rem;
        margin-bottom: 1rem;
    }
    .fc .fc-toolbar-chunk {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: .3rem;
    }
    .fc .fc-toolbar-title { font-size: 1.1rem; text-align: center; }
    .fc .fc-button { padding: .4rem .6rem; font-size: .82rem; }
    /* Ansicht-Umschalter (Monat/Woche/…) darf umbrechen */
    .fc .fc-button-group { flex-wrap: wrap; justify-content: center; }
}
