:root {
    --bg: #081a33;
    --bg-soft: #0f2a4d;
    --panel: rgba(13, 35, 63, 0.92);
    --panel-border: rgba(149, 180, 219, 0.18);
    --text: #eef5ff;
    --text-soft: #a8bfdc;
    --free: #1f9d61;
    --free-hover: #28b16f;
    --booked: #c54545;
    --booked-hover: #db5353;
    --today-ring: #ffd166;
    --shadow: 0 24px 60px rgba(2, 9, 20, 0.35);
    --radius: 18px;
    --font-body: "Instrument Sans", "Segoe UI", sans-serif;
    --font-display: "Space Grotesk", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    background:
        radial-gradient(circle at top left, rgba(46, 110, 198, 0.18), transparent 35%),
        radial-gradient(circle at bottom right, rgba(29, 173, 118, 0.12), transparent 24%),
        var(--bg);
    color: var(--text);
}

.theme-shell {
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    padding: 22px 26px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.topbar h1,
.login-panel h1 {
    margin: 6px 0 0;
    font-size: clamp(1.7rem, 2.8vw, 2.8rem);
    font-family: var(--font-display);
    letter-spacing: -0.04em;
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-soft);
    font-size: 0.78rem;
    font-family: var(--font-display);
    font-weight: 700;
}

.subtitle,
.login-copy {
    margin: 8px 0 0;
    color: var(--text-soft);
}

.topbar-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
}

.legend,
.week-switcher,
.admin-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-soft);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    display: inline-block;
}

.legend-dot.is-free {
    background: var(--free);
}

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

.nav-button,
.primary-button,
.link-button {
    border: 0;
    border-radius: 999px;
    padding: 11px 18px;
    background: #173b6d;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.16s ease, background 0.16s ease;
}

.nav-button:hover,
.primary-button:hover,
.link-button:hover {
    transform: translateY(-1px);
    background: #22508f;
}

.week-range {
    min-width: 180px;
    text-align: center;
    font-weight: 600;
}

.calendar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.calendar-grid {
    display: grid;
    gap: 14px;
    min-height: 0;
}

.day-row {
    display: grid;
    grid-template-columns: minmax(180px, 240px) 1fr;
    gap: 14px;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.day-row.is-today {
    border-color: rgba(255, 209, 102, 0.48);
}

.day-heading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
}

.day-name {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-display);
    letter-spacing: -0.03em;
}

.day-date {
    color: var(--text-soft);
}

.slots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(134px, 1fr));
    gap: 12px;
}

.slot-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 108px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}

[data-calendar-app="admin"] .slot-card {
    cursor: pointer;
}

.slot-card:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
    box-shadow: 0 10px 24px rgba(4, 8, 15, 0.26);
}

.slot-card.is-free {
    background: linear-gradient(180deg, rgba(31, 157, 97, 0.96), rgba(21, 112, 70, 0.96));
}

.slot-card.is-free:hover {
    background: linear-gradient(180deg, rgba(40, 177, 111, 0.98), rgba(24, 124, 77, 0.98));
}

.slot-card.is-booked {
    background: linear-gradient(180deg, rgba(197, 69, 69, 0.96), rgba(136, 34, 34, 0.96));
}

.slot-card.is-booked:hover {
    background: linear-gradient(180deg, rgba(219, 83, 83, 0.98), rgba(150, 42, 42, 0.98));
}

.slot-card.is-today::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 2px solid rgba(255, 209, 102, 0.88);
    border-radius: inherit;
    pointer-events: none;
}

.slot-time {
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

.slot-state {
    font-size: 0.95rem;
}

.slot-meta {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.82);
}

.modal-open {
    overflow: hidden;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(3, 8, 20, 0.62);
    backdrop-filter: blur(6px);
    z-index: 30;
}

.modal-panel {
    position: relative;
    width: min(520px, 100%);
    padding: 28px;
    background: #0c2342;
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-title {
    margin: 8px 0 10px;
    font-size: 1.7rem;
    font-family: var(--font-display);
    letter-spacing: -0.03em;
}

.modal-copy {
    margin: 0 0 22px;
    color: var(--text-soft);
}

.modal-form {
    display: grid;
    gap: 16px;
}

.modal-form label {
    display: grid;
    gap: 8px;
}

.modal-form input {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.modal-form input:focus {
    outline: 2px solid rgba(255, 209, 102, 0.5);
    border-color: transparent;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.danger-button {
    border: 0;
    border-radius: 999px;
    padding: 11px 18px;
    background: var(--booked);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease;
}

.danger-button:hover {
    transform: translateY(-1px);
    background: var(--booked-hover);
}

.reservation-detail {
    display: grid;
    gap: 14px;
    margin: 0;
}

.reservation-detail div {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
}

.reservation-detail dt {
    margin-bottom: 6px;
    color: var(--text-soft);
}

.reservation-detail dd {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.status-banner,
.form-alert {
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid transparent;
}

.status-banner {
    background: rgba(23, 59, 109, 0.55);
}

.status-banner.is-success {
    border-color: rgba(31, 157, 97, 0.4);
}

.status-banner.is-error,
.form-alert {
    border-color: rgba(197, 69, 69, 0.5);
    background: rgba(197, 69, 69, 0.14);
}

.login-body {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(440px, 100%);
    padding: 32px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.login-form label {
    display: grid;
    gap: 8px;
}

.login-form input {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.login-form input:focus {
    outline: 2px solid rgba(255, 209, 102, 0.5);
    border-color: transparent;
}

@media (max-width: 900px) {
    .app-shell {
        padding: 16px;
    }

    .topbar,
    .day-row {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 18px;
    }

    .topbar-actions {
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .slots {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .nav-button,
    .primary-button,
    .link-button {
        width: 100%;
        text-align: center;
    }

    .week-switcher,
    .admin-tools {
        width: 100%;
    }

    .week-range {
        width: 100%;
    }

    .modal-panel {
        padding: 22px 18px;
    }

    .modal-actions > * {
        width: 100%;
        text-align: center;
    }
}
