* {
    box-sizing: border-box;
}

:root {
    --blue: #3156e8;
    --blue-dark: #2345c9;
    --ink: #171a22;
    --muted: #7a8191;
    --line: #e5e8ef;
    --bg: #f4f6fa;
    --white: #ffffff;
    --green: #14804a;
    --green-bg: #eaf8f0;
    --red: #d64141;
    --red-bg: #fff1f1;
}

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

body {
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Arial, sans-serif;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 104px;
    padding: 22px max(24px, calc((100vw - 1180px) / 2));
    background: var(--white);
    border-bottom: 1px solid var(--line);
}

.topbar h1 {
    margin: 4px 0 0;
    font-size: 26px;
    letter-spacing: -0.04em;
}

.brand-kicker,
.eyebrow {
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.container {
    width: min(1180px, calc(100% - 40px));
    margin: 34px auto 70px;
}

.intro-card,
.result-head-card,
.warning-card,
.table-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 5px 24px rgba(31, 42, 68, 0.045);
}

.intro-card {
    padding: 28px 30px;
    margin-bottom: 22px;
}

.intro-card h2,
.result-head-card h2 {
    margin: 7px 0 8px;
    font-size: 25px;
    letter-spacing: -0.04em;
}

.intro-card p,
.result-head-card p,
.warning-card p,
.muted {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.course-card {
    padding: 24px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 5px 24px rgba(31, 42, 68, 0.045);
}

.course-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
}

.course-code {
    color: var(--blue);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.12em;
}

.course-head h3 {
    margin: 4px 0 0;
    font-size: 22px;
    letter-spacing: -0.04em;
}

.status-badge,
.selected-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.status-badge {
    padding: 7px 10px;
    color: #707789;
    background: #f0f2f6;
}

.status-badge.status-done,
.selected-chip {
    color: var(--green);
    background: var(--green-bg);
}

.selected-chip {
    padding: 5px 10px;
}

.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.stat-box {
    padding: 16px;
    background: #f7f8fb;
    border-radius: 13px;
}

.stat-box span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.stat-box strong {
    font-size: 25px;
}

.stat-box em {
    margin-left: 3px;
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.selected-stat strong {
    color: var(--blue);
}

.field-label {
    display: block;
    margin-bottom: 8px;
    color: #4c5260;
    font-size: 13px;
    font-weight: 800;
}

.text-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid #d8dce5;
    border-radius: 10px;
    outline: none;
    background: #fff;
}

.text-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(49, 86, 232, 0.09);
}

.count-input-wrap {
    position: relative;
    margin-bottom: 12px;
}

.count-input {
    padding-right: 45px;
    font-weight: 800;
}

.count-input-wrap > span {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 13px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 17px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 800;
    transition: 0.15s ease;
}

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

.btn-block {
    width: 100%;
}

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

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

.btn-light {
    color: #4a5060;
    background: #fff;
    border-color: var(--line);
}

.btn-excel {
    color: #fff;
    background: #16794e;
}

.btn-excel:hover {
    background: #11643f;
}

.btn-danger-outline {
    color: var(--red);
    background: #fff;
    border-color: #efbaba;
}

.btn-danger-outline:hover {
    background: var(--red-bg);
}

.action-stack {
    display: grid;
    gap: 9px;
}

.action-stack form {
    margin: 0;
}

.warning-card {
    margin-top: 20px;
    padding: 20px 24px;
    border-color: #f0d8d8;
}

.warning-card strong {
    display: block;
    margin-bottom: 5px;
    color: #9e3636;
}

.warning-card code {
    padding: 1px 5px;
    border-radius: 4px;
    background: #f3f4f6;
}

.alert {
    margin-bottom: 18px;
    padding: 14px 17px;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.6;
}

.alert-success {
    color: #136b40;
    background: #eaf8f0;
    border: 1px solid #ccebd9;
}

.alert-error {
    color: #a63535;
    background: #fff0f0;
    border: 1px solid #f2cccc;
}

.result-container {
    max-width: 1180px;
}

.result-head-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
    padding: 26px 30px;
}

.result-summary {
    min-width: 150px;
    padding: 16px 20px;
    text-align: center;
    background: #f4f6ff;
    border-radius: 13px;
}

.result-summary span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
}

.result-summary strong {
    color: var(--blue);
    font-size: 30px;
}

.result-summary em {
    margin-left: 4px;
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 16px 0;
}

.table-card {
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 850px;
}

.result-table th,
.result-table td {
    padding: 14px 15px;
    text-align: center;
    border-bottom: 1px solid #edf0f4;
    font-size: 13px;
    white-space: nowrap;
}

.result-table th {
    color: #5d6472;
    background: #f8f9fb;
    font-size: 12px;
    font-weight: 900;
}

.result-table tbody tr:hover {
    background: #fbfcff;
}

.result-table .name-cell {
    color: #151821;
    font-weight: 800;
}

.empty-state {
    padding: 70px 20px;
    text-align: center;
}

.empty-state strong {
    display: block;
    margin-bottom: 8px;
    font-size: 18px;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 25px;
    background: #eef1f7;
}

.login-card {
    width: min(420px, 100%);
    padding: 34px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 15px 50px rgba(26, 35, 57, 0.10);
}

.login-card h1 {
    margin: 6px 0 8px;
    font-size: 27px;
}

.login-card .muted {
    margin-bottom: 24px;
}

.login-card .text-input {
    margin-bottom: 12px;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 20, 32, 0.58);
}

.loading-overlay.active {
    display: flex;
}

.loading-box {
    width: min(360px, 100%);
    padding: 34px;
    text-align: center;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.18);
}

.loading-box h3 {
    margin: 15px 0 7px;
}

.loading-box p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.spinner {
    width: 38px;
    height: 38px;
    margin: 0 auto;
    border: 4px solid #e6eafb;
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

@media (max-width: 900px) {
    .course-grid {
        grid-template-columns: 1fr;
    }

    .course-card {
        padding: 22px;
    }
}

@media (max-width: 600px) {
    .topbar {
        min-height: 88px;
        padding: 18px 18px;
    }

    .topbar h1 {
        font-size: 20px;
    }

    .topbar .brand-kicker {
        font-size: 10px;
    }

    .container {
        width: calc(100% - 28px);
        margin-top: 20px;
    }

    .intro-card,
    .result-head-card {
        padding: 22px 20px;
    }

    .result-head-card {
        display: block;
    }

    .result-summary {
        margin-top: 18px;
    }

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

    .toolbar {
        align-items: stretch;
    }

    .toolbar .btn {
        flex: 1;
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* ch_add 최종본: 전체/대기/선정 3개 통계 */
.stats-row.stats-row-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stats-row-three .stat-box {
    padding: 14px 10px;
    text-align: center;
}
.stats-row-three .stat-box strong {
    font-size: 22px;
}
.waiting-stat strong {
    color: #7a8191;
}
.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}
@media (max-width: 1050px) {
    .course-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 520px) {
    .stats-row.stats-row-three {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
    }
    .stats-row-three .stat-box {
        padding: 12px 6px;
    }
    .stats-row-three .stat-box strong {
        font-size: 19px;
    }
    .stats-row-three .stat-box span {
        font-size: 11px;
    }
}
