:root {
    --ink: #172b3a;
    --muted: #587080;
    --navy: #12344a;
    --navy-deep: #0c2739;
    --blue: #176b87;
    --teal: #157a72;
    --canvas: #f3f6f7;
    --surface: #fff;
    --line: #dce5e9;
    --soft-blue: #eaf3f6;
    --danger: #a63b42;
    --radius: 18px;
    --shadow: 0 12px 32px rgba(20, 48, 65, 0.08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

a {
    color: var(--blue);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #70b9c9;
    outline-offset: 3px;
}

#headerSection {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    min-height: 76px;
    height: auto;
    padding: 0.75rem clamp(1rem, 3vw, 2.5rem);
    background: var(--navy-deep);
    box-shadow: 0 4px 16px rgba(12, 39, 57, 0.16);
}

#homePage {
    position: static;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: auto;
    height: auto;
    cursor: pointer;
    transition: opacity 160ms ease;
}

#homePage:hover {
    transform: none;
    opacity: 0.88;
}

#CITLogo {
    position: static;
    width: 44px;
    height: 44px;
    margin: 0;
    object-fit: contain;
}

#CITSignups {
    position: static;
    margin: 0;
    color: #fff;
    font-size: clamp(1.15rem, 2vw, 1.55rem);
    font-weight: 750;
    letter-spacing: -0.035em;
    line-height: 1.1;
}

#navLinks {
    position: static;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    max-width: none;
    transform: none;
}

.headerItem {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin: 0;
    padding: 0.45rem 0.8rem;
    border: 1px solid transparent;
    border-radius: 999px;
    color: #e9f2f5;
    font-size: 0.91rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 150ms ease, color 150ms ease;
}

#navLinks .headerItem:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

#accountMenu {
    position: relative;
    min-width: 0;
}

#optionBarTrigger {
    position: static;
    display: block;
    width: auto;
    margin: 0;
    transform: none;
    cursor: pointer;
    list-style: none;
}

#optionBarTrigger::-webkit-details-marker {
    display: none;
}

#signinText {
    max-width: 180px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
    padding: 0.45rem 0.8rem !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#accountMenu[open] #signinText,
#signinText:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

#dropdown {
    position: absolute;
    top: calc(100% + 0.55rem);
    right: 0;
    z-index: 30;
    display: grid;
    width: max-content;
    min-width: 180px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-5px);
    transition: opacity 140ms ease, transform 140ms ease;
}

#accountMenu[open] #dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

#dropdown a {
    color: var(--ink);
    text-decoration: none;
}

#dropdown span {
    display: block;
    padding: 0.7rem 1rem;
    color: inherit;
    font-weight: 600;
    text-shadow: none;
}

#dropdown a:hover {
    background: var(--soft-blue);
}

#dropdown #logOut {
    border: 0;
    border-radius: 0;
    background: transparent !important;
    color: var(--danger);
}

#bodySection {
    width: min(1120px, calc(100% - 2.5rem));
    margin: 2rem auto 4rem;
}

.roundedBox {
    margin: 0 0 1.25rem;
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: none;
}

.roundedBox h1,
.roundedBox h2,
.roundedBox h3 {
    color: var(--ink);
    line-height: 1.2;
}

#welcome {
    padding: clamp(1.4rem, 4vw, 2.75rem);
    border: 0;
    background: linear-gradient(120deg, var(--navy-deep), #1a536a);
    color: #fff;
    text-align: left;
}

#welcome h1 {
    margin: 0;
    color: inherit;
    font-size: clamp(1.65rem, 4vw, 2.5rem);
    letter-spacing: -0.04em;
}

#events {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    text-align: left;
}

#eventsMenu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
    gap: 1.25rem;
}

.eventBox {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background-color: var(--surface);
    box-shadow: var(--shadow);
    color: var(--ink);
    text-align: left;
}

.eventBox:hover {
    transform: none;
}

.event-card-link,
.eventTitleLink {
    display: flex;
    flex: 1;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
}

.eventTitle {
    display: flex;
    min-height: 150px;
    align-items: center;
    justify-content: flex-start;
    margin: 0;
    padding: 1.5rem;
    background: linear-gradient(180deg, rgba(12, 39, 57, 0.08), rgba(12, 39, 57, 0.78));
    color: white;
    font-size: clamp(1.25rem, 2vw, 1.65rem);
    line-height: 1.2;
}

.eventDimmer {
    display: inline-block;
    max-width: 100%;
    padding: 0;
    border-radius: 0;
    background: transparent;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}

.eventInfo {
    flex: 1;
    padding: 1rem 1.2rem;
    background: var(--surface);
    font-size: 0.95rem;
}

.eventInfo p {
    margin: 0.45rem 0;
    color: var(--muted);
}

.eventInfo p:has(i) {
    margin-top: 0.85rem;
    padding: 0.7rem 0.8rem;
    border: 0;
    border-left: 3px solid var(--teal);
    border-radius: 0 8px 8px 0;
    background: var(--soft-blue);
    color: var(--ink);
}

.textLink {
    color: var(--blue);
    overflow-wrap: anywhere;
}

.eventTitleLink {
    text-decoration: none;
}

.user-table th {
    background: var(--navy) !important;
    color: #fff !important;
}

.user-table td {
    border-color: var(--line) !important;
}

.user-table tr:hover {
    background: var(--soft-blue) !important;
}

.admin-badge,
.toggle-btn {
    border-radius: 999px;
}

.admin-yes,
.grant-btn {
    background: var(--teal) !important;
    color: #fff !important;
}

.admin-no {
    background: #e8edef !important;
    color: var(--muted) !important;
}

.revoke-btn {
    background: var(--danger) !important;
    color: #fff !important;
}

.stats-box {
    border-color: var(--teal) !important;
    border-radius: 12px !important;
    background: var(--soft-blue) !important;
}

.stats-box h3,
.stats-box p {
    color: var(--navy) !important;
}

.search-submit,
.send-btn {
    background: var(--navy) !important;
    color: #fff !important;
}

.clear-search,
.cancel-btn {
    background: #e8edef !important;
    color: var(--ink) !important;
}

.template-btn {
    border-color: var(--line) !important;
    border-radius: 10px !important;
    background: #f5f8f9 !important;
    color: var(--ink) !important;
}

.template-btn:hover,
.template-btn.active {
    border-color: var(--blue) !important;
    background: var(--blue) !important;
    color: #fff !important;
}

.event-info {
    border-color: var(--blue) !important;
    border-radius: 12px !important;
    background: var(--soft-blue) !important;
}

.event-info h3 {
    color: var(--navy) !important;
}

.big-button,
.edit-event-button,
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--navy);
    color: #fff;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    transition: background-color 150ms ease, box-shadow 150ms ease;
}

.big-button,
.edit-event-button {
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
}

.big-button:hover,
.edit-event-button:hover,
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
    background: var(--blue);
    box-shadow: 0 5px 14px rgba(18, 52, 74, 0.16);
}

.eventBox > .edit-event-button,
.eventBox > form {
    align-self: flex-start;
    margin: 0 0.75rem 0.75rem;
}

.eventBox > form .edit-event-button {
    margin: 0;
}

.eventBox .edit-event-button:not(.secondary-button):not(.danger-button) {
    background: var(--navy) !important;
}

.eventBox .secondary-button {
    background: var(--teal) !important;
}

.eventBox .danger-button {
    background: var(--danger) !important;
}

.reminder-link {
    display: inline-flex;
    align-items: center;
    margin: 0 0 0.75rem 0.65rem;
    color: #fff;
    text-decoration: none;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
select,
textarea {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    padding: 0.65rem 0.8rem;
    border: 1px solid #bdcbd2;
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

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

label {
    color: var(--ink);
    font-weight: 600;
}

form {
    max-width: 100%;
}

th,
td {
    overflow-wrap: anywhere;
}

.alert {
    margin: 0.75rem 0;
    padding: 0.8rem 1rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    text-align: left;
}

.alert-success {
    border-color: #b6d9cd;
    background: #eaf6f0;
    color: #205943;
}

.alert-danger {
    border-color: #e6c1c3;
    background: #fbefef;
    color: #812d34;
}

.alert-warning {
    border-color: #ead9aa;
    background: #fff8e6;
    color: #705318;
}

.alert-info {
    border-color: #bdd9e2;
    background: #edf7fa;
    color: #20566b;
}

#addEventInput,
#inputs,
#tableForm,
#deleteSignupPopup,
#deleteTablePopup,
.comment-popup {
    max-width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(12, 39, 57, 0.28);
}

#addEventInput,
#inputs {
    width: min(620px, calc(100vw - 2rem));
    height: auto;
    padding-bottom: 1.25rem;
}

#addEventInputHeader,
#inputHeader {
    position: relative;
    width: auto;
    margin: 0 0 1rem;
    padding: 1rem 3.5rem 1rem 1.25rem;
    border-radius: 0;
    background: var(--navy);
}

#addEventHeader,
#signUpHeader {
    margin: 0;
    color: white;
    font-size: 1.35rem;
}

#closeAddEvent,
#closeSignUp {
    top: 50%;
    right: 1rem;
    width: 28px;
    height: 28px;
    transform: translateY(-50%);
    object-fit: contain;
}

#closeAddEvent:hover,
#closeSignUp:hover {
    transform: translateY(-50%);
}

#addEventInput form,
#inputs form {
    display: grid;
    gap: 0.5rem;
    padding: 0 1.25rem;
    text-align: left;
}

#addEventInput form br,
#inputs form br {
    display: none;
}

.auth-page {
    display: grid;
    min-height: 100vh;
    height: auto;
    place-items: center;
    padding: 1.5rem;
    background: radial-gradient(ellipse at top, #e6f0f3, var(--canvas) 65%);
}

.auth-shell {
    width: min(100%, 440px);
    padding: clamp(1.5rem, 5vw, 2.5rem);
    border: 1px solid var(--line);
    border-radius: 20px;
    background: white;
    box-shadow: var(--shadow);
}

.auth-shell .logo {
    display: block;
    width: 76px;
    height: 76px;
    margin: 0 auto 1rem;
    object-fit: contain;
}

.auth-shell h1 {
    margin: 0 0 1.2rem;
    color: var(--ink);
    font-size: clamp(1.5rem, 5vw, 2rem);
    text-align: center;
}

.auth-shell form,
.auth-shell form > div {
    display: grid;
    gap: 0.6rem;
}

.auth-shell form {
    width: 100%;
    gap: 1rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.auth-shell form > div {
    min-width: 0;
}

.auth-shell form input[type="submit"] {
    width: 100%;
    margin-top: 0.3rem;
}

.auth-shell a {
    color: var(--blue);
    font-weight: 600;
}

.account-actions {
    display: grid;
    gap: 0.6rem;
    margin-top: 1rem;
}

.account-action-btn {
    display: block;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    text-align: center;
    text-decoration: none;
}

.create-account-btn {
    border-color: var(--navy);
    background: var(--navy);
    color: #fff !important;
}

.forgot-password-btn {
    background: #f5f8f9;
    color: var(--ink) !important;
}

@media (max-width: 820px) {
    #headerSection {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.5rem 1rem;
        padding: 0.7rem 1rem;
    }

    #navLinks {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-start;
        gap: 0.15rem;
    }

    #homePage {
        grid-column: 1;
        grid-row: 1;
    }

    #accountMenu {
        grid-column: 2;
        grid-row: 1;
    }

    #bodySection {
        width: min(100% - 1.25rem, 680px);
        margin-top: 1rem;
    }
}

@media (max-width: 520px) {
    #headerSection {
        position: relative;
        padding: 0.65rem 0.75rem;
    }

    #CITLogo {
        width: 36px;
        height: 36px;
    }

    #CITSignups {
        font-size: 1.2rem;
    }

    #navLinks .headerItem {
        min-height: 36px;
        padding: 0.35rem 0.6rem;
        font-size: 0.82rem;
    }

    #signinText {
        max-width: 125px;
        min-height: 36px;
        font-size: 0.82rem;
    }

    #bodySection {
        width: calc(100% - 1rem);
        margin: 0.75rem auto 2rem;
    }

    .roundedBox {
        margin-bottom: 0.85rem;
        padding: 1rem;
        border-radius: 14px;
    }

    #eventsMenu {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.85rem;
    }

    .eventTitle {
        min-height: 120px;
    }

    .auth-page {
        padding: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
