:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #667085;
    --line: #d9dee7;
    --primary: #145c52;
    --primary-strong: #0f463f;
    --accent: #c74432;
    --warning: #9a5b00;
    --warning-bg: #fff4d6;
    --success-bg: #e9f8ef;
    --error-bg: #fdecea;
    --shadow: 0 10px 30px rgba(22, 32, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

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

a {
    color: inherit;
}

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

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: #1d2939;
    color: #eef2f6;
    padding: 24px 18px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    color: inherit;
    text-decoration: none;
    margin-bottom: 32px;
}

.brand small {
    display: block;
    color: #b8c1cc;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a {
    padding: 11px 12px;
    border-radius: 8px;
    color: #d6dce5;
    text-decoration: none;
}

.nav a:hover,
.nav a.is-active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.content {
    min-width: 0;
    padding: 26px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 22px;
}

.topbar h1,
.auth-panel h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
}

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

.user-menu {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

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

.metric {
    padding: 18px;
}

.metric span {
    display: block;
    color: var(--muted);
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
}

.panel {
    padding: 20px;
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 20px;
}

.split {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

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

.form-narrow {
    width: min(520px, 100%);
    margin-top: 18px;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-weight: 600;
}

label:has(input[type="checkbox"]) {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    padding: 0;
}

.inline-options {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

textarea {
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 13px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.button-primary {
    background: var(--primary);
    color: #fff;
}

.button-primary:hover {
    background: var(--primary-strong);
}

.button-ghost {
    border-color: var(--line);
}

.button-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: #f1cf82;
}

.button-small {
    min-height: 32px;
    padding: 5px 10px;
}

.alert {
    margin-bottom: 14px;
    border-radius: 8px;
    padding: 11px 13px;
    border: 1px solid var(--line);
}

.alert-success {
    background: var(--success-bg);
    border-color: #aadfbd;
}

.alert-error {
    background: var(--error-bg);
    border-color: #f0b7b0;
}

.table-wrap {
    overflow-x: auto;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: #475467;
    font-size: 13px;
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2f6;
    color: #344054;
    font-size: 12px;
    font-weight: 700;
}

.badge-available {
    background: #dff3e6;
    color: #23693c;
}

.badge-removed {
    background: #fde2dc;
    color: #a63827;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 14px;
}

.segmented {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.segmented button {
    border: 0;
    border-right: 1px solid var(--line);
    background: #fff;
    padding: 7px 10px;
    cursor: pointer;
}

.segmented button:last-child {
    border-right: 0;
}

.segmented .is-selected {
    background: #e8f1ef;
    color: var(--primary);
    font-weight: 700;
}

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

.event {
    display: grid;
    grid-template-columns: 138px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.event time {
    color: var(--primary);
    font-weight: 800;
}

.event span,
.event small {
    display: block;
    color: var(--muted);
}

.auth-page {
    min-height: 100vh;
    background: #e8edf2;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-panel {
    width: min(440px, 100%);
    padding: 30px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-panel .brand-mark {
    margin-bottom: 20px;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        padding: 16px;
    }

    .brand {
        margin-bottom: 14px;
    }

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

    .metric-grid,
    .split {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 16px;
    }

    .topbar,
    .calendar-header {
        align-items: stretch;
        flex-direction: column;
    }

    .metric strong {
        font-size: 26px;
    }

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

    .segmented {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .segmented button {
        border-bottom: 1px solid var(--line);
    }
}
