:root {
    --court-clay: #c45c38;
    --court-clay-deep: #9a3f24;
    --graphite: #2e2e32;
    --graphite-hover: #1f1f22;
    --ink: #1a1c1e;
    --muted: #5c6168;
    --paper: #f3f4f6;
    --surface: rgba(255, 255, 255, 0.85);
    --line: rgba(15, 18, 22, 0.08);
    --fc-line: rgba(15, 18, 22, 0.07);
    --shadow: 0 16px 40px rgba(20, 24, 28, 0.08);
    --radius: 20px;
    --font: "Inter", system-ui, sans-serif;
    --busy: #8a8f96;
    --own: #c45c38;
    --blocked: #4a5058;
}

[data-bs-theme="dark"] {
    --ink: #f2f3f5;
    --muted: #b4b8be;
    --paper: #121416;
    --surface: rgba(28, 30, 34, 0.78);
    --line: rgba(255, 255, 255, 0.1);
    --fc-line: rgba(255, 255, 255, 0.08);
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    --graphite: #3a3f46;
    --graphite-hover: #4a5058;
}

html, body {
    min-height: 100%;
}

body {
    font-family: var(--font);
    color: var(--ink);
    background: #f4f5f7;
    letter-spacing: -0.011em;
}

[data-bs-theme="dark"] body {
    background: #111214;
}

.page-bg, .page-veil { display: none; }

h1, h2, h3, .navbar-brand strong, .modal-title {
    font-family: "Inter", system-ui, sans-serif;
    letter-spacing: -0.02em;
    font-weight: 700;
}

h1 { font-size: clamp(1.75rem, 3.6vw, 2.55rem); }
h2 { font-size: 1.28rem; font-weight: 600; }

a { color: var(--court-clay); }
[data-bs-theme="dark"] a { color: #e08a6a; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
}

[data-bs-theme="dark"] .site-header {
    background: rgba(17, 18, 20, 0.92);
}

.navbar { padding-top: 0.85rem; padding-bottom: 0.85rem; }

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--ink);
    text-decoration: none;
}

.navbar-brand small {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 500;
    letter-spacing: 0;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(145deg, #d36a42 0 48%, #2c3036 48% 100%);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.navbar-toggler {
    border: 0;
    color: var(--ink);
    font-size: 1.6rem;
    padding: 0.15rem 0.4rem;
}

.nav-link {
    color: var(--ink) !important;
    font-weight: 500;
    padding: 0.45rem 0.8rem !important;
    border-radius: 999px;
}

.nav-link:hover { background: rgba(196, 92, 56, 0.1); }

.btn-court {
    --bs-btn-bg: var(--court-clay);
    --bs-btn-border-color: var(--court-clay);
    --bs-btn-hover-bg: var(--court-clay-deep);
    --bs-btn-hover-border-color: var(--court-clay-deep);
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    border-radius: 999px;
    font-weight: 600;
    padding: 0.7rem 1.3rem;
    box-shadow: 0 10px 22px rgba(196, 92, 56, 0.25);
}

.btn-ghost {
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.45);
    color: var(--ink);
    font-weight: 600;
}

[data-bs-theme="dark"] .btn-ghost {
    background: rgba(255, 255, 255, 0.06);
}

.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    display: grid;
    place-items: center;
}

[data-bs-theme="light"] .icon-moon { display: none; }
[data-bs-theme="dark"] .icon-sun { display: none; }

.glass-card, .glass-modal, .glass-alert {
    background: #fff;
    border: 1px solid #e8eaee;
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 30px rgba(16, 24, 40, 0.05);
}

[data-bs-theme="dark"] .glass-card,
[data-bs-theme="dark"] .glass-modal,
[data-bs-theme="dark"] .glass-alert {
    background: #1b1d21;
    border-color: rgba(255, 255, 255, 0.08);
}

.glass-card {
    padding: 1.75rem 1.6rem;
}

.glass-modal .modal-body,
.glass-modal .modal-header,
.glass-modal .modal-footer {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

@media (min-width: 768px) {
    .glass-card { padding: 2.15rem 2.25rem; }
}

.hero {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 2.5rem !important;
}

@media (min-width: 768px) {
    .hero {
        grid-template-columns: 148px 1fr;
        align-items: center;
    }
}

.court-thumb {
    width: 132px;
    height: 132px;
    object-fit: cover;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--court-clay);
    margin-bottom: 0.45rem;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 1.25rem 0 1.35rem; }

.rule-pills {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rule-pills li {
    background: rgba(196, 92, 56, 0.1);
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
}

.calendar-wrap { margin-top: 0.25rem; }

.calendar-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.35rem;
}

.legend { display: flex; flex-wrap: wrap; gap: 0.85rem; font-size: 0.9rem; color: var(--muted); }
.dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-right: 0.25rem; }
.dot-free { background: rgba(196, 92, 56, 0.12); box-shadow: inset 0 0 0 1px var(--court-clay); }
.dot-busy { background: var(--busy); }
.dot-own { background: var(--own); }
.dot-blocked { background: var(--blocked); }

#courtCalendar {
    --fc-border-color: var(--fc-line);
    --fc-page-bg-color: transparent;
    --fc-neutral-bg-color: rgba(255, 255, 255, 0.25);
    --fc-today-bg-color: rgba(196, 92, 56, 0.08);
    --fc-now-indicator-color: var(--court-clay);
    --fc-button-bg-color: var(--graphite);
    --fc-button-border-color: var(--graphite);
    --fc-button-hover-bg-color: var(--graphite-hover);
    --fc-button-hover-border-color: var(--graphite-hover);
    --fc-button-active-bg-color: var(--court-clay);
    --fc-button-active-border-color: var(--court-clay);
    --fc-button-text-color: #fff;
    min-height: 560px;
}

.fc .fc-toolbar-title {
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.fc .fc-button {
    border-radius: 8px !important;
    text-transform: none;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    box-shadow: none !important;
}

.fc .fc-button-primary:not(:disabled).fc-button-active {
    background: var(--court-clay) !important;
    border-color: var(--court-clay) !important;
}

.fc .fc-scrollgrid,
.fc .fc-scrollgrid td,
.fc .fc-scrollgrid th,
.fc td, .fc th {
    border-color: var(--fc-line) !important;
}

.fc .fc-scrollgrid {
    border: 1px solid var(--fc-line) !important;
    border-radius: 8px;
    overflow: hidden;
}

.fc .fc-col-header-cell {
    padding: 0.55rem 0;
    font-weight: 600;
    font-size: 0.82rem;
}

.fc .fc-timegrid-slot { height: 3.05rem; }
.fc .fc-timegrid-slot-lane { cursor: pointer; }
.fc .fc-timegrid-slot-label { font-size: 0.78rem; color: var(--muted); }

.fc .fc-event {
    border: 0 !important;
    border-radius: 8px !important;
    font-weight: 600;
    padding: 3px 7px;
    box-shadow: none;
}

.fc .fc-daygrid-day,
.fc .fc-timegrid-col {
    border-radius: 0;
}

.evt-busy { background: #8a8f96 !important; color: #fff !important; }
.evt-own { background: var(--court-clay) !important; color: #fff !important; }
.evt-blocked { background: #4a5058 !important; color: #fff !important; }

.auth-grid {
    display: grid;
    place-items: start center;
}
.auth-card {
    width: min(28.5rem, 100%);
}

.rodo-box {
    background: rgba(196, 92, 56, 0.08);
    border-radius: 16px;
    padding: 1.1rem 1.15rem;
}

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.status-chip, .mini-status, .code-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.28rem 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
}

.status-resident, .mini-resident, .mini-confirmed, .mini-active {
    background: rgba(196, 92, 56, 0.14);
    color: var(--court-clay-deep);
}
[data-bs-theme="dark"] .status-resident,
[data-bs-theme="dark"] .mini-resident,
[data-bs-theme="dark"] .mini-confirmed,
[data-bs-theme="dark"] .mini-active { color: #f0b39a; }

.status-unverified, .mini-unverified, .mini-pending, .mini-expired {
    background: rgba(44, 48, 54, 0.1);
    color: var(--graphite);
}
[data-bs-theme="dark"] .status-unverified,
[data-bs-theme="dark"] .mini-unverified,
[data-bs-theme="dark"] .mini-pending,
[data-bs-theme="dark"] .mini-expired { color: #d0d4da; }

.mini-cancelled, .mini-used, .mini-blocked {
    background: rgba(138, 143, 150, 0.22);
    color: var(--ink);
}

.code-pill {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: rgba(196, 92, 56, 0.12);
    cursor: pointer;
}

.booking-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.7rem; }
.booking-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: center;
    padding: 0.95rem 0;
    border-bottom: 1px solid var(--line);
}

.form-control, .form-select {
    border-radius: 12px;
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.7);
    padding: 0.75rem 0.9rem;
    color: var(--ink);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background: rgba(255, 255, 255, 0.06);
}

.form-control:focus, .form-select:focus {
    border-color: var(--court-clay);
    box-shadow: 0 0 0 0.22rem rgba(196, 92, 56, 0.18);
}

.codes-table { --bs-table-bg: transparent; --bs-table-color: var(--ink); }
.codes-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filter-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.filter-pills button {
    border: 1px solid var(--line);
    background: transparent;
    border-radius: 999px;
    padding: 0.28rem 0.75rem;
    color: var(--ink);
}
.filter-pills button.is-on {
    background: var(--court-clay);
    color: #fff;
    border-color: var(--court-clay);
}

.stat-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.5rem 0.8rem;
}

.lead-slot { font-family: var(--font); font-size: 1.25rem; font-weight: 600; letter-spacing: -0.03em; }

.legal-doc h2 { margin-top: 1.5rem; }
.site-main { min-height: calc(100vh - 9rem); }

.site-footer {
    padding: 1.8rem 0 2.4rem;
    color: var(--muted);
    font-size: 0.92rem;
}
.site-footer a { color: inherit; }

.address-block { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.03em; }

@media (max-width: 767px) {
    #courtCalendar { min-height: 480px; }
    .fc .fc-toolbar { flex-direction: column; gap: 0.65rem; }
    .fc .fc-timegrid-slot { height: 2.7rem; }
    .site-header .navbar-brand strong { font-size: 0.92rem; }
}

.toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1080;
    display: grid;
    gap: 0.5rem;
}
.toast-note {
    background: var(--graphite);
    color: #fff;
    padding: 0.85rem 1.05rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 22rem;
}
.toast-note.is-error { background: var(--court-clay-deep); }

.check-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.35rem;
    letter-spacing: 0.18em;
    font-weight: 700;
}

.guard-result {
    text-align: center;
    padding: 2.2rem 1.4rem;
    border-radius: 20px;
}
.guard-result.is-ok { background: #e8f7ee; color: #0f6b38; }
.guard-result.is-bad { background: #fdecea; color: #b42318; }
[data-bs-theme="dark"] .guard-result.is-ok { background: #143322; color: #8ee0b0; }
[data-bs-theme="dark"] .guard-result.is-bad { background: #3a1614; color: #ffb4ab; }
.guard-result .check-code { font-size: 2rem; }

.qr-box { width: 148px; height: 148px; }
.qr-box canvas, .qr-box img { width: 148px; height: 148px; }

.staff-locked { opacity: 0.72; }
