:root {
    color-scheme: light;
    --bg: #f6f3ee;
    --panel: #ffffff;
    --panel-2: #fbfaf7;
    --text: #25211d;
    --muted: #766f68;
    --line: #ded6cc;
    --accent: #8d4b3f;
    --accent-2: #245a63;
    --good: #2f6d49;
    --warn: #9b6a18;
    --bad: #9f3232;
    --shadow: 0 14px 34px rgba(42, 34, 28, .08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

a { color: inherit; text-decoration: none; }

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

button {
    border: 0;
    background: var(--accent);
    color: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
}

button.ghost, button.icon {
    background: #efe8df;
    color: var(--text);
}

button.icon {
    padding: 7px 9px;
    font-size: 12px;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #efe8df;
    color: var(--text);
    padding: 9px 12px;
    font-weight: 800;
}

.button-link.small {
    min-height: 32px;
    padding: 6px 9px;
    font-size: 12px;
}

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

textarea {
    min-height: 84px;
    resize: vertical;
}

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

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

.login-shell {
    width: min(460px, 100%);
}

.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h1,
.section h2 {
    margin: 0;
    letter-spacing: 0;
}

.stack {
    display: grid;
    gap: 14px;
}

.alert {
    border: 1px solid #e3b2a7;
    background: #fff1ee;
    color: var(--bad);
    padding: 10px 12px;
    border-radius: 6px;
    margin: 16px 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(246, 243, 238, .94);
    backdrop-filter: blur(12px);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-actions select {
    min-width: 260px;
}

.menu-toggle,
.menu-button,
.menu-backdrop,
.menu-close {
    display: none;
}

.layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 22px;
    padding: 22px;
}

.sidebar {
    position: sticky;
    top: 86px;
    align-self: start;
    display: grid;
    gap: 6px;
    padding: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.menu-head {
    display: block;
}

.menu-title {
    margin: 2px 8px 6px;
    color: var(--accent-2);
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 900;
}

.sidebar a {
    padding: 10px 11px;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 700;
}

.sidebar a:hover,
.sidebar a.active {
    background: var(--panel-2);
    color: var(--text);
}

.sidebar a.active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.content {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.section-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--accent-2);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
}

.muted {
    color: var(--muted);
    margin: 5px 0 0;
}

.date-chip {
    border: 1px solid var(--line);
    background: var(--panel-2);
    border-radius: 999px;
    padding: 7px 11px;
    color: var(--muted);
    font-weight: 800;
    white-space: nowrap;
}

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

.metrics article {
    border: 1px solid var(--line);
    background: var(--panel-2);
    border-radius: 8px;
    padding: 14px;
}

.metrics span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.metrics strong {
    display: block;
    margin-top: 8px;
    font-size: 24px;
}

.progress-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.progress {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.progress div {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-weight: 800;
    font-size: 12px;
}

.progress i {
    display: block;
    height: 8px;
    margin-top: 10px;
    border-radius: 999px;
    background: #eee5db;
    overflow: hidden;
}

.progress em {
    display: block;
    height: 100%;
    background: var(--accent-2);
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.grid-form.compact {
    margin-bottom: 16px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.span-2 { grid-column: span 2; }

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

th, td {
    padding: 10px 11px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--panel-2);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }

.row-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.row-actions form {
    margin: 0;
}

.row-actions select {
    min-width: 132px;
    padding: 7px 8px;
    font-size: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eee5db;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge.good { background: #e6f2ea; color: var(--good); }
.badge.warn { background: #fff4d9; color: var(--warn); }
.badge.bad { background: #ffe7e5; color: var(--bad); }

.file-link {
    color: var(--accent-2);
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.calendar-panel {
    display: grid;
    gap: 12px;
    margin: 0 0 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
}

.calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}

.calendar-day {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
    font-weight: 800;
}

.calendar-day strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--accent-2);
    color: #fff;
    font-size: 12px;
}

.calendar-day.active {
    border-color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

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

@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .menu-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--line);
        background: #efe8df;
        color: var(--text);
        padding: 10px 14px;
        border-radius: 6px;
        cursor: pointer;
        font-weight: 800;
    }

    .menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 39;
        background: rgba(20, 17, 14, .42);
    }

    .menu-toggle:not(:checked) ~ .menu-backdrop {
        display: none;
    }

    .menu-toggle:checked ~ .menu-backdrop {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 40;
        width: min(310px, 84vw);
        display: grid;
        align-content: start;
        gap: 8px;
        overflow-y: auto;
        border-width: 0 1px 0 0;
        border-radius: 0;
        padding: 14px;
        box-shadow: 18px 0 34px rgba(42, 34, 28, .18);
        transform: translateX(-105%);
        transition: transform .18s ease;
    }

    .menu-toggle:checked ~ .layout .sidebar {
        transform: translateX(0);
    }

    .menu-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin: 0;
        padding: 0 0 8px;
        border-bottom: 1px solid var(--line);
    }

    .menu-title {
        margin: 0;
    }

    .menu-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--line);
        border-radius: 6px;
        padding: 8px 10px;
        background: var(--panel-2);
        color: var(--muted);
        cursor: pointer;
        font-size: 12px;
        font-weight: 800;
    }

    .sidebar a {
        border: 0;
        background: transparent;
        white-space: normal;
        font-size: 16px;
        padding: 12px 11px;
    }

    .sidebar a:hover,
    .sidebar a.active {
        background: var(--panel-2);
        color: var(--text);
    }

    .sidebar a.active {
        box-shadow: inset 3px 0 0 var(--accent);
    }

    body:has(.menu-toggle:checked) {
        overflow: hidden;
    }

    @supports not selector(:has(*)) {
        .menu-toggle:checked ~ .layout .sidebar {
            transform: translateX(0);
        }
    }

    .metrics,
    .progress-row,
    .grid-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .topbar,
    .top-actions {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .top-actions select {
        min-width: 0;
    }

    .menu-button {
        width: 100%;
    }

    .metrics,
    .progress-row,
    .grid-form {
        grid-template-columns: 1fr;
    }

    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .date-chip {
        width: fit-content;
    }

    .span-2 { grid-column: span 1; }
    .section { padding: 14px; }
}
