:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-strong: #eef3f8;
    --text: #172033;
    --muted: #657184;
    --line: #d6deea;
    --primary: #0b1f3a;
    --primary-strong: #07182d;
    --danger: #b04444;
    --success: #1d4ed8;
    --sidebar-width: 260px;
    --shadow: 0 12px 35px rgba(11, 31, 58, 0.08);
}

* {
    box-sizing: border-box;
}

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

a {
    color: inherit;
}

.topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 68px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.mobile-header,
.sidebar,
.menu-toggle,
.menu-backdrop {
    display: none;
}

.has-sidebar .topbar {
    display: none;
}

.sidebar {
    background: var(--primary);
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    bottom: 0;
    box-shadow: 12px 0 35px rgba(11, 31, 58, 0.12);
    color: white;
    display: flex;
    flex-direction: column;
    left: 0;
    padding: 24px 18px;
    position: fixed;
    top: 0;
    width: var(--sidebar-width);
    z-index: 20;
}

.sidebar-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 28px;
}

.sidebar .brand {
    color: white;
}

.sidebar-close {
    color: rgba(255, 255, 255, 0.76);
    cursor: pointer;
    display: none;
    font-size: 13px;
    font-weight: 800;
}

.brand {
    align-items: center;
    color: var(--text);
    display: inline-flex;
    font-size: 18px;
    font-weight: 750;
    gap: 10px;
    text-decoration: none;
}

.brand-icon {
    background: linear-gradient(135deg, #ffffff 0%, #dbeafe 100%);
    border: 2px solid rgba(255, 255, 255, 0.72);
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(11, 31, 58, 0.18);
    display: inline-block;
    height: 28px;
    position: relative;
    width: 28px;
}

.brand-icon::before {
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--primary);
    content: "";
    left: 4px;
    position: absolute;
    top: 4px;
}

.brand-icon::after {
    background: var(--primary);
    border-radius: 3px 3px 5px 5px;
    bottom: 5px;
    content: "";
    height: 11px;
    left: 7px;
    position: absolute;
    width: 12px;
}

.topbar .brand-icon,
.mobile-header .brand-icon {
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    border-color: transparent;
}

.topbar .brand-icon::before,
.mobile-header .brand-icon::before {
    border-bottom-color: white;
}

.topbar .brand-icon::after,
.mobile-header .brand-icon::after {
    background: white;
}

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

.topbar .nav {
    display: flex;
}

.nav a {
    align-items: center;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.88);
    display: flex;
    font-weight: 750;
    min-height: 44px;
    padding: 0 12px;
    text-decoration: none;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

.button {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 650;
    min-height: 40px;
    padding: 0 14px;
    text-decoration: none;
}

.button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

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

.button.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
    width: 100%;
}

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

.icon-button {
    font-size: 22px;
    justify-content: center;
    padding: 0;
    width: 42px;
}

.page {
    margin: 0 auto;
    max-width: 1240px;
    padding: 28px;
}

.has-sidebar .page {
    margin: 0 0 0 var(--sidebar-width);
    max-width: none;
}

.auth-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin: 70px auto;
    max-width: 430px;
    padding: 30px;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 34px;
    line-height: 1.1;
}

h2 {
    font-size: 20px;
    margin-bottom: 18px;
}

.eyebrow {
    color: var(--primary-strong);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

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

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

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

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

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    min-height: 42px;
    padding: 9px 11px;
    width: 100%;
}

textarea {
    resize: vertical;
}

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

.checkbox input {
    min-height: auto;
    width: auto;
}

.form-row {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr 1fr;
}

.calendar-shell,
.members-layout {
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(0, 1fr) 330px;
}

.calendar-main,
.side-panel,
.table-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 22px;
}

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

.calendar-weekdays {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    overflow: hidden;
    text-align: center;
    text-transform: uppercase;
}

.calendar-weekdays div {
    padding: 10px 6px;
}

.day {
    background: #fff;
    border: 1px solid var(--line);
    min-height: 128px;
    padding: 10px;
    position: relative;
}

.day.muted {
    background: #f8fafc;
    color: #909bae;
}

.day.today {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.day-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.day-number {
    font-size: 13px;
    font-weight: 800;
}

.quick-add {
    align-items: center;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--primary);
    display: inline-flex;
    font-size: 18px;
    font-weight: 850;
    height: 26px;
    justify-content: center;
    line-height: 1;
    text-decoration: none;
    width: 26px;
}

.quick-add:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.day-events {
    display: grid;
    gap: 6px;
}

.event-pill {
    background: #f8fbff;
    background: color-mix(in srgb, var(--event-color), white 84%);
    border-left: 4px solid var(--event-color);
    border-radius: 6px;
    color: var(--text);
    display: block;
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
    padding: 6px 7px;
    position: relative;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-pill:hover,
.event-pill:focus {
    overflow: visible;
    z-index: 5;
}

.event-pill span {
    color: var(--muted);
    font-weight: 800;
    margin-right: 4px;
}

.event-tooltip {
    background: var(--primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    bottom: calc(100% + 8px);
    box-shadow: 0 16px 35px rgba(11, 31, 58, 0.22);
    color: white;
    display: none;
    font-weight: 500;
    gap: 5px;
    left: 0;
    margin-right: 0;
    min-width: 230px;
    padding: 12px;
    position: absolute;
    white-space: normal;
    z-index: 40;
}

.event-pill:hover .event-tooltip,
.event-pill:focus .event-tooltip {
    display: grid;
}

.event-tooltip strong {
    color: white;
    font-size: 14px;
}

.event-tooltip small,
.event-tooltip em {
    color: rgba(255, 255, 255, 0.78);
    font-size: 12px;
    font-style: normal;
    line-height: 1.35;
}

.delete-form {
    margin-top: 14px;
}

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

.upcoming-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    padding: 12px;
}

.upcoming-item span {
    color: var(--muted);
    font-size: 13px;
}

.empty-state {
    color: var(--muted);
    margin: 0;
}

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

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

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

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

.alert {
    border-radius: 8px;
    font-weight: 700;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.alert-error {
    background: #f9eaea;
    color: #8d3030;
}

.alert-success {
    background: #eaf1ff;
    color: var(--success);
}

code {
    background: var(--surface-strong);
    border-radius: 5px;
    padding: 2px 5px;
}

@media (max-width: 920px) {
    .calendar-shell,
    .members-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .has-sidebar .page {
        margin-left: 0;
        padding-top: 82px;
    }

    .mobile-header {
        align-items: center;
        background: rgba(255, 255, 255, 0.94);
        border-bottom: 1px solid var(--line);
        display: flex;
        justify-content: space-between;
        min-height: 66px;
        padding: 0 16px;
        position: fixed;
        top: 0;
        width: 100%;
        z-index: 30;
    }

    .burger-button {
        align-items: center;
        background: var(--primary);
        border-radius: 8px;
        cursor: pointer;
        display: grid;
        gap: 4px;
        height: 42px;
        justify-content: center;
        padding: 0;
        width: 42px;
    }

    .burger-button span {
        background: white;
        border-radius: 999px;
        display: block;
        height: 2px;
        width: 20px;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 180ms ease;
    }

    .sidebar-close {
        display: inline-flex;
    }

    .menu-backdrop {
        background: rgba(11, 31, 58, 0.36);
        bottom: 0;
        cursor: pointer;
        left: 0;
        position: fixed;
        right: 0;
        top: 0;
        z-index: 15;
    }

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

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

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

    .topbar,
    .section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .page {
        padding: 16px;
    }

    .nav {
        width: 100%;
    }

    h1 {
        font-size: 28px;
    }

    .calendar-grid {
        display: block;
    }

    .calendar-weekdays {
        display: none;
    }

    .day {
        margin-bottom: 8px;
        min-height: auto;
    }

    .event-tooltip {
        bottom: auto;
        left: 0;
        min-width: min(260px, calc(100vw - 56px));
        top: calc(100% + 8px);
    }

    .day.muted {
        display: none;
    }
}
