/* KalenderApp Styles */

:root {
    --color-primary: #0ea5e9;
    --color-primary-hover: #0284c7;
    --color-primary-light: #e0f2fe;
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;
}

:root {
    color-scheme: light;
    --menu-bg: #ffffff;
    --menu-shadow: 0 14px 36px rgba(15, 23, 42, .18);
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --menu-bg: #1f2937;
        --menu-shadow: 0 14px 36px rgba(0, 0, 0, .55);
        --color-primary: #38bdf8;
        --color-primary-hover: #0ea5e9;
        --color-primary-light: #0c3d5c;
        --color-gray-50: #111827;
        --color-gray-100: #1f2937;
        --color-gray-200: #374151;
        --color-gray-300: #4b5563;
        --color-gray-400: #9ca3af;
        --color-gray-500: #6b7280;
        --color-gray-600: #d1d5db;
        --color-gray-700: #e5e7eb;
        --color-gray-800: #f3f4f6;
        --color-gray-900: #f9fafb;
    }
}

* {
    box-sizing: border-box;
}

/* Alpine.js: Elemente erst nach der Initialisierung anzeigen */
[x-cloak] {
    display: none !important;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background-color: var(--color-gray-200);
}

.calendar-day-header {
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gray-600);
    background-color: var(--color-gray-100);
}

.calendar-day {
    min-height: 100px;
    background-color: white;
    position: relative;
    transition: background-color 0.15s ease;
}

.calendar-day:hover {
    background-color: var(--color-gray-50);
}

.calendar-day.other-month {
    background-color: var(--color-gray-50);
    color: var(--color-gray-400);
}

.calendar-day.today {
    background-color: var(--color-primary-light);
}

.dark .calendar-day.today {
    background-color: var(--color-primary-light);
}

.calendar-day-number {
    padding: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.calendar-event {
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    margin: 0.125rem 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.calendar-event:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10;
}

.calendar-event.more {
    font-size: 0.7rem;
    padding: 0.125rem 0.375rem;
    background-color: var(--color-gray-200);
    color: var(--color-gray-600);
    text-align: center;
}

/* Week View */
.week-view {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    gap: 1px;
    background-color: var(--color-gray-200);
}

.week-hour-label {
    padding: 0.25rem;
    font-size: 0.75rem;
    text-align: right;
    color: var(--color-gray-600);
    background-color: var(--color-gray-100);
    border-bottom: 1px solid var(--color-gray-200);
}

.week-day-header {
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    background-color: var(--color-gray-100);
    border-bottom: 1px solid var(--color-gray-200);
}

.week-day-header.today {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

.week-time-slot {
    min-height: 60px;
    background-color: white;
    border-bottom: 1px solid var(--color-gray-200);
    border-right: 1px solid var(--color-gray-200);
    position: relative;
}

.week-time-slot:hover {
    background-color: var(--color-gray-50);
}

.week-event {
    position: absolute;
    left: 2px;
    right: 2px;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 50;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 32rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease-out;
}

.dark .modal-content {
    background-color: #1f2937;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Elements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-gray-300);
    border-radius: 0.375rem;
    background-color: white;
    color: var(--color-gray-900);
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dark input,
.dark select,
.dark textarea {
    background-color: var(--color-gray-800);
    border-color: var(--color-gray-600);
    color: var(--color-gray-100);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-primary-hover);
}

.btn-secondary {
    background-color: white;
    color: var(--color-gray-700);
    border-color: var(--color-gray-300);
}

.dark .btn-secondary {
    background-color: var(--color-gray-800);
    color: var(--color-gray-300);
    border-color: var(--color-gray-600);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--color-gray-100);
}

.dark .btn-secondary:hover:not(:disabled) {
    background-color: var(--color-gray-700);
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    border-color: #ef4444;
}

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Utility Classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }

.rounded { border-radius: 0.25rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-full { border-radius: 9999px; }

.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow { box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.space-x-1 > * + * { margin-left: 0.25rem; }
.space-x-2 > * + * { margin-left: 0.5rem; }
.space-x-4 > * + * { margin-left: 1rem; }
.space-y-1 > * + * { margin-top: 0.25rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-50 { z-index: 50; }

.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

.select-none { user-select: none; }

.transition { transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-colors { transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-gray-100);
}

.dark ::-webkit-scrollbar-track {
    background: var(--color-gray-800);
}

::-webkit-scrollbar-thumb {
    background: var(--color-gray-400);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-gray-500);
}

/* ==========================================================================
   Feinschliff (Design-Schicht)
   ========================================================================== */

:root {
    --brand: #38bdf8;
    --brand-600: #0369a1;
    --brand-50: #e0f2fe;
    --brand-100: #bae6fd;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --bg: #f6f7fb;
    --line: #e6e8f0;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --danger: #dc2626;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 24px -14px rgba(16, 24, 40, .22);
    --shadow-lg: 0 2px 4px rgba(16, 24, 40, .06), 0 22px 48px -24px rgba(16, 24, 40, .3);
}

html, body {
    background-color: var(--bg);
}

body {
    background-image:
        radial-gradient(900px 480px at 8% -12%, var(--brand-50) 0%, transparent 62%),
        radial-gradient(700px 420px at 102% -6%, #e6f6ff 0%, transparent 58%);
    background-repeat: no-repeat;
    color: var(--ink);
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    letter-spacing: -0.006em;
}

.shell {
    min-height: 100vh;
}

.container-page {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    .container-page { padding: 0 1.5rem; }
}

/* Kopfzeile */
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: 64px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .625rem;
    text-decoration: none;
    color: var(--ink);
    font-weight: 700;
    font-size: 1.0625rem;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(150deg, #7dd3fc 0%, #38bdf8 55%, #0ea5e9 100%);
    box-shadow: 0 4px 12px -4px rgba(56, 189, 248, .6);
    color: #fff;
}

.brand-mark svg { width: 18px; height: 18px; }

/* Flächen */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
}

.panel-flat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    height: 38px;
    padding: 0 .9rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .06s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: linear-gradient(180deg, #7dd3fc 0%, var(--brand) 100%);
    color: #05293f;
    box-shadow: 0 2px 6px -2px rgba(56, 189, 248, .55);
}

.btn-primary:hover { background: linear-gradient(180deg, #38bdf8 0%, #0ea5e9 100%); }

.btn-quiet {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink-2);
    box-shadow: var(--shadow-sm);
}

.btn-quiet:hover { background: var(--surface-2); border-color: #d7dbe7; }

.btn-danger-quiet { color: var(--danger); background: transparent; border-color: transparent; }
.btn-danger-quiet:hover { background: #fef2f2; }

.btn-icon {
    width: 38px;
    padding: 0;
    font-size: 1.15rem;
    color: var(--ink-2);
}

/* Segmentschalter */
.seg {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: #eff1f7;
    border-radius: 12px;
}

.seg a {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 .75rem;
    border-radius: 9px;
    font-size: .8125rem;
    font-weight: 600;
    color: #56607a;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.seg a:hover { color: var(--ink); }

.seg a.is-active {
    background: var(--surface);
    color: var(--brand-600);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .1);
}

/* Formularfelder in der Design-Schicht */
.field {
    width: 100%;
    height: 42px;
    padding: 0 .75rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background-color: var(--surface);
    color: var(--ink);
    -webkit-appearance: none;
    appearance: none;
    -webkit-text-fill-color: var(--ink);
    font-size: .9375rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}

/* Safari/iOS: Autofill und Datumsfelder nicht weiß übermalen */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    -webkit-text-fill-color: var(--ink);
    caret-color: var(--ink);
    transition: background-color 9999s ease-in-out 0s;
}

input::-webkit-date-and-time-value,
input::-webkit-datetime-edit { color: var(--ink); -webkit-text-fill-color: var(--ink); }

input::placeholder, textarea::placeholder, .field::placeholder {
    color: var(--muted);
    -webkit-text-fill-color: var(--muted);
    opacity: .45;
}

textarea.field { height: auto; padding: .625rem .75rem; line-height: 1.5; }

.field:focus,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: #a5b4fc;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .16);
}

.label {
    display: block;
    margin-bottom: .375rem;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--ink-2);
}

.hint { font-size: .75rem; color: var(--muted); }

/* Monatsraster */
.cal-wrap {
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.cal-head {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
}

.cal-head > div {
    padding: .55rem 0;
    text-align: center;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
    background: #fbfcfe;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
}

.cal-cell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: 18px;
    align-content: start;
    row-gap: 2px;
    min-height: 104px;
    padding: .5rem;
    overflow: hidden;
    background: var(--surface);
    text-decoration: none;
    transition: background-color .15s ease;
}

.cal-cell:hover { background: #f8f9ff; }
.cal-cell.is-out { background: #fafbfd; }
.cal-cell.is-weekend { background: var(--surface); }
.cal-cell.is-out.is-weekend { background: #fafbfd; }

.cal-dayhead {
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: .3rem;
    overflow: hidden;
}

.cal-holiday-inline {
    font-size: .625rem;
    font-weight: 600;
    color: #b91c1c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-daynum {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 .25rem;
    border-radius: 999px;
    font-size: .875rem;
    font-weight: 600;
    color: var(--ink);
}

.cal-cell.is-out .cal-daynum { color: #a7b0c0; font-weight: 500; }

.cal-daynum.is-today {
    background: linear-gradient(180deg, #7dd3fc 0%, var(--brand) 100%);
    color: #05293f;
    box-shadow: 0 2px 8px -2px rgba(56, 189, 248, .55);
}

.cal-holiday {
    margin-top: 2px;
    font-size: .6875rem;
    font-weight: 600;
    color: #b91c1c;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-chip {
    display: block;
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 7px;
    font-size: .6875rem;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: var(--brand-50);
    color: var(--brand-600);
}

.event-chip.is-holiday { background: #fef2f2; color: #b91c1c; }
.event-chip.is-series {
    margin-left: -.5rem;
    margin-right: -.5rem;
    padding-left: 10px;
    padding-right: 8px;
    border-radius: 0;
    background: #bae6fd;
    color: #0c4a6e;
}

.event-chip.is-series-first {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
    box-shadow: inset 3px 0 0 var(--brand);
}

.event-chip.is-series-last {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
    box-shadow: inset -3px 0 0 var(--brand);
}

/* Listenansicht */
.day-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s ease, border-color .15s ease;
}

.day-card:hover { box-shadow: var(--shadow-md); }

.day-card.is-today {
    border-color: #c7d2fe;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .12), var(--shadow-sm);
}

.day-card.is-weekend { background: var(--surface); }

.day-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .55rem .9rem;
    border-bottom: 1px solid #f1f3f9;
    text-decoration: none;
    color: inherit;
}

.day-card-head:hover { background: #f8f9ff; }

.day-name {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    width: 2.35rem;
}

.day-num { font-size: 1.0625rem; font-weight: 700; color: var(--ink); }
.day-card.is-today .day-num, .day-card.is-today .day-name { color: var(--brand-600); }

.day-body { padding: .4rem .55rem .55rem; }

.event-row {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .45rem .55rem;
    border-radius: 9px;
    text-decoration: none;
    color: inherit;
    transition: background-color .15s ease;
}

.event-row:hover { background: var(--surface-2); }

.event-row.is-series {
    background: #f5f4ff;
    box-shadow: inset 3px 0 0 var(--brand);
}

.event-row.is-series:hover { background: var(--brand-50); }

.event-time {
    width: 6rem;
    flex: 0 0 6rem;
    font-size: .8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
}

.event-time.is-allday {
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #94a3b8;
}

.event-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .9375rem;
    line-height: 1.45;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.event-row.is-holiday .event-title { color: #b91c1c; font-weight: 500; }

.tag-pill {
    flex: 0 0 auto;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: linear-gradient(180deg, #7dd3fc 0%, var(--brand) 100%);
    color: #05293f;
    font-size: .6875rem;
    font-weight: 700;
    white-space: nowrap;
}

.empty-row {
    padding: .3rem .55rem .45rem;
    font-size: .8125rem;
    color: #9aa4b8;
}

/* Auth-Seiten */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-accent { height: 6px; background: linear-gradient(90deg, #7dd3fc 0%, #38bdf8 50%, #0ea5e9 100%); }
.auth-body { padding: 1.75rem; }

.auth-title { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; }
.auth-sub { margin-top: .3rem; font-size: .875rem; color: var(--muted); }

.auth-card input {
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
}

/* Dunkelmodus */
@media (prefers-color-scheme: dark) {
    :root {
        --surface: #161c2b;
        --surface-2: #1b2233;
        --bg: #0d1220;
        --line: #262f45;
        --ink: #eef2f9;
        --ink-2: #c3ccdd;
        --muted: #8f9cb3;
        --brand: #7dd3fc;
        --brand-600: #38bdf8;
        --brand-50: #10283a;
        --shadow-md: 0 1px 2px rgba(0, 0, 0, .4), 0 14px 30px -18px rgba(0, 0, 0, .8);
        --shadow-lg: 0 2px 6px rgba(0, 0, 0, .5), 0 26px 50px -26px rgba(0, 0, 0, .9);
    }

    body {
        background-image:
            radial-gradient(900px 480px at 8% -12%, rgba(56, 189, 248, .16) 0%, transparent 62%),
            radial-gradient(700px 420px at 102% -6%, rgba(139, 92, 246, .12) 0%, transparent 58%);
    }

    .app-header { background: rgba(22, 28, 43, .85); }
    .seg { background: #1b2233; }
    .seg a { color: #9aa6bd; }
    .seg a.is-active { background: #242d44; color: #c7d2fe; }
    .cal-head > div, .cal-cell.is-out, .cal-cell:hover, .day-card-head:hover, .event-row:hover { background: #1a2132; }
    .day-card.is-weekend, .cal-cell.is-weekend { background: var(--surface); }
    .cal-cell.is-out, .cal-cell.is-out.is-weekend { background: #1a2132; }
    .cal-cell { background: var(--surface); }
    .cal-cell.is-out .cal-daynum { color: #5c6780; }
    .event-chip { background: #222b45; color: #c7d2fe; }
    .event-chip.is-series { background: #2b3560; color: #dbe3ff; }
    .event-chip.is-holiday { background: #3a1c22; color: #fca5a5; }
    .event-row.is-series { background: #1f2440; }
    .event-row.is-series:hover { background: #262c4d; }
    .day-card-head { border-bottom-color: #222b3f; }
    .auth-card input { background: #1b2233; }

    /* iOS/Safari im Dunkelmodus: Felder und Schrift bleiben sonst weiß */
    input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
    textarea,
    select {
        background-color: #1b2233 !important;
        color: #eef2f9 !important;
        -webkit-text-fill-color: #eef2f9 !important;
    }

    input::placeholder,
    textarea::placeholder,
    .field::placeholder,
    input::-webkit-input-placeholder {
        color: #8f9cb3 !important;
        -webkit-text-fill-color: #8f9cb3 !important;
        opacity: .55 !important;
    }

    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus,
    input:-internal-autofill-selected,
    textarea:-webkit-autofill {
        -webkit-box-shadow: 0 0 0 1000px #1b2233 inset !important;
        -webkit-text-fill-color: #eef2f9 !important;
        caret-color: #eef2f9;
    }
    .btn-quiet { background: #1b2233; border-color: var(--line); color: var(--ink-2); }
    .btn-quiet:hover { background: #222b3f; }
    .empty-row { color: #6d7994; }
    .menu-panel { background: #1b2233; border-color: var(--line); box-shadow: var(--menu-shadow); }
    .menu-user { color: #8b97ae; border-bottom-color: var(--line); }
    .menu-item { color: var(--ink); }
    .menu-item:hover { background: #242d44; }
}

/* Antraege */
.leave-row {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    border-top: 1px solid var(--line);
}

.leave-row:first-child {
    border-top: 0;
}

/* Verlauf */
.hist-row {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    padding: .6rem 1rem;
    border-top: 1px solid var(--line);
}

.hist-row:first-child {
    border-top: 0;
}

.hist-badge {
    flex: 0 0 auto;
    padding: .1rem .45rem;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-top: .1rem;
}

.hist-anfrage { background: #e0f2fe; color: #0369a1; }
.hist-hinweis { background: #f1f5f9; color: #475569; }

/* Auswahlbox Konten */
.invite-box {
    padding: .6rem .75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.invite-summary {
    cursor: pointer;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-2);
}

/* Punkt fuer ungelesene Anfragen */
.menu-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: .45rem;
    border-radius: 50%;
    background: #ef4444;
    vertical-align: middle;
}

/* Punkt am Menü-Button */
.menu-btn { position: relative; }

.menu-dot-btn {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 9px;
    height: 9px;
    margin: 0;
    box-shadow: 0 0 0 2px var(--surface);
}

/* Benutzerliste */
.user-row {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1rem;
    border-top: 1px solid var(--line);
}

.user-row:first-child {
    border-top: 0;
}

.user-info {
    min-width: 0;
    flex: 1 1 220px;
}

.user-name {
    font-size: .9375rem;
    font-weight: 700;
    color: var(--ink);
}

.user-sub {
    margin-top: .15rem;
    font-size: .8125rem;
    color: var(--ink-2);
}

.role-badge {
    padding: .05rem .45rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
}

.role-sl { background: #e0f2fe; color: #0369a1; }
.role-at { background: #f1f5f9; color: #475569; }

.user-state { font-size: .75rem; color: #047857; }
.user-state-warn { color: #b45309; }

.user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    align-items: center;
}

@media (max-width: 640px) {
    .user-actions { width: 100%; }
    .user-actions form { flex: 1 1 45%; }
    .user-actions button, .user-actions select { width: 100%; }
}

/* Kopfmenü */
.menu-wrap {
    position: relative;
}

.menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + .45rem);
    min-width: 210px;
    padding: .35rem;
    display: flex;
    flex-direction: column;
    background: var(--menu-bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--menu-shadow);
    z-index: 70;
}

.menu-user {
    padding: .4rem .6rem .5rem;
    margin-bottom: .25rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid var(--line);
}

.menu-item {
    display: block;
    width: 100%;
    padding: .5rem .6rem;
    border: 0;
    border-radius: 9px;
    background: none;
    font-family: inherit;
    font-size: .875rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    color: var(--ink);
    cursor: pointer;
}

.menu-item:hover {
    background: var(--surface-2);
}

/* ==========================================================================
   Tages-Pop-up
   ========================================================================== */
[x-cloak] { display: none !important; }

.day-popup-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 1rem;
    overflow: auto;
    background: rgba(15, 23, 42, .45);
}

.day-popup-panel {
    width: 100%;
    max-width: 560px;
    margin: auto;
    max-height: 84vh;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    padding: 1.1rem 1.2rem;
}

.day-popup-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
}

.day-popup-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    font-size: 1.25rem;
    line-height: 1;
    color: var(--ink-2);
    cursor: pointer;
}

.day-popup-close:hover { background: var(--brand-50); color: var(--brand-600); }

.day-popup-foot {
    display: flex;
    gap: .5rem;
    margin-top: 1rem;
    padding-top: .75rem;
    border-top: 1px solid var(--line);
}

@media (max-width: 640px) {
    .day-popup-backdrop { padding: .75rem; }
    .day-popup-panel { max-width: none; max-height: 84vh; }
}

/* Monatswechsel direkt an der Monatsauswahl */
.month-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 1.125rem;
    line-height: 1;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.month-arrow:hover { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-100); }

/* Datumsauswahl im Antrag (eigener Kalender, sperrt Tage vor "Von") */
.dp-wrap { position: relative; }

.dp-trigger {
    display: flex;
    align-items: center;
    text-align: left;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

.dp-trigger.is-empty { color: var(--muted); }

.dp-pop {
    position: absolute;
    z-index: 40;
    top: calc(100% + .35rem);
    left: 0;
    width: 268px;
    padding: .7rem .75rem .8rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.dp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
    margin-bottom: .5rem;
}

.dp-month { font-size: .875rem; font-weight: 700; color: var(--ink); }

.dp-nav {
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.dp-nav:hover { background: var(--brand-50); color: var(--brand-600); }

.dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.dp-wd {
    font-size: .625rem;
    font-weight: 700;
    color: var(--muted);
    text-align: center;
    padding-bottom: .15rem;
}

.dp-day {
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font-size: .8125rem;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.dp-day:hover:not(:disabled) { background: var(--brand-50); color: var(--brand-600); }

.dp-day.is-out { color: var(--muted); opacity: .6; }

.dp-day.is-selected {
    background: var(--brand);
    color: #05293f;
    font-weight: 700;
}

.dp-day.is-disabled {
    color: var(--muted);
    opacity: .3;
    cursor: not-allowed;
    text-decoration: line-through;
}

.dp-hint {
    margin: 0 0 .4rem;
    font-size: .6875rem;
    font-weight: 600;
    color: var(--muted);
}

.dp-foot {
    display: flex;
    justify-content: space-between;
    gap: .4rem;
    margin-top: .55rem;
    padding-top: .5rem;
    border-top: 1px solid var(--line);
}

/* Bereichsmarkierung */
.dp-day.is-range { background: var(--brand-50); color: var(--brand-600); }

.dp-day.is-from,
.dp-day.is-to {
    background: var(--brand);
    color: #05293f;
    font-weight: 700;
}

.dp-day.is-to { box-shadow: inset 0 0 0 2px #0ea5e9; }

@media (max-width: 520px) {
    .dp-pop { width: min(302px, calc(100vw - 2.5rem)); }
}

/* Feiertagseintrag in Tag- und Tagesfenster-Ansicht */
.event-holiday { border-color: #fecaca; background: #fffbfb; }

@media (prefers-color-scheme: dark) {
    .event-holiday { border-color: #4b1d24; background: #2a1417; }
}
