@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,300;0,400;0,600;1,300&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #ffffff;
    --bg-secondary: #f7f6f3;
    --bg-hover: #efefef;
    --bg-active: #e8e8e5;
    --sidebar-bg: #fbfbfa;
    --border: #e9e9e7;
    --border-focus: #b0b0a8;
    --text: #37352f;
    --text-muted: #9b9a97;
    --text-light: #c7c6c3;
    --accent: #2e75cc;
    --accent-light: #e8f1fc;
    --success: #0f7b6c;
    --success-bg: #e8f5f3;
    --warn: #b85c00;
    --warn-bg: #fef3e8;
    --error: #c0392b;
    --error-bg: #fdf0ef;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .12);
    --radius: 6px;
    --radius-lg: 10px;
    --sidebar-w: 240px;
    --calendar-day-h: 112px;
    --font-body: 'Crimson Pro', Georgia, serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 0.15s ease;
}

/* ---- Reset ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 1rem;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---- Utility ---- */
.hidden {
    display: none !important;
}

.flex-2 {
    flex: 2 !important;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    background-image: radial-gradient(circle at 20% 20%, #eaf0fb 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, #fef8f0 0%, transparent 50%);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.auth-brand {
    text-align: center;
}

.brand-icon {
    font-size: 2.5rem;
    color: var(--accent);
    line-height: 1;
    margin-bottom: .5rem;
}

.brand-name {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1.75rem;
    letter-spacing: -.02em;
    color: var(--text);
}

.brand-tagline {
    font-size: .9rem;
    color: var(--text-muted);
    font-style: italic;
}

.auth-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .25rem;
}

.auth-switch {
    text-align: center;
    font-size: .9rem;
    color: var(--text-muted);
    margin-top: .25rem;
}

.app-page {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

/* -- Sidebar -- */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: width var(--transition);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1rem 1rem .75rem;
    border-bottom: 1px solid var(--border);
}

.brand-icon-sm {
    font-size: 1.1rem;
    color: var(--accent);
    flex-shrink: 0;
}

.sidebar-brand {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: .2rem .4rem;
    border-radius: var(--radius);
    line-height: 1;
    transition: background var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
}

.sidebar-nav {
    flex: 1;
    padding: .75rem .5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: .7rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-light);
    padding: .5rem .75rem .25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .75rem;
    border-radius: var(--radius);
    font-size: .95rem;
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none !important;
}

.nav-item:hover {
    background: var(--bg-hover);
}

.nav-item.active {
    background: var(--bg-active);
    font-weight: 600;
}

.nav-icon {
    font-size: 1rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-footer {
    padding: .75rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: .7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* -- Main -- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    min-height: 100dvh;
    min-width: 0;
    padding: 2rem 2.5rem;
    max-width: calc(100vw - var(--sidebar-w));
}

/* -- Views -- */
.view {
    display: none;
}

.view.active {
    display: block;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.9rem;
    font-weight: 600;
    letter-spacing: -.02em;
    line-height: 1.2;
}

.page-subtitle {
    font-size: .95rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: .2rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.cal-day-header {
    background: var(--bg-secondary);
    padding: .6rem .5rem;
    font-family: var(--font-mono);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    text-align: center;
}

.cal-day {
    background: var(--bg);
    height: var(--calendar-day-h);
    padding: .4rem;
    position: relative;
    cursor: default;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border-focus) transparent;
}

.cal-day.other-month .cal-date {
    color: var(--text-light);
}

.cal-day.today {
    background: #fefef7;
}

.cal-day.today .cal-date {
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cal-date {
    font-family: var(--font-mono);
    font-size: .75rem;
    color: var(--text-muted);
    margin-bottom: .15rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1;
    background: inherit;
}

.cal-day::-webkit-scrollbar {
    width: 6px;
}

.cal-day::-webkit-scrollbar-thumb {
    background: var(--border-focus);
    border-radius: 999px;
}

.cal-day::-webkit-scrollbar-track {
    background: transparent;
}

.cal-event {
    appearance: none;
    width: 100%;
    text-align: left;
    font-size: .72rem;
    line-height: 1.3;
    padding: .15rem .35rem;
    border-radius: 3px;
    margin-bottom: 2px;
    cursor: pointer;
    white-space: normal;
    overflow: hidden;
    text-overflow: clip;
    border: 0;
    border-left: 2px solid;
    transition: opacity var(--transition);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    word-break: break-word;
    flex-shrink: 0;
}

.cal-event:hover {
    opacity: .8;
}

.cal-event.event-hidden {
    background: var(--bg-secondary);
    border-left-color: var(--border);
    color: var(--text-light);
    cursor: default;
}

.events-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.user-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.user-card-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.user-card-subtitle {
    font-size: .92rem;
    color: var(--text-muted);
}

.user-card-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .4rem;
}

.user-status-badge {
    display: inline-flex;
    align-items: center;
    padding: .25rem .65rem;
    border-radius: 999px;
    font-size: .68rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: .05em;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.user-status-badge.approved {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(15, 123, 108, .18);
}

.user-status-badge.pending {
    background: var(--warn-bg);
    color: var(--warn);
    border-color: rgba(184, 92, 0, .18);
}

.user-status-badge.reset-required {
    background: var(--error-bg);
    color: var(--error);
    border-color: rgba(192, 57, 43, .18);
}

.user-status-badge.self {
    background: var(--accent-light);
    color: var(--accent);
    border-color: rgba(46, 117, 204, .18);
}

.user-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.user-card-section {
    display: flex;
    flex-direction: column;
    gap: .65rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
}

.user-card-section-title {
    font-size: .85rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}

.user-card-note {
    font-size: .9rem;
    color: var(--text-muted);
}

.event-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
}

.event-row:hover {
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.event-row.event-row-unapproved {
    border-color: rgba(184, 92, 0, .32);
    background: linear-gradient(90deg, var(--warn-bg) 0, rgba(254, 243, 232, .55) 180px, var(--bg) 100%);
}

.event-row-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.event-row-title {
    flex: 1;
    font-weight: 600;
    font-size: 1rem;
}

.event-row-meta {
    font-size: .8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.event-row-tag {
    font-size: .7rem;
    padding: .15rem .5rem;
    border-radius: 3px;
    font-family: var(--font-mono);
}

.event-status-badge {
    font-size: .68rem;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: .06em;
    background: var(--warn-bg);
    color: var(--warn);
    border: 1px solid rgba(184, 92, 0, .2);
    white-space: nowrap;
}

.event-row-actions {
    display: flex;
    gap: .3rem;
}

.link-button {
    appearance: none;
    background: none;
    border: none;
    padding: 0;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
}

.search-input {
    width: 200px;
}

.form-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 760px;
    box-shadow: var(--shadow-sm);
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 140px;
}

.conflict-box {
    background: var(--warn-bg);
    border: 1px solid #f0c070;
    border-radius: var(--radius);
    padding: 1rem;
    margin: .5rem 0;
}

.conflict-box h4 {
    font-size: .85rem;
    font-weight: 600;
    color: var(--warn);
    margin-bottom: .5rem;
    font-family: var(--font-mono);
}

.conflict-item {
    font-size: .85rem;
    padding: .3rem 0;
    border-bottom: 1px solid #f0c07055;
    color: var(--text-muted);
}

.conflict-item:last-child {
    border-bottom: none;
}

.conflict-item strong {
    color: var(--text);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .3);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    animation: fadeIn .15s ease;
}

.modal {
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    margin: 1rem;
    animation: slideUp .2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-tag-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.modal-title {
    flex: 1;
    font-size: 1.3rem;
    font-weight: 600;
}

.modal-close {
    color: var(--text-muted);
    font-size: .85rem;
}

.modal-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.modal-meta-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    font-size: .9rem;
}

.modal-meta-icon {
    color: var(--text-muted);
    width: 1.2rem;
}

.modal-status-badge {
    margin-left: .1rem;
}

.modal-description {
    font-size: .95rem;
    color: var(--text);
    line-height: 1.7;
    padding: .75rem 0;
    border-top: 1px solid var(--border);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.form-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.form-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-family: var(--font-body);
    font-style: italic;
    color: var(--text-light);
}

.form-input {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .55rem .75rem;
    font-family: var(--font-body);
    font-size: .95rem;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(46, 117, 204, .1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-select {
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: .95rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    font-weight: 500;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-full {
    width: 100%;
}

.btn-primary {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}

.btn-primary:hover:not(:disabled) {
    background: #1a1915;
    box-shadow: var(--shadow-sm);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
}

.btn-danger {
    background: transparent;
    color: var(--error);
    border-color: #f5c6c3;
}

.btn-danger:hover:not(:disabled) {
    background: var(--error-bg);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: .9rem;
    padding: .3rem .5rem;
    border-radius: var(--radius);
    transition: background var(--transition), color var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-sm {
    padding: .3rem .65rem;
    font-size: .85rem;
}

.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    border: 1px solid;
}

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

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

.alert-warn {
    background: var(--warn-bg);
    color: var(--warn);
    border-color: #f0c070;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: .4;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: .5rem;
}

.empty-state p {
    font-size: .9rem;
    font-style: italic;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: .9rem;
    gap: .5rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(12px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cal-event.event-unapproved {
    background: var(--warn-bg) !important;
    border-left-color: var(--warn) !important;
    color: var(--warn) !important;
    opacity: .95;
}

.cal-event.event-denied {
    background: var(--error-bg) !important;
    border-left-color: var(--error) !important;
    color: var(--error) !important;
    text-decoration: line-through;
    opacity: .8;
}

.event-row.event-row-unapproved {
    border-color: rgba(184, 92, 0, .32);
    background: linear-gradient(90deg, var(--warn-bg) 0, rgba(254, 243, 232, .55) 180px, var(--bg) 100%);
}

.event-row.event-row-denied {
    border-color: rgba(192, 57, 43, .28);
    background: linear-gradient(90deg, var(--error-bg) 0, rgba(253, 240, 239, .45) 180px, var(--bg) 100%);
}

.event-row.event-row-denied .event-row-title {
    color: var(--error);
    text-decoration: line-through;
}

.event-status-badge.badge-denied {
    background: var(--error-bg);
    color: var(--error);
    border-color: rgba(192, 57, 43, .25);
}

.event-row-dot {
    appearance: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: transform var(--transition), opacity var(--transition);
}

.event-row-dot:hover {
    transform: scale(1.25);
    opacity: .85;
}

@media (max-width: 1024px) {

    :root {
        --sidebar-w: 200px;
        --calendar-day-h: 96px;
    }

    .main-content {
        padding: 1.75rem 2rem;
    }

    .cal-day {
        padding: .35rem;
    }

    .cal-event {
        font-size: .68rem;
    }

    .form-card {
        max-width: 100%;
    }

    .search-input {
        width: 160px;
    }

    .event-row-meta {
        white-space: normal;
    }

    .user-card-grid {
        grid-template-columns: 1fr;
    }

    .page-actions form.page-actions {
        display: flex;
        align-items: center;
        gap: .5rem;
        flex: 1 1 320px;
        width: auto;
        min-width: 0;
    }

    .page-actions form.page-actions .search-input {
        width: auto;
        min-width: 0;
        flex: 1 1 auto;
    }

    .page-actions form.page-actions .btn {
        flex: 0 0 auto;
        width: auto;
        justify-content: center;
    }
}

@media (max-width: 768px) {

    :root {
        --sidebar-w: 0px;
        --calendar-day-h: 64px;
    }

    .sidebar {
        width: min(82vw, 320px);
        overflow: visible;
        left: auto;
        right: 0;
        transform: translateX(calc(100% - 1.25rem));
        transition: transform var(--transition), background var(--transition), box-shadow var(--transition), border-color var(--transition);
        box-shadow: none;
        background: transparent;
        border-right-color: transparent;
        border-left: 1px solid transparent;
        border-radius: 1.25rem 0 0 1.25rem;
    }

    .sidebar.open {
        transform: translateX(0);
        background: var(--sidebar-bg);
        border-left-color: var(--border);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open::after {
        content: '';
        position: fixed;
        inset: 0;
        right: min(82vw, 320px);
        background: rgba(0, 0, 0, .25);
        z-index: -1;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        max-width: 100vw;
    }

    .sidebar-header {
        position: relative;
        min-height: 4rem;
        padding: .9rem 1rem;
        border-bottom-color: transparent;
        transition: border-color var(--transition);
    }

    .sidebar.open .sidebar-header {
        border-bottom-color: var(--border);
    }

    .brand-icon-sm {
        opacity: 0;
        transition: opacity var(--transition), transform var(--transition);
        transform: translateX(8px);
    }

    .sidebar.open .brand-icon-sm {
        opacity: 1;
        transform: translateX(0);
    }

    .sidebar-brand,
    .sidebar-nav,
    .sidebar-footer {
        opacity: 0;
        pointer-events: none;
        transform: translateX(12px);
        transition: opacity var(--transition), transform var(--transition);
    }

    .sidebar.open .sidebar-brand,
    .sidebar.open .sidebar-nav,
    .sidebar.open .sidebar-footer {
        opacity: 1;
        pointer-events: auto;
        transform: translateX(0);
    }

    .sidebar-toggle {
        position: absolute;
        top: auto;
        bottom: 1rem;
        left: -3.5rem;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 14px;
        box-shadow: var(--shadow-sm);
        color: var(--text);
        font-size: 1rem;
        padding: 0;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: left var(--transition), background var(--transition), box-shadow var(--transition), border-color var(--transition), transform var(--transition);
    }

    .sidebar.open .sidebar-toggle {
        left: -3.5rem;
        box-shadow: none;
        background: var(--bg-hover);
        border-color: var(--border);
        transform: none;
    }

    .main-content > *:first-child {
        margin-top: 2.75rem;
    }

    .page-header {
        flex-direction: column;
        gap: .75rem;
        margin-bottom: 1.25rem;
        padding-bottom: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .page-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .calendar-grid {
        border-radius: var(--radius);
    }

    .cal-day-header {
        padding: .4rem .2rem;
        font-size: .6rem;
        letter-spacing: 0;
    }

    .cal-day {
        padding: .2rem .15rem;
    }

    .cal-date {
        font-size: .65rem;
        margin-bottom: .15rem;
    }

    .cal-event {
        width: 100%;
        font-size: .56rem;
        line-height: 1.2;
        padding: .1rem .2rem;
        margin-bottom: 2px;
        border-radius: 3px;
        border-left-width: 2px;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        line-clamp: 1;
    }

    .cal-event.event-hidden {
        border-left-color: var(--border);
    }

    .event-row {
        flex-wrap: wrap;
        gap: .5rem;
        padding: .75rem .85rem;
    }

    .user-card {
        padding: 1rem;
    }

    .user-card-header {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: .85rem;
        gap: .75rem;
    }

    .user-card-badges {
        justify-content: flex-start;
        gap: .35rem;
    }

    .user-card-section {
        padding: .9rem;
    }

    .user-card-title {
        font-size: 1.05rem;
        line-height: 1.25;
    }

    .user-card-subtitle {
        font-size: .86rem;
        overflow-wrap: anywhere;
    }

    .user-card-grid {
        gap: .75rem;
    }

    .user-card-section .btn {
        width: 100%;
        justify-content: center;
    }

    .event-row-title {
        font-size: .95rem;
        flex-basis: calc(100% - 22px);
        order: 1;
    }

    .event-row-dot {
        order: 0;
        align-self: flex-start;
        margin-top: .3rem;
    }

    .event-row-meta {
        font-size: .72rem;
        order: 2;
        flex-basis: 100%;
        white-space: normal;
    }

    .event-row-tag,
    .event-status-badge {
        order: 3;
    }

    .event-row-actions {
        order: 4;
        margin-left: auto;
    }

    .form-card {
        padding: 1.25rem;
        border-radius: var(--radius);
        box-shadow: none;
        border-left: none;
        border-right: none;
        margin: 0;
        width: 100%;
        max-width: 100%;
    }

    .form-row {
        flex-direction: column;
        gap: .75rem;
    }

    .form-row .form-group {
        min-width: unset;
        flex: unset;
    }

    .flex-2 {
        flex: unset !important;
    }

    .form-actions {
        flex-direction: column-reverse;
        gap: .5rem;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .search-input {
        width: 100%;
        flex: 1;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: .75rem .75rem calc(.75rem + env(safe-area-inset-bottom, 0));
    }

    .modal {
        margin: 0;
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: min(90dvh, calc(100dvh - .75rem));
        overflow-y: auto;
        animation: slideUpSheet .22s ease;
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--bg);
        padding: 1rem 1rem .85rem;
    }

    .modal-title {
        font-size: 1.1rem;
        line-height: 1.2;
    }

    .modal-body {
        padding: 1rem;
        font-size: .95rem;
    }

    .modal-meta-row {
        align-items: flex-start;
        font-size: .86rem;
        line-height: 1.4;
    }

    .modal-description {
        font-size: .9rem;
        line-height: 1.55;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        background: var(--bg);
        flex-wrap: wrap;
        gap: .5rem;
        padding: .85rem 1rem calc(1rem + env(safe-area-inset-bottom, 0));
    }

    .modal-footer .btn,
    .modal-footer form {
        flex: 1;
        min-width: 0;
    }

    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }

    .auth-container {
        padding: 1rem;
    }

    .auth-card {
        padding: 1.5rem 1.25rem;
    }
}

@media (max-width: 480px) {

    html {
        font-size: 15px;
    }

    :root {
        --calendar-day-h: 48px;
    }

    .cal-day-header {
        font-size: .55rem;
        padding: .3rem .1rem;
    }

    .page-title {
        font-size: 1.3rem;
    }

    .page-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .page-actions .btn,
    .page-actions form {
        width: 100%;
    }

    .page-actions .btn {
        justify-content: center;
    }

    .page-actions form.page-actions {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: .5rem;
    }

    .page-actions form.page-actions .search-input {
        flex: 1 1 auto;
        min-width: 0;
    }

    .page-actions form.page-actions .btn {
        width: auto;
        flex: 0 0 auto;
    }

    .conflict-box {
        padding: .75rem;
    }

    .users-list {
        gap: .75rem;
    }

    .user-card {
        padding: .85rem;
        border-radius: .85rem;
    }

    .user-card-header {
        gap: .65rem;
    }

    .user-card-title {
        font-size: 1rem;
    }

    .user-card-subtitle {
        font-size: .82rem;
        line-height: 1.45;
    }

    .user-card-badges {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        width: 100%;
    }

    .user-status-badge {
        justify-content: center;
        text-align: center;
        min-height: 2rem;
        white-space: normal;
        line-height: 1.25;
        padding: .35rem .5rem;
    }

    .user-card-grid {
        gap: .65rem;
    }

    .user-card-section {
        padding: .8rem;
        gap: .55rem;
    }

    .user-card-section-title {
        font-size: .74rem;
        letter-spacing: .05em;
    }

    .user-card-note {
        font-size: .82rem;
        line-height: 1.5;
    }

    .user-card-section .form-label {
        font-size: .72rem;
    }

    .user-card-section .form-input {
        padding: .65rem .7rem;
        font-size: .92rem;
    }

    .empty-state {
        padding: 2.5rem 1rem;
    }

    .empty-state-icon {
        font-size: 2.25rem;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer form {
        width: 100%;
    }
}

@media (max-width: 932px) and (orientation: landscape) {

    .modal-overlay {
        align-items: center;
        padding: .5rem max(.75rem, env(safe-area-inset-right, 0)) .5rem max(.75rem, env(safe-area-inset-left, 0));
    }

    .modal {
        width: min(100%, 720px);
        max-height: calc(100dvh - 1rem);
        border-radius: var(--radius-lg);
    }

    .modal-header {
        padding: .8rem 1rem .75rem;
    }

    .modal-title {
        font-size: 1rem;
    }

    .modal-body {
        padding: .85rem 1rem;
        gap: .55rem;
    }

    .modal-meta-row {
        font-size: .8rem;
    }

    .modal-description {
        font-size: .84rem;
        line-height: 1.45;
        padding: .55rem 0;
    }

    .modal-footer {
        padding: .75rem 1rem .8rem;
        gap: .4rem;
    }

    .modal-footer .btn,
    .modal-footer form {
        flex: 0 1 auto;
    }
}

@keyframes slideUpSheet {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
