/* ── 리셋 & 기본 ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.6;
}

/* ── 레이아웃 ── */
.layout { display: flex; min-height: 100vh; }

/* 사이드바 */
.sidebar {
    width: 220px;
    background: #1a1a2e;
    color: #fff;
    padding: 24px 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
}
.sidebar h1 {
    font-size: 18px;
    padding: 0 20px 20px;
    border-bottom: 1px solid #2d2d44;
    margin-bottom: 8px;
}
.sidebar nav a {
    display: block;
    padding: 12px 20px;
    color: #a0a0b8;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
}
.sidebar nav a:hover,
.sidebar nav a.active {
    background: #2d2d44;
    color: #fff;
}
.sidebar nav a.active { border-left: 3px solid #4a90d9; }

/* 메인 콘텐츠 */
.main { margin-left: 220px; padding: 24px 32px; flex: 1; }
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; }

/* 헤더 컨트롤 */
.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-controls select {
    min-width: 140px;
}

/* ── 요약 카드 ── */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card .label { font-size: 13px; color: #666; margin-bottom: 4px; }
.card .value { font-size: 28px; font-weight: 700; }
.card .value.danger { color: #e74c3c; }

/* ── 테이블 ── */
.table-wrap {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}
.table-wrap .table-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th {
    text-align: left;
    padding: 12px 16px;
    background: #fafafa;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    font-size: 13px;
    color: #666;
}
td {
    padding: 10px 16px;
    border-bottom: 1px solid #f5f5f5;
}
tr:hover td { background: #f8f9ff; }
tr.level-warning td { background: #fff8e1; }
tr.level-danger td { background: #ffeaea; }

/* 기관 행 */
tr.org-row td { background: #f8f9fa; }
tr.org-row:hover td { background: #e9ecef; }

/* 학생 행 배경색 */
tr.student-achieved td { background: #f0faf0; }
tr.student-underachieved td { background: #fef0f0; }
tr.student-achieved:hover td { background: #e0f5e0; }
tr.student-underachieved:hover td { background: #fde0e0; }

/* 토글 화살표 */
.toggle-arrow { font-size: 12px; color: #888; }

/* ── 배지 ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}
.badge-danger { background: #ffeaea; color: #e74c3c; }
.badge-warning { background: #fff3cd; color: #e67e22; }
.badge-success { background: #d4edda; color: #27ae60; }
.badge-info { background: #e3f2fd; color: #2196f3; }

/* ── 폼/버튼 ── */
select, input, textarea {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: #4a90d9;
}
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #4a90d9; color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── 알림 배너 ── */
.alert-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
    display: none;
}
.alert-banner.show { display: block; }

/* ── 모달 ── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    justify-content: center;
    align-items: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 480px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal h3 { margin-bottom: 16px; }
.modal .form-group { margin-bottom: 12px; }
.modal .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}
.modal .form-group input,
.modal .form-group select,
.modal .form-group textarea { width: 100%; }
.modal .btn-row {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ── 기관 카드 그리드 ── */
.org-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.org-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.org-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.org-card .org-name { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.org-card .org-meta { font-size: 13px; color: #666; }
.org-card .org-rate { font-size: 24px; font-weight: 700; margin-top: 8px; }
.org-card .org-rate.low { color: #e74c3c; }

/* 주간 등급 */
.grade {
    display: inline-block;
    font-size: 14px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
}
.grade-a { background: #d4edda; color: #27ae60; }
.grade-b { background: #fff3cd; color: #e67e22; }
.grade-c { background: #ffeaea; color: #e74c3c; }

/* 등급 컬럼 레이아웃 */
.grade-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}
.grade-col {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 0 12px 12px;
}
.grade-col-header {
    padding: 14px 8px;
    font-size: 15px;
    font-weight: 700;
    border-bottom: 2px solid #eee;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.grade-header-a { border-bottom-color: #27ae60; }
.grade-header-b { border-bottom-color: #e67e22; }
.grade-header-c { border-bottom-color: #e74c3c; }
.grade-count {
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
    color: #888;
}
.grade-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
}
.grade-chip {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
}
.grade-chip small {
    font-weight: 400;
    color: #888;
    margin-left: 2px;
}
.grade-chip-empty {
    font-size: 13px;
    color: #aaa;
    padding: 4px 0;
}

/* 카드 목록 컨트롤 */
.list-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

/* ── 진행 상황 모달 ── */
#progress-log div {
    padding: 2px 0;
    border-bottom: 1px solid #eee;
}
#progress-log div:last-child {
    border-bottom: none;
    font-weight: 600;
    color: #27ae60;
}

/* ── 유틸 ── */
.mt-16 { margin-top: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none; }
