/* ========================================
   Modern Clean Theme
   ======================================== */

:root {
    --primary: #10A37F;
    --primary-light: #14B88F;
    --primary-dark: #0B7A5F;
    --primary-bg: rgba(16, 163, 127, 0.08);

    --accent: #0F766E;
    --accent-light: #14B8A6;
    --accent-muted: #CCFBF1;
    --accent-bg: rgba(15, 118, 110, 0.08);

    --neutral-50: #FCFDFE;
    --neutral-100: #F8FAFC;
    --neutral-200: #EEF2F6;
    --neutral-300: #DCE3EA;
    --neutral-400: #B6C0CC;
    --neutral-500: #7A8797;
    --neutral-600: #556171;
    --neutral-700: #334155;
    --neutral-800: #0F172A;

    --success: #15803D;
    --success-light: #16A34A;
    --success-bg: rgba(21, 128, 61, 0.1);

    --info: #2563EB;
    --info-light: #3B82F6;
    --info-bg: rgba(37, 99, 235, 0.1);

    --warning: #D97706;
    --warning-light: #F59E0B;
    --warning-bg: rgba(217, 119, 6, 0.12);

    --bg-body: radial-gradient(circle at top, #FFFFFF 0%, #F6F8FA 42%, #EEF2F6 100%);
    --bg-card: #FFFFFF;
    --bg-card-hover: #FFFFFF;
    --bg-section: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --text-inverse: #FFFFFF;

    --border-light: rgba(15, 23, 42, 0.08);
    --border-medium: rgba(15, 23, 42, 0.14);
    --border-accent: rgba(16, 163, 127, 0.18);

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.08);
    --shadow-xl: 0 24px 64px rgba(15, 23, 42, 0.1);

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --grade-1: #15803D;
    --grade-2: #0F766E;
    --grade-3: #0369A1;
    --grade-4: #D97706;
    --grade-5: #7A8797;
}

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

body {
    font-family: 'Pretendard Variable', 'Pretendard', 'SUIT Variable', 'Noto Sans KR', sans-serif;
    background: var(--bg-body);
    min-height: 100vh;
    padding: 18px;
    position: relative;
    overflow-x: hidden;
    color: var(--text-primary);
}

.container {
    max-width: 1320px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-light);
}

header {
    background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
    color: var(--text-primary);
    padding: 28px 36px 24px;
    text-align: left;
    border-bottom: 1px solid var(--neutral-200);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 6px;
    font-weight: 600;
    letter-spacing: -0.04em;
    position: relative;
}

.header-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 720px;
    line-height: 1.6;
}

.badge-lite {
    display: inline-block;
    margin-left: 10px;
    padding: 4px 10px;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--neutral-100);
    border: 1px solid var(--neutral-300);
    border-radius: 999px;
    letter-spacing: 0.08em;
    vertical-align: middle;
    text-transform: uppercase;
}

.upload-section {
    padding: 32px 36px;
    text-align: center;
    border-bottom: 1px solid var(--neutral-200);
    position: relative;
    background: linear-gradient(180deg, var(--neutral-50) 0%, var(--bg-card) 100%);
}

.container.post-analysis > header,
.container.post-analysis .upload-guide,
.container.post-analysis .section-divider,
.container.post-analysis .file-input-wrapper,
.container.post-analysis #fileList,
.container.post-analysis #analyzeBtn {
    display: none !important;
}

.file-input-wrapper {
    margin-bottom: 30px;
}

.file-input-wrapper input[type="file"] {
    display: none;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(100%, 720px);
    min-height: 88px;
    margin: 0 auto;
    padding: 18px 28px;
    background: var(--bg-card);
    border: 1.5px dashed var(--neutral-300);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.upload-hint {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.file-input-label:hover {
    background: var(--neutral-50);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.file-input-label.dragover {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-bg) inset;
}

/* 업로드 섹션 전체 드래그오버 강조 및 오버레이 안내 */
.upload-section.dragover {
    border: 1.5px dashed var(--primary);
    border-radius: var(--radius-lg);
    background: var(--primary-bg);
}
.upload-section.dragover::after {
    content: '여기에 파일을 드롭하세요';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary);
    font-weight: 600;
    font-size: 1rem;
    padding: 12px 18px;
    background: var(--bg-card);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-sm);
    pointer-events: none;
    box-shadow: var(--shadow-lg);
}

.analyze-btn {
    background: var(--primary);
    color: var(--text-inverse);
    border: 1px solid transparent;
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: none;
}

.analyze-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--primary-dark);
}

.analyze-btn:active:not(:disabled) {
    transform: translateY(0);
}

.analyze-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--neutral-400);
    box-shadow: none;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.secondary-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--neutral-300);
}

.secondary-btn:hover:not(:disabled) {
    background: var(--neutral-100);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.export-btn {
    background: var(--bg-card);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 13px 32px;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.export-btn:hover:not(:disabled) {
    background: var(--primary);
    color: var(--text-inverse);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.export-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upload-guide {
    background: var(--bg-card);
    border: 1px solid var(--neutral-200);
    padding: 22px 24px;
    margin: 0 auto 18px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    max-width: 920px;
    text-align: left;
}

.upload-guide p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.guide-title {
    color: var(--text-primary);
    margin-bottom: 8px !important;
    font-size: 1rem;
    font-weight: 700;
}

.upload-guide strong {
    color: var(--text-primary);
}

.section-divider {
    height: 1px;
    background: linear-gradient(90deg, rgba(0,0,0,0.06), rgba(0,0,0,0.12), rgba(0,0,0,0.06));
    margin: 16px 0 22px 0;
    border: none;
}

.warning-text {
    color: var(--warning);
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: 10px;
    text-align: left;
    padding: 8px 12px;
    background-color: var(--warning-bg);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--warning);
}

/* 강조 색상: XLS vs XLS data 구분 표시 */
.warning-text .xls {
    color: var(--warning);
    background: rgba(217, 119, 6, 0.12);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 800;
}
.warning-text .xlsdata {
    color: var(--success);
    background: var(--success-bg);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 800;
}

.privacy-notice {
    margin-top: 10px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--neutral-100);
    border: 1px solid var(--neutral-200);
    color: var(--text-secondary);
}
.privacy-notice p {
    margin: 0 0 8px 0;
    font-weight: 600;
    color: var(--text-primary);
}
.privacy-notice ul {
    margin: 0;
    padding-left: 18px;
    list-style: disc;
    color: var(--text-secondary);
}
.privacy-notice li {
    margin: 3px 0;
    line-height: 1.5;
}
.privacy-notice .privacy-footnote {
    color: var(--text-muted);
    opacity: 1;
    margin-top: 8px;
}

.results-section {
    padding: 28px 36px 36px;
}

/* 하단 크레딧 푸터 */
.app-footer {
    padding: 16px 36px 24px 36px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    border-top: 1px solid var(--neutral-200);
}
.app-footer .footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.app-footer .credits {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: none;
    padding: 0;
    border-radius: 0;
}
.app-footer .credits a:not(.help-btn) {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dashed var(--neutral-400);
}
.app-footer .credits a:not(.help-btn):hover {
    color: var(--text-primary);
    border-bottom-color: var(--neutral-500);
}

/* last updated 표시 */
.app-footer .updated {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 8px;
}

/* 도움말 버튼 */
.help-btn {
    display: inline-block;
    padding: 8px 14px;
    font-size: 0.85rem;
    line-height: 1;
    border-radius: 999px;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--neutral-300);
    text-decoration: none;
    transition: all 0.2s ease;
}
.help-btn:hover {
    color: var(--primary-dark);
    background: var(--neutral-100);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.tabs {
    display: inline-flex;
    gap: 6px;
    padding: 6px;
    background: var(--neutral-100);
    border: 1px solid var(--neutral-200);
    border-radius: 16px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: none;
    min-width: 128px;
    padding: 12px 18px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.25s ease;
    border-radius: 12px;
    position: relative;
}

.tab-btn.active {
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-content h2 {
    color: var(--text-primary);
    margin-bottom: 22px;
    font-size: 1.45rem;
    font-weight: 600;
}


.subject-averages {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.subject-item {
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--neutral-50) 100%);
    border-radius: var(--radius-lg);
    padding: 22px;
    border: 1px solid var(--neutral-200);
    transition: all 0.25s ease;
    box-shadow: none;
}

.subject-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.subject-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.subject-header h3 {
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 600;
}

.credits {
    background: var(--neutral-100);
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 15px;
    border: 1px solid var(--neutral-200);
    font-size: 0.8rem;
    font-weight: 500;
}

.average-score {
    text-align: center;
}

.average-score .score {
    display: block;
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.average-score .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.achievement-bars {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--neutral-200);
}

.achievement-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.achievement-label {
    width: 25px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: center;
}

.achievement-bar-container {
    flex: 1;
    height: 20px;
    background: var(--neutral-200);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.achievement-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s ease;
    min-width: 2px;
}

.achievement-bar:nth-child(1) .achievement-bar-fill { background: linear-gradient(135deg, var(--success), var(--success-light)); }
.achievement-bar:nth-child(2) .achievement-bar-fill { background: linear-gradient(135deg, var(--info), var(--info-light)); }
.achievement-bar:nth-child(3) .achievement-bar-fill { background: linear-gradient(135deg, var(--accent), var(--accent-light)); }
.achievement-bar:nth-child(4) .achievement-bar-fill { background: linear-gradient(135deg, var(--warning), var(--primary-light)); }
.achievement-bar:nth-child(5) .achievement-bar-fill { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }

.achievement-percentage {
    width: 50px;
    text-align: right;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.achievement-distribution {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.distribution-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 25px;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s ease;
}

.distribution-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.distribution-item h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: 500;
}

.distribution-bars {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.grade-bar {
    display: flex;
    align-items: center;
    gap: 15px;
}

.grade-label {
    width: 30px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.bar-container {
    flex: 1;
    height: 25px;
    background: var(--neutral-200);
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.bar {
    height: 100%;
    background: linear-gradient(135deg, var(--info) 0%, var(--info-light) 100%);
    border-radius: 15px;
    transition: width 0.8s ease;
    min-width: 2px;
}

.percentage {
    width: 60px;
    text-align: right;
    font-weight: 500;
    color: var(--text-primary);
}

.student-analysis {
    width: 100%;
}

.search-box {
    margin-bottom: 25px;
}

.search-box input {
    width: 100%;
    max-width: 400px;
    padding: 14px 18px;
    border: 1px solid var(--neutral-300);
    border-radius: 14px;
    font-size: 1rem;
    outline: none;
    transition: all 0.25s ease;
    background: var(--bg-card);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.student-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: none;
    border: 1px solid var(--neutral-200);
    transition: all 0.25s ease;
    overflow: hidden;
}

.student-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.student-card-header {
    background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
    color: var(--text-primary);
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--neutral-200);
}

.student-basic-info h4 {
    margin: 0 0 5px 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.student-number {
    font-size: 0.88rem;
    color: var(--text-secondary);
    opacity: 1;
}

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

.summary-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.summary-metric-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--neutral-100);
    border: 1px solid var(--neutral-200);
    padding: 6px 10px;
    border-radius: 6px;
    min-width: fit-content;
}

.summary-metric-inline .metric-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.summary-metric-inline .metric-value {
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    color: var(--text-primary);
}

.summary-metric {
    text-align: center;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 12px;
    border-radius: 8px;
    min-width: 70px;
}

.summary-metric .metric-label {
    display: block;
    font-size: 0.7rem;
    opacity: 0.8;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-metric .metric-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
}

.student-subjects {
    padding: 15px 20px;
    max-height: none;
    overflow: visible;
}

.subject-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--neutral-200);
}

.subject-row:last-child {
    border-bottom: none;
}

.subject-row.no-grade {
    opacity: 0.7;
}

.subject-name {
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    font-size: 0.9rem;
}

.subject-data {
    display: flex;
    gap: 8px;
    align-items: center;
}

.subject-score {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.85rem;
    min-width: 45px;
    text-align: right;
}

.subject-achievement {
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 3px;
    min-width: 20px;
    text-align: center;
}

.subject-grade {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8rem;
    min-width: 35px;
    text-align: center;
}

.subject-percentile {
    font-weight: 500;
    color: var(--success);
    font-size: 0.8rem;
    min-width: 40px;
    text-align: right;
}

.student-card-footer {
    background: var(--bg-card);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--neutral-200);
}

.grade-subjects-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.view-detail-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--neutral-300);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
    font-weight: 500;
}

.view-detail-btn:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
    color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

.achievement.A {
    background: var(--success);
    color: var(--text-inverse);
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}

.achievement.B {
    background: var(--info);
    color: var(--text-inverse);
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}

.achievement.C {
    background: var(--accent);
    color: var(--text-inverse);
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}

.achievement.D {
    background: var(--warning);
    color: var(--text-inverse);
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}

.achievement.E, .achievement.미도달 {
    background: var(--primary);
    color: var(--text-inverse);
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}

.score {
    font-weight: 600;
    color: var(--text-primary);
}

.grade {
    text-align: center;
    font-weight: 500;
}

.rank {
    text-align: center;
    font-weight: 500;
    color: var(--text-secondary);
}

.avg-grade {
    text-align: center;
    font-weight: 600;
    color: var(--primary);
    font-size: 1.1rem;
}

.grade-analysis-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 20px;
    margin-bottom: 30px;
}

.chart-section {
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--neutral-50) 100%);
    border-radius: var(--radius-lg);
    padding: 22px;
    text-align: center;
    border: 1px solid var(--neutral-200);
}

.chart-section h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: 500;
}

.chart-section canvas {
    max-width: 100%;
    height: 350px !important;
}

.stats-section {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--neutral-50) 100%);
    border-radius: var(--radius-lg);
    padding: 22px;
    border: 1px solid var(--neutral-200);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: none;
    border: 1px solid var(--neutral-200);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.stat-value {
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 600;
}

@media (max-width: 768px) {
    .grade-analysis-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .stats-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .chart-section {
        padding: 15px;
    }
    
    .stat-item {
        padding: 15px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-secondary);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--neutral-200);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.error-message {
    background: var(--warning-bg);
    color: var(--warning);
    padding: 20px;
    margin: 20px 40px;
    border-radius: var(--radius-md);
    border-left: 5px solid var(--warning);
    font-size: 1rem;
}

.file-list {
    background: var(--neutral-100);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 20px 0;
    border: 1px solid var(--neutral-200);
}

.file-list h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.file-list ul {
    list-style: none;
    padding: 0;
}

.file-list li {
    background: var(--bg-card);
    padding: 10px 15px;
    margin: 8px 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--neutral-200);
    box-shadow: none;
}

.file-selector-section {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid var(--neutral-200);
}

.file-selector-section label {
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
}

.file-select {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid var(--neutral-300);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg-card);
    outline: none;
    transition: all 0.25s ease;
}

.file-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.comparison-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

.comparison-section {
    background: var(--neutral-100);
    border-radius: var(--radius-lg);
    padding: 25px;
    border: 1px solid var(--border-light);
}

.comparison-section h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: 500;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.comparison-table th,
.comparison-table td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid var(--neutral-200);
}

.comparison-table th {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-inverse);
    font-weight: 500;
    font-size: 0.9rem;
}

.comparison-table tr:nth-child(even) {
    background: var(--neutral-100);
}

.comparison-table tr:hover {
    background: var(--primary-bg);
}

@media (max-width: 768px) {
    .file-selector-section {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .file-select {
        width: 100%;
    }
    
    .comparison-table {
        font-size: 0.8rem;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 8px 6px;
    }
}

/* 학생 선택 및 상세 분석 스타일 */
.student-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    flex-wrap: wrap;
    border: 1px solid var(--neutral-200);
    box-shadow: var(--shadow-sm);
}

.selector-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selector-group label {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.selector {
    padding: 10px 12px;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-card);
    min-width: 120px;
    transition: all 0.25s ease;
}

.selector:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.detail-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--neutral-300);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.detail-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.detail-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.view-toggle {
    display: flex;
    background: var(--neutral-100);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
    width: fit-content;
    border: 1px solid var(--neutral-200);
}

.toggle-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.25s ease;
    font-weight: 500;
    color: var(--text-secondary);
}

.toggle-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* 학생 상세 분석 스타일 */
.student-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--neutral-100) 100%);
    color: var(--text-primary);
    padding: 22px 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
}

.student-info h3 {
    font-size: 1.5rem;
    margin-bottom: 6px;
    font-weight: 400;
}

.student-meta {
    display: flex;
    gap: 14px;
    font-size: 0.85rem;
    opacity: 0.9;
    flex-wrap: wrap;
}

.overall-stats {
    display: flex;
    gap: 12px;
}

.stat-card {
    text-align: center;
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    min-width: 110px;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.8;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.grade {
    color: var(--primary);
}

.student-detail-content {
    display: flex;
    flex-direction: column;
    gap: 22px;
    margin-bottom: 24px;
}

.analysis-overview {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
    gap: 20px;
    margin-bottom: 20px;
    align-items: start;
}

.student-summary {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.summary-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.summary-header {
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--neutral-200);
}

.summary-header h4 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.summary-grid {
    display: grid;
    gap: 10px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    text-align: right;
}

.summary-value-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.summary-reference-list {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.summary-reference-item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.summary-reference-label {
    min-width: 38px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--neutral-200);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
}

.summary-reference-value {
    color: var(--accent);
    font-size: 1.02rem;
    font-weight: 600;
}

.summary-value.highlight {
    color: var(--primary);
    font-size: 1.05rem;
    font-weight: 600;
}

.summary-value.orange {
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 600;
}

.summary-note {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
    line-height: 1.35;
    max-width: 210px;
}

.metric-value.orange {
    color: var(--accent);
    font-weight: 600;
}

.chart-container {
    background: var(--neutral-100);
    border-radius: var(--radius-lg);
    padding: 16px 18px 18px;
    text-align: center;
    border: 1px solid var(--border-light);
    width: 100%;
    max-width: 460px;
    justify-self: end;
}

.chart-container h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 600;
}

.chart-container canvas {
    display: block;
    width: min(100%, 360px) !important;
    height: 360px !important;
    margin: 0 auto;
}

.subject-details h4 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: 500;
}

.subject-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    max-height: none;
}

@media (max-width: 1200px) {
    .subject-cards {
        grid-template-columns: 1fr;
    }
}

/* 교과(군)별 섹션 스타일 */
.subject-group-section {
    background: var(--neutral-100);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border-light);
}

.subject-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.subject-group-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.subject-group-header .subject-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--neutral-200);
    padding: 4px 10px;
    border-radius: 10px;
    font-weight: 500;
}

.subject-group-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 15px;
}

/* 컴팩트 테이블 스타일 */
.subject-group-section.compact {
    padding: 14px;
    margin-bottom: 0;
    height: fit-content;
}

.subject-group-section.compact .subject-group-header {
    margin-bottom: 12px;
    padding: 8px 12px;
}

.subject-group-section.compact .subject-group-header h5 {
    font-size: 0.95rem;
}

.subject-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-size: 0.8rem;
}

.subject-table thead {
    background: linear-gradient(135deg, var(--neutral-200) 0%, var(--neutral-100) 100%);
}

.subject-table th {
    padding: 8px 6px;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--neutral-300);
}

.subject-table th:first-child {
    text-align: left;
    padding-left: 10px;
}

.subject-table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--neutral-200);
    color: var(--text-primary);
}

.subject-table td.center {
    text-align: center;
}

.subject-table td.subject-name-cell {
    font-weight: 500;
    padding-left: 10px;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subject-table tbody tr:hover {
    background: var(--neutral-100);
}

.subject-table tbody tr:last-child td {
    border-bottom: none;
}

.subject-table tr.no-grade-row {
    opacity: 0.7;
    background: var(--neutral-50);
}

.subject-table .score-value {
    font-weight: 600;
    color: var(--text-primary);
}

.subject-table .avg-value {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 2px;
}

.subject-table .achievement-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
}

.subject-table .achievement-badge.A { background: var(--success); color: var(--text-inverse); }
.subject-table .achievement-badge.B { background: var(--info); color: var(--text-inverse); }
.subject-table .achievement-badge.C { background: var(--accent); color: var(--text-inverse); }
.subject-table .achievement-badge.D { background: var(--warning); color: var(--text-inverse); }
.subject-table .achievement-badge.E { background: var(--primary); color: var(--text-inverse); }

.subject-table .grade9-value {
    color: var(--accent);
    font-weight: 600;
}

@media (max-width: 768px) {
    .subject-table {
        font-size: 0.75rem;
    }

    .subject-table th,
    .subject-table td {
        padding: 8px 4px;
    }

    .subject-table td.subject-name-cell {
        max-width: 80px;
    }

    .subject-table .avg-value {
        display: none;
    }
}

.subject-card.no-grade {
    opacity: 0.8;
    border-left: 4px solid var(--neutral-500);
}

.subject-metrics.simple {
    grid-template-columns: 1fr 1fr;
    margin-bottom: 0;
}

.no-grade-notice {
    text-align: center;
    padding: 15px;
    background: var(--neutral-200);
    border-radius: var(--radius-sm);
    margin-top: 15px;
}

.no-grade-notice span {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

.subject-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    border: 1px solid var(--border-light);
}

.subject-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-medium);
}

.subject-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--neutral-200);
}

.subject-header h5 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.subject-header .credits {
    background: var(--info);
    color: var(--text-inverse);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.subject-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.subject-metrics:last-of-type {
    grid-template-columns: 1fr 1fr 0fr;
}

.metric {
    text-align: center;
}

.metric-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.metric-average {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: normal;
    margin-top: 2px;
}

.metric-value.achievement.A {
    background: var(--success);
    color: var(--text-inverse);
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}
.metric-value.achievement.B {
    background: var(--info);
    color: var(--text-inverse);
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}
.metric-value.achievement.C {
    background: var(--accent);
    color: var(--text-primary);
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}
.metric-value.achievement.D {
    background: var(--warning);
    color: var(--text-inverse);
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}
.metric-value.achievement.E, .metric-value.achievement.미도달 {
    background: var(--primary);
    color: var(--text-inverse);
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
}

.percentile-bar {
    height: 8px;
    background: var(--neutral-200);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.percentile-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
}

.percentile-fill.excellent { background: linear-gradient(90deg, var(--success), var(--success-light)); }
.percentile-fill.good { background: linear-gradient(90deg, var(--info), var(--info-light)); }
.percentile-fill.average { background: linear-gradient(90deg, var(--warning), var(--warning-light)); }
.percentile-fill.low { background: linear-gradient(90deg, var(--neutral-500), var(--neutral-400)); }

.percentile.excellent { color: var(--success); font-weight: 600; }
.percentile.good { color: var(--info); font-weight: 600; }
.percentile.average { color: var(--warning); font-weight: 600; }
.percentile.low { color: var(--neutral-500); font-weight: 500; }

@media (max-width: 1024px) {
    .analysis-overview {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .chart-container {
        padding: 20px;
    }
    
    .student-detail-header {
        flex-direction: column;
        gap: 20px;
    }
    
    .overall-stats {
        align-self: stretch;
        justify-content: space-around;
    }
    
    .subject-cards {
        grid-template-columns: 1fr;
    }
}

/* 출력용 스타일 */
@page {
    size: A4 portrait;
    margin: 10mm;
}
@media print {
    .print-area {
        transform-origin: top left !important;
    }
    .print-area.apply-print-scale {
        transform: scale(var(--page-scale, 1)) !important;
    }
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body {
        background: white !important;
        margin: 0;
        padding: 0;
        font-size: 12px;
        line-height: 1.4;
        color: #000 !important;
    }
    
    .container {
        max-width: none;
        margin: 0;
        box-shadow: none;
        border-radius: 0;
        background: white;
    }
    
    header {
        display: none !important;
    }
    
    .upload-section,
    .tabs,
    .view-toggle,
    .student-selector,
    .search-box,
    .print-controls {
        display: none !important;
    }
    
    .results-section {
        padding: 15px;
    }
    
    .tab-content {
        display: block !important;
    }
    
    .tab-content:not(.print-target) {
        display: none !important;
    }

    /* 학생 탭 인쇄 시 개인 상세 페이지만 표시 */
    #students-tab.only-class-print > *:not(.class-print-area) {
        display: none !important;
    }

    /* A4에 맞춘 폭 고정 및 중앙 정렬 */
    .class-print-area {
        width: 190mm;
        margin: 0 auto;
    }
    .class-print-area .student-print-page {
        width: 190mm;
        transform-origin: top left !important;
    }
    .class-print-area .student-print-page.apply-print-scale {
        transform: scale(var(--page-scale, 1)) !important;
    }

    /* 학급 전체 인쇄 모드: 더 컴팩트한 카드와 차트 크기 */
    #students-tab.only-class-print .student-detail-header {
        padding: 12px;
        margin-bottom: 10px;
    }
    #students-tab.only-class-print .student-info h3 {
        font-size: 14px;
    }
    #students-tab.only-class-print .student-meta {
        font-size: 11px;
    }
    #students-tab.only-class-print .summary-card,
    #students-tab.only-class-print .stat-card {
        margin-bottom: 8px;
        padding: 10px;
    }
    
    /* 별도 프린트 헤더는 사용하지 않음 */
    .print-header {
        display: none !important;
    }
    
    .print-header h2 {
        margin: 0;
        color: #2c3e50;
        font-size: 18px;
        font-weight: bold;
    }
    
    .print-date {
        margin-top: 10px;
        font-size: 12px;
        color: #666;
    }
    
    .student-detail-header {
        background: #f8f9fa !important;
        border: 2px solid #4facfe;
        margin-bottom: 15px;
        padding: 20px;
        page-break-after: avoid;
    }
    
    .student-info h3 {
        color: #2c3e50 !important;
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .student-meta {
        color: #666 !important;
        font-size: 12px;
    }
    
    .stat-card {
        border: 1px solid #ddd !important;
        background: white !important;
    }
    
    .stat-label {
        color: #666 !important;
        font-size: 10px;
    }
    
    .stat-value {
        color: #2c3e50 !important;
        font-size: 14px;
    }
    
    .analysis-overview {
        grid-template-columns: 1fr;
        gap: 15px;
        page-break-inside: avoid;
    }
    
    /* 레이더 차트도 출력/PDF에 포함 */
    .chart-container {
        display: block !important;
    }
    
    .summary-card {
        border: 1px solid #ddd !important;
        background: #f9f9f9 !important;
        margin-bottom: 15px;
    }
    
    .summary-header h4 {
        color: #2c3e50 !important;
        font-size: 14px;
    }
    
    .summary-label {
        color: #666 !important;
        font-size: 11px;
    }
    
    .summary-value {
        color: #2c3e50 !important;
        font-size: 12px;
    }
    
    .summary-value.highlight {
        color: #4facfe !important;
        font-weight: bold;
    }
    
    .subject-details h4 {
        color: #2c3e50 !important;
        font-size: 14px;
        margin-bottom: 15px;
    }
    
    .subject-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        page-break-inside: avoid;
    }
    
    .subject-card {
        border: 1px solid #ddd !important;
        background: white !important;
        page-break-inside: avoid;
        margin-bottom: 8px;
        padding: 12px;
    }
    
    .subject-header h5 {
        color: #2c3e50 !important;
        font-size: 12px;
        margin: 0 0 8px 0;
    }
    
    .subject-header .credits {
        background: #4facfe !important;
        color: white !important;
        font-size: 9px;
        padding: 2px 6px;
    }
    
    .subject-metrics {
        gap: 8px;
        margin-bottom: 8px;
    }
    
    .metric-label {
        font-size: 9px;
        color: #666 !important;
    }
    
    .metric-value {
        font-size: 11px;
        color: #2c3e50 !important;
    }
    
    .metric-average {
        font-size: 9px;
        color: #666 !important;
    }
    
    .percentile-bar {
        height: 6px;
        background: #e9ecef !important;
    }
    
    .no-grade-notice {
        background: rgba(108, 117, 125, 0.1) !important;
        font-size: 10px;
    }
    
    .no-grade-notice span {
        color: #666 !important;
    }
    
    /* 성취도 색상 */
    .achievement.A, .metric-value.achievement.A { 
        background: #28a745 !important; 
        color: white !important; 
    }
    .achievement.B, .metric-value.achievement.B { 
        background: #17a2b8 !important; 
        color: white !important; 
    }
    .achievement.C, .metric-value.achievement.C { 
        background: #ffc107 !important; 
        color: #212529 !important; 
    }
    .achievement.D, .metric-value.achievement.D { 
        background: #fd7e14 !important; 
        color: white !important; 
    }
    .achievement.E, .achievement.미도달, 
    .metric-value.achievement.E, .metric-value.achievement.미도달 { 
        background: #dc3545 !important; 
        color: white !important; 
    }
    
    /* 페이지 나누기 규칙 */
    .subject-card {
        break-inside: avoid;
    }
    
    .summary-card {
        break-inside: avoid;
    }

    /* 학급 전체 인쇄: 학생별 한 페이지씩 */
    .class-print-area .student-print-page {
        page-break-after: always;
        break-after: page;
    }
    .class-print-area .student-print-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }
}

/* PDF 출력 버튼 스타일 */
.print-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.student-nav-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.student-nav-status {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0 4px;
}

.print-btn, .pdf-btn {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
    color: var(--text-inverse);
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.pdf-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.print-btn:hover, .pdf-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.print-btn::before {
    content: "🖨️";
    font-size: 16px;
}

.pdf-btn::before {
    content: "📄";
    font-size: 16px;
}

@media (max-width: 768px) {
    .student-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .selector-group {
        justify-content: space-between;
    }

    .selector {
        min-width: unset;
        flex: 1;
    }

    .subject-metrics {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .container {
        margin: 10px;
        border-radius: var(--radius-lg);
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .header-subtitle {
        font-size: 0.92rem;
    }

    .upload-section,
    .results-section {
        padding: 20px;
    }

    .file-input-label {
        min-height: 74px;
        padding: 16px 18px;
    }

    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .subject-averages {
        grid-template-columns: 1fr;
    }

    .tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    .tab-btn {
        min-width: 0;
        padding: 12px 10px;
    }

    .tab-btn.active {
        border-left: none;
    }

    .students-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .student-card-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .student-summary {
        justify-content: space-around;
    }

    .subject-data {
        gap: 6px;
    }

    .subject-name {
        font-size: 0.85rem;
    }

    .subject-score, .subject-achievement, .subject-grade, .subject-percentile {
        font-size: 0.75rem;
    }

    .print-controls {
        justify-content: center;
    }

    .print-btn, .pdf-btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }

    .analyze-btn,
    .secondary-btn {
        width: 100%;
        justify-content: center;
    }

    .rank-visibility-toggle {
        width: 100%;
        justify-content: center;
    }

    .print-controls,
    .student-nav-controls {
        justify-content: center;
    }

    .chart-section canvas {
        height: 260px !important;
    }

    /* 모바일 학생 필터 접이식 */
    .student-selector {
        position: relative;
    }
    .student-selector.collapsed .selector-group,
    .student-selector.collapsed .detail-btn:not(.filter-toggle-btn) {
        display: none;
    }
    .student-selector.collapsed .filter-toggle-btn {
        width: 100%;
    }
}

/* ========================================
   Toast Notification System
   ======================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--neutral-200);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 420px;
    animation: toastSlideIn 0.3s ease;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.removing {
    opacity: 0;
    transform: translateX(60px);
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1.2rem;
    line-height: 1.4;
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast.toast-success {
    border-left: 4px solid var(--success);
}
.toast.toast-error {
    border-left: 4px solid #DC2626;
}
.toast.toast-warning {
    border-left: 4px solid var(--warning);
}
.toast.toast-info {
    border-left: 4px solid var(--info);
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========================================
   Progress Loading
   ======================================== */
.loading-progress {
    width: 100%;
    max-width: 320px;
    margin-top: 16px;
}

.progress-bar-container {
    height: 8px;
    background: var(--neutral-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ========================================
   Analysis Complete Summary
   ======================================== */
.analysis-summary-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--success-bg);
    border: 1px solid rgba(21, 128, 61, 0.2);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    animation: fadeIn 0.4s ease;
}

.analysis-summary-banner .summary-icon {
    font-size: 1.4rem;
}

.analysis-summary-banner .summary-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.analysis-summary-banner .summary-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

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

/* ========================================
   File List with Remove Buttons
   ======================================== */
.file-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    line-height: 1;
}

.file-remove-btn:hover {
    color: #DC2626;
    background: rgba(220, 38, 38, 0.08);
}

/* ========================================
   Upload Icon
   ======================================== */
.file-input-label .upload-icon {
    margin-right: 10px;
    font-size: 1.3rem;
    opacity: 0.7;
}

/* ========================================
   Error with Close Button
   ======================================== */
.error-message {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.error-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--warning);
    font-size: 1.2rem;
    padding: 2px;
    line-height: 1;
    opacity: 0.7;
}

.error-close-btn:hover {
    opacity: 1;
}

/* ========================================
   Subject Filter (과목별 분석)
   ======================================== */
.subject-filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.subject-filter-btn {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--neutral-300);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.subject-filter-btn.active {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.subject-filter-btn:hover:not(.active) {
    border-color: var(--primary);
    color: var(--primary-dark);
}

/* ========================================
   Sortable Table Headers
   ======================================== */
.student-card-header .sort-indicator {
    display: none;
}

/* ========================================
   Export Buttons in Results
   ======================================== */
.results-export-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.rank-visibility-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border: 1px solid var(--neutral-300);
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.rank-visibility-toggle:hover {
    border-color: var(--primary);
    background: var(--neutral-50);
}

.rank-visibility-toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.rank-visibility-switch {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--neutral-300);
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.rank-visibility-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
    transition: transform 0.2s ease;
}

.rank-visibility-toggle input:checked + .rank-visibility-switch {
    background: var(--primary);
}

.rank-visibility-toggle input:checked + .rank-visibility-switch::after {
    transform: translateX(18px);
}

.rank-visibility-toggle input:focus-visible + .rank-visibility-switch {
    box-shadow: 0 0 0 4px var(--primary-bg);
}

.results-section.rankings-hidden .ranking-visibility-target,
.rankings-hidden .ranking-visibility-target,
.results-section.rankings-hidden .rank-column,
.rankings-hidden .rank-column,
.results-section.rankings-hidden .rank-sort-control,
.rankings-hidden .rank-sort-control {
    display: none !important;
}

/* ========================================
   Mobile Filter Toggle
   ======================================== */
.filter-toggle-btn {
    display: none;
}

@media (max-width: 768px) {
    .filter-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
}

/* ========================================
   In-app Help Modal
   ======================================== */
.help-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.help-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 560px;
    width: 92%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: var(--shadow-xl);
}

.help-modal h3 {
    margin: 0 0 16px 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.help-modal .help-section {
    margin-bottom: 16px;
}

.help-modal .help-section h4 {
    font-size: 0.95rem;
    color: var(--primary-dark);
    margin-bottom: 8px;
    font-weight: 600;
}

.help-modal .help-section p,
.help-modal .help-section li {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-modal .help-section ol {
    padding-left: 20px;
}

.help-modal .help-close-btn {
    display: block;
    margin: 16px auto 0;
    padding: 10px 28px;
    border: 1px solid var(--neutral-300);
    background: var(--bg-card);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.help-modal .help-close-btn:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
}

/* ========================================
   Lite Badge Tooltip
   ======================================== */
.badge-lite {
    position: relative;
    cursor: help;
}

.badge-lite-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--neutral-800);
    color: var(--text-inverse);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
}

.badge-lite:hover .badge-lite-tooltip {
    display: block;
}
