:root {
    --bg: #fdf6e3;
    --surface: #fffef9;
    --surface-muted: #f2ead2;
    --text: #073642;
    --muted: #586e75;
    --accent: #cb4b16;
    --accent-dark: #b0300b;
    --ghost: #d8c8a4;
    --danger: #dc322f;
    --success: #2aa198;
    --warning: #b58900;
    font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: linear-gradient(180deg, #fdf6e3 0%, #f6e8c3 60%, #fefaf0 100%);
    color: var(--text);
    min-height: 100vh;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 4vw;
    position: sticky;
    top: 0;
    backdrop-filter: blur(12px);
    background: rgba(253, 246, 227, 0.85);
    border-bottom: 1px solid rgba(7, 54, 66, 0.08);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brand-icon {
    width: 1.35rem;
    height: 1.35rem;
    flex: 0 0 auto;
}

nav a {
    margin-right: 1rem;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.8rem;
}

nav.guest-nav {
    flex: 1;
    justify-content: center;
}

nav a:last-child {
    margin-right: 0;
}

nav a.active,
nav a:hover {
    color: var(--accent);
}

.auth-block {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.help-link {
    text-decoration: none;
    border: 1px dashed rgba(88, 110, 117, 0.55);
    color: var(--accent-dark);
    background: rgba(88, 110, 117, 0.06);
    padding: 0.45rem 0.85rem;
    margin-right: 0.6rem;
    border-radius: 999px;
    font-weight: 600;
    white-space: nowrap;
}

.help-link.active,
.help-link:hover {
    border-color: rgba(88, 110, 117, 0.75);
    background: rgba(88, 110, 117, 0.12);
}

.auth-block a {
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid transparent;
}

.auth-block .welcome {
    font-size: 0.95rem;
    color: var(--muted);
}

.page {
    padding: 2rem 4vw 4rem;
}

.flash-list {
    list-style: none;
    padding-left: 0;
    margin: 0 0 1rem 0;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 0.6rem;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(7, 54, 66, 0.15);
    background: rgba(238, 232, 213, 0.9);
}

.flash.success {
    border-color: var(--success);
}

.flash.danger {
    border-color: var(--danger);
}

.flash.warning {
    border-color: var(--warning);
}

.site-footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.hero h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    margin: 0.25rem 0 1rem;
}

.hero-meta {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.stat {
    background: var(--surface);
    border-radius: 1rem;
    padding: 1rem 1.5rem;
    border: 1px solid rgba(7, 54, 66, 0.08);
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 1.5rem;
}

.stat strong {
    display: block;
    font-size: 1.5rem;
}

.stat strong + strong {
    margin-top: 0.45rem;
}

.stat strong.stat-muted-line {
    color: var(--muted);
}

.stat small {
    display: block;
    margin-top: 0.45rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.stat-costs {
    text-align: right;
}

.stat-costs .day-total {
    display: block;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(7, 54, 66, 0.15);
    font-weight: 600;
}

.stat-balance {
    border: 2px solid rgba(38, 139, 210, 0.35);
    background: linear-gradient(135deg, rgba(38, 139, 210, 0.12), rgba(42, 161, 152, 0.12));
}

.stat-balance strong {
    font-size: 1.5rem;
}

.stat-balance.is-negative {
    border-color: rgba(220, 50, 47, 0.35);
    background: linear-gradient(135deg, rgba(220, 50, 47, 0.12), rgba(203, 75, 22, 0.12));
}

.day-card {
    background: var(--surface);
    border-radius: 1.5rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 24px 60px rgba(88, 110, 117, 0.2);
    border: 1px solid rgba(7, 54, 66, 0.06);
}

.day-card header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.eyebrow {
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    font-size: 0.75rem;
    margin: 0;
}

.cost-display {
    font-size: 1rem;
    color: var(--muted);
}


.slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
    align-items: stretch;
}

.slot-panel {
    background: var(--surface-muted);
    border-radius: 1.25rem;
    padding: 1.25rem;
    border: 1px solid rgba(7, 54, 66, 0.08);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.slot-panel.needs-players {
    border-color: rgba(181, 137, 0, 0.45);
    background: rgba(255, 249, 219, 0.9);
}

.slot-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
    min-height: 320px;
}

.booking-table-wrapper {
    flex: 0 0 240px;
    min-height: 240px;
    max-height: 240px;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 0.9rem;
    border: 1px solid rgba(7, 54, 66, 0.08);
    padding: 0.5rem 0.75rem;
    background: #fffef9;
}

.booking-table-wrapper--overview {
    flex: 0 0 380px;
    min-height: 380px;
    max-height: 380px;
}

.booking-table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.booking-table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(7, 54, 66, 0.2);
    border-radius: 999px;
}

.day-card.history .slot-panel {
    background: var(--surface);
}

.slot-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.slot-head h3 {
    margin: 0;
    font-size: 1.35rem;
}

.capacity {
    font-size: 0.9rem;
    color: var(--muted);
}

.court-chip {
    display: inline-flex;
    margin-top: 0.25rem;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(7, 54, 66, 0.15);
    background: rgba(253, 246, 227, 0.9);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.booking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.booking-table th,
.booking-table td {
    border-bottom: 1px solid rgba(7, 54, 66, 0.08);
    padding: 0.4rem 0.2rem;
    vertical-align: middle;
}

.booking-table th {
    text-align: left;
    color: var(--muted);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
}

.badge {
    margin-left: 0.4rem;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: rgba(203, 75, 22, 0.15);
    border: 1px solid rgba(203, 75, 22, 0.35);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.6rem;
    padding: 0.15rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    border: 1px solid rgba(7, 54, 66, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.status-pill.success {
    color: var(--success);
    border-color: rgba(42, 161, 152, 0.5);
}

.status-pill.warning {
    color: var(--warning);
    border-color: rgba(181, 137, 0, 0.6);
}

.slot-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0;
}

.slot-panel > .slot-actions {
    margin-top: auto;
}

.booking-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
}

.booking-form select,
.booking-form input {
    flex: 1 1 180px;
    min-width: 0;
}

.booking-form button {
    flex: 0 0 auto;
}

.note-form {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.note-form input {
    flex: 1;
    padding: 0.3rem 0.55rem;
    font-size: 0.9rem;
    height: 32px;
}

.inline-action {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 32px;
}

.inline-action form {
    margin: 0;
    display: inline-flex;
}

.action-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    color: var(--muted);
    min-height: 32px;
}

.session-comments {
    border-top: 1px solid rgba(7, 54, 66, 0.12);
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.session-comments ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.session-comments li {
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.session-comments em {
    font-size: 0.75rem;
    color: var(--muted);
}

.comment-form {
    display: flex;
    gap: 0.5rem;
}

.comment-form input {
    flex: 1;
}

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

input,
select {
    border-radius: 0.9rem;
    border: 1px solid rgba(7, 54, 66, 0.2);
    background: #fffefa;
    color: var(--text);
    padding: 0.65rem 0.9rem;
}

button,
.primary,
.ghost {
    border: none;
    border-radius: 999px;
    padding: 0.65rem 1.2rem;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.primary {
    background: var(--accent);
    color: #fffef9;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(203, 75, 22, 0.3);
}

.primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.ghost,
.auth-block .ghost {
    background: #fffef9;
    color: var(--muted);
    border: 1px solid rgba(7, 54, 66, 0.2);
    box-shadow: none;
}

.ghost.small {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
}

button:hover:not(:disabled),
.primary:hover:not(:disabled),
.ghost:hover {
    transform: translateY(-2px);
}

.muted {
    color: var(--muted);
    text-align: center;
}

.note {
    font-style: italic;
}

.warning-line {
    color: var(--warning);
    font-size: 0.85rem;
    margin: 0;
    text-align: left;
}

.day-cancel-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.day-cancel-form input {
    min-width: 320px;
}

.auth-card,
.admin-grid article {
    background: var(--surface);
    padding: 2rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(7, 54, 66, 0.08);
    box-shadow: 0 20px 60px rgba(95, 111, 123, 0.25);
}

.auth-card {
    max-width: 480px;
    margin: 0 auto;
}

.account-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.account-grid.account-grid-self {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.account-grid article {
    background: var(--surface);
    border-radius: 1.25rem;
    padding: 1.5rem;
    border: 1px solid rgba(7, 54, 66, 0.08);
    box-shadow: 0 20px 60px rgba(95, 111, 123, 0.15);
}

.account-grid .account-panel-wide {
    grid-column: span 2;
}

.account-grid.account-grid-self .account-panel-compact {
    grid-column: span 2;
}

.account-grid.account-grid-self .account-panel-wide {
    grid-column: span 3;
}

.account-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.account-table-wrap {
    overflow-x: auto;
    margin-top: 1rem;
}

.account-table-wrap .account-table {
    margin-top: 0;
    min-width: 520px;
}

.account-table th,
.account-table td {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(7, 54, 66, 0.08);
    text-align: left;
    vertical-align: top;
}

.account-table th {
    color: var(--muted);
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.account-table .col-date {
    white-space: nowrap;
    width: 1%;
    padding-right: 1.4rem;
}

.account-table .col-slot {
    padding-left: 0.35rem;
}

.account-table .booking-note,
.account-table .col-note {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
}

.auth-form label,
.admin-form label {
    font-size: 0.85rem;
    color: var(--muted);
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 1rem;
}

.admin-form label {
    display: block;
    margin-bottom: 0.3rem;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
    width: 100%;
    display: block;
}

.admin-form button {
    align-self: flex-start;
}

.pricing-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem 1.25rem;
    margin-top: 1rem;
}

.pricing-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.pricing-form .form-group.full-span {
    grid-column: 1 / -1;
}

.pricing-form .form-group.span-two {
    grid-column: span 2;
}

@media (max-width: 640px) {
    .pricing-form {
        grid-template-columns: 1fr;
    }

    .pricing-form .form-group.span-two {
        grid-column: 1 / -1;
    }

    .account-grid .account-panel-wide {
        grid-column: auto;
    }
}

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

    .account-grid.account-grid-self .account-panel-compact,
    .account-grid.account-grid-self .account-panel-wide {
        grid-column: span 1;
    }
}

@media (max-width: 640px) {
    .account-grid.account-grid-self {
        grid-template-columns: 1fr;
    }
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.transaction-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.transaction-table th,
.transaction-table td {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(7, 54, 66, 0.08);
    text-align: left;
}

.transaction-table .plus {
    color: var(--success);
}

.transaction-table .minus {
    color: var(--danger);
}

.info-line {
    color: var(--success);
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    .site-header {
        flex-direction: column;
        gap: 1rem;
    }

    .hero-meta {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .booking-form {
        flex-direction: column;
        align-items: stretch;
    }

    .booking-form select,
    .booking-form input,
    .booking-form button {
        flex: 1 1 auto;
        width: 100%;
    }

    .slot-content {
        min-height: 0;
    }

    .booking-table-wrapper {
        flex: 1 1 auto;
        max-height: none;
    }

    .comment-form {
        flex-direction: column;
    }

    .comment-form button {
        width: 100%;
    }

    .slot-actions form {
        width: 100%;
    }

    .slot-actions form button,
    .slot-actions > button {
        width: 100%;
    }

    button,
    .primary,
    .ghost,
    input,
    select,
    textarea,
    .inline-action,
    .action-placeholder,
    .note-form input {
        min-height: 44px;
    }
}

@media (max-width: 860px) {
    .site-header {
        align-items: flex-start;
        gap: 0.8rem;
    }

    .help-link {
        order: 2;
    }

    .auth-block {
        width: 100%;
        justify-content: space-between;
    }

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