/* =====================================================================
   Basis-Styles und Komponenten
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-md);
    line-height: var(--lh);
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }
a { color: var(--c-accent); }
code { font-family: var(--font-mono); font-size: 0.92em; background: var(--c-surface-3); padding: 1px 5px; border-radius: var(--r-xs); }
small { font-size: var(--fs-sm); }
.muted { color: var(--c-text-2); }
.subtle { color: var(--c-text-3); font-size: var(--fs-sm); }
.hidden { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.icon { width: 16px; height: 16px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
    min-height: 36px; padding: 0 var(--s-4);
    font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1;
    color: var(--c-text); background: var(--c-surface);
    border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
    user-select: none;
}
.btn:hover { background: var(--c-surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { color: var(--c-text-inverse); background: var(--c-accent); border-color: var(--c-accent); }
.btn-primary:hover { background: var(--c-accent-hover); border-color: var(--c-accent-hover); }
.btn-danger { color: var(--c-text-inverse); background: var(--c-danger); border-color: var(--c-danger); }
.btn-danger:hover { background: var(--c-danger-hover); border-color: var(--c-danger-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--c-text-2); }
.btn-ghost:hover { background: var(--c-surface-3); color: var(--c-text); }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--c-accent); font-weight: 600; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-sm { min-height: 30px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; min-height: 42px; }
.btn .icon { width: 16px; height: 16px; flex: none; }

/* ---------- Formulare ---------- */
.form-stack { display: flex; flex-direction: column; gap: var(--s-4); }
.form-row { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: flex-end; }
.form-row > .field { flex: 1 1 180px; }
.field { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); }
.field-label small { font-weight: 400; color: var(--c-text-3); }
.field-hint { font-size: var(--fs-xs); color: var(--c-text-3); }

.input, .select, .textarea {
    width: 100%; min-height: 38px; padding: 7px 10px;
    font: inherit; font-size: var(--fs-md); color: var(--c-text);
    background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--c-text-3); }
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-focus-ring);
}
.textarea { min-height: 80px; resize: vertical; line-height: var(--lh); }
.input-sm { min-height: 30px; padding: 4px 8px; font-size: var(--fs-sm); }

.check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-size: var(--fs-md); }
.check input { width: 18px; height: 18px; accent-color: var(--c-accent); margin: 0; }

/* ---------- Hinweise ---------- */
.alert {
    padding: var(--s-3) var(--s-4); border-radius: var(--r-sm);
    border: 1px solid transparent; font-size: var(--fs-sm);
}
.alert p { margin: 0 0 var(--s-1); }
.alert-danger { background: var(--c-danger-soft); color: var(--c-danger); border-color: #f4c3bf; }
.alert-info { background: var(--c-info-soft); color: var(--c-info); border-color: #c8dbf3; }
.alert-warn { background: var(--c-warn-soft); color: var(--c-warn); border-color: var(--c-warn-border); }
.alert-success { background: var(--c-success-soft); color: var(--c-success); border-color: #bfe1cb; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: var(--s-1);
    height: 22px; padding: 0 var(--s-2);
    font-size: var(--fs-xs); font-weight: 600; line-height: 1;
    color: var(--c-text-2); background: var(--c-surface-3);
    border: 1px solid transparent; border-radius: var(--r-pill); white-space: nowrap;
}
.badge-accent  { color: var(--c-accent-text); background: var(--c-accent-soft); }
.badge-warn    { color: var(--c-warn); background: var(--c-warn-soft); border-color: var(--c-warn-border); }
.badge-editing { color: var(--c-editing); background: var(--c-editing-soft); }
.badge-holiday { color: var(--c-holiday); background: var(--c-holiday-soft); }

/* ---------- Karten ---------- */
.card {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--r-md); box-shadow: var(--sh-1);
}
.card-body { padding: var(--s-5); }
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
    padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border);
}

.empty {
    padding: var(--s-8) var(--s-4); text-align: center; color: var(--c-text-3);
    border: 1px dashed var(--c-border-strong); border-radius: var(--r-md); background: var(--c-surface-2);
}
.empty strong { display: block; color: var(--c-text-2); font-size: var(--fs-lg); margin-bottom: var(--s-1); }

/* ---------- Tabellen ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table th, .table td { padding: var(--s-3) var(--s-4); text-align: left; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table th { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-3); background: var(--c-surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: var(--s-2); }
.table-wrap { overflow-x: auto; position: relative; }
.show-sm { display: none; }

/* =====================================================================
   App-Layout
   ===================================================================== */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: var(--s-4);
    height: var(--topbar-h); padding: 0 var(--s-5);
    padding-left: max(var(--s-5), env(safe-area-inset-left));
    padding-right: max(var(--s-5), env(safe-area-inset-right));
    background: var(--c-surface); border-bottom: 1px solid var(--c-border);
}
.brand { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; font-size: var(--fs-md); color: var(--c-text); text-decoration: none; white-space: nowrap; }
.brand-mark {
    width: 22px; height: 22px; border-radius: 6px; flex: none;
    background: linear-gradient(135deg, var(--c-accent) 0 50%, #2a9a94 50% 100%);
}
.nav { display: flex; gap: var(--s-1); margin-left: var(--s-4); }
.nav a {
    display: inline-flex; align-items: center; height: 34px; padding: 0 var(--s-3);
    font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); text-decoration: none;
    border-radius: var(--r-sm); transition: background var(--t-fast), color var(--t-fast);
}
@media (hover: hover) { .nav a:hover { background: var(--c-surface-3); color: var(--c-text); } }
.nav a[aria-current="page"] { background: var(--c-accent-soft); color: var(--c-accent-text); }
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--c-text-2); }
.topbar-user form { margin: 0; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%;
    font-size: var(--fs-xs); font-weight: 700; color: var(--c-accent-text); background: var(--c-accent-soft);
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-success); flex: none; }
.sync-dot.is-offline { background: var(--c-danger); }

.view {
    flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto;
    padding: var(--s-5);
    padding-left: max(var(--s-5), env(safe-area-inset-left));
    padding-right: max(var(--s-5), env(safe-area-inset-right));
    outline: none;
}

/* ---------- Ansichts-Kopf mit Datumsnavigation ---------- */
.view-header {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s-4);
    margin-bottom: var(--s-5);
}
.view-header-left { justify-self: start; display: flex; gap: var(--s-2); flex-wrap: wrap; }
.view-header-right { justify-self: end; display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: flex-end; }
.date-nav { display: flex; align-items: center; gap: var(--s-2); }
.date-nav-title {
    min-width: 260px; text-align: center; font-size: var(--fs-xl); font-weight: 600;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.date-nav-title .subtle { font-weight: 400; }
.date-nav-tools { display: flex; align-items: center; justify-content: center; gap: var(--s-2); margin-top: var(--s-2); }
.date-input { width: auto; min-height: 30px; padding: 3px 8px; font-size: var(--fs-sm); }

/* ---------- Verwaltung ---------- */
.admin { display: grid; grid-template-columns: 220px 1fr; gap: var(--s-5); align-items: start; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-h) + var(--s-5)); }
.admin-nav a {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
    font-size: var(--fs-md); font-weight: 500; color: var(--c-text-2); text-decoration: none;
}
.admin-nav a:hover { background: var(--c-surface-3); color: var(--c-text); }
.admin-nav a[aria-current="page"] { background: var(--c-surface); color: var(--c-accent-text); font-weight: 600; box-shadow: var(--sh-1); }
.admin-main { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }

/* ---------- Dialoge ---------- */
.dialog {
    width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
    padding: 0; border: 0; border-radius: var(--r-lg);
    background: var(--c-surface); color: var(--c-text); box-shadow: var(--sh-3);
}
.dialog-wide { width: min(880px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(20, 28, 38, 0.38); }
.dialog[open] { display: flex; flex-direction: column; animation: dialog-in var(--t-med); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border); }
.dialog-body { padding: var(--s-5); overflow: auto; }
.dialog-footer { display: flex; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap; padding: var(--s-4) var(--s-5); border-top: 1px solid var(--c-border); background: var(--c-surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.dialog-footer .spacer { flex: 1; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed; z-index: 1000; left: 50%; bottom: max(var(--s-5), env(safe-area-inset-bottom));
    transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--s-2); align-items: center;
    pointer-events: none; width: min(480px, calc(100vw - 32px));
}
.toast {
    pointer-events: auto; display: flex; align-items: center; gap: var(--s-3);
    padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
    font-size: var(--fs-sm); color: #fff; background: #26303a; box-shadow: var(--sh-3);
    animation: toast-in var(--t-med);
}
.toast-error { background: var(--c-danger); }
.toast-warn { background: var(--c-warn); }
.toast-success { background: var(--c-success); }
.toast .btn-link { color: #fff; text-decoration: underline; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Ladezustand ---------- */
.loading { padding: var(--s-8); text-align: center; color: var(--c-text-3); }
.spinner {
    display: inline-block; width: 18px; height: 18px; vertical-align: middle;
    border: 2px solid var(--c-border-strong); border-top-color: var(--c-accent);
    border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Anmeldung / Einrichtung ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--s-4); }
.auth-card {
    width: 100%; max-width: 400px; padding: var(--s-7);
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-2);
    display: flex; flex-direction: column; gap: var(--s-4);
}
.auth-brand { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; color: var(--c-text-2); }
.auth-title { font-size: var(--fs-2xl); }

/* =====================================================================
   Tagesansicht
   ===================================================================== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.toolbar-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.day-list { display: flex; flex-direction: column; gap: var(--s-4); }
.day-row {
    display: grid; gap: var(--s-4); align-items: stretch;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 1.25fr) minmax(0, 1fr);
}
.notes-col { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }

.appt-tile {
    position: relative; display: flex; flex-direction: column; gap: var(--s-2);
    min-height: 112px; padding: var(--s-4) var(--s-5);
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
    box-shadow: var(--sh-1); cursor: pointer;
    transition: box-shadow var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.appt-tile::before {
    content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 4px;
    border-radius: 0 4px 4px 0; background: var(--c-accent);
}
.appt-tile:hover { box-shadow: var(--sh-2); border-color: var(--c-border-strong); }
.appt-tile:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.icon { width: 16px; height: 16px; flex: none; }
.appt-tile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); }
.appt-title { font-size: var(--fs-lg); font-weight: 650; overflow-wrap: anywhere; }
.appt-tile-head .badge { flex: none; margin-top: 2px; }
.appt-meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); font-size: var(--fs-sm); color: var(--c-text-2); }
.appt-time, .appt-hours { display: inline-flex; align-items: center; gap: var(--s-1); font-variant-numeric: tabular-nums; }
.appt-time::before, .appt-hours::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c-border-strong); }
.appt-fleets { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: auto; padding-top: var(--s-2); }
.fleet-badge { cursor: pointer; height: 26px; padding: 0 var(--s-3); font-size: var(--fs-sm); }
.fleet-badge:hover { background: #d3e9e7; }

/* ---------- Monatskalender ---------- */
.month-picker {
    padding: var(--s-3); border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface-2);
    user-select: none; -webkit-user-select: none;
}
.mp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); }
.mp-title { font-weight: 600; }
.mp-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; touch-action: none; }
.mp-dow { text-align: center; font-size: var(--fs-xs); font-weight: 600; color: var(--c-text-3); padding: 2px 0 4px; }
.mp-day {
    height: 36px; border: 1px solid transparent; border-radius: var(--r-sm);
    font: inherit; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: var(--c-text);
    background: var(--c-surface); cursor: pointer; transition: background var(--t-fast);
}
.mp-day:hover { border-color: var(--c-border-strong); }
.mp-day.is-outside { background: transparent; cursor: default; }
.mp-day.is-today { border-color: var(--c-accent); font-weight: 700; }
.mp-day.is-holiday { color: var(--c-holiday); background: var(--c-holiday-soft); }
.mp-day.is-selected { color: #fff; background: var(--c-accent); border-color: var(--c-accent); font-weight: 600; }
.mp-foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--s-2); }
.mp-hint { margin-top: var(--s-1); font-size: var(--fs-xs); }

/* ---------- Termin-Dialog ---------- */
.appt-edit-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.appt-days { display: flex; flex-direction: column; gap: var(--s-2); }
.appt-days-empty { padding: var(--s-5); border: 1px dashed var(--c-border-strong); border-radius: var(--r-md); text-align: center; }
.appt-day-row { display: grid; grid-template-columns: minmax(96px, 1fr) 72px 112px 112px 30px; gap: var(--s-2); align-items: center; }
.appt-day-row > * { min-width: 0; }
.appt-day-head { font-size: var(--fs-xs); font-weight: 600; color: var(--c-text-3); text-transform: uppercase; letter-spacing: .04em; }
.appt-day-label { display: flex; align-items: center; gap: var(--s-1); flex-wrap: wrap; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.appt-copy { align-self: flex-start; font-size: var(--fs-sm); margin-top: var(--s-1); }
.appt-delete { color: var(--c-danger); }
.appt-delete:hover { background: var(--c-danger-soft); color: var(--c-danger); }

/* =====================================================================
   Notizen
   ===================================================================== */
.notes-col { position: relative; padding: 2px 0; }
.note {
    position: relative; display: flex; align-items: flex-start; gap: 2px;
    padding: 5px 4px 5px 2px; min-height: 36px;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-sm);
    font-size: var(--fs-sm); transition: border-color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.note:hover { border-color: var(--c-border-strong); }
.note:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-focus-ring); }
.note.is-dragging { opacity: .4; }
.note.is-saving::after, .note.is-saved::after, .note.is-error::after {
    content: ""; position: absolute; right: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%;
}
.note.is-saving::after { background: var(--c-warn-border); }
.note.is-saved::after { background: var(--c-success); }
.note.is-error::after { background: var(--c-danger); }

.note-handle {
    flex: none; display: flex; align-items: center; justify-content: center;
    width: 16px; height: 26px; color: var(--c-text-3); cursor: grab; opacity: 0; transition: opacity var(--t-fast);
}
.note-handle .icon { width: 14px; height: 14px; }
.note:hover .note-handle, .note:focus-within .note-handle { opacity: 1; }
.note-handle:active { cursor: grabbing; }

.note-body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; padding-left: 2px; }
.note-label { font-weight: 600; color: var(--c-text-2); padding: 3px 0; white-space: nowrap; }
.note-label::after { content: ":"; }
.note-input {
    flex: 1 1 120px; min-width: 0; min-height: 26px; padding: 3px 4px; margin: 0;
    font: inherit; line-height: 1.4; color: var(--c-text);
    border: 0; border-radius: var(--r-xs); background: transparent; resize: none; overflow: hidden;
}
.note-input:hover { background: var(--c-surface-2); }
.note-input:focus { outline: none; background: var(--c-surface-2); }
.note-input::placeholder { color: var(--c-text-3); }
.note-select {
    flex: none; max-width: 100%; height: 26px; padding: 0 22px 0 9px;
    font: inherit; font-size: var(--fs-sm); font-weight: 600;
    border: 1px solid transparent; border-radius: var(--r-pill); cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: right 11px center, right 7px center; background-size: 4px 4px; background-repeat: no-repeat;
}
.note-select:focus { outline: none; box-shadow: 0 0 0 3px var(--c-focus-ring); }
.note-select.opt-none { background-color: var(--c-surface-3); color: var(--c-text-3); border-color: var(--c-border); }
.note-select option { background: #fff; color: var(--c-text); font-weight: 400; }
.note-extra { flex: 1 1 100px; }
@media (hover: hover) {
    .note:not(:hover):not(:focus-within) .note-extra:placeholder-shown::placeholder { color: transparent; }
}

.note-actions { flex: none; display: flex; align-items: center; }
.note-actions .btn-sm { min-height: 26px; height: 26px; width: 26px; }
.note-menu-btn { font-size: 18px; line-height: 1; letter-spacing: 1px; color: var(--c-text-3); opacity: 0; }
.note:hover .note-menu-btn, .note:focus-within .note-menu-btn, .note-menu-btn:focus { opacity: 1; }

.note-add {
    display: inline-flex; align-items: center; gap: 4px; align-self: flex-start;
    height: 28px; padding: 0 var(--s-2); margin-top: 2px;
    font: inherit; font-size: var(--fs-xs); font-weight: 600; color: var(--c-text-3);
    background: none; border: 1px dashed transparent; border-radius: var(--r-sm); cursor: pointer;
    opacity: 0; transition: opacity var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.note-add .icon { width: 14px; height: 14px; }
.day-row:hover .note-add, .note-add:focus-visible, .appt-notes-section .note-add, .notes-col:not(:has(.note)) .note-add { opacity: 1; }
.note-add:hover { color: var(--c-accent); border-color: var(--c-border-strong); }
.notes-col.is-drop-target { background: var(--c-accent-softer); border-radius: var(--r-sm); }
.note-drop-indicator { height: 3px; margin: -2px 0; border-radius: 2px; background: var(--c-accent); }

/* Farben der Dropdown-Optionen */
.opt-grau    { background-color: var(--opt-grau-bg);    color: var(--opt-grau-fg); }
.opt-gruen   { background-color: var(--opt-gruen-bg);   color: var(--opt-gruen-fg); }
.opt-gelb    { background-color: var(--opt-gelb-bg);    color: var(--opt-gelb-fg); }
.opt-orange  { background-color: var(--opt-orange-bg);  color: var(--opt-orange-fg); }
.opt-rot     { background-color: var(--opt-rot-bg);     color: var(--opt-rot-fg); }
.opt-blau    { background-color: var(--opt-blau-bg);    color: var(--opt-blau-fg); }
.opt-tuerkis { background-color: var(--opt-tuerkis-bg); color: var(--opt-tuerkis-fg); }
.opt-lila    { background-color: var(--opt-lila-bg);    color: var(--opt-lila-fg); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; flex: none; }
.opt-pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* Optionen-Editor */
.opt-editor { display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-start; }
.opt-rows { display: flex; flex-direction: column; gap: var(--s-2); width: 100%; }
.opt-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) minmax(0, 140px) 30px 30px 30px; gap: var(--s-2); align-items: center; }
.opt-row-simple { grid-template-columns: 38px 1fr; }
.opt-row .opt-pill { justify-self: start; }
.color-btn { padding: 0; }

/* Menü */
.menu {
    position: fixed; z-index: 2000; min-width: 200px; padding: var(--s-1);
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); box-shadow: var(--sh-3);
}
.menu-item {
    display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: 34px; padding: 0 var(--s-3);
    font: inherit; font-size: var(--fs-sm); color: var(--c-text); text-align: left;
    background: none; border: 0; border-radius: var(--r-sm); cursor: pointer;
}
.menu-item .icon { width: 16px; height: 16px; color: var(--c-text-3); }
.menu-item:hover, .menu-item:focus { background: var(--c-surface-3); outline: none; }
.menu-item.is-danger { color: var(--c-danger); }
.menu-item.is-danger .icon { color: var(--c-danger); }
.menu-item.is-active { font-weight: 700; }
.menu-item:disabled { opacity: .45; cursor: default; }
.menu-sep { height: 1px; margin: var(--s-1) 0; background: var(--c-border); }

/* Notiz hinzufügen */
.tpl-group-title { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-3); margin-bottom: var(--s-2); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-2); }
.tpl-choice {
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 48px; padding: var(--s-2) var(--s-3);
    font: inherit; text-align: left; color: var(--c-text);
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-sm); cursor: pointer;
    transition: border-color var(--t-fast), background var(--t-fast);
}
.tpl-choice:hover { border-color: var(--c-accent); background: var(--c-accent-softer); }
.tpl-choice-label { font-weight: 600; }
.tpl-choice-opts { display: flex; flex-wrap: wrap; gap: 4px; }
.tpl-free { flex-direction: row; align-items: center; border-style: dashed; color: var(--c-accent-text); }

/* Notizen im Termin-Dialog */
.appt-notes-section { display: flex; flex-direction: column; gap: var(--s-2); padding-top: var(--s-4); border-top: 1px solid var(--c-border); }
.appt-notes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.appt-notes-side { margin-bottom: var(--s-1); font-size: var(--fs-xs); }
.appt-notes-section .notes-col { gap: var(--s-2); min-height: 40px; }

/* Vorlagen-Verwaltung */
.tpl-list { display: flex; flex-direction: column; gap: var(--s-2); }
.tpl-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); }
.tpl-card-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tpl-card-title { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.tpl-card-title strong { font-size: var(--fs-md); }
.tpl-card-opts { display: flex; flex-wrap: wrap; gap: 4px; }
.tpl-card-actions { display: flex; gap: var(--s-1); align-items: center; }
.tpl-order { display: flex; flex-direction: column; }
.tpl-order .btn { min-height: 22px; height: 22px; }

/* =====================================================================
   Flottenansicht
   ===================================================================== */
.toolbar-title { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; }
.view-title { font-size: var(--fs-xl); }
.fleet-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s-5); align-items: start; }
.fleet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: var(--s-4); align-content: start; }
.fleet-grid > .empty, .fleet-grid > .loading { grid-column: 1 / -1; }

.fleet-card {
    position: relative; display: flex; flex-direction: column; gap: var(--s-3);
    padding: var(--s-4); min-height: 180px;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); box-shadow: var(--sh-1);
    transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.fleet-card::before { content: ""; position: absolute; left: 16px; right: 16px; top: -1px; height: 3px; border-radius: 0 0 3px 3px; background: var(--c-accent); }
.fleet-card.is-drop-target { border-color: var(--c-accent); background: var(--c-accent-softer); box-shadow: 0 0 0 3px var(--c-focus-ring); }
.is-dragging-emp .fleet-card:not(.is-drop-target) { border-style: dashed; border-color: var(--c-border-strong); }
.fleet-card.is-saving::after, .fleet-card.is-saved::after, .fleet-card.is-error::after { content: ""; position: absolute; right: 8px; bottom: 8px; width: 8px; height: 8px; border-radius: 50%; }
.fleet-card.is-saving::after { background: var(--c-warn-border); }
.fleet-card.is-saved::after { background: var(--c-success); }
.fleet-card.is-error::after { background: var(--c-danger); }

.fleet-head { display: flex; align-items: center; gap: var(--s-2); }
.fleet-name {
    flex: 1; min-width: 0; padding: 4px 6px; margin-left: -6px;
    font: inherit; font-size: var(--fs-lg); font-weight: 650; color: var(--c-text);
    background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
}
.fleet-name:hover { background: var(--c-surface-2); }
.fleet-name:focus { outline: none; border-color: var(--c-accent); background: var(--c-surface); box-shadow: 0 0 0 3px var(--c-focus-ring); }

.fleet-apps { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.fleet-app-select { width: auto; max-width: 100%; min-width: 0; text-overflow: ellipsis; min-height: 30px; padding: 3px 8px; font-size: var(--fs-sm); color: var(--c-text-2); background: var(--c-surface-2); }
.app-chip {
    display: inline-flex; align-items: center; gap: 2px; max-width: 100%; height: 28px; padding: 0 2px 0 10px;
    font-size: var(--fs-sm); font-weight: 600; color: var(--c-accent-text); background: var(--c-accent-soft); border-radius: var(--r-sm);
}
.app-chip-label { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-chip-label:hover { text-decoration: underline; }

.fleet-emps { display: flex; flex-wrap: wrap; gap: 6px; min-height: 34px; align-content: flex-start; }
.fleet-empty { padding: var(--s-2) 0; }
.chip {
    display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 30px; padding: 0 4px 0 10px;
    font-size: var(--fs-sm); font-weight: 500; color: var(--c-text);
    background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-pill);
    cursor: grab; user-select: none;
}
.chip-sm { height: 24px; padding: 0 8px; font-size: var(--fs-xs); cursor: default; }
.chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-flag { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; font-size: 11px; font-weight: 700; color: #fff; background: var(--c-warn); }
.chip.is-absent-chip .chip-label { text-decoration: line-through; color: var(--c-text-3); }
.chip.is-archived .chip-label { font-style: italic; color: var(--c-text-3); }
.chip-x {
    display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0;
    color: var(--c-text-3); background: none; border: 0; border-radius: 50%; cursor: pointer;
}
.chip-x .icon { width: 13px; height: 13px; }
.chip-x:hover { background: rgba(0,0,0,.07); color: var(--c-text); }
.fleet-note {
    width: 100%; min-height: 60px; margin-top: auto; padding: var(--s-2) var(--s-3);
    font: inherit; font-size: var(--fs-sm); line-height: 1.45; color: var(--c-text);
    background: var(--c-surface-2); border: 1px solid transparent; border-radius: var(--r-sm); resize: none; overflow: hidden;
}
.fleet-note:hover { border-color: var(--c-border); }
.fleet-note:focus { outline: none; background: var(--c-surface); border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-focus-ring); }

/* Mitarbeiterliste */
.emp-panel {
    position: sticky; top: calc(var(--topbar-h) + var(--s-4));
    display: flex; flex-direction: column; max-height: calc(100vh - var(--topbar-h) - var(--s-6));
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); box-shadow: var(--sh-1);
    transition: border-color var(--t-fast), background var(--t-fast);
}
.emp-panel-head { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-2); border-bottom: 1px solid var(--c-border); }
.emp-panel-title { font-size: var(--fs-md); }
.check-sm { font-size: var(--fs-sm); color: var(--c-text-2); }
.check-sm input { width: 16px; height: 16px; }
.emp-list { flex: 1; overflow-y: auto; padding: var(--s-1); overscroll-behavior: contain; }
.emp-item {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 6px var(--s-2); min-height: 34px;
    border-radius: var(--r-sm); cursor: grab; user-select: none; font-size: var(--fs-sm);
}
.emp-item:hover { background: var(--c-surface-3); }
.emp-item:focus-visible { outline: 2px solid var(--c-accent); outline-offset: -2px; }
.emp-name { font-weight: 600; }
.emp-note { font-size: var(--fs-xs); color: var(--c-text-3); }
.emp-fleets { flex-basis: 100%; font-size: var(--fs-xs); color: var(--c-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emp-flag { margin-left: auto; font-size: var(--fs-xs); font-weight: 600; color: var(--c-text-3); }
.emp-flag-warn { color: var(--c-warn); }
.emp-item.is-assigned .emp-name { color: var(--c-muted-state); font-weight: 500; }
.emp-item.is-double { background: var(--c-warn-soft); }
.emp-item.is-double .emp-name { color: var(--c-warn); font-weight: 600; }
.emp-item.is-absent .emp-name { text-decoration: line-through; color: var(--c-text-3); font-weight: 400; }
.emp-sep { margin: var(--s-2) var(--s-2) var(--s-1); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-3); }
.emp-empty { padding: var(--s-4); text-align: center; }
.emp-drop-hint { display: none; padding: var(--s-3); text-align: center; font-size: var(--fs-sm); font-weight: 600; color: var(--c-accent-text); border-top: 1px dashed var(--c-accent); }
.is-dragging-from-fleet .emp-drop-hint { display: block; }
.emp-panel.is-drop-target { border-color: var(--c-accent); background: var(--c-accent-softer); }

.chip.is-double, .emp-item.is-double { border-color: var(--c-warn-border); }
.chip.is-double { background: var(--c-warn-soft); color: var(--c-warn); font-weight: 600; }

/* Segment-Tabs (nur Handy) */
.seg-tabs { display: none; }
.seg-tab {
    flex: 1; min-height: 40px; font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2);
    background: none; border: 0; border-radius: var(--r-sm); cursor: pointer;
}
.seg-tab.is-active { background: var(--c-surface); color: var(--c-accent-text); box-shadow: var(--sh-1); }

/* Bottom-Sheet-Liste */
.sheet-list { display: flex; flex-direction: column; gap: var(--s-2); }
.sheet-item {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
    min-height: 52px; padding: 0 var(--s-4); font: inherit; text-align: left; color: var(--c-text);
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); cursor: pointer;
}
.sheet-item:hover { border-color: var(--c-accent); }
.sheet-item:disabled { opacity: .55; cursor: default; }
.sheet-item-title { font-weight: 600; }

/* Übernehmen-Dialog */
.copy-list { display: flex; flex-direction: column; gap: var(--s-2); }
.copy-head { display: flex; align-items: center; justify-content: space-between; }
.copy-item { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3); border: 1px solid var(--c-border); border-radius: var(--r-md); cursor: pointer; }
.copy-item:has(input:checked) { border-color: var(--c-accent); background: var(--c-accent-softer); }
.copy-item input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--c-accent); flex: none; }
.copy-item-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.copy-emps { display: flex; flex-wrap: wrap; gap: 4px; }
.copy-note { white-space: pre-line; }

/* Popover (Flotten-Badge) */
.popover { min-width: 220px; max-width: 320px; padding: var(--s-3); }
.popover h4 { font-size: var(--fs-sm); margin-bottom: var(--s-2); }
.popover ul { list-style: none; margin: 0 0 var(--s-2); padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); }
.popover .is-absent { text-decoration: line-through; color: var(--c-text-3); }

/* =====================================================================
   Wochenansicht
   ===================================================================== */
.week { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); box-shadow: var(--sh-1); overflow: hidden; }
.week-head { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-bottom: 1px solid var(--c-border); }
.week-day-head {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: var(--s-3) var(--s-4);
    color: var(--c-text); text-decoration: none; border-left: 1px solid var(--c-border);
    transition: background var(--t-fast);
}
.week-day-head:first-child { border-left: 0; }
.week-day-head:hover { background: var(--c-surface-2); }
.week-dow { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-3); }
.week-date { font-size: var(--fs-xl); font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.15; }
.week-day-meta { font-size: var(--fs-xs); color: var(--c-text-3); }
.week-day-head .badge { margin-top: 2px; }
.week-day-head.is-today .week-date {
    display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; border-radius: var(--r-pill);
    color: #fff; background: var(--c-accent);
}
.week-day-head.is-today .week-dow { color: var(--c-accent-text); }

.week-grid {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); min-height: 440px; padding-bottom: var(--s-3);
}
.week-col { border-left: 1px solid var(--c-border); cursor: pointer; transition: background var(--t-fast); }
.week-col:first-child { border-left: 0; }
.week-col:hover { background: var(--c-surface-2); }
.week-col.is-today { background: var(--c-accent-softer); }
.week-col.is-holiday { background: repeating-linear-gradient(135deg, transparent 0 10px, var(--c-holiday-soft) 10px 20px); }

.week-bar {
    position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; gap: 1px;
    min-width: 0; margin: 4px 6px; padding: 6px 10px 6px 12px;
    font: inherit; text-align: left; color: var(--c-text);
    background: var(--c-surface); border: 1px solid var(--c-border-strong); border-left: 4px solid var(--c-accent);
    border-radius: var(--r-sm); box-shadow: var(--sh-1); cursor: pointer;
    transition: box-shadow var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.week-bar:hover { box-shadow: var(--sh-2); border-color: var(--c-accent); border-left-color: var(--c-accent); }
.week-bar.cont-left { border-left-style: dashed; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.week-bar.cont-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.week-bar.cont-right::after {
    content: "›"; position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    font-size: 18px; line-height: 1; color: var(--c-text-3);
}
.week-bar-title { font-size: var(--fs-sm); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.week-bar-meta { font-size: var(--fs-xs); color: var(--c-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.week-empty { padding: var(--s-4); text-align: center; }

/* Agenda (Handy) */
.agenda { display: flex; flex-direction: column; gap: var(--s-3); }
.agenda-day { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); overflow: hidden; }
.agenda-day .week-day-head { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; border-left: 0; border-bottom: 1px solid var(--c-border); background: var(--c-surface-2); }
.agenda-day .week-date { font-size: var(--fs-lg); }
.agenda-item {
    display: flex; flex-direction: column; gap: 2px; width: 100%; min-height: 52px; padding: var(--s-2) var(--s-4) var(--s-2) var(--s-4);
    font: inherit; text-align: left; color: var(--c-text); background: none; border: 0; border-bottom: 1px solid var(--c-border);
    border-left: 4px solid var(--c-accent); cursor: pointer;
}
.agenda-item:last-child { border-bottom: 0; }
.agenda-empty { padding: var(--s-3) var(--s-4); }

/* =====================================================================
   Zustände (werden in mehreren Ansichten verwendet)
   ===================================================================== */
.is-assigned { color: var(--c-muted-state); }
.is-absent   { color: var(--c-text-3); text-decoration: line-through; }
.is-double   { background: var(--c-warn-soft) !important; border-color: var(--c-warn-border) !important; color: var(--c-warn) !important; }
.is-editing  { box-shadow: 0 0 0 2px var(--c-editing), var(--sh-2) !important; }

/* =====================================================================
   Responsiv
   ===================================================================== */
@media (max-width: 900px) {
    .admin { grid-template-columns: 1fr; }
    .admin-nav { position: static; flex-direction: row; overflow-x: auto; gap: var(--s-1); padding-bottom: var(--s-1); }
    .admin-nav a { white-space: nowrap; }
    .view-header { grid-template-columns: 1fr 1fr; gap: var(--s-3); }
    .view-header-center { grid-column: 1 / -1; order: -1; justify-self: center; }
    .view-header-left, .view-header-right { justify-self: stretch; }
    .view-header-left > *, .view-header-right > * { flex: 1; }
}

@media (max-width: 1100px) {
    .fleet-layout { grid-template-columns: minmax(0, 1fr) 260px; gap: var(--s-4); }
    .day-row { grid-template-columns: minmax(0, 1fr) minmax(280px, 1.4fr) minmax(0, 1fr); gap: var(--s-3); }
}
@media (max-width: 760px) {
    .day-row { grid-template-columns: 1fr; gap: var(--s-2); }
    .day-row .appt-tile { order: -1; min-height: 0; }
    .day-row .notes-col { gap: 0; }
    .day-row .notes-col .note { border-radius: 0; margin-top: -1px; }
    .day-row .notes-left .note-add { display: none; }
    .day-row .notes-left:not(:has(.note)) { display: none; }
    .note-add { opacity: 1; height: 40px; }
    .note-menu-btn { opacity: 1; }
    .note-actions .btn-sm { width: 36px; height: 36px; min-height: 36px; }
    .note { min-height: 44px; }
    .note-input, .note-select { min-height: 32px; font-size: 16px; }
    .note-select { height: 32px; }
    .appt-notes-grid { grid-template-columns: 1fr; }
    .opt-row { grid-template-columns: 36px minmax(0, 1fr) 36px 36px 36px; }
    .opt-row .opt-pill { display: none; }
    .tpl-card { grid-template-columns: minmax(0, 1fr) auto; }
    .seg-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: var(--s-3); background: var(--c-surface-3); border-radius: var(--r-md); }
    .fleet-layout { grid-template-columns: 1fr; }
    .fleet-layout[data-tab="fleets"] .emp-panel { display: none; }
    .fleet-layout[data-tab="employees"] .fleet-grid { display: none; }
    .emp-panel { position: static; max-height: none; }
    .emp-item { min-height: 48px; cursor: pointer; }
    .fleet-grid { grid-template-columns: minmax(0, 1fr); }
    .chip { height: 36px; cursor: pointer; padding: 0 12px; }
    .fleet-app-select { min-height: 36px; font-size: 16px; }
    .fleet-name, .fleet-note { font-size: 16px; }
    .toolbar .toolbar-actions { width: 100%; }
    .toolbar .toolbar-actions .btn { flex: 1; }
    .tpl-order { display: none; }
    .appt-edit-grid { grid-template-columns: 1fr; }
    .appt-day-head { display: none; }
    .appt-day-row {
        grid-template-columns: 72px 1fr 1fr; grid-template-areas: "label label remove" "hours from to";
        gap: var(--s-2); padding: var(--s-2) 0; border-bottom: 1px solid var(--c-border);
    }
    .appt-day-row > :nth-child(1) { grid-area: label; }
    .appt-day-row > :nth-child(2) { grid-area: hours; }
    .appt-day-row > :nth-child(3) { grid-area: from; }
    .appt-day-row > :nth-child(4) { grid-area: to; }
    .appt-day-row > :nth-child(5) { grid-area: remove; justify-self: end; }
    .mp-day { height: 42px; }
}

@media (max-width: 640px) {
    :root { --topbar-h: 52px; }
    .topbar { gap: var(--s-2); padding-left: max(var(--s-3), env(safe-area-inset-left)); padding-right: max(var(--s-3), env(safe-area-inset-right)); }
    .brand-name, .topbar-user .username, .topbar-user .avatar { display: none; }
    .nav { margin-left: 0; gap: 0; }
    .nav a { padding: 0 var(--s-2); }
    .hide-sm { display: none !important; }
    .btn-sm .btn-label { display: none; }
    .btn-sm:has(.btn-label) { width: 36px; padding: 0; }
    .view { padding: var(--s-3); }
    .btn { min-height: var(--tap); }
    .btn-sm { min-height: 36px; }
    .btn-icon { width: var(--tap); }
    .input, .select, .textarea { min-height: var(--tap); font-size: 16px; } /* 16px verhindert Zoom auf iOS */
    .date-nav-title { min-width: 0; font-size: var(--fs-lg); }
    .card-body { padding: var(--s-4); }
    .table th, .table td { padding: var(--s-2) var(--s-3); }
    .dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
    .dialog-footer { border-radius: 0; padding-bottom: max(var(--s-4), env(safe-area-inset-bottom)); }
    .auth-card { padding: var(--s-5); }
}

.fleet-badge { border: 0; font-family: inherit; }
.fleet-badge-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; background: rgba(255,255,255,.7); }

/* Mitarbeiter-Verwaltung */
.admin-filter { align-items: center; }
.abs-list { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.abs-edit { display: flex; flex-direction: column; gap: var(--s-3); }
.abs-add { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.abs-add .input { width: auto; }
.abs-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--c-border); border-radius: var(--r-sm); }
.abs-rows li { display: flex; align-items: center; gap: var(--s-3); padding: 4px 4px 4px var(--s-3); border-bottom: 1px solid var(--c-border); font-variant-numeric: tabular-nums; }
.abs-rows li:last-child { border-bottom: 0; }
.abs-rows li > :first-child { flex: 1; }
.abs-rows li.is-past { color: var(--c-text-3); }

/* Präsenz ("bearbeitet gerade") */
.alert-editing { background: var(--c-editing-soft); color: var(--c-editing); border-color: #d8cdf5; }
.presence-slot:empty { display: none; }
.presence-badge { gap: 6px; height: 24px; }
.presence-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c-editing); animation: presence-pulse 1.6s ease-in-out infinite; }
@keyframes presence-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.appt-tile.is-editing, .fleet-card.is-editing { border-color: var(--c-editing); box-shadow: 0 0 0 2px var(--c-editing-soft), var(--sh-1); }
.appt-tile.is-editing::before { background: var(--c-editing); }
.fleet-card.is-editing::before { background: var(--c-editing); }
.week-bar.is-editing { border-left-color: var(--c-editing); box-shadow: 0 0 0 2px var(--c-editing-soft); }
.week-bar .presence-dot { position: absolute; right: 8px; top: 8px; }
.sync-dot { transition: background var(--t-med); }

/* Änderungsverlauf */
.hist-filter .field { flex: 1 1 180px; }
.hist-list { display: flex; flex-direction: column; }
.hist-date { position: sticky; top: 0; z-index: 1; padding: var(--s-3) 0 var(--s-1); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-3); background: var(--c-surface); }
.hist-item { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--c-border); }
.hist-item:last-child { border-bottom: 0; }
.hist-item.is-undone .hist-main > :not(.subtle) { opacity: .55; }
.hist-time { font-size: var(--fs-sm); color: var(--c-text-3); font-variant-numeric: tabular-nums; padding-top: 2px; }
.hist-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hist-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.hist-field { font-size: var(--fs-sm); color: var(--c-text-2); }
.hist-label { font-size: var(--fs-sm); color: var(--c-text-2); overflow-wrap: anywhere; }
.hist-diff { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: var(--fs-sm); }
.hist-old { padding: 1px 6px; border-radius: var(--r-xs); background: var(--c-danger-soft); color: var(--c-danger); text-decoration: line-through; overflow-wrap: anywhere; }
.hist-new { padding: 1px 6px; border-radius: var(--r-xs); background: var(--c-success-soft); color: var(--c-success); overflow-wrap: anywhere; }
.hist-arrow { color: var(--c-text-3); }
.hist-actions { display: flex; align-items: flex-start; }
.badge-danger { color: var(--c-danger); background: var(--c-danger-soft); }
.hist-dialog-body { min-height: 300px; }
.seg-tabs.seg-tabs-always { display: flex; gap: 4px; padding: 4px; background: var(--c-surface-3); border-radius: var(--r-md); }

/* Gesamtstände */
.snap-list { display: flex; flex-direction: column; gap: var(--s-2); }
.snap-item { border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); }
.snap-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; font-size: var(--fs-sm); }
.snap-actions { display: flex; gap: var(--s-2); align-items: center; }
.snap-details { display: flex; flex-direction: column; gap: 6px; margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px dashed var(--c-border); font-size: var(--fs-sm); }
.snap-notes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.snap-notes ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

/* Papierkorb */
.trash-title { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

@media (max-width: 640px) {
    .hist-item { grid-template-columns: 40px minmax(0, 1fr); }
    .hist-actions { grid-column: 2; }
    .snap-notes { grid-template-columns: 1fr; }
    .btn-label-md { display: none; }
}

/* PWA */
@media (max-width: 640px) { .install-btn { display: none; } }
@media (display-mode: standalone) {
    .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
}

/* Feinschliff Handy */
@media (max-width: 640px) {
    .show-sm { display: block; }
    .fleet-badge { height: 34px; padding: 0 var(--s-3); }
    .app-chip { height: 36px; }
    .app-chip .chip-x { width: 34px; height: 34px; }
    .menu-item { min-height: 44px; }
    .hist-item .btn-sm, .snap-item .btn-sm { min-height: 36px; }
    .toasts { bottom: max(var(--s-4), env(safe-area-inset-bottom)); }
}
@media (max-width: 400px) {
    .topbar { gap: 2px; }
    .nav a { padding: 0 6px; font-size: var(--fs-xs); }
    .brand-mark { width: 20px; height: 20px; }
    .topbar-user { gap: 2px; }
}
@media (max-width: 640px) {
    .dialog-footer { flex-wrap: nowrap; gap: var(--s-1); }
    .dialog-footer .btn { padding: 0 var(--s-3); }
}
