.certificate-app {
    --cert-red: #ed174c;
    --cert-navy: #0d2345;
    --cert-line: #dfe4eb;
    --cert-muted: #687386;
    margin: 44px 0 90px;
    color: #172033;
}

.certificate-tabs { overflow-x: auto; }
.certificate-tabs a, .certificate-tabs span { flex: 0 0 auto; }

.certificate-progress {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    max-width: 900px;
    margin: 0 auto 42px;
    padding: 0;
    list-style: none;
}

.certificate-progress li {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #98a1b1;
    font-size: 14px;
    font-weight: 700;
}

.certificate-progress li::before {
    position: absolute;
    top: 17px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: #e3e7ed;
    content: "";
}

.certificate-progress li:first-child::before { display: none; }

.certificate-progress span {
    position: relative;
    z-index: 1;
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 2px solid #d8dde5;
    border-radius: 50%;
    background: #fff;
}

.certificate-progress .is-active, .certificate-progress .is-done { color: var(--cert-red); }
.certificate-progress .is-active span, .certificate-progress .is-done span { border-color: var(--cert-red); }
.certificate-progress .is-active span { background: var(--cert-red); color: #fff; }
.certificate-progress .is-done::before { background: var(--cert-red); }

.certificate-panel { display: none; }
.certificate-panel.is-active { display: block; animation: certificateFade .22s ease-out; }

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

.certificate-intro, .certificate-card, .certificate-complete {
    max-width: 980px;
    margin: 0 auto;
}

.certificate-intro { margin-bottom: 28px; text-align: center; }
.certificate-intro h2, .certificate-card-heading h2 { margin: 5px 0 10px; font-size: 30px; }
.certificate-intro > p:last-child, .certificate-card-heading > p:last-child { color: var(--cert-muted); line-height: 1.7; }
.certificate-kicker { margin: 0; color: var(--cert-red); font-size: 13px; font-weight: 800; letter-spacing: .16em; }

.certificate-type-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    max-width: 980px;
    margin: 0 auto;
}

.certificate-type-card {
    position: relative;
    min-height: 240px;
    padding: 38px;
    overflow: hidden;
    border: 1px solid var(--cert-line);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 12px 40px rgba(26, 39, 64, .08);
    text-align: left;
    transition: .2s ease;
}

.certificate-type-card:hover, .certificate-type-card:focus, .certificate-type-card.is-selected {
    border-color: var(--cert-red);
    box-shadow: 0 16px 48px rgba(237, 23, 76, .13);
    transform: translateY(-3px);
}

.certificate-type-card strong { display: block; margin: 38px 0 12px; color: var(--cert-navy); font-size: 27px; }
.certificate-type-card small { display: block; max-width: 340px; color: var(--cert-muted); font-size: 15px; line-height: 1.65; }
.certificate-type-number { position: absolute; top: 28px; right: 34px; color: #edf0f5; font-size: 70px; font-weight: 900; line-height: 1; }

.certificate-card {
    padding: 38px 44px;
    border: 1px solid var(--cert-line);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 12px 40px rgba(26, 39, 64, .07);
}

.certificate-card-heading { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--cert-line); }
.certificate-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.certificate-field { display: flex; flex-direction: column; gap: 9px; }
.certificate-field-wide { grid-column: 1 / -1; }
.certificate-field > span { font-size: 14px; font-weight: 700; }
.certificate-field b { color: var(--cert-red); }
.certificate-field input, .certificate-auth-row input {
    height: 50px;
    padding: 0 15px;
    border: 1px solid #cfd5de;
    border-radius: 8px;
    background: #fff;
    font-size: 15px;
}
.certificate-field input:focus, .certificate-auth-row input:focus { border-color: var(--cert-red); outline: 0; box-shadow: 0 0 0 3px rgba(237, 23, 76, .1); }
.certificate-auth-types { display: flex; gap: 10px; }
.certificate-auth-types label { min-width: 160px; padding: 14px 18px; border: 1px solid #d7dce4; border-radius: 8px; cursor: pointer; }
.certificate-auth-types input { margin-right: 7px; accent-color: var(--cert-red); }
.certificate-auth-row { display: grid; grid-template-columns: 180px 1fr 160px; gap: 10px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--cert-line); }
.certificate-status { min-height: 24px; margin: 14px 0 0; color: var(--cert-muted); font-size: 14px; }
.certificate-status.is-success { color: #087c50; }
.certificate-status.is-error { color: #c92345; }

.certificate-button {
    display: inline-flex;
    min-width: 140px;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    padding: 11px 24px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}
.certificate-button.primary { background: var(--cert-red); color: #fff; }
.certificate-button.secondary { border-color: var(--cert-navy); background: var(--cert-navy); color: #fff; }
.certificate-button.ghost { border-color: #cfd5de; background: #fff; color: #343e50; }
.certificate-button:disabled { cursor: wait; opacity: .62; }
.certificate-actions { display: flex; max-width: 980px; margin: 22px auto 0; justify-content: center; gap: 10px; }
.certificate-actions.split { justify-content: space-between; }

.certificate-player-summary, .certificate-preview-identity, .certificate-preview-purpose {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    margin: 0 0 28px;
    overflow: hidden;
    border: 1px solid var(--cert-line);
    border-radius: 10px;
    background: var(--cert-line);
}
.certificate-player-summary > div, .certificate-preview-identity > div, .certificate-preview-purpose > div { display: grid; grid-template-columns: 110px 1fr; background: #fff; }
.certificate-player-summary dt, .certificate-preview-identity dt, .certificate-preview-purpose dt { padding: 14px; background: #f5f7fa; font-weight: 800; }
.certificate-player-summary dd, .certificate-preview-identity dd, .certificate-preview-purpose dd { margin: 0; padding: 14px; word-break: break-word; }
.certificate-performance-fields { margin: 30px 0; padding: 26px; border-radius: 12px; background: #f7f8fa; }
#performanceRequiredFields[hidden] { display: none; }
.certificate-season-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 30px; }
.certificate-season-heading h3 { margin: 0 0 7px; font-size: 21px; }
.certificate-season-heading p { margin: 0; color: var(--cert-muted); }
.certificate-text-button { border: 0; background: transparent; color: var(--cert-red); font-weight: 800; }
.certificate-season-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.certificate-season-option { display: flex; min-height: 76px; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid #d8dde5; border-radius: 10px; cursor: pointer; }
.certificate-season-option.is-checked { border-color: var(--cert-red); background: #fff6f8; }
.certificate-season-option input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--cert-red); }
.certificate-season-option strong, .certificate-season-option small { display: block; }
.certificate-season-option small { margin-top: 5px; color: var(--cert-muted); }

.certificate-preview-card { max-width: 1100px; }
.certificate-preview-content { padding: 35px; border: 1px solid #bcc4cf; background: #fff; }
.certificate-preview-content > h3 { margin: 0 0 32px; text-align: center; font-size: 30px; letter-spacing: .08em; }
.certificate-preview-registration { padding: 38px; text-align: center; }
.certificate-preview-registration p { font-size: 17px; }
.certificate-preview-registration ul { display: inline-block; margin: 18px auto 0; text-align: left; line-height: 2; }
.certificate-preview-table-wrap { overflow-x: auto; }
.certificate-preview-table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.certificate-preview-table-wrap th, .certificate-preview-table-wrap td { padding: 10px; border: 1px solid #cfd5de; text-align: center; }
.certificate-preview-table-wrap th { background: #f4f6f8; }
.certificate-preview-purpose { margin: 20px 0 0; }

.certificate-complete { padding: 90px 30px; border: 1px solid var(--cert-line); border-radius: 18px; background: #fff; text-align: center; }
.certificate-complete-icon { display: grid; width: 78px; height: 78px; margin: 0 auto 24px; place-items: center; border-radius: 50%; background: var(--cert-red); color: #fff; font-size: 38px; }
.certificate-complete h2 { margin: 0 0 12px; font-size: 30px; }
.certificate-complete > p { color: var(--cert-red); font-size: 18px; font-weight: 800; }
.certificate-complete-actions { display: flex; justify-content: center; gap: 10px; margin-top: 28px; }

/* 공통 서브페이지가 OS 다크 테마를 적용할 때 카드 밖 안내문 대비를 보완한다. */
@media (prefers-color-scheme: dark) {
    .certificate-intro h2 { color: #fff; }
    .certificate-intro > p:last-child { color: #d2d7df; }
    .certificate-progress li { color: #c2c8d2; }
    .certificate-progress li::before { background: #737b87; }
    .certificate-progress span { color: #737d8d; }
    .certificate-progress .is-active, .certificate-progress .is-done { color: #ff315f; }
    .certificate-progress .is-active span, .certificate-progress .is-done span { border-color: #ff315f; }
    .certificate-progress .is-active span { background: #ed174c; color: #fff; }
    .certificate-progress .is-done::before { background: #ed174c; }
}

/* Standalone A4 print page */
.certificate-print-body { margin: 0; background: #e9edf2; color: #111; font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
.certificate-print-controls { display: flex; width: 210mm; box-sizing: border-box; margin: 22px auto 10px; justify-content: flex-end; gap: 8px; }
.certificate-print-controls button, .certificate-print-error button { padding: 10px 24px; border: 1px solid #aab2bf; border-radius: 5px; background: #fff; font-weight: 700; cursor: pointer; }
.certificate-print-controls .primary { border-color: #ed174c; background: #ed174c; color: #fff; }
.certificate-document { position: relative; width: 210mm; min-height: 297mm; box-sizing: border-box; margin: 0 auto 30px; padding: 20mm 17mm 17mm; overflow: hidden; background: #fff; box-shadow: 0 4px 30px rgba(0, 0, 0, .13); }
.certificate-watermark { position: absolute; z-index: 0; top: 41%; left: 50%; width: 47mm; opacity: .08; transform: translate(-50%, -50%); }
.certificate-document > *:not(.certificate-watermark) { position: relative; z-index: 1; }
.certificate-document-header h1 { margin: 0; text-align: center; font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; font-size: 27pt; font-weight: 700; letter-spacing: .08em; }
.certificate-document-number { margin: 18px 0 13mm; text-align: right; font-size: 12pt; }
.certificate-page-number { margin-left: 7px; color: #555; font-size: 10px; }
.certificate-identity-table, .certificate-record-table, .certificate-purpose-table { width: 100%; border-collapse: collapse; }
.certificate-identity-table th, .certificate-identity-table td { padding: 9px 11px; border: 1px solid #b8b8b8; font-size: 12pt; }
.certificate-identity-table th { width: 18%; background: #f7f7f7; letter-spacing: .25em; }
.certificate-registration-body { min-height: 102mm; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-family: serif; font-size: 16px; line-height: 2; }
.certificate-registration-seasons { display: flex; flex-direction: column; align-items: center; margin: 5mm 0 2mm; gap: 2mm; }
.certificate-registration-seasons strong { font-size: 18px; }
.certificate-record-table { margin-top: 7mm; table-layout: fixed; font-size: 8.5px; }
.certificate-record-table thead { display: table-header-group; }
.certificate-record-table th, .certificate-record-table td { padding: 5px 4px; border: 1px solid #aaa; text-align: center; overflow-wrap: anywhere; word-break: keep-all; }
.certificate-record-table th { background: #f5f5f5; font-size: 9px; }
.certificate-record-table th:nth-child(1) { width: 20%; }
.certificate-record-table th:nth-child(2) { width: 27%; }
.certificate-record-table th:nth-child(3) { width: 43%; }
.certificate-record-table th:nth-child(4) { width: 10%; }
.certificate-purpose-table { margin-top: 6mm; font-size: 10px; }
.certificate-purpose-table th, .certificate-purpose-table td { padding: 7px; border: 1px solid #aaa; }
.certificate-purpose-table th { width: 13%; background: #f5f5f5; letter-spacing: .15em; }
.certificate-document-footer { margin-top: 12mm; text-align: center; }
.certificate-issued-date { margin: 0 0 13mm; font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; font-size: 13px; letter-spacing: .12em; }
.certificate-authority { position: relative; display: inline-block; min-width: 90mm; font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
.certificate-authority-composite { display: block; width: 90mm; height: auto; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.certificate-contact { display: flex; margin-top: 11mm; align-items: center; gap: 8px; border-top: 1px solid #ddd; padding-top: 5mm; text-align: left; }
.certificate-contact img { width: 21mm; }
.certificate-contact p { margin: 0; color: #444; font-size: 8px; line-height: 1.5; }
.certificate-print-error { max-width: 600px; margin: 120px auto; padding: 50px; border-radius: 12px; background: #fff; text-align: center; }

/* 경기실적은 페이지당 최대 20행이 A4 안에 들어오도록 간격을 압축한다. */
.certificate-document.is-performance { height: 297mm; padding: 15mm 14mm 12mm; }
.is-performance .certificate-document-header h1 { font-size: 27pt; }
.is-performance .certificate-document-number { margin: 12px 0 7mm; }
.is-performance .certificate-identity-table th, .is-performance .certificate-identity-table td { padding: 7px 9px; }
.is-performance .certificate-record-table { margin-top: 4mm; font-size: 9pt; }
.is-performance .certificate-record-table th, .is-performance .certificate-record-table td { box-sizing: border-box; padding: 4px; line-height: 1.35; }
.is-performance .certificate-record-table th { height: 6mm; font-size: 12pt; }
.is-performance .certificate-record-table td { height: 7mm; }
.is-performance .certificate-record-table th:nth-child(1) { width: 25%; }
.is-performance .certificate-record-table th:nth-child(2) { width: 24%; }
.is-performance .certificate-record-table th:nth-child(3) { width: 42%; }
.is-performance .certificate-record-table th:nth-child(4) { width: 9%; }
.is-performance .certificate-record-table td:first-child { white-space: nowrap; }
.is-performance .certificate-purpose-table { margin-top: 3mm; font-size: 12pt; }
.is-performance .certificate-purpose-table th, .is-performance .certificate-purpose-table td { padding: 5px; }
.is-performance .certificate-document-footer { position: absolute; right: 14mm; bottom: 12mm; left: 14mm; z-index: 1; margin: 0; }
.is-performance .certificate-issued-date { margin-bottom: 5mm; font-size: 12pt; }
.is-performance .certificate-authority-composite { width: 90mm; }
.is-performance .certificate-contact { margin-top: 4mm; padding-top: 2mm; }
.is-performance .certificate-contact img { width: 12mm; }
.is-performance .certificate-contact p { font-size: 7px; line-height: 1.35; }

/* 제공된 선수등록 확인서 양식 */
.certificate-document.is-registration { padding: 21mm 17mm 13mm; }
.certificate-document.is-registration::after { position: absolute; inset: 8mm; border: .35mm solid #777; content: ""; pointer-events: none; }
.is-registration .certificate-document-header h1 { margin-top: 8mm; font-size: 27pt; }
.is-registration .certificate-document-number { width: calc(100% - 16mm); margin: 15mm auto 14mm; font-size: 12pt; }
.is-registration .certificate-identity-table { width: calc(100% - 16mm); margin: 0 auto; table-layout: fixed; }
.is-registration .certificate-identity-table th, .is-registration .certificate-identity-table td { height: 13mm; box-sizing: border-box; padding: 3mm 4mm; border-width: .25mm 0; font-size: 12pt; }
.is-registration .certificate-identity-table th { width: 23%; border-right: .25mm solid #aaa; background: #fff; font-weight: 800; text-align: center; }
.is-registration .certificate-identity-table td { text-align: center; }
.is-registration .certificate-identity-table tr:first-child td { letter-spacing: .28em; }
.is-registration .certificate-watermark { top: 49%; width: 53mm; opacity: .18; }
.is-registration .certificate-registration-body { min-height: 82mm; box-sizing: border-box; padding-top: 31mm; justify-content: flex-start; font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; font-size: 16pt; line-height: 1.9; }
.is-registration .certificate-registration-body p { margin: 0; letter-spacing: .02em; }
.is-registration .certificate-registration-seasons { align-items: flex-start; margin: 5mm 0 2mm; }
.is-registration .certificate-registration-seasons strong { font-size: 16pt; }
.is-registration .certificate-registration-body.is-multiple-seasons { padding-top: 17mm; font-size: 16pt; line-height: 1.6; }
.is-registration .is-multiple-seasons .certificate-registration-seasons { margin: 4mm 0 2mm; gap: 1.5mm; }
.is-registration .is-multiple-seasons .certificate-registration-seasons strong { font-size: 16pt; line-height: 1.4; }
.is-registration .certificate-registration-body.is-many-seasons { padding-top: 8mm; font-size: 16pt; line-height: 1.55; }
.is-registration .is-many-seasons .certificate-registration-seasons { margin: 3mm 0 1mm; gap: 1mm; }
.is-registration .is-many-seasons .certificate-registration-seasons strong { font-size: 16pt; line-height: 1.35; }
.is-registration .certificate-document-footer { position: static; margin-top: 4mm; }
.is-registration .certificate-issued-date { position: relative; z-index: 1; margin: 0 0 33mm; font-size: 12pt; }
.is-registration .certificate-authority { min-width: 100mm; }
.is-registration .certificate-authority-composite { width: 100mm; }
.is-registration .certificate-contact { position: absolute; z-index: 1; bottom: 11mm; left: 22mm; width: 75mm; margin: 0; padding: 0; border: 0; }
.is-registration .certificate-contact img { width: 14mm; }
.is-registration .certificate-contact p { font-size: 8px; line-height: 1.45; }
.is-registration .certificate-contact p strong { font-size: 8px; }

@page { size: A4 portrait; margin: 0; }
@media print {
    .certificate-print-body { background: #fff; }
    .certificate-print-controls { display: none !important; }
    .certificate-document { width: 210mm; min-height: 297mm; margin: 0; box-shadow: none; page-break-after: always; }
    .certificate-document:last-child { page-break-after: auto; }
    .certificate-document.is-performance { height: 297mm; break-inside: avoid; page-break-inside: avoid; }
    .certificate-record-table tr { break-inside: avoid; page-break-inside: avoid; }
}

@media (max-width: 900px) {
    .certificate-progress { grid-template-columns: repeat(5, minmax(76px, 1fr)); overflow-x: auto; padding-bottom: 8px; }
    .certificate-progress li { font-size: 12px; }
    .certificate-type-grid, .certificate-form-grid, .certificate-season-list { grid-template-columns: 1fr; }
    .certificate-field-wide { grid-column: auto; }
    .certificate-card { padding: 28px 20px; }
    .certificate-auth-row { grid-template-columns: 1fr; }
    .certificate-auth-row input { width: 100%; box-sizing: border-box; }
    .certificate-player-summary, .certificate-preview-identity, .certificate-preview-purpose { grid-template-columns: 1fr; }
    .certificate-season-heading { align-items: flex-start; gap: 15px; }
    .certificate-actions.split { justify-content: center; }
}

@media (max-width: 560px) {
    .certificate-app { margin-top: 25px; }
    .certificate-type-card { min-height: 200px; padding: 28px 24px; }
    .certificate-type-card strong { font-size: 23px; }
    .certificate-auth-types { flex-direction: column; }
    .certificate-auth-types label { min-width: 0; }
    .certificate-player-summary > div, .certificate-preview-identity > div, .certificate-preview-purpose > div { grid-template-columns: 90px 1fr; }
    .certificate-preview-content { padding: 20px 12px; }
    .certificate-complete-actions { flex-direction: column; }
}
