:root {
    color-scheme: light;
    --paper: #f5f3ee;
    --surface: #fffefb;
    --ink: #20261f;
    --muted: #687067;
    --line: #d9ddd4;
    --green: #236a4b;
    --green-soft: #dcecdf;
    --orange: #bd5d2c;
    --orange-soft: #f6ddce;
    --yellow: #f3c64c;
    --yellow-soft: #fff2b8;
    --school: #34799a;
    --school-soft: #e3f1f7;
    --red: #aa3f3f;
    font-family: ui-sans-serif, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: var(--paper);
    background-image: linear-gradient(90deg, rgba(32, 38, 31, .025) 1px, transparent 1px);
    background-size: 48px 48px;
    color: var(--ink);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    max-width: 1440px;
    margin: 0 auto;
    padding: 38px 32px 24px;
    border-bottom: 1px solid var(--line);
}

.header-subtitle {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: .95rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.save-status {
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 600;
}

.save-status>span {
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 4px var(--green-soft);
}

.save-status.error {
    color: var(--red);
}

.save-status.error>span {
    background: var(--red);
    box-shadow: 0 0 0 4px #f8dcdc;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--green);
    font-size: .76rem;
    font-weight: 700;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(2.2rem, 4vw, 4rem);
    font-weight: 600;
    letter-spacing: 0;
}

main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px 32px 48px;
}

.control-panel {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 254, 251, .92);
    box-shadow: 0 16px 40px rgba(32, 38, 31, .06);
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 14px;
}

label>span:first-child,
.summary-label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 600;
}

input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
    color: var(--ink);
    padding: 9px 11px;
}

input:focus,
select:focus,
button:focus-visible {
    outline: 3px solid rgba(35, 106, 75, .22);
    outline-offset: 1px;
}

.input-unit {
    display: flex;
    position: relative;
}

.input-unit input {
    padding-right: 48px;
}

.input-unit>span {
    position: absolute;
    top: 12px;
    right: 12px;
    color: var(--muted);
    pointer-events: none;
}

.summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin-top: 18px;
    border-block: 1px solid var(--line);
    background: #fafbf7;
}

.summary>div {
    position: relative;
    padding: 18px 20px;
}

.summary>div::before {
    position: absolute;
    top: 0;
    left: 20px;
    width: 32px;
    height: 3px;
    background: var(--green);
    content: "";
}

.summary>div:nth-child(2)::before {
    background: var(--orange);
}

.summary>div:nth-child(3)::before {
    background: var(--yellow);
}

.summary>div+div {
    border-left: 1px solid var(--line);
}

.summary strong {
    display: block;
    font-family: Georgia, serif;
    font-size: 1.6rem;
}

.summary small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.segmented-control {
    display: inline-flex;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    padding: 3px;
}

.segmented-control button {
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--muted);
    padding: 8px 12px;
    font-weight: 600;
}

.segmented-control button {
    transition: background-color .15s ease, color .15s ease, transform .15s ease;
}

.segmented-control button:hover:not(.active) {
    background: #eef2eb;
    color: var(--ink);
}

.segmented-control button.active {
    background: var(--ink);
    color: white;
}

.booking-mode {
    margin-left: auto;
}

.swatch {
    display: inline-block;
    width: 11px;
    height: 11px;
    margin-right: 7px;
    border-radius: 2px;
    vertical-align: -1px;
}

.swatch.vacation {
    background: var(--green);
}

.swatch.overtime {
    background: var(--orange);
}

.swatch.holiday {
    background: var(--yellow);
}

.swatch.school {
    background: var(--school);
}

.month-picker-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.month-picker-wrap select {
    min-width: 150px;
    min-height: 42px;
}

.icon-button,
.button {
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
    color: var(--ink);
    min-height: 40px;
    padding: 8px 14px;
    font-weight: 600;
}

.icon-button {
    width: 42px;
    font-size: 1.15rem;
    padding: 6px;
}

.button.secondary:hover,
.icon-button:hover {
    border-color: var(--ink);
}

.hint {
    margin: 18px 0 16px;
    color: var(--muted);
    font-size: .88rem;
}

.hint::before {
    margin-right: 8px;
    color: var(--green);
    font-weight: 700;
    content: "+";
}

.calendar {
    display: grid;
    gap: 18px;
}

.calendar.all-months {
    grid-template-columns: repeat(3, minmax(260px, 1fr));
}

.calendar.year-list {
    display: flex;
    flex-direction: column;
}

.month-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    box-shadow: 0 5px 18px rgba(32, 38, 31, .035);
}

.month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 16px 12px;
    border-bottom: 1px solid var(--line);
}

.month-header h2 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: 1.35rem;
}

.month-header span {
    color: var(--muted);
    font-size: .78rem;
}

.weekdays,
.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.weekdays span {
    padding: 9px 3px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    text-align: center;
}

.day {
    position: relative;
    min-width: 0;
    aspect-ratio: 1;
    border: 0;
    border-right: 1px solid #eef0eb;
    border-top: 1px solid #eef0eb;
    background: var(--surface);
    color: var(--ink);
    padding: 5px;
    text-align: left;
}

.day:nth-child(7n) {
    border-right: 0;
}

.day {
    transition: background-color .13s ease, box-shadow .13s ease;
}

.day:hover:not(:disabled) {
    z-index: 1;
    background: #edf5ef;
    box-shadow: inset 0 0 0 2px var(--green);
}

.day.empty {
    background: #f8f7f3;
}

.day.weekend {
    background: #eeeee9;
    color: #899087;
}

.day.holiday {
    background: var(--yellow-soft);
}

.day.school-vacation:not(.holiday):not(.weekend):not(.booked-vacation):not(.booked-overtime) {
    background: var(--school-soft);
}

.day.school-vacation::after {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: var(--school);
    content: "";
}

.day.booked-vacation {
    background: var(--green-soft);
    box-shadow: inset 4px 0 0 var(--green);
}

.day.booked-overtime {
    background: var(--orange-soft);
    box-shadow: inset 4px 0 0 var(--orange);
}

.day:disabled {
    cursor: not-allowed;
    opacity: 1;
}

.day-number {
    display: block;
    font-size: .86rem;
    font-weight: 700;
}

.day-status {
    position: absolute;
    left: 5px;
    right: 4px;
    bottom: 5px;
    overflow: hidden;
    font-size: .58rem;
    line-height: 1.15;
    text-overflow: ellipsis;
}

.day-marker {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .65;
}

.today-dot {
    box-shadow: inset 0 0 0 2px var(--ink);
}

.single-month {
    max-width: 900px;
}

.single-month .day {
    min-height: 110px;
    aspect-ratio: auto;
}

.single-month .day-number {
    font-size: 1rem;
}

.single-month .day-status {
    font-size: .72rem;
}

.year-list .month-card {
    display: grid;
    grid-template-columns: 180px 1fr;
}

.year-list .month-header {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    border-right: 1px solid var(--line);
    border-bottom: 0;
}

.year-list .calendar-body {
    min-width: 0;
}

.year-list .day {
    min-height: 54px;
    aspect-ratio: auto;
}

.year-list .day.empty,
.year-list .weekdays span {
    min-height: 36px;
}

.year-list .day-status {
    white-space: nowrap;
}

footer {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 32px 36px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .82rem;
}

.legend {
    display: flex;
    gap: 18px;
}

.toast {
    position: fixed;
    z-index: 10;
    right: 24px;
    bottom: 24px;
    max-width: 380px;
    padding: 12px 16px;
    border-radius: 5px;
    background: var(--ink);
    box-shadow: 0 12px 34px rgba(0, 0, 0, .18);
    color: white;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity .18s, transform .18s;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 1000px) {
    .calendar.all-months {
        grid-template-columns: repeat(2, minmax(240px, 1fr));
    }

    .input-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .booking-mode {
        margin-left: 0;
    }
}

@media (max-width: 680px) {

    .app-header,
    main,
    footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 18px;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .control-panel {
        padding: 14px;
    }

    .button.secondary {
        font-size: .8rem;
    }

    .input-grid,
    .summary,
    .calendar.all-months {
        grid-template-columns: 1fr;
    }

    .summary>div+div {
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .toolbar,
    .segmented-control {
        width: 100%;
    }

    .segmented-control button {
        flex: 1;
        padding-inline: 7px;
    }

    .month-picker-wrap {
        width: 100%;
    }

    .month-picker-wrap select {
        flex: 1;
    }

    .year-list .month-card {
        grid-template-columns: 1fr;
    }

    .year-list .month-header {
        flex-direction: row;
        align-items: center;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .year-list .day-status {
        font-size: .5rem;
    }

    .single-month .day {
        min-height: 70px;
    }

    footer {
        align-items: flex-start;
        flex-direction: column;
    }
}