:root {
    --bg: #f3f6ff;
    --surface: rgba(255, 255, 255, 0.78);
    --surface-solid: #ffffff;
    --surface-muted: #f8faff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --line: #e5e7eb;
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --shadow: 0 18px 44px rgba(79, 70, 229, .12);
}

html, body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: radial-gradient(1200px 700px at -20% -20%, #dbeafe 0%, transparent 50%),
                radial-gradient(1200px 700px at 120% 0%, #ede9fe 0%, transparent 50%),
                var(--bg);
    color: var(--text);
}

a {
    color: var(--brand);
}

.invalid {
    color: #dc2626;
}

body > div:first-child {
    display: contents;
}

.page {
    min-height: 100vh;
}

.main {
    display: flex;
    flex-direction: column;
}

.top-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.25rem;
    margin: .75rem;
    border: 1px solid rgba(255,255,255,.6);
    border-radius: 14px;
    background: var(--surface);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
}

.content {
    flex: 1;
}

.glass-card {
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 16px;
    background: var(--surface);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.schedule-page {
    padding: .75rem;
}

.schedule-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}

.hero-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: .9rem;
}

.hero-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
}

.nav-toggle {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hamburger-icon {
    width: 18px;
    height: 14px;
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger-icon span {
    display: block;
    height: 2px;
    border-radius: 999px;
    background-color: currentColor;
    transition: transform .2s ease, opacity .2s ease;
}

.nav-toggle.is-open .hamburger-icon span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.nav-toggle.is-open .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.is-open .hamburger-icon span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.loading-state {
    min-height: 260px;
    display: grid;
    place-items: center;
}

.admin-shell {
    display: grid;
    grid-template-columns: 270px 1fr;
    gap: 1rem;
}

.admin-shell.sidebar-collapsed {
    grid-template-columns: 64px 1fr;
}

.admin-sidebar {
    padding: .6rem;
    height: fit-content;
    position: sticky;
    top: .75rem;
}

.admin-shell.sidebar-collapsed .admin-sidebar {
    padding: .5rem;
}

.admin-shell.sidebar-collapsed .sidebar-body {
    display: none;
}

.sidebar-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: .5rem;
}

.sidebar-body {
    display: block;
}

.sidebar-block + .sidebar-block {
    margin-top: 1rem;
}

.sidebar-block h6 {
    margin: 0 0 .5rem;
    color: color-mix(in oklab, var(--brand) 72%, var(--text));
    font-weight: 700;
    font-size: .88rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.sidebar-link {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: .5rem .6rem;
    border-radius: 10px;
    color: var(--text);
}

.sidebar-link:hover,
.sidebar-link.active {
    background: color-mix(in oklab, var(--brand) 14%, var(--surface-solid));
    color: color-mix(in oklab, var(--brand) 72%, var(--text));
}

.sidebar-tools .sidebar-action {
    margin-top: .3rem;
    width: 100%;
}

.planner-content,
.user-shell {
    padding: .75rem;
}

.planner-toolbar,
.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.planner-toolbar h2,
.user-header h2 {
    margin: 0;
}

.planner-subtitle {
    color: var(--text-muted);
    font-size: .9rem;
}

.toolbar-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.admin-action-button,
.admin-row-action {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.admin-user-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.admin-inline-actions {
    display: inline-flex;
    gap: .35rem;
}

.admin-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    display: grid;
    place-items: center;
    padding: 1rem;
    z-index: 1100;
}

.admin-dialog {
    width: min(100%, 520px);
    padding: 1rem;
}

.admin-dialog-header h3 {
    margin: 0 0 .5rem;
}

.admin-dialog-body {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.admin-dialog-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .85rem;
}

.admin-dialog-grid label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    color: var(--text);
}

.admin-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1rem;
}

.admin-dialog-message {
    margin: 0;
}

.planner-board {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: auto;
    background: var(--surface-solid);
}

.planner-table {
    width: 100%;
    min-width: 960px;
    border-collapse: collapse;
}

.planner-table th,
.planner-table td {
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding: .5rem;
    vertical-align: top;
    color: var(--text);
}

.planner-table th {
    background: var(--surface-muted);
    font-weight: 700;
}

.planner-table th.is-today-col,
.planner-table td.is-today-col {
    background-color: color-mix(in oklab, var(--brand) 5%, var(--surface-solid));
    border-left: 1px solid color-mix(in oklab, var(--brand) 45%, white);
    border-right: 1px solid color-mix(in oklab, var(--brand) 45%, white);
}

.planner-table thead th.is-today-col {
    border-top: 1px solid color-mix(in oklab, var(--brand) 45%, white);
}

.planner-table tbody tr:last-child td.is-today-col {
    border-bottom: 1px solid color-mix(in oklab, var(--brand) 45%, white);
}

.user-cell {
    font-weight: 700;
    white-space: nowrap;
}

.empty-day {
    color: #9ca3af;
    text-align: center;
}

.free-day {
    display: inline-block;
    padding: .15rem .45rem;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font-size: .75rem;
    font-weight: 700;
}

.planner-item {
    border-radius: 10px;
    padding: .4rem 0;
}

.planner-item-title {
    display: inline-block;
    padding: .22rem .5rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: .82rem;
    line-height: 1.2;
    margin-bottom: .3rem;
}

.planner-item-time {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: .25rem;
}

.planner-item-activity {
    font-size: .8rem;
    color: var(--text-muted);
}

.dienst-assignment + .dienst-assignment {
    margin-top: .55rem;
    padding-top: .55rem;
    border-top: 1px dashed var(--line);
}

.dienst-assignment-user {
    font-size: .8rem;
    font-weight: 700;
}

.month-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-solid);
}

.weekday-header {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--line);
    padding: .55rem;
    text-align: center;
    font-weight: 700;
    font-size: .85rem;
    color: var(--text);
}

.calendar-day {
    min-height: 128px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: .45rem;
    color: var(--text);
}

.calendar-day:nth-child(7n) {
    border-right: 0;
}

.calendar-day-number {
    font-weight: 700;
    margin-bottom: .35rem;
    color: var(--text);
}

.calendar-day.is-outside {
    background: color-mix(in oklab, var(--surface-solid) 92%, var(--text) 8%);
    color: var(--text-muted);
}

.calendar-day.is-outside .calendar-day-number {
    color: var(--text-muted);
}

.calendar-day.is-today {
    box-shadow: inset 0 0 0 2px var(--brand);
}

.day-service {
    display: inline-block;
    padding: .2rem .45rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    margin-bottom: .2rem;
}

.day-activity {
    margin-top: .25rem;
    padding: .2rem .35rem;
    border-radius: 6px;
    background: color-mix(in oklab, var(--brand) 10%, var(--surface-solid));
    color: var(--text);
    font-size: .75rem;
    line-height: 1.2;
}

.day-more {
    margin-top: .25rem;
    font-size: .72rem;
    color: var(--text-muted);
}

.user-day-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-day-list .holiday-card {
    border: 1px solid var(--line);
    background: var(--surface-solid);
}

.user-day-schedule-item {
    padding: 0;
}

.user-day-list .holiday-card-user {
    display: inline-block;
    padding: .22rem .5rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: .9rem;
    color: var(--text);
    background: color-mix(in oklab, var(--brand) 12%, var(--surface-solid));
}

.user-day-list .holiday-card-range {
    margin-top: .5rem;
    font-weight: 600;
    color: var(--text-muted);
}

.user-day-list .holiday-card-notes {
    margin-top: .4rem;
    color: var(--text-muted);
}

@media (max-width: 1100px) {
    .planner-table {
        min-width: 0;
    }

    .planner-table thead,
    .planner-table tbody,
    .planner-table tr,
    .planner-table th,
    .planner-table td {
        display: block;
    }

    .planner-table thead {
        display: none;
    }

    .planner-table tr {
        border-bottom: 1px solid var(--line);
    }

    .planner-table td {
        border-right: 0;
    }

    .planner-table td.is-today-col {
        border-left: 0;
    }

    .planner-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: .35rem;
        font-size: .75rem;
        font-weight: 700;
        color: var(--text-muted);
    }

    .month-calendar {
        grid-template-columns: 1fr;
    }

    .weekday-header {
        display: none;
    }

    .calendar-day {
        min-height: 0;
        border-right: 0;
    }
}

@media (max-width: 1100px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
    }

    .admin-shell.sidebar-collapsed .admin-sidebar {
        width: fit-content;
    }

    .nav-toggle {
        display: inline-flex;
    }
}

@media (max-width: 900px) {
    .month-calendar {
        grid-template-columns: 1fr;
    }

    .weekday-header {
        display: none;
    }

    .calendar-day {
        min-height: 0;
        border-right: 0;
    }
}

@media (max-width: 768px) {
    .top-row {
        flex-wrap: wrap;
        margin: .5rem;
    }

    .schedule-page {
        padding: .5rem;
    }

    .planner-toolbar,
    .user-header,
    .schedule-hero {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions,
    .hero-actions {
        width: 100%;
    }

    .toolbar-actions .btn,
    .hero-actions .btn {
        flex: 1 1 auto;
    }

    .hero-actions .nav-toggle {
        flex: 0 0 auto;
        width: 42px;
    }
}


.holiday-overview-shell {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.holiday-overview-header {
    margin-bottom: 0;
}

.holiday-filter-bar {
    display: grid;
    grid-template-columns: minmax(180px, 220px) minmax(120px, 140px) minmax(220px, 1fr) auto;
    gap: .75rem;
    align-items: end;
}

.holiday-filter-group {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.holiday-filter-group label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text, #374151);
}

.holiday-filter-actions {
    display: flex;
    justify-content: flex-start;
}

.holiday-day-group {
    display: flex;
    flex-direction: column;
    gap: .65rem;
}

.holiday-day-heading {
    font-weight: 700;
    color: var(--brand, #1d4ed8);
    padding: .55rem .75rem;
    border: 1px solid var(--line, #dbeafe);
    border-radius: 10px;
    background: var(--surface-muted, #f8fafc);
}

.holiday-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line, #e5e7eb);
    border-radius: 12px;
    background: var(--surface-solid, #fff);
}

.holiday-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.holiday-col-user {
    width: 18%;
}

.holiday-col-from,
.holiday-col-to {
    width: 19%;
}

.holiday-col-days {
    width: 10%;
}

.holiday-col-notes {
    width: 34%;
}

.holiday-table th,
.holiday-table td {
    padding: .8rem .9rem;
    border-bottom: 1px solid var(--line, #e5e7eb);
    text-align: left;
    vertical-align: top;
}

.holiday-table th {
    background: var(--surface-muted, #f8fafc);
    color: var(--text, #111827);
    font-size: .85rem;
    font-weight: 700;
    white-space: nowrap;
}

.holiday-table td {
    color: var(--text, #374151);
    font-size: .92rem;
    overflow-wrap: anywhere;
}

.holiday-table tbody tr:last-child td {
    border-bottom: 0;
}

.holiday-table td:first-child {
    font-weight: 700;
    white-space: nowrap;
}

.holiday-mobile-list {
    display: none;
    gap: .75rem;
}

.holiday-card {
    border: 1px solid var(--line, #e5e7eb);
    border-radius: 12px;
    padding: .9rem 1rem;
    background: var(--surface-solid, #fff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.holiday-card-main {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem 1rem;
}

.holiday-card-user {
    font-weight: 700;
    color: var(--text, #111827);
    font-size: 1rem;
}

.holiday-card-range {
    color: var(--text-muted, #4b5563);
    font-size: .92rem;
}

.holiday-card-meta {
    margin-top: .55rem;
}

.holiday-days-badge {
    display: inline-block;
    padding: .24rem .6rem;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: .78rem;
    font-weight: 700;
}

.holiday-card-notes {
    margin-top: .6rem;
    color: var(--text, #374151);
    font-size: .92rem;
    white-space: pre-wrap;
}

@media (max-width: 900px) {
    .holiday-filter-bar {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 700px) {
    .holiday-filter-bar {
        grid-template-columns: 1fr;
    }

    .holiday-filter-actions .btn {
        width: 100%;
    }

    .holiday-table-wrap {
        display: none;
    }

    .holiday-mobile-list {
        display: grid;
    }

    .holiday-card-main {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (prefers-color-scheme: dark) {
    .schedule-page.theme-auto,
    .schedule-page.theme-dark {
        --bg: #0b1220;
        --surface: rgba(17, 25, 40, 0.72);
        --surface-solid: #101a2e;
        --surface-muted: #17233c;
        --text: #e5e7eb;
        --text-muted: #9ca3af;
        --line: #24314b;
        --shadow: 0 24px 48px rgba(0, 0, 0, .45);
    }

    .schedule-page.theme-auto .planner-table th.is-today-col,
    .schedule-page.theme-auto .planner-table td.is-today-col,
    .schedule-page.theme-dark .planner-table th.is-today-col,
    .schedule-page.theme-dark .planner-table td.is-today-col {
        background-color: color-mix(in oklab, #60a5fa 12%, var(--surface-solid));
        border-left-color: color-mix(in oklab, #93c5fd 55%, #0f172a);
        border-right-color: color-mix(in oklab, #93c5fd 55%, #0f172a);
    }

    .schedule-page.theme-auto .planner-table thead th.is-today-col,
    .schedule-page.theme-dark .planner-table thead th.is-today-col {
        border-top-color: color-mix(in oklab, #93c5fd 55%, #0f172a);
    }

    .schedule-page.theme-auto .planner-table tbody tr:last-child td.is-today-col,
    .schedule-page.theme-dark .planner-table tbody tr:last-child td.is-today-col {
        border-bottom-color: color-mix(in oklab, #93c5fd 55%, #0f172a);
    }
}

.schedule-page.theme-dark {
    --bg: #0b1220;
    --surface: rgba(17, 25, 40, 0.72);
    --surface-solid: #101a2e;
    --surface-muted: #17233c;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --line: #24314b;
    --shadow: 0 24px 48px rgba(0, 0, 0, .45);
}

.schedule-page.theme-light {
    --bg: #f3f6ff;
}

.print-only {
    display: none;
}

.print-schedule-list {
    display: none;
}

@page {
    size: A4 portrait;
    margin: 10mm;
}

@media print {
    html,
    body {
        background: #fff !important;
        color: #000 !important;
    }

    body {
        margin: 0;
    }

    .top-row,
    .admin-sidebar,
    .admin-dialog-backdrop,
    .print-hidden {
        display: none !important;
    }

    .page,
    .main,
    .content,
    .schedule-page,
    .admin-shell,
    .planner-content,
    .print-schedule-scope {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: auto !important;
        height: auto !important;
        background: #fff !important;
        box-shadow: none !important;
        border: 0 !important;
        backdrop-filter: none !important;
    }

    .glass-card,
    .holiday-card,
    .user-day-list .holiday-card {
        background: #fff !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
    }

    .print-only {
        display: block !important;
    }

    .print-header {
        margin: 0 0 6mm !important;
        padding: 0 !important;
        break-after: avoid;
        page-break-after: avoid;
    }

    .print-header h2 {
        margin: 0 0 2mm;
        font-size: 16pt;
    }

    .planner-subtitle {
        color: #444 !important;
    }

    .print-schedule-list {
        display: grid !important;
        gap: 4mm;
    }

    .admin-print-list {
        display: grid !important;
        gap: 5mm;
    }

    .print-schedule-card {
        border: 1px solid #d1d5db;
        border-radius: 10px;
        padding: 3mm;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .print-schedule-date {
        margin-bottom: 2mm;
        font-size: 10pt;
        font-weight: 700;
        color: #111;
    }

    .print-schedule-main {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 4mm;
        flex-wrap: wrap;
    }

    .print-schedule-time,
    .print-schedule-activity,
    .print-schedule-notes,
    .holiday-card-range,
    .holiday-card-notes {
        color: #374151 !important;
    }

    .print-schedule-time {
        font-size: 9pt;
        font-weight: 600;
    }

    .print-schedule-activity,
    .print-schedule-notes {
        margin-top: 1.5mm;
        font-size: 9pt;
    }

    .admin-print-card {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .admin-print-entry + .admin-print-entry {
        margin-top: 3mm;
        padding-top: 3mm;
        border-top: 1px dashed #d1d5db;
    }

    .admin-print-entry-date {
        margin-bottom: 1.5mm;
        font-size: 9pt;
        font-weight: 700;
        color: #111;
    }

    .admin-dienst-print-layout {
        color: #111 !important;
    }

    .admin-dienst-print-title {
        margin-bottom: 3mm;
        font-size: 16pt;
        font-weight: 700;
        text-align: center;
    }

    .admin-dienst-print-meta {
        margin-bottom: 1.5mm;
        font-size: 10pt;
    }

    .admin-dienst-print-table {
        width: 100%;
        margin-top: 4mm;
        border-collapse: collapse;
        font-size: 9pt;
        color: #111 !important;
    }

    .admin-dienst-print-table th,
    .admin-dienst-print-table td {
        padding: 1.5mm 2mm;
        vertical-align: top;
        text-align: left;
    }

    .admin-dienst-print-table thead th {
        border-bottom: 1px solid #9ca3af;
        font-weight: 700;
    }

    .admin-dienst-print-table tbody tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .admin-dienst-print-table tbody td:nth-child(1),
    .admin-dienst-print-table tbody td:nth-child(2) {
        font-weight: 700;
    }

    .day-service,
    .planner-item-title,
    .free-day {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .user-day-list {
        gap: 4mm;
    }

    .holiday-card {
        border: 1px solid #d1d5db !important;
        page-break-inside: avoid;
    }

    .holiday-card-main {
        align-items: center;
    }
}

@media (max-width: 768px) {
    .admin-user-cell {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-inline-actions,
    .admin-dialog-grid,
    .admin-dialog-actions {
        width: 100%;
    }

    .admin-dialog-grid {
        grid-template-columns: 1fr;
    }

    .admin-dialog-actions .btn {
        flex: 1 1 auto;
    }
}
