/* ISKOREA 공통 디자인 시스템 (HIC27 / WCL 동일 테마 유지) */
:root {
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --bg-soft: #f1f3f5;
    --text-primary: #111111;
    --text-muted: #868e96;
    --border-strong: #111111;
    --border-light: #e9ecef;
    --brand-orange: #ff7f00;
    --pro-green: #12b886;
    --banner-pass-bg: #8ce99a;
    --banner-warn-bg: #ffec99;
    --banner-fail-bg: #ffc9c9;
    --banner-text: #0b2e13;
}

html:not(.dark) { color-scheme: light !important; }
html.dark {
    color-scheme: dark !important;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-soft: #334155;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --border-strong: #475569;
    --border-light: #334155;
    --banner-pass-bg: #15803d;
    --banner-warn-bg: #b45309;
    --banner-fail-bg: #b91c1c;
    --banner-text: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Pretendard', 'Malgun Gothic', -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    padding-bottom: 48px;
}

.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }

/* 메인 컨테이너 및 외곽선 카드 (HIC27 동일 규격) */
.main-container {
    max-width: 920px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.outline-card {
    background-color: var(--bg-card);
    border: 1.5px solid var(--border-strong);
    border-radius: 12px;
    padding: 18px 20px;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.card-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--brand-orange);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
}

/* 그리드 & 입력 컨트롤 */
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.three-col-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.four-col-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 700; color: var(--text-muted); }

.input-control, .select-control, .textarea-control {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1.5px solid var(--border-light);
    border-radius: 8px;
    background-color: var(--bg-soft);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
    outline: none;
    transition: border-color 0.15s ease;
}

.textarea-control {
    height: auto;
    min-height: 68px;
    padding: 10px 12px;
    resize: vertical;
    font-family: inherit;
}

.input-control:focus, .select-control:focus, .textarea-control:focus {
    border-color: var(--brand-orange);
}

.input-control[readonly] {
    opacity: 0.78;
    cursor: not-allowed;
}

/* 선택 + 수동 입력 겸용 콤보 드롭다운 */
.combo-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.combo-wrap .input-control {
    padding-right: 34px;
}
.combo-toggle-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.combo-toggle-btn:hover {
    background-color: var(--border-light);
    color: var(--brand-orange);
}
.combo-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background-color: var(--bg-card);
    border: 1.5px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
    z-index: 500;
}
.combo-item {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-bottom: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}
.combo-item:last-child { border-bottom: none; }
.combo-item:hover {
    background-color: var(--bg-soft);
    color: var(--brand-orange);
}

/* WPS 6번 섹션 접기/열기 버튼 */
.wps-sec-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.wps-collapse-btn {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}
.wps-collapse-btn:hover {
    background: var(--brand-orange);
    border-color: var(--brand-orange);
}
.pqr-data-collapsed {
    display: none;
}

/* 규격 토글 버튼 (HIC27 .std-btn 동일) */
.std-toggle-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.std-toggle-group.two-col { grid-template-columns: 1fr 1fr; }
.std-btn {
    height: 42px;
    border: none;
    border-radius: 8px;
    background-color: var(--bg-soft);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.std-btn.active { background-color: var(--brand-orange); color: #ffffff; }

/* 액션 버튼 바 */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn {
    height: 38px;
    padding: 0 14px;
    border: none;
    border-radius: 8px;
    background-color: var(--bg-soft);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: opacity 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-orange { background-color: var(--brand-orange); color: #ffffff; }
.btn-green { background-color: var(--pro-green); color: #ffffff; }
.btn-outline { border: 1.5px solid var(--border-strong); background-color: var(--bg-card); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12px; }

/* 체크박스 칩 */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--border-light);
    background-color: var(--bg-soft);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
}
.chip-check input { accent-color: var(--brand-orange); width: 15px; height: 15px; cursor: pointer; }

/* Pass 입력 테이블 */
.table-scroll { width: 100%; overflow-x: auto; }
.pass-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.pass-table th, .pass-table td {
    border: 1px solid var(--border-light);
    padding: 7px 6px;
    text-align: center;
}
.pass-table th {
    background-color: var(--bg-soft);
    font-weight: 800;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}
.pass-table input, .pass-table select {
    width: 100%;
    min-width: 62px;
    height: 32px;
    padding: 0 6px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}
.pass-hi-cell { font-weight: 800; color: var(--brand-orange); white-space: nowrap; }

/* 상태 배너 (PASS / WARN / FAIL) */
.status-banner {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 800;
    line-height: 1.5;
    border: 1.5px solid var(--border-strong);
}
.status-banner.PASS { background-color: var(--banner-pass-bg); color: var(--banner-text); }
.status-banner.WARN { background-color: var(--banner-warn-bg); color: #111111; }
html.dark .status-banner.WARN { color: #ffffff; }
.status-banner.FAIL { background-color: var(--banner-fail-bg); color: #7f1d1d; }
html.dark .status-banner.FAIL { color: #ffffff; }

/* 요약 KPI 카드 */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.kpi-box {
    background-color: var(--bg-soft);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 12px 14px;
}
.kpi-label { font-size: 11.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; }
.kpi-value { font-size: 15px; font-weight: 900; color: var(--text-primary); line-height: 1.35; }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* 오버라이드 & 충돌 리스트 */
.override-list, .conflict-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    font-size: 12.5px;
    font-weight: 700;
}
.override-list li {
    padding: 7px 10px;
    border-radius: 6px;
    background-color: var(--bg-soft);
    border-left: 4px solid var(--brand-orange);
}
.conflict-list li.error {
    padding: 8px 10px;
    border-radius: 6px;
    background-color: var(--banner-fail-bg);
    color: #7f1d1d;
}
html.dark .conflict-list li.error { color: #ffffff; }
.conflict-list li.warning {
    padding: 8px 10px;
    border-radius: 6px;
    background-color: var(--banner-warn-bg);
    color: #111111;
}
html.dark .conflict-list li.warning { color: #ffffff; }

/* WPS 문서 미리보기 페이지 (A4 비율 느낌) */
.wps-doc-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.wps-page {
    background-color: #ffffff;
    color: #111111;
    border: 2px solid #111111;
    border-radius: 6px;
    padding: 24px 26px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.wps-doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    border-bottom: 2.5px solid #111111;
    padding-bottom: 10px;
    margin-bottom: 14px;
}
.wps-doc-title { font-size: 19px; font-weight: 900; letter-spacing: 0.4px; }
.wps-doc-sub { font-size: 11.5px; font-weight: 700; color: #495057; margin-top: 3px; line-height: 1.4; }
.wps-doc-meta { text-align: right; font-size: 12px; font-weight: 800; line-height: 1.5; white-space: nowrap; flex-shrink: 0; }

/* 데이터 관리 영역: 목록과 5개 버튼 한 줄 정렬 */
.data-mgr-grid {
    display: grid;
    grid-template-columns: 1fr 1.45fr;
    gap: 14px;
    align-items: end;
}
.data-mgr-actions {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}
.data-mgr-actions .btn {
    padding: 0 6px;
    white-space: nowrap;
    font-size: 12px;
}

.wps-sec-title {
    background-color: #111111;
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 800;
    padding: 5px 10px;
    margin-top: 12px;
    margin-bottom: 0;
    letter-spacing: 0.3px;
}

.wps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    color: #111111;
}
.wps-table th, .wps-table td {
    border: 1px solid #343a40;
    padding: 6px 8px;
    text-align: left;
    vertical-align: middle;
}
.wps-table th {
    background-color: #f1f3f5;
    font-weight: 800;
    width: 22%;
}
.wps-table.center th, .wps-table.center td {
    text-align: center;
    width: auto;
}

.wps-highlight-box {
    border: 1.5px solid #ff7f00;
    background-color: #fff4e6;
    padding: 10px 12px;
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.5;
}

.wps-sign-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1px solid #343a40;
    margin-top: 16px;
}
.wps-sign-cell {
    border-right: 1px solid #343a40;
    padding: 8px 10px;
    min-height: 70px;
    font-size: 11.5px;
}
.wps-sign-cell:last-child { border-right: none; }
.wps-sign-role { font-weight: 800; border-bottom: 1px dashed #adb5bd; padding-bottom: 4px; margin-bottom: 24px; }

/* 도움말 모달 */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-box {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border-strong);
    border-radius: 14px;
    max-width: 560px;
    width: 100%;
    max-height: 82vh;
    overflow-y: auto;
    padding: 20px 22px;
}
.modal-box h3 { font-size: 17px; font-weight: 900; margin-bottom: 12px; }
.modal-box p, .modal-box li { font-size: 13px; line-height: 1.6; color: var(--text-primary); }
.modal-box ul { padding-left: 18px; margin: 8px 0 14px 0; }

/* 반응형 */
@media (max-width: 720px) {
    .main-container { padding: 12px; }
    .two-col-grid, .three-col-grid, .four-col-grid, .summary-grid, .data-mgr-grid { grid-template-columns: 1fr; }
    .data-mgr-actions { grid-template-columns: repeat(3, 1fr); }
    .wps-page { padding: 14px; }
    .wps-doc-header { flex-direction: column; align-items: flex-start; gap: 6px; }
    .wps-doc-meta { text-align: left; white-space: normal; }
}

/* 도움말 모달 섹션별 아코디언 접기/펼치기 */
.help-acc {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 8px;
    background: var(--bg-soft);
    overflow: hidden;
}
.help-acc summary {
    cursor: pointer;
    padding: 9px 12px;
    font-weight: 800;
    font-size: 13px;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.help-acc summary::-webkit-details-marker { display: none; }
.help-acc summary::after {
    content: '▼';
    font-size: 11px;
    color: var(--pro-orange);
    transition: transform 0.15s ease;
}
.help-acc[open] summary::after {
    transform: rotate(180deg);
}
.help-acc-body {
    padding: 8px 14px 10px 14px;
    border-top: 1px solid var(--border-light);
    background: #ffffff;
}
.help-acc-body ul {
    margin: 4px 0 0 16px;
}
