* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f5f8;
    color: #1f2937;
}

.login-wrapper {
    min-height: calc(100vh - 48px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: white;
    padding: 30px;
    border-radius: 22px;
    box-shadow: 0 20px 45px rgba(0,0,0,0.12);
}

.login-card h1 {
    margin-top: 0;
    font-size: 32px;
}

label {
    display: block;
    margin-top: 18px;
    font-weight: 600;
}

input {
    width: 100%;
    padding: 14px;
    margin-top: 6px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    font-size: 16px;
}

button {
    width: 100%;
    margin-top: 24px;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: #2563eb;
    color: white;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: #1d4ed8;
}

.alert {
    padding: 12px;
    border-radius: 12px;
    margin: 12px 0;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
}

.topbar {
    background: #111827;
    color: white;
    padding: 14px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 20px;
    font-weight: 800;
}

nav {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: 600;
}

.container {
    padding: 24px;
    max-width: 1200px;
    margin: auto;
}

.welcome-card,
.card {
    background: white;
    border-radius: 22px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
}

.grid {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

@media (max-width: 800px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    nav {
        width: 100%;
    }

    nav a {
        background: rgba(255,255,255,0.12);
        padding: 10px 12px;
        border-radius: 12px;
    }

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

    .container {
        padding: 16px;
    }
}

.small-button {
    width: auto;
    padding: 10px 16px;
    margin-top: 12px;
    font-size: 15px;
}

.user-list {
    margin-top: 24px;
    display: grid;
    gap: 16px;
}

.user-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 22px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.user-card h2 {
    margin: 0 0 8px 0;
}

.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.badge.green {
    background: #dcfce7;
    color: #166534;
}

.badge.red {
    background: #fee2e2;
    color: #991b1b;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

select {
    width: 100%;
    padding: 14px;
    margin-top: 6px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    font-size: 16px;
    background: white;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}

.checkbox-row input {
    width: auto;
    margin: 0;
}

.modal {
    display: none;
    position: fixed;
    z-index: 999;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal-content {
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    background: white;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 25px 70px rgba(0,0,0,0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
}

.icon-button {
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    font-size: 26px;
    line-height: 1;
    background: #e5e7eb;
    color: #111827;
}

.icon-button:hover {
    background: #d1d5db;
}

@media (max-width: 700px) {
    .user-card {
        flex-direction: column;
        align-items: stretch;
    }

    .small-button {
        width: 100%;
    }

    .modal-content {
        border-radius: 20px;
        padding: 20px;
    }
}

.flash-area {
    margin-bottom: 16px;
}

.calendar-header-card {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.calendar-card {
    margin-top: 24px;
    background: white;
    border-radius: 24px;
    padding: 18px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
}

#calendar {
    width: 100%;
}

textarea {
    width: 100%;
    padding: 14px;
    margin-top: 6px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
}

.entry-details {
    margin-top: 18px;
    line-height: 1.5;
}

.muted {
    color: #6b7280;
}

.danger-button {
    background: #dc2626;
}

.danger-button:hover {
    background: #b91c1c;
}

.fc {
    font-family: inherit;
}

.fc .fc-toolbar-title {
    font-size: 22px;
    font-weight: 800;
}

.fc .fc-button {
    border-radius: 10px !important;
    border: none !important;
    background: #2563eb !important;
}

.fc .fc-button:hover {
    background: #1d4ed8 !important;
}

.fc .fc-button-primary:not(:disabled).fc-button-active {
    background: #111827 !important;
}

@media (max-width: 800px) {
    .calendar-header-card {
        flex-direction: column;
        align-items: stretch;
    }

    .calendar-card {
        padding: 10px;
        border-radius: 18px;
    }

    .fc .fc-toolbar {
        flex-direction: column;
        gap: 10px;
    }

    .fc .fc-toolbar-title {
        font-size: 18px;
    }

    .fc .fc-button {
        padding: 7px 9px !important;
        font-size: 13px !important;
    }
}

.color-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    border: 1px solid rgba(0,0,0,0.15);
}

.permission-box {
    margin-top: 18px;
    padding: 14px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

input[type="color"] {
    height: 48px;
    padding: 6px;
}

.large-modal {
    max-width: 700px;
}

.modal-divider {
    margin: 24px 0;
    border: none;
    border-top: 1px solid #e5e7eb;
}

#deleteEntryForm {
    margin-top: 14px;
}

.fc-event {
    border-radius: 10px !important;
    padding: 2px 4px;
    border: none !important;
    cursor: pointer;
}

.fc-daygrid-event {
    white-space: normal !important;
}

.message-list {
    margin-top: 24px;
    display: grid;
    gap: 16px;
}

.message-card {
    background: white;
    border-radius: 22px;
    padding: 22px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    border-left: 6px solid transparent;
}

.message-card.unread {
    border-left-color: #2563eb;
}

.message-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.badge.blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.button-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.button-row form {
    margin: 0;
}

.secondary-button {
    background: #374151;
}

.secondary-button:hover {
    background: #1f2937;
}

@media (max-width: 700px) {
    .message-top {
        flex-direction: column;
    }

    .button-row {
        flex-direction: column;
    }

    .button-row form,
    .button-row button {
        width: 100%;
    }
}

.inline-link {
    display: inline-block;
    margin-top: 10px;
    color: #2563eb;
    font-weight: 700;
    text-decoration: none;
}

.inline-link:hover {
    text-decoration: underline;
}

.approval-box {
    margin-top: 14px;
    padding: 14px;
    border-radius: 16px;
    background: #fffbeb;
    border: 1px solid #f59e0b;
}

.dashboard-grid {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.mini-entry {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
}

.mini-entry:last-child {
    border-bottom: none;
}

@media (max-width: 800px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.nav-mail {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #dc2626;
    color: white;
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.badge.orange {
    background: #ffedd5;
    color: #c2410c;
}

.badge.gray {
    background: #e5e7eb;
    color: #374151;
}

.message-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.logo-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.menu-toggle {
    display: none;
    width: auto;
    margin: 0;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 24px;
}

@media (max-width: 800px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 800;
    }

    .menu-toggle {
        display: block;
    }

    #mainNav {
        display: none;
        flex-direction: column;
        gap: 8px;
    }

    #mainNav.open {
        display: flex;
    }

    #mainNav a {
        background: rgba(255,255,255,0.12);
        padding: 12px;
        border-radius: 12px;
    }

    .logo {
        text-align: left;
    }

    .fc .fc-toolbar {
        flex-direction: column;
        gap: 10px;
    }

    .fc .fc-toolbar-chunk {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }

    .fc .fc-toolbar-title {
        font-size: 18px;
        text-align: center;
    }
}

.password-card {
    margin-top: 24px;
    max-width: 520px;
}

.password-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.password-row input {
    flex: 1;
}

.password-row button {
    margin-top: 6px;
    white-space: nowrap;
}

.generated-password-box {
    margin-top: 12px;
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
}

.generated-password-box code {
    display: block;
    margin: 8px 0;
    padding: 10px;
    border-radius: 10px;
    background: #111827;
    color: white;
    font-size: 16px;
    word-break: break-all;
}

@media (max-width: 700px) {
    .password-row {
        flex-direction: column;
        align-items: stretch;
    }
}
