* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #dbe1e8;
    --primary: #34476f;
    --primary-dark: #263754;
    --special: #f7e8aa;
    --danger-bg: #fde8e8;
    --danger-text: #9b1c1c;
    --success-bg: #def7ec;
    --success-text: #03543f;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    text-decoration: none;
    display: flex;
    flex-direction: column;
}

.brand-title {
    color: var(--primary);
    font-size: 22px;
    font-weight: 800;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user form {
    margin: 0;
}

.link-button {
    border: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.page {
    padding-top: 32px;
    padding-bottom: 60px;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin: 12px 0 24px;
}

.page-heading h1 {
    margin: 0 0 6px;
}

.muted {
    color: var(--muted);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 20px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
    font: inherit;
}

.button-primary {
    background: var(--primary);
    color: #fff;
}

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

.button-secondary {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 20px;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.student-grid {
    display: grid;
    gap: 12px;
}

.student-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    text-decoration: none;
    color: var(--text);
}

.student-card:hover {
    border-color: #aeb8c5;
}

.student-card h2 {
    margin: 0 0 5px;
    font-size: 18px;
}

.student-card p {
    margin: 0;
    color: var(--muted);
}

.student-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
}

.student-meta span {
    background: var(--bg);
    border-radius: 20px;
    padding: 5px 9px;
}

.form-card label,
.form-stack label {
    display: block;
}

.form-card label > span,
.form-stack label > span,
.form-grid label > span {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #cbd2da;
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    padding: 10px 11px;
    font: inherit;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid rgba(52, 71, 111, .18);
    border-color: var(--primary);
}

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

.checkbox-field {
    display: flex !important;
    align-items: center;
    gap: 9px;
    align-self: end;
    min-height: 42px;
}

.checkbox-field input {
    width: auto;
}

.checkbox-field span {
    margin: 0 !important;
}

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

.sticky-actions {
    position: sticky;
    bottom: 14px;
    padding: 12px;
    background: rgba(244, 246, 249, .94);
    backdrop-filter: blur(8px);
    border-radius: 10px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.details {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 10px 16px;
    margin: 0;
}

.details dt {
    color: var(--muted);
}

.details dd {
    margin: 0;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.table-wrap,
.instruction-wrap {
    overflow-x: auto;
}

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

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

.progress-list {
    display: grid;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
}

.progress-row {
    display: grid;
    grid-template-columns: minmax(200px, 1.4fr) minmax(150px, .7fr) minmax(220px, 1.2fr);
    gap: 12px;
    align-items: center;
    background: #fff;
    padding: 10px;
}

.progress-special {
    background: var(--special);
}

.progress-name {
    font-weight: 700;
}

.legend {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.card-table {
    padding: 0;
    overflow: hidden;
}

.instruction-table {
    width: max-content;
    min-width: 100%;
    font-size: 14px;
}

.instruction-table th,
.instruction-table td {
    border-right: 1px solid #bbb;
    border-bottom: 1px solid #bbb;
    text-align: center;
    min-width: 42px;
    padding: 7px;
}

.instruction-table .topic-column {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 250px;
    text-align: left;
    background: #fff;
}

.instruction-table thead .topic-column {
    z-index: 3;
}

.instruction-table .special-row th,
.instruction-table .special-row td {
    background: var(--special);
}

.instruction-table .level {
    font-weight: 800;
}

.level-1 { background-image: linear-gradient(rgba(0,0,0,.03), rgba(0,0,0,.03)); }
.level-2 { background-image: linear-gradient(rgba(0,0,0,.07), rgba(0,0,0,.07)); }
.level-3 { background-image: linear-gradient(rgba(0,0,0,.12), rgba(0,0,0,.12)); }
.level-4 { background-image: linear-gradient(rgba(0,0,0,.18), rgba(0,0,0,.18)); }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 15px 50px rgba(22, 30, 46, .08);
}

.login-brand {
    text-align: center;
    margin-bottom: 26px;
}

.login-brand h1 {
    margin: 0;
    color: var(--primary);
}

.login-brand p {
    margin: 6px 0 0;
    color: var(--muted);
}

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

.back-link {
    display: inline-block;
    margin-bottom: 10px;
    text-decoration: none;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
}

@media (max-width: 760px) {
    .header-inner,
    .page-heading,
    .student-card,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-user {
        width: 100%;
        justify-content: space-between;
    }

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

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

    .student-meta {
        justify-content: flex-start;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .button {
        flex: 1;
    }
}
