.multi-calendar {
    --calendar-border: #d8dee8;
    --calendar-primary: #2762a9;
    --calendar-primary-soft: #eaf2ff;
    --calendar-weekend: #fff8e1;
    --calendar-surface: #ffffff;
    --calendar-muted: #5f6b7a;
    position: relative;
    color: #1f2937;
}

.page-description {
    margin: 0.5rem 0 0;
    color: var(--calendar-muted);
}

.calendar-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-block-end: 1rem;
}

.calendar-navigation {
    display: inline-flex;
    align-items: stretch;
}

.calendar-nav-button,
.calendar-today-button {
    min-width: 2.75rem;
    min-height: 2.75rem;
    border: 0.0625rem solid var(--calendar-border);
    background: var(--calendar-surface);
    color: var(--calendar-primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.calendar-nav-button:first-child {
    border-radius: 0.5rem 0 0 0.5rem;
}

.calendar-nav-button:last-child {
    border-radius: 0 0.5rem 0.5rem 0;
}

.calendar-today-button {
    padding-inline: 1rem;
    border-inline: 0;
}

.calendar-nav-button:hover:not(:disabled),
.calendar-today-button:hover:not(:disabled) {
    background: var(--calendar-primary-soft);
}

.calendar-nav-button:focus-visible,
.calendar-today-button:focus-visible,
.price-cell-button:focus-visible,
.price-dialog-close:focus-visible {
    outline: 0.1875rem solid rgba(39, 98, 169, 0.35);
    outline-offset: 0.125rem;
}

.calendar-nav-button:disabled,
.calendar-today-button:disabled {
    color: #8a94a3;
    cursor: not-allowed;
}

.calendar-period {
    margin: 0;
    font-size: clamp(1rem, 0.95rem + 0.3vw, 1.25rem);
    font-weight: 700;
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin-block-end: 1rem;
    padding: 0.75rem 1rem;
    border: 0.0625rem solid var(--calendar-border);
    border-radius: 0.625rem;
    background: #f7f9fc;
}

.calendar-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--calendar-muted);
    font-size: 0.8125rem;
    font-weight: 600;
}

.calendar-legend-swatch {
    width: 1.5rem;
    height: 1.5rem;
    border: 0.0625rem solid #b8c4d6;
    border-radius: 0.25rem;
    background: #ffffff;
}

.calendar-legend-swatch.booked-full {
    background: linear-gradient(135deg, #5b8fd4 0%, #5b8fd4 100%);
}

.calendar-legend-swatch.booked-first-half {
    background: linear-gradient(to right, #5b8fd4 0 50%, #ffffff 50% 100%);
}

.calendar-legend-swatch.booked-second-half {
    background: linear-gradient(to right, #ffffff 0 50%, #5b8fd4 50% 100%);
}

.calendar-legend-swatch.booked-turnover {
    background: linear-gradient(to right, #5b8fd4 0 49%, #ffffff 49% 51%, #2f8f6d 51% 100%);
    border-color: #8a94a3;
}

.calendar-legend-swatch.unavailable {
    background: #fff0f0;
    border-color: #e6b4b7;
}

.calendar-legend-note {
    flex: 1 1 100%;
    margin: 0;
    color: var(--calendar-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.calendar-region {
    position: relative;
    min-height: 12rem;
}

.calendar-scroll {
    max-height: calc(100vh - 16rem);
    overflow: auto;
    border: 0.0625rem solid var(--calendar-border);
    border-radius: 0.75rem;
    background: var(--calendar-surface);
    box-shadow: 0 0.25rem 1rem rgba(15, 23, 42, 0.06);
}

.calendar-scroll:focus-visible {
    outline: 0.1875rem solid rgba(39, 98, 169, 0.25);
    outline-offset: 0.125rem;
}

.calendar-table {
    width: max-content;
    min-width: 100%;
    border-spacing: 0;
    table-layout: fixed;
}

.calendar-table th,
.calendar-table td {
    box-sizing: border-box;
    width: 6.25rem;
    min-width: 6.25rem;
    height: 4.5rem;
    padding: 0;
    border-inline-end: 0.0625rem solid var(--calendar-border);
    border-block-end: 0.0625rem solid var(--calendar-border);
}

.calendar-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    height: 4.25rem;
    padding: 0.5rem;
    background: #f7f9fc;
    text-align: center;
}

.calendar-table .housing-column {
    position: sticky;
    left: 0;
    z-index: 3;
    width: clamp(11rem, 22vw, 17rem);
    min-width: clamp(11rem, 22vw, 17rem);
    padding-inline: 1rem;
    background: var(--calendar-surface);
    text-align: start;
}

.calendar-table thead .housing-column {
    z-index: 4;
    background: #f7f9fc;
}

.housing-name {
    overflow: hidden;
    color: #1f2937;
    font-size: 0.9375rem;
    font-weight: 600;
}

.housing-name-content {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}

.housing-name-title,
.housing-group-differences {
    display: block;
    overflow: hidden;
    width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.housing-group-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999rem;
    background: #e8f1ff;
    color: #1f5796;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1.3;
}

.housing-group-differences {
    color: #5f6b7a;
    font-size: 0.6875rem;
    font-weight: 500;
}

.date-weekday,
.date-day,
.date-month {
    display: block;
}

.date-weekday,
.date-month {
    color: var(--calendar-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.date-day {
    margin-block: 0.0625rem;
    font-size: 1.125rem;
}

.calendar-table .weekend {
    background: var(--calendar-weekend);
}

.calendar-table .today {
    background: var(--calendar-primary-soft);
}

.price-cell-button {
    position: relative;
    display: grid;
    width: 100%;
    height: 100%;
    place-content: center;
    border: 0;
    background: transparent;
    color: #26364a;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.price-cell-button:hover {
    background: rgba(39, 98, 169, 0.1);
    box-shadow: inset 0 0 0 0.125rem var(--calendar-primary);
}

.price-value {
    font-size: 0.9375rem;
    font-weight: 700;
    white-space: nowrap;
}

.availability-label {
    margin-block-start: 0.25rem;
    color: #9f1d24;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
}

.calendar-table td.unavailable {
    background-color: #fff0f0;
}

.calendar-table td.has-booking {
    background-color: #f5f9ff;
}

.price-cell-button .booking-occupancy-indicator {
    position: absolute;
    inset: 0.1875rem;
    border-radius: 0.25rem;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    border: 0.0625rem solid rgba(39, 98, 169, 0.18);
}

.price-cell-button .booking-half {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
}

.price-cell-button .booking-half-first {
    left: 0;
}

.price-cell-button .booking-half-second {
    right: 0;
}

.price-cell-button .booking-tone-0 {
    background: rgba(39, 98, 169, 0.34);
}

.price-cell-button .booking-tone-1 {
    background: rgba(22, 128, 98, 0.34);
}

.price-cell-button .booking-tone-2 {
    background: rgba(180, 98, 26, 0.34);
}

.price-cell-button .booking-tone-3 {
    background: rgba(107, 66, 168, 0.34);
}

.price-cell-button .booking-occupancy-indicator.is-turnover::after {
    content: "";
    position: absolute;
    top: 0.125rem;
    bottom: 0.125rem;
    left: 50%;
    z-index: 1;
    width: 0.125rem;
    background: #ffffff;
    box-shadow: 0 0 0 0.0625rem rgba(15, 23, 42, 0.18);
    transform: translateX(-50%);
}

.price-cell-button .price-value,
.price-cell-button .availability-label {
    position: relative;
    z-index: 1;
}

.price-cell-button.booked-full .price-value,
.price-cell-button.booked-first-half .price-value,
.price-cell-button.booked-second-half .price-value,
.price-cell-button.booking-turnover .price-value {
    color: #16365f;
}

.calendar-table td.unavailable.has-booking .availability-label {
    color: #7a1420;
}

.calendar-loading,
.calendar-empty {
    display: grid;
    min-height: 12rem;
    place-content: center;
    gap: 0.75rem;
    color: var(--calendar-muted);
    text-align: center;
}

.calendar-empty i {
    color: #8a94a3;
    font-size: 2rem;
}

.calendar-empty p {
    margin: 0;
}

.calendar-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-content: center;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.72);
}

.price-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    padding: 1rem;
    place-items: center;
    background: rgba(15, 23, 42, 0.56);
}

.price-dialog {
    width: min(100%, 36rem);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    border-radius: 0.875rem;
    background: var(--calendar-surface, #ffffff);
    box-shadow: 0 1.5rem 3rem rgba(15, 23, 42, 0.3);
}

.price-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-block-end: 0.0625rem solid #d8dee8;
}

.price-dialog-header h2 {
    margin: 0;
    color: #1f2937;
    font-size: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem);
}

.price-dialog-header p {
    margin: 0.35rem 0 0;
    color: #5f6b7a;
    font-size: 0.875rem;
}

.price-dialog-close {
    display: grid;
    flex: 0 0 2.5rem;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    place-content: center;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: #4b5563;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
}

.price-dialog-close:hover {
    background: #eef1f5;
    color: #111827;
}

.price-dialog-body {
    display: grid;
    gap: 1.25rem;
    padding: 1.5rem;
}

.date-range-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.date-range-actions,
.price-apply-modes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.price-apply-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.price-apply-fieldset legend {
    width: auto;
    margin-block-end: 0.625rem;
    color: #26364a;
    font-size: 1rem;
    font-weight: 600;
}

.price-apply-mode-btn {
    min-height: 2.5rem;
    padding: 0.55rem 0.85rem;
    border: 0.0625rem solid #9aa6b5;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #26364a;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.price-apply-mode-btn:hover {
    border-color: #2762a9;
    background: #f0f5fc;
}

.price-apply-mode-btn:focus-visible {
    outline: 0.1875rem solid rgba(39, 98, 169, 0.35);
    outline-offset: 0.125rem;
}

.price-apply-mode-btn.active {
    border-color: #2762a9;
    background: #2762a9;
    color: #ffffff;
}

.price-apply-help {
    margin: 0.625rem 0 0;
    color: #5f6b7a;
    font-size: 0.8125rem;
}

.form-field {
    display: grid;
    gap: 0.5rem;
}

.form-field label {
    color: #26364a;
    font-weight: 600;
}

.form-control {
    min-height: 2.75rem;
}

.price-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-block-start: 0.0625rem solid #d8dee8;
    background: #f7f9fc;
}

@media (max-width: 47.9375rem) {
    .calendar-toolbar {
        align-items: stretch;
    }

    .calendar-navigation {
        width: 100%;
    }

    .calendar-today-button {
        flex: 1;
    }

    .calendar-period {
        width: 100%;
        text-align: center;
    }

    .calendar-scroll {
        max-height: calc(100vh - 18rem);
    }

    .calendar-table .housing-column {
        width: 10rem;
        min-width: 10rem;
        padding-inline: 0.75rem;
    }

    .calendar-table th,
    .calendar-table td {
        width: 5.5rem;
        min-width: 5.5rem;
    }

    .price-dialog-overlay {
        align-items: end;
        padding: 0;
    }

    .price-dialog {
        width: 100%;
        max-height: 92vh;
        border-radius: 1rem 1rem 0 0;
    }

    .date-range-fields {
        grid-template-columns: 1fr;
    }

    .date-range-actions .btn,
    .price-apply-mode-btn {
        flex: 1 1 10rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .calendar-nav-button,
    .calendar-today-button,
    .price-cell-button,
    .price-apply-mode-btn {
        transition: none;
    }
}
