:root {
    --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "JetBrains Mono", monospace;
    --bg: #f5f7fa;
    --bg-soft: #eef2f6;
    --surface: #ffffff;
    --surface-subtle: #f8fafc;
    --surface-strong: #f1f5f9;
    --sidebar: #f7f9fb;
    --line: #e3e8ef;
    --line-strong: #d4dde7;
    --text: #1f2d3d;
    --text-muted: #5b6b7d;
    --text-light: #7c8a9a;
    --accent: #07c160;
    --accent-press: #06ad56;
    --accent-soft: rgba(7, 193, 96, 0.12);
    --accent-line: rgba(7, 193, 96, 0.22);
    --danger: #e34d59;
    --danger-soft: rgba(227, 77, 89, 0.1);
    --warning-soft: rgba(255, 184, 0, 0.12);
    --shadow-sm: 0 10px 24px rgba(31, 45, 61, 0.06);
    --shadow-md: 0 18px 40px rgba(31, 45, 61, 0.08);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: var(--font-sans);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(7, 193, 96, 0.08), transparent 26%),
        radial-gradient(circle at top right, rgba(16, 185, 129, 0.06), transparent 24%),
        linear-gradient(180deg, #f8fafc 0%, #f3f6f8 100%);
    padding: 24px;
    line-height: 1.6;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        linear-gradient(rgba(31, 45, 61, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 45, 61, 0.03) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.18), transparent 88%);
    pointer-events: none;
}

body > * {
    position: relative;
    z-index: 1;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: none;
    background: none;
}

strong {
    font-weight: 700;
}

small {
    color: var(--text-light);
}

.login-page {
    min-height: calc(100vh - 48px);
    display: grid;
    place-items: center;
}

.login-box {
    width: min(100%, 460px);
    background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow-md);
    padding: 36px 34px 30px;
    position: relative;
    overflow: hidden;
}

.login-box::before {
    content: "";
    position: absolute;
    inset: 0 0 auto auto;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(7, 193, 96, 0.18), transparent 68%);
    transform: translate(30%, -30%);
    pointer-events: none;
}

.login-brand {
    position: relative;
    z-index: 1;
}

.login-eyebrow,
.brand-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #159457;
}

.login-box h1,
.brand-block h1 {
    font-size: clamp(2rem, 4vw, 2.5rem);
    line-height: 1.12;
    letter-spacing: -0.03em;
    margin-top: 14px;
    color: #18212b;
}

.login-subtitle,
.brand-subtitle,
.section-desc,
.hint,
.evaluation-info p,
.period-display p,
.ranking-period-info p,
.score-rules p,
.admin-section p,
.checkin-info li,
.login-note,
.score-input-item span,
.class-info,
.evaluation-detail,
.empty-hint {
    color: var(--text-muted);
}

.login-subtitle,
.brand-subtitle {
    margin-top: 10px;
    font-size: 14px;
}

.login-highlights {
    margin: 22px 0 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.login-highlights span {
    padding: 8px 12px;
    border-radius: 999px;
    background: #f1f8f4;
    border: 1px solid rgba(7, 193, 96, 0.12);
    color: #157d4b;
    font-size: 13px;
    font-weight: 600;
}

#loginForm {
    display: grid;
    gap: 16px;
}

#loginForm .btn-primary,
.evaluation-form > .btn-primary,
#submitHomeworkBtn,
#importExcelBtn {
    width: 100%;
}

.login-note {
    margin-top: 18px;
    font-size: 13px;
}

.container {
    max-width: 1460px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 30px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(14px);
    overflow: hidden;
}

header {
    padding: 28px 30px 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(249, 251, 252, 0.94) 100%);
    border-bottom: 1px solid var(--line);
}

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

.brand-block {
    max-width: 680px;
}

.header-right {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

#welcomeUser {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    color: var(--text-muted);
    font-size: 14px;
}

.current-time {
    margin-top: 12px;
    color: var(--text-light);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.workspace-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: calc(100vh - 200px);
}

.workspace-sidebar {
    padding: 24px 18px;
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.sidebar-head {
    padding: 10px 8px 20px;
}

.sidebar-head h2 {
    margin-top: 10px;
    font-size: 24px;
    line-height: 1.2;
    letter-spacing: -0.03em;
}

.tabs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tab-btn {
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1px solid transparent;
    color: var(--text-muted);
    background: transparent;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.88);
    border-color: var(--line);
    color: var(--text);
    transform: translateX(2px);
}

.tab-btn.active {
    background: linear-gradient(180deg, #ebfff2 0%, #e7faee 100%);
    border-color: var(--accent-line);
    color: #127646;
    box-shadow: inset 0 0 0 1px rgba(7, 193, 96, 0.08);
}

.app-main {
    padding: 24px;
    min-width: 0;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: grid;
    gap: 20px;
    animation: fadeIn 0.24s ease;
}

.tab-content > h2,
.checkin-info h2,
.admin-section > h3,
.headteacher-result > h3,
.evaluation-history > h3,
.score-rules > h3,
.evaluation-section > h3,
.modal-content h3,
.score-config-group h4,
.rule-card h4,
.class-list-container h4,
.deduction-history h4,
.export-template h4,
.import-result h4,
.import-format-hint h4 {
    color: var(--text);
}

.tab-content > h2 {
    font-size: 28px;
    letter-spacing: -0.03em;
}

.checkin-info,
.evaluation-info,
.disabled-notice,
.evaluation-history,
.headteacher-result,
.admin-section,
.score-rules,
.ranking-period-info,
.import-result,
.import-format-hint,
.period-display,
.evaluation-section,
.score-config-group,
.summer-toggle,
.import-panel,
.evaluation-level,
.rule-card,
.teacher-item,
.class-item,
.class-teacher-item,
.deduction-item,
.class-checkbox-item,
.class-info-display {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.checkin-info,
.evaluation-info,
.disabled-notice,
.evaluation-history,
.headteacher-result,
.score-rules,
.ranking-period-info,
.import-result,
.import-format-hint,
.period-display,
.evaluation-section {
    padding: 22px;
}

.admin-section {
    padding: 28px 30px;
    display: grid;
    gap: 18px;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at top right, rgba(7, 193, 96, 0.08), transparent 24%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(250, 252, 253, 0.98) 100%);
}

.admin-section::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 160px;
    height: 160px;
    background: radial-gradient(circle, rgba(15, 118, 110, 0.08), transparent 70%);
    transform: translate(-35%, -35%);
    pointer-events: none;
}

.admin-section > * {
    position: relative;
    z-index: 1;
}

.admin-section > h3,
.evaluation-history > h3,
.headteacher-result > h3,
.score-rules > h3,
.evaluation-section > h3 {
    margin-bottom: 0;
    font-size: 19px;
}

.admin-section .hint {
    max-width: 72ch;
    color: #6a7b8d;
}

.checkin-info {
    background: linear-gradient(180deg, #f7fcf9 0%, #ffffff 100%);
    border-color: rgba(7, 193, 96, 0.14);
}

.checkin-info ul {
    list-style: none;
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.checkin-info li {
    position: relative;
    padding-left: 18px;
}

.checkin-info li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(7, 193, 96, 0.12);
}

.evaluation-info,
.ranking-period-info,
.period-display {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.disabled-notice {
    background: linear-gradient(180deg, #fff8f8 0%, #fffdfd 100%);
    border-color: rgba(227, 77, 89, 0.16);
}

.evaluation-form,
.teacher-add-form,
.class-management,
.class-teacher-management,
.password-management,
.deduction-control,
.import-content,
.import-section {
    display: grid;
    gap: 16px;
}

.evaluation-levels-homework,
.score-config-grid,
.rules-grid {
    display: grid;
    gap: 16px;
}

.score-config-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.rules-grid,
.evaluation-levels-homework {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.evaluation-level {
    padding: 18px;
}

.evaluation-form > .btn-primary,
#submitHomeworkBtn {
    margin-top: 2px;
}

.level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 15px;
    border-radius: var(--radius-md);
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    margin-bottom: 14px;
}

.level-header h3 {
    font-size: 15px;
    line-height: 1.4;
}

.level-count {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(7, 193, 96, 0.08);
    color: #167548;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.level-header.excellent,
.level-header.homework-excellent {
    border-left: 4px solid #07c160;
}

.level-header.good,
.level-header.homework-good {
    border-left: 4px solid #2ac06d;
}

.level-header.medium,
.level-header.homework-medium {
    border-left: 4px solid #90a4b8;
}

.level-header.qualified,
.level-header.homework-below {
    border-left: 4px solid #f4b400;
}

.level-header.below,
.level-header.homework-poor,
.level-header.poor {
    border-left: 4px solid #e67e22;
}

.teacher-select,
.class-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
}

.teacher-checkbox,
.class-checkbox-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.teacher-checkbox:hover,
.class-checkbox-item:hover {
    border-color: var(--accent-line);
    box-shadow: 0 8px 18px rgba(7, 193, 96, 0.08);
    transform: translateY(-1px);
}

.teacher-checkbox.selected {
    border-color: rgba(7, 193, 96, 0.28);
    background: #f1fcf5;
    color: #17693f;
    box-shadow: 0 10px 20px rgba(7, 193, 96, 0.09);
}

.teacher-checkbox.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.teacher-checkbox input,
.checkbox-group input,
.checkbox-label input,
.summer-toggle input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
    flex-shrink: 0;
}

.form-group,
.period-field,
.summer-toggle,
.class-input-wrapper,
.class-batch-import,
.deduction-history,
.export-template,
.password-management,
.class-list-container {
    margin-bottom: 0;
}

.teacher-add-form,
.password-management,
.class-batch-import,
.deduction-control {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(248, 251, 252, 0.96) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.form-group label,
.period-field label,
.period-control label,
.class-input-wrapper > label,
.checkbox-label,
.summer-toggle label {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.checkbox-group,
.checkbox-label,
.summer-toggle label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-label span,
.summer-toggle span {
    margin-bottom: 0;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="file"],
select,
textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input::placeholder,
textarea::placeholder {
    color: #9aa7b5;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(7, 193, 96, 0.32);
    box-shadow: 0 0 0 4px rgba(7, 193, 96, 0.12);
}

input[readonly] {
    background: #f5f7fa;
    color: var(--text-muted);
}

select option {
    color: var(--text);
}

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

input[type="file"] {
    padding: 10px 12px;
    background: #fbfcfe;
}

input[type="file"]::file-selector-button {
    margin-right: 14px;
    padding: 0 16px;
    min-height: 38px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: #ffffff;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

input[type="file"]::file-selector-button:hover {
    background: #f7fbf8;
    border-color: rgba(7, 193, 96, 0.22);
    transform: translateY(-1px);
}

#deductPoints.points-input {
    width: 120px;
}

.form-row,
.period-control-row,
.period-control,
.modal-actions,
.deduction-control .form-row,
.class-teacher-management .form-row,
.teacher-add-form .form-row,
.export-template,
.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.form-row > *,
.period-control > *,
.period-field {
    flex: 1 1 180px;
}

.period-control label {
    flex: 0 0 auto;
}

.checkbox-row {
    align-items: center;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-edit,
.btn-remove,
.btn-small,
.btn-delete,
.btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn-primary {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-press) 100%);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(7, 193, 96, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(7, 193, 96, 0.24);
}

.btn-secondary,
.btn-edit,
.btn-small,
.btn-logout {
    background: #ffffff;
    color: var(--text);
    border-color: var(--line-strong);
}

.btn-secondary:hover,
.btn-edit:hover,
.btn-small:hover,
.btn-logout:hover {
    background: #f7fbf8;
    border-color: rgba(7, 193, 96, 0.22);
    color: #17693f;
    transform: translateY(-1px);
}

.btn-danger,
.btn-delete,
.btn-remove {
    background: #fff6f7;
    color: var(--danger);
    border-color: rgba(227, 77, 89, 0.18);
}

.btn-danger:hover,
.btn-delete:hover,
.btn-remove:hover {
    background: #ffeeef;
    transform: translateY(-1px);
}

.btn-small {
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
}

#changePasswordBtn,
#logoutBtn {
    min-height: 42px;
}

.class-selector {
    min-width: 168px;
    background: #ffffff;
}

.teacher-list,
.class-list,
.deduction-list,
.class-teacher-list {
    display: grid;
    gap: 12px;
}

.teacher-item,
.class-item,
.class-teacher-item,
.deduction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
}

.teacher-item .info,
.class-item .info {
    min-width: 0;
}

.teacher-item .name {
    display: inline-block;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.teacher-item .meta {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.class-info,
.role-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid transparent;
}

.class-info {
    background: #f6f8fb;
    border-color: var(--line);
}

.role-badge.teacher {
    color: #45637f;
    background: #f4f7fa;
    border-color: #dfe6ee;
}

.role-badge.head-teacher {
    color: #157d4b;
    background: #edfbf2;
    border-color: rgba(7, 193, 96, 0.18);
}

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

.deduction-info {
    color: var(--text);
}

.class-info-display {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 16px;
}

.evaluation-history .level-item {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
}

.evaluation-history .level-item:last-child {
    border-bottom: none;
}

.level-name {
    color: var(--text);
    font-weight: 700;
}

.score-input-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
    margin-top: 0;
}

.score-input-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.score-input-item {
    display: grid;
    gap: 10px;
}

.score-input-item span {
    font-size: 15px;
    font-weight: 700;
    color: #5e6f81;
}

.score-input-item input[type="number"] {
    min-height: 56px;
    padding: 14px 18px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 18px;
}

.score-config-group {
    padding: 22px 22px 20px;
    display: grid;
    gap: 16px;
    align-content: start;
    background: linear-gradient(180deg, rgba(248, 251, 252, 0.98) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.score-config-group h4 {
    font-size: 20px;
    letter-spacing: -0.02em;
}

.score-config-group-bonus {
    grid-column: 1 / -1;
    background:
        radial-gradient(circle at right top, rgba(7, 193, 96, 0.12), transparent 30%),
        linear-gradient(180deg, rgba(244, 251, 247, 0.98) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.score-config-group-bonus .score-input-grid.compact {
    max-width: 760px;
}

.admin-actions-emphasis {
    justify-content: flex-end;
    padding-top: 18px;
    border-top: 1px solid rgba(212, 221, 231, 0.8);
}

.admin-actions-emphasis .btn-secondary {
    min-width: 168px;
}

.summer-toggle {
    padding: 18px;
}

.import-panel.active {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.9fr);
    gap: 20px;
    align-items: start;
}

.import-format-hint {
    margin-bottom: 0;
    padding: 24px 26px;
    background: linear-gradient(135deg, rgba(246, 250, 252, 0.98) 0%, rgba(255, 255, 255, 0.98) 100%);
    min-height: 100%;
}

.import-format-hint p + p {
    margin-top: 6px;
}

.import-upload-panel {
    display: grid;
    gap: 18px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(250, 252, 253, 0.98) 0%, rgba(255, 255, 255, 0.98) 100%);
    min-height: 100%;
}

.import-file-field {
    display: grid;
    gap: 10px;
}

.import-inline-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
}

.import-inline-actions .btn-primary,
.import-inline-actions .btn-secondary {
    width: 100%;
    min-height: 48px;
}

.result-list {
    display: grid;
    gap: 14px;
}

.password-management {
    overflow-x: auto;
}

.scores-table,
.history-table,
.password-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.scores-table th,
.scores-table td,
.history-table th,
.history-table td,
.password-table th,
.password-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #edf1f5;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

.scores-table thead,
.history-table thead,
.password-table thead {
    background: #f7faf8;
}

.scores-table th,
.history-table th,
.password-table th {
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
}

.scores-table tbody tr:hover,
.history-table tbody tr:hover,
.password-table tbody tr:hover {
    background: #fbfefd;
}

.scores-table tbody tr:last-child td,
.history-table tbody tr:last-child td,
.password-table tbody tr:last-child td {
    border-bottom: none;
}

.rank-1,
.rank-2,
.rank-3 {
    position: relative;
}

.rank-1 td:first-child,
.rank-2 td:first-child,
.rank-3 td:first-child {
    font-weight: 800;
}

.rank-1 {
    background: rgba(255, 246, 221, 0.72);
}

.rank-2 {
    background: rgba(243, 247, 250, 0.9);
}

.rank-3 {
    background: rgba(246, 240, 233, 0.9);
}

.password-cell {
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.ranking-table td strong {
    color: #0f6a3e;
}

.rule-card {
    padding: 18px;
}

.rule-card h4 {
    margin-bottom: 8px;
    font-size: 16px;
}

.rule-card p + p {
    margin-top: 4px;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(18, 33, 43, 0.36);
    backdrop-filter: blur(6px);
    z-index: 30;
}

.modal-content {
    width: min(100%, 520px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 24px 48px rgba(16, 24, 40, 0.18);
    padding: 26px;
}

.modal-content form {
    display: grid;
    gap: 16px;
}

.modal-content h3 {
    margin-bottom: 18px;
    font-size: 22px;
}

.modal-content .modal-actions {
    position: sticky;
    bottom: 0;
    padding-top: 16px;
    margin-top: 4px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #ffffff 28%, #ffffff 100%);
    border-top: 1px solid rgba(227, 232, 239, 0.92);
}

#editClassInputWrapper {
    display: grid;
    gap: 12px;
}

#editTeacherClassCheckboxes {
    max-height: min(42vh, 360px);
    overflow-y: auto;
    padding-right: 6px;
    align-content: start;
}

#editTeacherClassCheckboxes::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 8px;
}

#editTeacherClassCheckboxes::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.55);
    border-radius: 999px;
}

#editTeacherClassCheckboxes::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.9);
    border-radius: 999px;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    min-width: 240px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(31, 45, 61, 0.92);
    color: #ffffff;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.18);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 40;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: rgba(7, 193, 96, 0.94);
}

.toast.error {
    background: rgba(227, 77, 89, 0.94);
}

.toast.warning {
    background: rgba(222, 156, 0, 0.94);
}

[style*="color: #999"] {
    color: var(--text-muted) !important;
}

[style*="color: #28a745"] {
    color: #159457 !important;
}

[style*="color: #dc3545"] {
    color: var(--danger) !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1180px) {
    .workspace-shell {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .rules-grid,
    .evaluation-levels-homework {
        grid-template-columns: 1fr;
    }

    .score-config-grid,
    .import-panel.active {
        grid-template-columns: 1fr;
    }

    .score-config-group-bonus {
        grid-column: auto;
    }
}

@media (max-width: 960px) {
    body {
        padding: 18px;
    }

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

    .workspace-sidebar {
        padding: 18px 18px 14px;
        border-right: none;
        border-bottom: 1px solid var(--line);
        max-height: none;
        overflow-y: visible;
    }

    .tabs {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 6px;
    }

    .tab-btn {
        width: auto;
        min-width: 132px;
        white-space: nowrap;
        text-align: center;
    }

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

    .header-top {
        flex-direction: column;
    }

    .header-right {
        justify-content: flex-start;
    }
}

@media (max-width: 760px) {
    body {
        padding: 12px;
    }

    .login-page {
        min-height: calc(100vh - 24px);
    }

    .login-box,
    .modal-content {
        padding: 24px 20px;
        border-radius: 22px;
    }

    .modal {
        align-items: flex-start;
        padding: 12px;
    }

    .modal-content {
        width: 100%;
        max-height: calc(100vh - 24px);
        margin: auto;
    }

    header {
        padding: 22px 18px 18px;
    }

    .app-main {
        padding: 18px;
    }

    .checkin-info,
    .evaluation-info,
    .disabled-notice,
    .evaluation-history,
    .headteacher-result,
    .admin-section,
    .score-rules,
    .ranking-period-info,
    .import-result,
    .import-format-hint,
    .period-display,
    .evaluation-section {
        padding: 18px;
    }

    .admin-section,
    .score-config-group,
    .import-format-hint,
    .import-upload-panel,
    .teacher-add-form,
    .password-management,
    .class-batch-import,
    .deduction-control {
        padding: 18px;
    }

    .teacher-select,
    .class-checkboxes {
        grid-template-columns: 1fr;
    }

    .score-input-grid,
    .score-input-grid.compact,
    .import-inline-actions {
        grid-template-columns: 1fr;
    }

    #editTeacherClassCheckboxes {
        max-height: min(46vh, 420px);
    }

    .form-row,
    .period-control-row,
    .period-control,
    .modal-actions,
    .deduction-control .form-row,
    .class-teacher-management .form-row,
    .teacher-add-form .form-row,
    .export-template,
    .admin-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .form-row > *,
    .period-control > *,
    .period-field {
        width: 100%;
        flex: 1 1 auto;
    }

    #welcomeUser,
    .class-selector,
    #changePasswordBtn,
    #logoutBtn {
        width: 100%;
    }

    .teacher-item,
    .class-item,
    .class-teacher-item,
    .deduction-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .actions {
        width: 100%;
    }

    .scores-table,
    .history-table,
    .password-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        max-width: none;
    }
}

@media (max-width: 560px) {
    .login-eyebrow,
    .brand-chip,
    .current-time {
        letter-spacing: 0.1em;
    }

    .tab-content > h2 {
        font-size: 24px;
    }

    .sidebar-head h2 {
        font-size: 22px;
    }

    .tab-btn {
        min-width: 124px;
    }
}
