:root {
    --bg: #f7f7f5;
    --panel: #ffffff;
    --text: #202124;
    --muted: #71717a;
    --border: #dedbd4;
    --available: #e8f7ee;
    --available-text: #137a3d;
    --booked: #fdecec;
    --booked-text: #b42318;
    --blocked: #fff4df;
    --blocked-text: #b86b00;
    --apple: #edf2ff;
    --apple-text: #315aa8;
    --primary: #303030;
    --primary-dark: #151515;
    --control: #efeeeb;
    --control-hover: #e5e3df;
    --shadow: 0 12px 32px rgba(32, 33, 36, 0.06);
    --soft-shadow: 0 8px 22px rgba(32, 33, 36, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.topbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(28px, 3.5vw, 42px);
    line-height: 1.05;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 14px;
    font-size: 20px;
}

h3 {
    margin: 22px 0 10px;
    font-size: 15px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    color: var(--muted);
    font-size: 14px;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
}

.dot.available {
    background: var(--available-text);
}

.dot.booked {
    background: var(--booked-text);
}

.dot.blocked {
    background: var(--blocked-text);
}

.dot.apple {
    background: var(--apple-text);
}

.controls {
    display: grid;
    grid-template-columns: auto minmax(150px, 190px) auto auto;
    align-items: end;
    gap: 14px;
    padding: 16px;
    margin-bottom: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.view-switch,
.date-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.view-switch {
    align-self: end;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f3f2ef;
}

.view-button,
button.secondary {
    background: var(--control);
    color: var(--text);
}

.view-button {
    min-height: 38px;
    padding: 0 14px;
    border-radius: 7px;
}

.view-button.active {
    background: var(--primary);
    color: #fff;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 13px;
    background: #fff;
    color: var(--text);
    min-height: 46px;
}

textarea {
    resize: vertical;
}

button {
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    padding: 0 18px;
    background: var(--primary);
    color: #fff;
    font-weight: 750;
    cursor: pointer;
}

button:hover {
    background: var(--primary-dark);
}

.view-button:hover,
button.secondary:hover {
    background: var(--control-hover);
}

.view-button.active:hover {
    background: var(--primary-dark);
}

button.secondary {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 7px;
}

.message {
    display: none;
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel);
}

.message.show {
    display: block;
}

.message.error {
    border-color: #e7c9c9;
    color: var(--booked-text);
}

.message.success {
    border-color: #c9dfcf;
    color: var(--available-text);
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
}

.calendar-panel,
.booking-panel,
.admin-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.calendar-panel {
    overflow: auto;
}

.calendar {
    display: grid;
    gap: 18px;
    padding: 16px;
    min-width: min(100%, 780px);
}

.calendar-week {
    min-width: 760px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: var(--soft-shadow);
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(var(--day-count), minmax(108px, 1fr));
}

.calendar[data-view="day"] .calendar-week {
    min-width: 320px;
}

.calendar[data-view="day"] .week-grid {
    grid-template-columns: minmax(280px, 1fr);
}

.calendar[data-view="day"] .day-title {
    min-height: 70px;
}

.day {
    min-width: 0;
    border-right: 1px solid var(--border);
    background: #fff;
}

.day:last-child {
    border-right: 0;
}

.day-title {
    display: grid;
    gap: 3px;
    min-height: 86px;
    padding: 13px 12px 12px;
    border-bottom: 1px solid var(--border);
    background: #f4f3f0;
}

.day-title span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: capitalize;
}

.day-title strong {
    font-size: 18px;
    line-height: 1.2;
}

.day-title small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
}

.slots-list {
    display: grid;
    gap: 8px;
    padding: 11px;
}

.slot {
    width: 100%;
    display: grid;
    align-content: center;
    justify-content: start;
    gap: 0;
    min-height: 52px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 11px;
    text-align: left;
    color: var(--text);
    background: #f5f5f3;
}

.slot-time {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 15px;
    font-weight: 850;
    line-height: 1.2;
}

.slot-separator {
    color: currentColor;
    opacity: 0.8;
}

.slot-status {
    display: block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.slot.available {
    background: var(--available);
    color: var(--available-text);
    border-color: #bfe7cc;
}

.slot.available:hover,
.slot.available.selected {
    background: #d9f2e3;
    border-color: #52b873;
    box-shadow: inset 0 0 0 1px #52b873;
}

.slot.booked {
    background: var(--booked);
    color: var(--booked-text);
    cursor: not-allowed;
}

.slot.blocked {
    background: var(--blocked);
    color: var(--blocked-text);
    cursor: not-allowed;
}

.slot.apple {
    background: var(--apple);
    color: var(--apple-text);
    cursor: not-allowed;
}

.side-panel {
    display: grid;
    gap: 18px;
}

.admin-panel {
    display: none;
}

body.admin-unlocked .admin-panel {
    display: block;
}

.booking-panel,
.admin-panel {
    padding: 18px;
}

form {
    display: grid;
    gap: 12px;
}

.selected-slot {
    min-height: 24px;
    color: var(--muted);
    font-weight: 650;
}

.list {
    display: grid;
    gap: 8px;
}

.list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f5f5f3;
}

.list-item strong {
    display: block;
    margin-bottom: 3px;
    font-size: 14px;
}

.list-item small {
    color: var(--muted);
}

.empty {
    color: var(--muted);
    font-size: 14px;
}

.empty-day {
    margin: 0;
    padding: 14px 8px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

@media (max-width: 920px) {
    .topbar {
        align-items: start;
        flex-direction: column;
    }

    .controls {
        grid-template-columns: 1fr 1fr;
    }

    .layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .app {
        width: min(100% - 20px, 1280px);
        padding-top: 20px;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .view-switch,
    .date-nav {
        width: 100%;
    }

    .view-button,
    .date-nav button,
    #refreshBtn {
        flex: 1;
    }

    .calendar {
        padding: 10px;
    }

    .calendar-week {
        min-width: 0;
    }

    .week-grid {
        grid-template-columns: 1fr;
    }

    .day {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .day:last-child {
        border-bottom: 0;
    }
}
