/* ═══════════════════════════════════════════════════════════════
   KNG ERP High-Density Spreadsheet Grid Design System
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. 그리드 외부 스크롤 래퍼 ── */
.erp-grid-wrapper {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 0 !important;
    overflow-x: auto !important;
    overflow-y: auto;
    min-height: 140px;
    width: 100% !important;
    box-sizing: border-box !important;
    position: relative;
}

/* ── 2. 엑셀/ERP 플랫 시트 테이블 기본 ── */
.erp-sheet-table {
    width: 100%;
    max-width: none;
    border-collapse: collapse !important;
    font-size: 12px;
    table-layout: fixed !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    border: 1px solid #cbd5e1 !important;
    background-color: #cbd5e1 !important;
}

/* ── 3. 헤더 (Sticky Top, 26px 고밀도) ── */
.erp-sheet-table thead th {
    background-color: #f8fafc !important;
    background-clip: padding-box !important;
    color: #1e293b !important;
    font-weight: 700 !important;
    text-align: center !important;
    vertical-align: middle !important;
    padding: 2px 4px !important;
    font-size: 11.5px !important;
    border: 1px solid #cbd5e1 !important;
    white-space: nowrap !important;
    position: sticky !important;
    top: 0;
    z-index: 6;
    height: 26px !important;
    line-height: 1.2 !important;
    box-sizing: border-box !important;
    user-select: none;
    overflow: visible !important;
}

/* 행 번호(No.) 전용 헤더 */
.erp-sheet-table thead th.th-no,
.erp-sheet-table thead th.chk-col {
    text-align: center !important;
    vertical-align: middle !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 26px !important;
    line-height: 26px !important;
}

/* ── 4. 본문 데이터 셀 (26px 초고밀도 플랫 셀) ── */
.erp-sheet-table tbody td {
    padding: 0 !important;
    border: 1px solid #cbd5e1 !important;
    vertical-align: middle !important;
    background-color: #ffffff;
    background-clip: padding-box !important;
    height: 26px !important;
    box-sizing: border-box !important;
    font-size: 12px;
    color: #1e293b;
}

/* 텍스트 패딩용 헬퍼 셀 */
.erp-sheet-table tbody td.px-cell {
    padding: 1px 6px !important;
}

/* 행 번호 셀 */
.erp-sheet-table tbody td.row-index {
    text-align: center !important;
    vertical-align: middle !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 26px !important;
    line-height: 26px !important;
    color: #64748b !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    background-color: #f8fafc !important;
}

/* 읽기 전용 / 비활성 셀 */
.erp-sheet-table tbody td.td-readonly,
.erp-sheet-table tbody td:has(.bg-readonly),
.erp-sheet-table tbody td:has([readonly]),
.erp-sheet-table tbody td:has([disabled]) {
    background-color: #f8fafc !important;
    background-clip: padding-box !important;
}

/* 행 마우스 호버 효과 */
.erp-sheet-table tbody tr:hover td {
    background-color: #f1f5f9;
}
.erp-sheet-table tbody tr:hover td.td-readonly,
.erp-sheet-table tbody tr:hover td:has(.bg-readonly) {
    background-color: #edf2f7 !important;
}

/* 활성 셀(Focus) 엑셀 파란색 하이라이트 */
.erp-sheet-table tbody td:focus-within {
    box-shadow: inset 0 0 0 2px #2563eb !important;
    background-color: #eff6ff !important;
    position: relative !important;
    z-index: 5 !important;
}

/* ── 5. 셀 내부 일체형 인풋 필드 ── */
.erp-cell-input {
    width: 100% !important;
    height: 100% !important;
    min-height: 25px;
    border: none !important;
    outline: none !important;
    padding: 1px 6px !important;
    font-size: 12px !important;
    background: transparent !important;
    background-color: transparent !important;
    color: #1e293b;
    text-align: left;
    border-radius: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
}
.erp-cell-input:focus {
    box-shadow: none !important;
    outline: none !important;
    background: transparent !important;
}
.erp-cell-input.text-end { text-align: right !important; }
.erp-cell-input.text-center { text-align: center !important; }
.erp-cell-input[readonly], .erp-cell-input[disabled], .erp-cell-input.bg-readonly {
    background: transparent !important;
    color: #475569 !important;
    cursor: default !important;
}

/* 셀 내부 인라인 드롭다운 */
.erp-sheet-table select.erp-cell-select {
    width: 100% !important;
    height: 25px !important;
    border: none !important;
    outline: none !important;
    padding: 0 4px !important;
    font-size: 11.5px !important;
    background-color: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: #1e293b;
}

/* ── 6. 엑셀식 마우스 열 너비 조절 핸들러 (Column Resizer) ── */
/* ── 6. 엑셀식 마우스 열 너비 조절 핸들러 (Column Resizer) ── */
body.erp-resizing,
body.erp-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

.col-resizer {
    position: absolute;
    top: 0;
    right: -4px;
    width: 9px;
    height: 100%;
    cursor: col-resize !important;
    user-select: none;
    z-index: 30;
    display: flex;
    justify-content: center;
    align-items: center;
}
.col-resizer::after {
    content: '';
    width: 2px;
    height: 100%;
    background-color: transparent;
    transition: background-color 0.12s ease;
}
.col-resizer:hover::after,
.col-resizer.is-resizing::after {
    background-color: #2563eb;
    box-shadow: 0 0 3px rgba(37, 99, 235, 0.5);
}

/* ── 7. 하단 고정 서머리 바 (tfoot) ── */
.erp-sheet-table tfoot td {
    padding: 3px 6px !important;
    background-color: #f8fafc !important;
    background-clip: padding-box !important;
    border: 1px solid #cbd5e1 !important;
    font-size: 12px;
    font-weight: 700;
    vertical-align: middle !important;
    height: 26px !important;
    color: #0f172a;
}

/* ── 8. 콤팩트 그리드 툴바 & 툴 버튼 ── */
.erp-grid-toolbar {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-bottom: none;
    padding: 3px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11.5px;
    box-sizing: border-box;
}
.erp-tool-btn {
    height: 22px;
    font-size: 11px;
    font-weight: 600;
    padding: 0 8px;
    border-radius: 2px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #334155;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    transition: all 0.1s ease;
    white-space: nowrap;
}
.erp-tool-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}
.erp-tool-btn.btn-primary-erp {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}
.erp-tool-btn.btn-primary-erp:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

/* ── 9. 그리드 내 액션 버튼 ── */
.btn-grid-action {
    height: 22px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 0 6px !important;
    border-radius: 2px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    white-space: nowrap;
}

/* ── 10. 아코디언 행 및 토글 아이콘 ── */
.accordion-icon {
    font-size: 1.15rem;
    vertical-align: middle;
    transition: transform 0.2s ease, color 0.2s ease;
    display: inline-block;
}
.accordion-icon.rotate-90 {
    transform: rotate(90deg);
}
.accordion-sub-row {
    background-color: #f8fafc !important;
}

/* ── 11. 인쇄 미디어 쿼리 ── */
@media print {
    .erp-grid-toolbar,
    .col-resizer {
        display: none !important;
    }
    .erp-grid-wrapper {
        border: none !important;
        overflow: visible !important;
    }
    .erp-sheet-table {
        border: 1px solid #000000 !important;
    }
    .erp-sheet-table th,
    .erp-sheet-table td {
        border: 1px solid #000000 !important;
    }
}
