:root {
    --red-950: #4b0000;
    --red-900: #650000;
    --red-800: #7f0000;
    --red-700: #981313;
    --red-600: #b21f24;
    --red-500: #c92d32;
    --red-100: #f9dddd;
    --red-050: #fff4f4;

    --gray-950: #24262a;
    --gray-900: #32353a;
    --gray-800: #484c52;
    --gray-700: #62676f;
    --gray-500: #8a9098;
    --gray-300: #c8ccd2;
    --gray-200: #dde0e4;
    --gray-100: #eceef1;
    --gray-050: #f6f7f9;

    --white: #ffffff;
    --success: #247746;
    --danger: #9e1015;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 6px 18px rgba(31, 20, 20, .08);
    --shadow-md: 0 15px 38px rgba(65, 0, 0, .14);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--gray-100);
    color: var(--gray-950);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

/* Header */

.main-header {
    background:
        linear-gradient(110deg, var(--red-950), var(--red-800) 58%, var(--red-600));
    color: var(--white);
    box-shadow: 0 4px 16px rgba(55, 0, 0, .22);
}

.header-container {
    display: flex;
    width: min(1280px, 92%);
    min-height: 88px;
    margin: auto;
    align-items: center;
    justify-content: space-between;
    gap: 26px;
}

.branding {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 14px;
}

.school-logo {
    display: block;
    width: 64px !important;
    height: 64px !important;
    max-width: 64px !important;
    max-height: 64px !important;
    flex: 0 0 64px;
    border: 3px solid rgba(255, 255, 255, .92);
    border-radius: 50%;
    background: var(--white);
    object-fit: contain;
    box-shadow: 0 5px 14px rgba(0, 0, 0, .24);
}

.brand-copy {
    min-width: 0;
}

.brand-copy h1 {
    margin: 0;
    font-size: clamp(20px, 2.2vw, 28px);
    line-height: 1.05;
    letter-spacing: .2px;
    text-transform: uppercase;
}

.brand-copy p {
    margin: 6px 0 0;
    color: #f4dcdc;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.55px;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.top-navigation a,
.logout-button {
    display: inline-flex;
    min-height: 40px;
    padding: 9px 13px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 750;
    transition: background .18s, color .18s, transform .15s;
}

.top-navigation a {
    border: 1px solid transparent;
    color: #f8eaea;
}

.top-navigation a:hover,
.top-navigation a.active {
    border-color: rgba(255,255,255,.24);
    background: var(--white);
    color: var(--red-900);
    transform: translateY(-1px);
}

.logout-button {
    border: 1px solid rgba(255,255,255,.36);
    background: var(--gray-900);
    color: var(--white);
}

.logout-button:hover {
    background: var(--gray-950);
    transform: translateY(-1px);
}

.user-strip {
    border-bottom: 1px solid var(--gray-300);
    background: var(--gray-900);
    color: var(--white);
}

.user-strip-inner {
    display: flex;
    width: min(1280px, 92%);
    min-height: 38px;
    margin: auto;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    font-size: 12px;
}

.role-badge {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--red-600);
    color: var(--white);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

/* Layout */

.page-container {
    width: min(1280px, 92%);
    margin: 30px auto;
}

.registration-layout {
    display: grid;
    grid-template-columns: minmax(270px, .72fr) minmax(0, 1.55fr);
    gap: 24px;
    align-items: stretch;
}

.information-panel {
    min-height: 520px;
    padding: 38px 30px;
    border-radius: var(--radius-lg);
    background:
        linear-gradient(155deg, var(--red-950), var(--red-700) 72%, var(--gray-900) 72%);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.section-label,
.eyebrow {
    color: var(--red-700);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1.45px;
}

.information-panel .section-label {
    color: #ffd2d2;
}

.information-panel h2 {
    margin: 17px 0;
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1.1;
}

.information-panel > p {
    margin-bottom: 36px;
    color: #f1dddd;
    font-size: 16px;
    line-height: 1.65;
}

.information-item {
    display: flex;
    padding: 17px 0;
    border-top: 1px solid rgba(255,255,255,.24);
    flex-direction: column;
    gap: 6px;
}

.information-item span {
    color: #e7dede;
    line-height: 1.5;
}

/* Cards */

.form-card,
.management-card {
    border: 1px solid var(--gray-300);
    border-top: 5px solid var(--red-700);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.form-card {
    padding: 31px;
}

.card-heading {
    display: flex;
    margin-bottom: 26px;
    align-items: flex-start;
    gap: 13px;
}

.heading-line {
    width: 6px;
    height: 55px;
    border-radius: 5px;
    background: linear-gradient(var(--red-500), var(--red-900));
}

.card-heading p,
.table-heading p {
    margin: 0 0 6px;
}

.card-heading h2,
.table-heading h3 {
    margin: 0;
}

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

.single-column-form {
    display: grid;
    gap: 18px;
}

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

.form-group label,
.filter-form label {
    margin-bottom: 7px;
    color: var(--gray-900);
    font-size: 14px;
    font-weight: 750;
}

.form-group label span {
    color: var(--red-600);
}

input,
select {
    width: 100%;
    min-height: 47px;
    padding: 11px 13px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--gray-050);
    color: var(--gray-950);
}

input:focus,
select:focus {
    border-color: var(--red-600);
    outline: none;
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(178, 31, 36, .13);
}

.form-actions {
    display: flex;
    margin-top: 28px;
    justify-content: flex-end;
    gap: 10px;
}

.button {
    display: inline-flex;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 800;
    transition: transform .15s, background .18s;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    border-color: var(--red-700);
    background: linear-gradient(135deg, var(--red-600), var(--red-900));
    color: var(--white);
}

.button-primary:hover {
    background: linear-gradient(135deg, var(--red-700), var(--red-950));
}

.button-secondary {
    border-color: var(--gray-700);
    background: var(--gray-800);
    color: var(--white);
}

.button-secondary:hover {
    background: var(--gray-950);
}

/* Alerts */

.alert {
    margin-bottom: 21px;
    padding: 13px 15px;
    border-left: 5px solid;
    border-radius: var(--radius-sm);
    font-weight: 650;
}

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

.alert-error {
    border-color: var(--danger);
    background: var(--red-100);
    color: var(--danger);
}

/* Admin and users */

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

.admin-heading h2 {
    margin: 5px 0;
    color: var(--gray-950);
    font-size: clamp(26px, 4vw, 36px);
}

.admin-description {
    margin: 0;
    color: var(--gray-700);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 260px));
    margin-bottom: 22px;
    gap: 16px;
}

.summary-card {
    padding: 18px;
    border: 1px solid var(--gray-300);
    border-left: 5px solid var(--red-700);
    border-radius: 8px;
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.summary-card span {
    display: block;
    color: var(--gray-700);
    font-size: 13px;
}

.summary-card strong {
    display: block;
    margin-top: 5px;
    color: var(--red-800);
    font-size: 29px;
}

.management-card {
    overflow: hidden;
}

.filter-form {
    display: grid;
    padding: 22px;
    border-bottom: 1px solid var(--gray-300);
    background: var(--gray-200);
    grid-template-columns: minmax(250px, 1.5fr) minmax(180px, 1fr) minmax(170px, .8fr) auto;
    gap: 13px;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.table-heading {
    display: flex;
    padding: 22px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.result-count {
    padding: 7px 11px;
    border-radius: 999px;
    background: var(--red-100);
    color: var(--red-800);
    font-size: 12px;
    font-weight: 800;
}

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

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

.student-table th,
.student-table td {
    padding: 14px;
    border-top: 1px solid var(--gray-200);
    text-align: left;
    vertical-align: middle;
}

.student-table th {
    border-top: 0;
    background: linear-gradient(110deg, var(--red-950), var(--red-700));
    color: var(--white);
    font-size: 13px;
    white-space: nowrap;
}

.student-table tbody tr:nth-child(even) {
    background: var(--gray-050);
}

.student-table tbody tr:hover {
    background: var(--red-050);
}

.year-badge,
.view-only {
    display: inline-block;
    padding: 7px 10px;
    border-radius: 999px;
    background: var(--gray-200);
    color: var(--gray-900);
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.table-actions form {
    margin: 0;
}

.action-button {
    display: inline-flex;
    min-height: 34px;
    padding: 8px 11px;
    border: 0;
    border-radius: 5px;
    align-items: center;
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.edit-button {
    background: var(--gray-800);
    color: var(--white);
}

.delete-button {
    background: var(--red-700);
    color: var(--white);
}

.empty-state {
    padding: 42px !important;
    color: var(--gray-700);
    text-align: center !important;
}

.edit-page {
    display: flex;
    justify-content: center;
}

.edit-card {
    width: min(900px, 100%);
}

.users-layout {
    display: grid;
    grid-template-columns: minmax(280px, .55fr) minmax(0, 1.65fr);
    gap: 23px;
    align-items: start;
}

.inline-access-form {
    display: grid;
    min-width: 360px;
    grid-template-columns: minmax(125px, 1fr) minmax(105px, .8fr) auto;
    gap: 7px;
    align-items: center;
}

.inline-access-form select {
    min-height: 36px;
    padding: 7px 8px;
    font-size: 12px;
}

/* Footer */

.main-footer {
    margin-top: 42px;
    padding: 22px;
    border-top: 4px solid var(--red-700);
    background: var(--gray-950);
    color: #dedede;
    text-align: center;
}

.main-footer p {
    margin: 0;
}

/* Login */

.login-body {
    background:
        linear-gradient(135deg, rgba(75, 0, 0, .97), rgba(152, 19, 19, .95)),
        radial-gradient(circle at 15% 20%, rgba(255,255,255,.12), transparent 35%);
}

.login-page {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(330px, 1.05fr) minmax(390px, .95fr);
}

.login-brand-panel {
    position: relative;
    display: flex;
    overflow: hidden;
    padding: clamp(44px, 7vw, 96px);
    background:
        linear-gradient(145deg, var(--red-950), var(--red-700) 75%, var(--gray-900) 75%);
    color: var(--white);
    flex-direction: column;
    justify-content: center;
}

.login-brand-panel::after {
    position: absolute;
    right: -95px;
    bottom: -95px;
    width: 310px;
    height: 310px;
    border: 36px solid rgba(255,255,255,.06);
    border-radius: 50%;
    content: "";
}

.login-school-logo {
    z-index: 1;
    display: block;
    width: 118px !important;
    height: 118px !important;
    max-width: 118px !important;
    max-height: 118px !important;
    margin-bottom: 25px;
    border: 4px solid rgba(255,255,255,.9);
    border-radius: 50%;
    background: var(--white);
    object-fit: contain;
    box-shadow: 0 11px 28px rgba(0,0,0,.28);
}

.login-eyebrow {
    z-index: 1;
    color: #ffd2d2;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 1.85px;
}

.login-brand-panel h1 {
    z-index: 1;
    max-width: 570px;
    margin: 11px 0 17px;
    font-size: clamp(40px, 5.5vw, 66px);
    line-height: 1.02;
}

.login-description {
    z-index: 1;
    max-width: 550px;
    color: #f1dede;
    font-size: 18px;
    line-height: 1.6;
}

.login-card {
    width: min(460px, 84%);
    margin: auto;
    padding: 36px;
    border: 1px solid var(--gray-300);
    border-top: 6px solid var(--red-700);
    border-radius: 12px;
    background: var(--white);
    box-shadow: 0 22px 52px rgba(65,0,0,.26);
}

.login-card-heading h2 {
    margin: 7px 0;
    font-size: 29px;
}

.login-card-heading > p:last-child {
    margin: 0 0 24px;
    color: var(--gray-700);
}

.login-form {
    display: grid;
    gap: 18px;
}

.login-button {
    width: 100%;
    margin-top: 4px;
}

/* Responsive */

@media (max-width: 1050px) {
    .header-container {
        padding: 14px 0;
    }

    .header-actions {
        align-items: flex-end;
        flex-direction: column;
    }

    .registration-layout,
    .users-layout {
        grid-template-columns: 1fr;
    }

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

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

    .login-brand-panel {
        min-height: 390px;
    }

    .login-card {
        margin: 42px auto;
    }
}

@media (max-width: 760px) {
    .header-container,
    .admin-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions {
        width: 100%;
        align-items: stretch;
    }

    .top-navigation {
        width: 100%;
    }

    .top-navigation a {
        flex: 1;
        text-align: center;
    }

    .logout-button {
        width: 100%;
    }

    .form-grid,
    .filter-form,
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .form-card {
        padding: 23px 18px;
    }

    .form-actions,
    .filter-actions {
        flex-direction: column-reverse;
    }

    .form-actions .button,
    .filter-actions .button,
    .admin-heading .button {
        width: 100%;
    }

    .table-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .user-strip-inner {
        padding: 8px 0;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .login-brand-panel {
        min-height: 350px;
        padding: 40px 8%;
    }

    .login-school-logo {
        width: 100px !important;
        height: 100px !important;
        max-width: 100px !important;
        max-height: 100px !important;
    }

    .login-card {
        width: 90%;
        padding: 27px 21px;
    }

    .inline-access-form {
        min-width: 320px;
    }
}
