:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-muted: #eef2f4;
    --ink: #172026;
    --muted: #66737f;
    --line: #d9e0e5;
    --blue: #1d5f99;
    --green: #2d7d55;
    --amber: #b26a00;
    --red: #b93838;
    --purple: #6a4fb3;
    --teal: #0f766e;
    --shadow: 0 8px 24px rgba(23, 32, 38, 0.08);
}

* {
    box-sizing: border-box;
}

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

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

button {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    background: var(--blue);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

button:hover {
    filter: brightness(0.96);
}

button.ghost,
.tab {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 28px clamp(16px, 4vw, 48px);
    background: #18252d;
    color: #fff;
}

.app-header h1,
.section-heading h2,
.panel h3 {
    margin: 0;
}

.app-header h1 {
    font-size: clamp(1.8rem, 3vw, 3rem);
}

.eyebrow {
    margin: 0 0 4px;
    color: #8ca1af;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

main {
    width: min(1480px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.tab {
    flex: 0 0 auto;
}

.tab.active {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 24px;
}

.summary-grid article,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.summary-grid article {
    padding: 16px;
    display: grid;
    gap: 4px;
    color: var(--muted);
}

.metric {
    color: var(--ink);
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.metric.warning {
    color: var(--red);
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 16px;
}

.legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.9rem;
}

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

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

.available { background: var(--green); }
.practice { background: var(--blue); }
.unavailable { background: var(--muted); }
.pending { background: var(--amber); }
.conflict { background: var(--red); }

.calendar-shell {
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.calendar-grid {
    min-width: 1100px;
    display: grid;
    grid-template-columns: 120px repeat(4, minmax(220px, 1fr));
}

.calendar-cell,
.time-cell,
.gym-head {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.gym-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f9fbfc;
    padding: 14px;
    font-weight: 800;
}

.time-cell {
    background: #f9fbfc;
    padding: 12px;
    color: var(--muted);
    font-size: 0.88rem;
}

.calendar-cell {
    min-height: 150px;
    padding: 8px;
    display: grid;
    align-content: start;
    gap: 6px;
}

.day-label {
    font-weight: 800;
    color: var(--ink);
}

.block {
    border-left: 5px solid var(--line);
    background: var(--surface-muted);
    border-radius: 8px;
    padding: 8px;
    font-size: 0.86rem;
}

.block strong {
    display: block;
    color: var(--ink);
}

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

.block.available-block { border-color: var(--green); background: #eaf6ef; }
.block.practice-block { border-color: var(--blue); background: #e8f1f8; }
.block.unavailable-block { border-color: var(--muted); background: #eef1f3; }
.block.pending-block { border-color: var(--amber); background: #fff4df; }
.block.conflict-block { border-color: var(--red); background: #fae9e9; }

.split-layout,
.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.wide-left {
    grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
}

.admin-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel {
    padding: 18px;
}

.panel h3 {
    margin-bottom: 14px;
    font-size: 1rem;
}

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

.list-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.list-item header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 10px;
    margin-bottom: 6px;
}

.list-item strong {
    display: block;
}

.list-item p {
    margin: 4px 0 0;
    color: var(--muted);
}

.compact-list .list-item {
    padding: 10px;
}

.status,
.source-tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 9px;
    font-size: 0.75rem;
    font-weight: 800;
    white-space: nowrap;
}

.status.confirmed { background: #e8f1f8; color: var(--blue); }
.status.pending { background: #fff4df; color: #8a5200; }
.status.canceled { background: #eef1f3; color: #53606a; }
.status.conflict { background: #fae9e9; color: var(--red); }
.status.approved { background: #eaf6ef; color: var(--green); }
.status.denied { background: #fae9e9; color: var(--red); }
.source-tag { background: var(--surface-muted); color: var(--muted); }

.field {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.field.inline {
    grid-template-columns: auto minmax(180px, 260px);
    align-items: center;
}

.field.compact input {
    min-width: 160px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
}

textarea {
    resize: vertical;
}

.filter-bar,
.form-panel {
    display: grid;
    gap: 12px;
}

.filter-bar {
    grid-template-columns: repeat(7, minmax(120px, 1fr));
    align-items: end;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.check-field {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.check-field input {
    width: auto;
}

.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.request-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.request-actions button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.84rem;
}

.request-actions .deny {
    background: var(--red);
}

.request-actions .suggest {
    background: var(--teal);
}

.empty-state {
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #fff;
}

.admin-forms {
    margin-bottom: 16px;
}

.form-message {
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.88rem;
    font-weight: 700;
}

.form-message[data-tone="success"] {
    background: #eaf6ef;
    color: var(--green);
}

.form-message[data-tone="error"] {
    background: #fae9e9;
    color: var(--red);
}

@media (max-width: 1100px) {
    .summary-grid,
    .split-layout,
    .wide-left,
    .admin-grid,
    .results-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-bar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .app-header,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .summary-grid,
    .split-layout,
    .wide-left,
    .admin-grid,
    .results-grid,
    .filter-bar,
    .two-col {
        grid-template-columns: 1fr;
    }

    main {
        width: min(100vw - 20px, 1480px);
        padding-top: 14px;
    }

    .header-actions {
        align-items: stretch;
    }

    .header-actions > * {
        flex: 1 1 100%;
    }

    .field.inline {
        grid-template-columns: 1fr;
    }
}
