/* ---------- 校园查询界面视觉系统 ---------- */
:root {
    --ink: #18233f;
    --muted: #66708a;
    --paper: #fffdf7;
    --paper-2: #f6f1e5;
    --blue: #274b8f;
    --blue-2: #3f6db7;
    --sky: #dfeafe;
    --green: #237a57;
    --red: #c84040;
    --amber: #b66a1d;
    --line: rgba(39, 75, 143, 0.16);
    --shadow: 0 24px 70px rgba(24, 35, 63, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Inter", "LXGW WenKai", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 18% 12%, rgba(63, 109, 183, 0.20), transparent 30%),
        radial-gradient(circle at 88% 8%, rgba(35, 122, 87, 0.14), transparent 28%),
        linear-gradient(135deg, #eef4ff 0%, #f8f3e8 48%, #e8f0fb 100%);
    padding: 28px 18px;
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(39, 75, 143, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(39, 75, 143, 0.045) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(to bottom, black, transparent 88%);
}

.panel,
#loginSection,
#passwordSection,
#resetPasswordSection,
.result-panel {
    position: relative;
    max-width: 440px;
    width: 100%;
    padding: 30px 26px;
    border-radius: 26px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255,253,247,0.90)),
        var(--paper);
    backdrop-filter: blur(18px);
    user-select: none;
    animation: panelIn 0.38s ease both;
}

.panel::after,
#loginSection::after,
#passwordSection::after,
#resetPasswordSection::after,
.result-panel::after {
    content: "";
    position: absolute;
    left: 26px;
    right: 26px;
    top: 0;
    height: 5px;
    border-radius: 999px;
    background: repeating-linear-gradient(90deg, var(--blue) 0 28px, transparent 28px 38px, var(--green) 38px 56px, transparent 56px 66px);
    opacity: 0.9;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    letter-spacing: 0.22em;
    font-size: 11px;
    font-weight: 800;
    color: var(--green);
    border: 1px solid rgba(35, 122, 87, 0.22);
    background: rgba(35, 122, 87, 0.08);
    padding: 5px 9px;
    border-radius: 999px;
    margin-bottom: 12px;
}

#loginSection h2,
#passwordSection h2,
#resetPasswordSection h2,
#resultSection h2 {
    color: var(--ink);
    font-weight: 850;
    font-size: clamp(25px, 4vw, 34px);
    line-height: 1.12;
    letter-spacing: -0.04em;
    margin: 0 0 10px;
    text-align: left;
}

.section-subtitle {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
    margin: 0 0 18px;
}

#loginSection input,
#passwordSection input,
#resetPasswordSection input {
    width: 100%;
    padding: 14px 15px;
    margin: 8px 0 12px;
    font-size: 16px;
    border-radius: 16px;
    border: 1.5px solid rgba(39, 75, 143, 0.20);
    background: rgba(255, 255, 255, 0.78);
    color: var(--ink);
    transition: border-color 0.22s, box-shadow 0.22s, transform 0.22s;
}

#loginSection input:focus,
#passwordSection input:focus,
#resetPasswordSection input:focus,
#filterTerm:focus,
#filterWeek:focus {
    border-color: var(--blue-2);
    outline: none;
    box-shadow: 0 0 0 4px rgba(63, 109, 183, 0.14);
    transform: translateY(-1px);
}

#passwordSection input:read-only {
    background-color: #f4f4f0;
    color: var(--muted);
    cursor: not-allowed;
}

.btnGroup {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

button {
    font: inherit;
}

#loginSection button,
#passwordSection button,
#resetPasswordSection button,
#exportBtn,
#logoutBtn {
    border: none;
    cursor: pointer;
    user-select: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

#loginSection button,
#passwordSection button,
#resetPasswordSection button {
    flex: 1;
    min-height: 50px;
    padding: 13px 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--blue), var(--blue-2));
    color: white;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 12px 24px rgba(39, 75, 143, 0.22);
}

#loginSection button:hover:not(:disabled),
#passwordSection button:hover:not(:disabled),
#resetPasswordSection button:hover:not(:disabled),
#exportBtn:hover,
#logoutBtn:hover {
    transform: translateY(-2px);
}

#loginSection button:disabled,
#passwordSection button:disabled,
#resetPasswordSection button:disabled {
    opacity: 0.68;
    cursor: wait;
    transform: none;
}

.spinner {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.45);
    border-top-color: #fff;
    display: inline-block;
    vertical-align: -2px;
    margin-right: 8px;
    animation: spin 0.8s linear infinite;
}

#loginMsg,
#passwordMsg,
#resetPasswordMsg {
    min-height: 28px;
    margin: 10px 0 0;
    font-weight: 700;
    text-align: left;
    line-height: 1.55;
}

.message-error { color: var(--red); }
.message-success { color: var(--green); }
.message-loading::before {
    content: "";
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
    margin-right: 8px;
    background: currentColor;
    animation: pulse 1s ease-in-out infinite;
}

#noticeToggle,
#passwordNoticeToggle,
#resetPasswordNoticeToggle {
    cursor: pointer;
    color: var(--blue);
    font-weight: 800;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

#noticeContent,
#passwordNoticeContent,
#resetPasswordNoticeContent {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.3s ease;
    background: rgba(223, 234, 254, 0.58);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 0 14px;
    margin-top: 8px;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
}

#noticeContent.open,
#passwordNoticeContent.open,
#resetPasswordNoticeContent.open {
    max-height: 240px;
    padding: 13px 15px;
}

#noticeContent ul,
#passwordNoticeContent ul,
#resetPasswordNoticeContent ul {
    margin: 0;
    padding-left: 18px;
}

#noticeContent li,
#passwordNoticeContent li,
#resetPasswordNoticeContent li {
    margin-bottom: 8px;
}

.change-pwd-link {
    text-align: right;
    margin-top: 4px;
}

.change-pwd-link a {
    color: var(--blue);
    text-decoration: none;
    font-size: 14px;
    font-weight: 800;
}

.change-pwd-link a:hover {
    text-decoration: underline;
}

.password-checklist {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: -2px 0 12px;
}

.password-checklist span,
.password-match-hint {
    border: 1px solid rgba(102, 112, 138, 0.20);
    color: var(--muted);
    background: rgba(255,255,255,0.58);
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 750;
}

.password-checklist span::before {
    content: "○ ";
}

.password-checklist span.is-met {
    border-color: rgba(35, 122, 87, 0.25);
    color: var(--green);
    background: rgba(35, 122, 87, 0.08);
}

.password-checklist span.is-met::before {
    content: "✓ ";
}

.password-match-hint {
    display: inline-block;
    margin: -4px 0 10px;
}

.password-match-hint:empty {
    display: none;
}

.password-match-hint.is-met {
    color: var(--green);
    border-color: rgba(35, 122, 87, 0.25);
    background: rgba(35, 122, 87, 0.08);
}

.password-match-hint.is-error {
    color: var(--red);
    border-color: rgba(200, 64, 64, 0.22);
    background: rgba(200, 64, 64, 0.08);
}

#resultSection {
    width: 100%;
    max-width: 1040px;
    padding: 28px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 12px;
}

.result-header .section-subtitle {
    max-width: 340px;
    margin-top: 22px;
    text-align: right;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 16px 0 18px;
}

.stat-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(246,241,229,0.72));
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 10px 14px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.stat-card strong {
    display: block;
    margin-top: 2px;
    color: var(--ink);
    font-size: 24px;
    letter-spacing: -0.04em;
}

.term-info,
.empty-state {
    background: rgba(223, 234, 254, 0.62);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 12px 16px;
    margin-bottom: 14px;
    color: var(--blue);
    font-size: 14px;
    font-weight: 800;
    text-align: center;
}

.term-info {
    display: none;
    padding: 6px 12px !important;
    font-size: 13px !important;
    border-radius: 10px !important;
    margin-bottom: 0 !important;
    white-space: nowrap;
    background: rgba(223, 234, 254, 0.62);
    border: 1px solid var(--line);
    color: var(--blue);
    font-weight: 800;
}

.empty-state {
    color: var(--muted);
    background: rgba(255,255,255,0.64);
    padding: 30px 18px;
}

.mobile-grades-list {
    display: none;
}

#toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

#filterGroup,
#weekFilterGroup {
    display: flex;
    align-items: center;
    gap: 6px;
}

#filterGroup label,
#weekFilterGroup label {
    white-space: nowrap;
    font-size: 13px;
}

#filterTerm,
#filterWeek {
    width: 150px;
    padding: 7px 10px;
    font-size: 14px;
    border-radius: 10px;
    border: 1.4px solid var(--line);
    background: rgba(255,255,255,0.78);
    color: var(--ink);
    cursor: pointer;
}

#exportBtn,
#logoutBtn {
    border-radius: 14px;
    padding: 10px 16px;
    font-weight: 850;
    font-size: 14px;
}

#exportBtn {
    background: var(--blue);
    color: white;
    box-shadow: 0 10px 20px rgba(39, 75, 143, 0.18);
}

#logoutBtn {
    background: rgba(24, 35, 63, 0.08);
    color: var(--muted);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.70);
}

#note {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
    margin: 12px 4px 0;
    text-align: left;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    table-layout: fixed;
}

thead tr {
    background: linear-gradient(90deg, var(--blue), #1d386d);
    color: #fff;
    font-weight: 850;
}

th,
td {
    border: none;
    border-bottom: 1px solid rgba(39, 75, 143, 0.13);
    border-right: 1px solid rgba(39, 75, 143, 0.09);
    padding: 12px 10px;
    text-align: center;
    vertical-align: middle;
    white-space: normal;
    word-break: break-word;
}

tbody tr:nth-child(even) td {
    background-color: rgba(246, 241, 229, 0.34);
}

tbody tr:hover td {
    background-color: rgba(223, 234, 254, 0.62);
}

.score-pill {
    display: inline-flex;
    min-width: 48px;
    justify-content: center;
    border-radius: 999px;
    padding: 5px 10px;
    background: rgba(39, 75, 143, 0.08);
    color: var(--blue);
    font-weight: 850;
}

.score-pill.score-excellent {
    color: var(--green);
    background: rgba(35, 122, 87, 0.10);
}

.score-pill.score-danger {
    color: var(--red);
    background: rgba(200, 64, 64, 0.10);
}

.schedule-cell {
    text-align: left !important;
    vertical-align: top !important;
    padding: 9px !important;
}

.course-item {
    position: relative;
    margin-bottom: 8px;
    padding: 10px 10px 10px 12px;
    border-radius: 15px;
    background: linear-gradient(135deg, rgba(39, 75, 143, 0.10), rgba(35, 122, 87, 0.07));
    border: 1px solid rgba(39, 75, 143, 0.13);
}

.course-item:last-child {
    margin-bottom: 0;
}

.course-name {
    font-weight: 900;
    color: var(--ink);
    font-size: 13px;
    margin-bottom: 5px;
}

.course-detail {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.45;
}

.free-slot {
    color: rgba(102,112,138,0.42);
    font-size: 12px;
}

.today-col {
    background-color: rgba(35, 122, 87, 0.08) !important;
}

thead .today-col {
    background: linear-gradient(135deg, var(--green), #1c6248) !important;
}

tbody tr.hover-highlight td,
tbody td.hover-highlight-col {
    background-color: rgba(63, 109, 183, 0.12) !important;
}

tbody tr td {
    transition: background-color 0.25s ease;
}

.success-dialog {
    position: fixed;
    inset: 0;
    background: rgba(24, 35, 63, 0.36);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.25s ease;
    padding: 18px;
}

.success-dialog-content {
    background: var(--paper);
    padding: 28px 30px;
    border-radius: 24px;
    box-shadow: var(--shadow);
    text-align: center;
    min-width: 300px;
    max-width: 420px;
    animation: panelIn 0.28s ease;
    border: 1px solid rgba(255, 255, 255, 0.78);
}

.success-message {
    color: var(--green);
    font-size: 23px;
    font-weight: 900;
    margin: 0 0 14px;
}

.countdown-message {
    color: var(--muted);
    font-size: 16px;
    margin: 0;
    line-height: 1.7;
}

.countdown-message span {
    color: var(--blue);
    font-weight: 900;
    font-size: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.35; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes panelIn {
    from { transform: translateY(16px) scale(0.985); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.export-sheet {
    position: fixed;
    left: -99999px;
    top: 0;
    width: 1120px;
    min-height: 640px;
    padding: 34px;
    background: var(--paper);
    color: var(--ink);
    border-radius: 0;
    font-family: "Inter", "Microsoft YaHei", Arial, sans-serif;
    overflow: visible;
}

.export-sheet-schedule {
    width: 1380px;
}

.export-watermark {
    position: absolute;
    right: 42px;
    bottom: 70px;
    font-size: 54px;
    font-weight: 900;
    color: rgba(39, 75, 143, 0.055);
    letter-spacing: -0.04em;
    pointer-events: none;
}

.export-watermark-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    user-select: none;
    max-height: 60%;
    object-fit: contain;
}

.export-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    border-bottom: 3px solid var(--blue);
    padding-bottom: 18px;
    margin-bottom: 18px;
}

.export-brand {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(35, 122, 87, 0.10);
    color: var(--green);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.22em;
    margin-bottom: 10px;
}

.export-header h1 {
    margin: 0;
    color: var(--ink);
    font-size: 38px;
    letter-spacing: -0.04em;
}

.export-header p {
    margin: 8px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.export-site {
    text-align: right;
    color: var(--muted);
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.export-site strong {
    color: var(--blue);
    font-size: 18px;
}

.export-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}

.export-stats div {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.70);
}

.export-stats span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.export-stats strong {
    display: block;
    margin-top: 4px;
    font-size: 24px;
    color: var(--ink);
}

.export-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: white;
    border: 1px solid rgba(39, 75, 143, 0.18);
}

.export-table th,
.export-table td {
    border: 1px solid rgba(39, 75, 143, 0.16);
    padding: 10px 9px;
    text-align: center;
    color: var(--ink);
}

.export-table thead th {
    background: var(--blue);
    color: white;
    font-weight: 900;
}

.export-table tbody tr:nth-child(even) td,
.export-table tbody tr:nth-child(even) th {
    background: rgba(246, 241, 229, 0.45);
}

.export-schedule-table {
    font-size: 12px;
}

.export-schedule-table td {
    vertical-align: top;
    text-align: left;
}

.export-course {
    display: grid;
    gap: 3px;
    padding: 7px;
    border-radius: 10px;
    background: rgba(39, 75, 143, 0.08);
    margin-bottom: 6px;
}

.export-course strong {
    color: var(--ink);
    font-size: 12px;
}

.export-course span,
.export-empty {
    color: var(--muted);
    font-size: 10px;
}

.export-footer {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(39, 75, 143, 0.18);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
}

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

@media (max-width: 720px) {
    body {
        padding: 14px 10px;
        align-items: stretch;
    }

    .panel,
    #loginSection,
    #passwordSection,
    #resetPasswordSection,
    #resultSection {
        max-width: 100%;
        padding: 22px 18px;
        border-radius: 22px;
    }

    .btnGroup,
    #toolbar,
    .result-header {
        flex-direction: column;
        align-items: stretch;
    }

    .result-header .section-subtitle {
        margin-top: 0;
        text-align: left;
        max-width: none;
    }

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

    #filterGroup {
        align-items: stretch;
        flex-direction: column;
    }

    #filterTerm,
    #exportBtn,
    #logoutBtn {
        width: 100%;
    }
}

@media (max-width: 520px) {
    #resultSection h2,
    #loginSection h2,
    #passwordSection h2,
    #resetPasswordSection h2 {
        font-size: 27px;
    }

    #resultTable.mode-grades {
        display: none !important;
    }

    .table-wrapper.mode-grades-wrapper {
        display: none;
    }

    .mobile-grades-list {
        display: block;
    }

    .mobile-term-group {
        border: 1px solid var(--line);
        border-radius: 18px;
        background: rgba(255,255,255,0.70);
        overflow: hidden;
        margin-bottom: 10px;
    }

    .mobile-term-header {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 12px 14px;
        border: none;
        background: rgba(223, 234, 254, 0.62);
        color: var(--ink);
        text-align: left;
        cursor: pointer;
    }

    .mobile-term-header span {
        font-size: 15px;
        font-weight: 900;
    }

    .mobile-term-header em {
        color: var(--muted);
        font-size: 12px;
        font-style: normal;
        font-weight: 800;
        white-space: nowrap;
    }

    .mobile-term-body {
        padding: 8px;
    }

    .mobile-term-group.single-term {
        border: none;
        background: transparent;
        margin-bottom: 0;
    }

    .mobile-term-group.single-term .mobile-term-body {
        padding: 0;
    }

    .mobile-term-group.is-collapsed .mobile-term-body {
        display: none;
    }

    .mobile-grade-card {
        padding: 10px 10px 9px;
        border-radius: 14px;
        background: rgba(255,253,247,0.86);
        border: 1px solid rgba(39, 75, 143, 0.10);
        margin-bottom: 8px;
    }

    .mobile-grade-card:last-child {
        margin-bottom: 0;
    }

    .mobile-grade-main {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
    }

    .mobile-grade-main h3 {
        margin: 0;
        color: var(--ink);
        font-size: 15px;
        line-height: 1.35;
        font-weight: 850;
    }

    .mobile-grade-main .score-pill {
        flex: 0 0 auto;
        min-width: 48px;
        padding: 5px 9px;
    }

    .mobile-grade-meta {
        display: flex;
        gap: 8px;
        margin-top: 7px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
    }

    table {
        table-layout: auto;
    }

    th,
    td {
        min-width: 96px;
    }

    .course-name { font-size: 12px; }
    .course-detail { font-size: 10px; }
}
