:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #0ea5e9;
    --bg-app: #f1f5f9;
    --bg-grid: #ffffff;
    --border: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --radius: 4px;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    font-family: 'Noto Sans KR', 'Inter', -apple-system, system-ui, sans-serif;
}

/* 텍스트 선택 허용 설정 */
body {
    user-select: text !important;
    -webkit-user-select: text !important;
}

/* 버튼, 탭, 아이콘 등 UI 컨트롤 요소는 선택 방지 (사용성 개선) */
button,
.btn,
.tab-btn,
.tree-icon,
.tree-toggle,
.top-bar,
.tabs,
.tree-toggle span,
.filter-group-header b,
.filter-group-header strong {
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* 데이터가 담긴 인풋 필드는 읽기 전용이어도 텍스트 커서 표시 및 선택 허용 */
.data-grid input,
.data-grid select,
.data-grid td,
.data-grid span {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    cursor: text !important;
    pointer-events: auto !important;
}

.data-grid input[readonly] {
    background-color: transparent;
}

.noselect {
    user-select: none !important;
    -webkit-user-select: none !important;
}

body {
    font-family: 'Noto Sans KR', 'Inter', -apple-system, system-ui, sans-serif;
    color: var(--text-main);
    background: var(--bg-app);
    margin: 0;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* TOP BAR */
.top-bar {
    background: #ffffff;
    padding: 0 16px 8px 16px;
    border-bottom: 2px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.top-bar-first {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
}

.top-bar-second {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.top-left {
    flex-shrink: 0;
}

.top-center.actions-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.top-right.actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-wrap: wrap;
}

.tabs {
    display: flex;
    gap: 4px;
    background: transparent;
    padding: 0;
}

.tab-btn {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 600;
    color: #475569;
    font-size: 12px;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.tab-btn.active {
    background: #4a90e2;
    color: #fff;
    border-color: #4a90e2;
}

/* Actions moved to top-right.actions in top-bar section */

.search-box input {
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    width: 180px;
    outline: none;
    background: #fff url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg>') 8px center no-repeat;
    transition: all 0.2s;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.btn {
    padding: 6px 14px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.btn-special-add {
    background: #06b6d4;
    /* Cyan */
    color: #fff;
    border: none;
    padding: 8px 20px;
}

.btn-special-add:hover {
    background: #0891b2;
}

.btn-duplicate {
    background: #a855f7;
    /* Purple */
    color: #fff;
    border: none;
    padding: 8px 20px;
}

.btn-duplicate:hover {
    background: #9333ea;
}

#btn-mail-copy {
    background: #0ea5e9 !important;
    /* Blue */
    color: #fff !important;
    border: none !important;
    padding: 8px 20px;
}

#btn-mail-copy:hover {
    background: #0284c7 !important;
}

#btn-arrival-check {
    background: #f59e0b !important;
    /* Orange */
    color: #fff !important;
    border: none !important;
    padding: 8px 20px;
}

#btn-arrival-check:hover {
    background: #d97706 !important;
}

.btn-print-main {
    background: #1e293b;
    color: #fff;
    border-color: #1e293b;
}

.btn-print-main:hover {
    background: #0f172a;
}

.search-box input {
    height: 38px;
    width: 250px;
    padding: 0 12px 0 35px;
    border: 2px solid #e2e8f0;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    outline: none;
}

.btn-edit-toggle {
    background: #f59e0b;
    color: #fff;
    border-color: #f59e0b;
}

.btn-edit-toggle.locked {
    background: #64748b;
}

.data-grid.locked input,
.data-grid.locked select {
    pointer-events: none;
    color: #64748b;
    background: #fbfcfd;
}

/* Locked row behavior: inputs don't capture clicks */
.data-grid tr.locked-row td {
    cursor: pointer;
}

.data-grid tr.locked-row input,
.data-grid tr.locked-row select {
    pointer-events: none;
    border: none;
    background: transparent;
    color: var(--text-main);
}

/* Selected row highlight */
.data-grid tr.selected {
    background: #f0f7ff !important;
    box-shadow: inset 4px 0 0 var(--primary);
}

.data-grid tr.selected td {
    background: transparent !important;
}

.data-grid tr:hover {
    background: #f8fafc;
}

/* MAIN LAYOUT */
.main-layout {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

.input-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    transition: margin-right 0.3s ease;
    min-width: 0;
    /* Prevent expansion by wide children */
}

.table-container {
    flex: 1;
    overflow-x: scroll;
    overflow-y: auto;
    padding: 0;
    min-width: 0;
    position: relative;
}

.data-grid {
    min-width: 100%;
    width: max-content;
    border-collapse: collapse;
    font-size: 13px;
}

.data-grid th {
    background: #4a90e2 !important;
    border-bottom: 2px solid #357ebd;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 2px;
    font-weight: 700;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 20;
    color: #ffffff;
    font-size: 13px;
    letter-spacing: -1px;
    user-select: none;
    white-space: nowrap;
}

.header-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1px 0;
    gap: 3px;
    /* 간격 축소 */
}

.header-name {
    width: 90%;
    display: block;
    text-align: center;
    font-weight: 700;
    margin-bottom: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.5px;
}

.header-btns {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding-top: 1px;
}

.header-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    width: 17px;
    /* 크기 축소 */
    height: 17px;
    /* 높이 약간 조절 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    /* 아이콘 폰트 크기 축소 */
    cursor: pointer;
    color: rgba(255, 255, 255, 0.9);
    padding: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.header-btn.active {
    background: #ffffff;
    color: var(--primary);
    border-color: #ffffff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

/* Column Resizer Style */
.resizer {
    position: absolute;
    right: -4px;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 10;
}

.resizer:hover {
    background: rgba(59, 130, 246, 0.4);
}

/* 필터 버튼 활성화 시 색상 차별화 (선택사항) */
.filter-btn.active {
    background: #ec4899;
    /* 핑크계열로 필터와 정렬 구분 */
    border-color: #ec4899;
}

.data-grid td {
    border-bottom: 1px solid #e8ecf1;
    border-right: 1px solid #f1f5f9;
    padding: 0;
    vertical-align: middle;
    background: #fff;
    white-space: nowrap;
}

.data-grid td.action-cell {
    width: 65px;
    text-align: center;
    padding: 2px 4px;
    background: #f8fafc !important;
}

.btn-inline-edit,
.btn-inline-save,
.btn-inline-delete {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

.btn-inline-edit {
    background: #ffffff;
    color: #475569;
}

.btn-inline-save {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.btn-inline-delete {
    background: #ffffff;
    color: #ef4444;
    border-color: #fee2e2;
}

.btn-inline-edit:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.btn-inline-save:hover {
    background: #059669;
}

.btn-inline-delete:hover {
    background: #fee2e2;
    border-color: #ef4444;
}

/* .status-badge 정의는 하단 공통 영역(2341번 라인 부근)으로 통합됨 */

.text-green-bold {
    color: #059669 !important;
    background: #ecfdf5 !important;
    border: 1px solid #10b981 !important;
    font-weight: 900 !important;
}

.status-mail-sent {
    background: #0284c7;
}

.status-received {
    background: #16a34a;
}

.status-draft {
    background: #94a3b8;
}

.status-request {
    background: #f59e0b;
}

/* 샘플입하 전용 상태 색상 */
.status-arrival-pending {
    background: #f59e0b;
    /* Amber */
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.status-arrival-completed {
    background: #0369a1;
    /* Deep Blue (MES 스타일과 통일) */
    box-shadow: 0 2px 4px rgba(3, 105, 161, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-default {
    background: #64748b;
}

/* 부품폐기 전용 상태 색상 */
.status-pending {
    background: #eab308; /* Yellow-500 */
    color: #000 !important; /* 검은색 글씨로 시인성 향상 */
    box-shadow: 0 2px 4px rgba(234, 179, 8, 0.2);
}

.status-completed {
    background: #10b981;
    /* Emerald/Green */
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

/* 전표작성완료 전용 상태 색상 */
.status-invoice-completed {
    background: #3b82f6; /* Blue-500 */
    color: #000 !important;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn-inline-calc {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border: 1px solid #4338ca;
    background: #4f46e5;
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-inline-calc:hover {
    background: #4338ca;
    border-color: #3730a3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.data-grid tr:hover td {
    background: #f0f6fc;
}

.data-grid tr.selected {
    background: #e6f2ff !important;
}

.data-grid tr.selected td {
    background: #e6f2ff !important;
    border-bottom-color: #b3d4fc;
}

.data-grid tr.editing-row {
    background: #fffbeb !important;
}

.data-grid tr.editing-row td {
    background: #fffbeb !important;
    border-bottom-color: #fcd34d;
}

/* [추가] 샘플의뢰 상태별 행 스타일 */
.data-grid tr.row-delayed td[data-col="status"] {
    background: #fee2e2 !important;
}

.data-grid tr.row-completed td[data-col="status"] {
    background: #dcfce7 !important;
}

.data-grid input {
    width: 100%;
    min-width: 50px;
    /* 최소 너비 확보하여 찌러짐 방지 */
    height: 36px;
    /* 42px -> 36px로 축소 */
    border: 1px solid transparent;
    padding: 2px 1px;
    /* 패딩 추가 축소 */
    box-sizing: border-box;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    /* 폰트 약간 축소 */
    font-weight: 500;
    outline: none;
    text-align: center;
    transition: all 0.2s;
    border-radius: 4px;
}

.data-grid select {
    width: 100%;
    min-width: 50px;
    height: 36px;
    border: 1px solid transparent;
    padding: 2px 4px;
    box-sizing: border-box;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    text-align: center;
    text-align-last: center;
    /* select 텍스트 중앙 정렬 강화 */
    transition: all 0.2s;
    border-radius: 4px;
    appearance: none;
    /* 브라우저 기본 화살표 제거 */
    -webkit-appearance: none;
    cursor: pointer;
}

/* [추가] 신규LIST 상태 뱃지 컴팩트 스타일 */
.data-grid select.status-badge-compact,
.data-grid span.status-badge-compact {
    width: 55px !important;
    min-width: 55px !important;
    max-width: 55px !important;
    height: 20px !important;
    padding: 0 4px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 20px !important;
    border-radius: 10px !important;
    border: none !important;
    color: #000 !important;
    text-align: center !important;
    text-align-last: center !important;
    display: inline-block !important;
    box-sizing: border-box !important;
    cursor: pointer;
}

/* 호버 시에만 선택창임을 알 수 있게 미세한 배경색 부여 */
.data-grid select:hover {
    background: rgba(0, 0, 0, 0.03);
}

/* Editing State Styling */
.data-grid tr.editing-row input,
.data-grid tr.editing-row select {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
}

.data-grid tr.editing-row input:hover,
.data-grid tr.editing-row select:hover {
    border-color: var(--primary);
}

.data-grid input:focus,
.data-grid select:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    z-index: 10;
}

/* Date Input Wrapper and Icon */
.date-input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.date-input-container input[type="date"] {
    padding-right: 30px !important;
    text-align: left !important;
    padding-left: 8px !important;
}

/* Hide native icon to prevent duplication with custom icon */
.date-input-container input[type="date"]::-webkit-calendar-picker-indicator {
    display: none !important;
}

.date-input-container input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.calendar-icon-btn {
    position: absolute;
    right: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
    user-select: none;
    display: none;
    /* Only show in editing mode */
}

tr.editing-row .calendar-icon-btn {
    display: block;
}

/* Locked (non-editing) rows styling */
.data-grid tr.locked-row input {
    color: #475569;
    cursor: default;
}

/* 특정 필드 왼쪽 정렬 (가독성 개선) */
.data-grid td[data-col="car_model"] input,
.data-grid td[data-col="part_name"] input,
.data-grid td[data-col="special_notes"] input,
.data-grid td[data-col="change_content"] input {
    text-align: left !important;
}

/* Filter Search UI Additions */
.filter-menu-search {
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
    background-color: #f8fafc;
}

#filter-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 13px;
    transition: all 0.2s;
}

#filter-search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.table-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    font-size: 12px;
    color: var(--text-muted);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

#row-count {
    grid-column: 1;
}

.pagination-container {
    grid-column: 2;
    display: flex;
    gap: 2px;
}

/* Custom Scrollbar Styling (Right Slidebar) */
.table-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-left: 1px solid var(--border);
}

.table-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border: 3px solid #f1f5f9;
    border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.p-btn {
    padding: 5px 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    min-width: 35px;
    transition: all 0.2s;
}

.p-btn:hover:not(:disabled) {
    background: #f1f5f9;
}

.p-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.p-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* MODAL STYLES */
.modal {
    display: none;
    position: fixed;
    z-index: 1001;
    /* Higher than top-bar */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    overflow: hidden;
    /* Prevent modal container scroll */
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: #f1f5f9;
    margin: 0;
    padding: 0;
    border: none;
    width: 95%;
    max-width: 1100px;
    height: 90vh;
    /* Fixed height for modal */
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    position: relative;
    animation: modalAppear 0.3s ease-out;

    /* 크기 조절 기능 공통 */
    resize: both;
    overflow: hidden;
    /* handle scroll in body instead */
    min-width: 400px;
    min-height: 300px;
}

/* 크기 조절 핸들 디자인 */
.modal-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 15px;
    height: 15px;
    cursor: nwse-resize;
    z-index: 1002;
    background: linear-gradient(135deg, transparent 50%, #475569 50%);
    border-bottom-right-radius: 12px;
}

.modal-content::-webkit-resizer {
    background-color: transparent;
}

/* 리사이즈 가능 힌트 (우측 하단 모서리) */
.modal-content::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, #3b82f6 50%);
    border-bottom-right-radius: 12px;
    cursor: nwse-resize;
    opacity: 0.7;
    transition: opacity 0.2s;
    pointer-events: none;
}

.modal-content:hover::after {
    opacity: 1;
}

/* sample_arrival 탭 미리보기 - 가로 모드 최적화 */
.paper.landscape .preview-page-wrapper {
    width: 100% !important;
    max-width: 100%;
    overflow-x: auto;
}

/* sample_arrival 테이블이 모달 크기에 맞게 조정되도록 */
.paper.landscape table {
    max-width: 100%;
    table-layout: auto;
}

#mail-preview-modal .modal-content {
    width: 90vw;
    /* 핸들 잡기 편하게 약간 여유 둠 */
    max-width: none !important;
    /* 가로 크기 제한 완전 해제 */
    margin: 10px auto;
}

#mail-preview-modal .modal-body {
    overflow-x: auto;
    padding: 10px;
}

#mail-preview-modal #mail-preview-table-container {
    overflow-x: auto;
    max-width: 100%;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    background: #1e293b;
    color: #fff;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    flex-shrink: 0;
    cursor: move;
    /* 드래그 가능 표시 */
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.modal-body {
    padding: 0;
    flex: 1;
    /* Take remaining space */
    overflow-y: auto;
    background: #cbd5e1;
}

/* Inspection Modal Styles */
#inspection-modal .modal-content {
    height: auto !important;
    max-height: 95vh;
}

.inspection-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    padding: 0;
}

.insp-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 15px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.insp-row:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.insp-label {
    font-weight: 900;
    font-size: 16px;
    margin-bottom: 18px;
    color: #1e293b;
    letter-spacing: -0.5px;
}

.insp-btns {
    display: flex;
    gap: 6px;
    width: 100%;
    justify-content: center;
}

.btn-toggle {
    flex: 1;
    padding: 10px 0;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    transition: all 0.2s;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-toggle.active-o {
    background: #3b82f6 !important;
    color: white !important;
    border-color: #2563eb !important;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.btn-toggle.active-x {
    background: #ef4444 !important;
    color: white !important;
    border-color: #dc2626 !important;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.modal-body div[contenteditable] img,
.dev-form-table div img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 5px 0;
}

.modal-footer {
    padding: 12px 25px;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.close-modal {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.btn-secondary {
    background: #fff;
    color: #64748b;
    border-color: #cbd5e1;
}

.btn-secondary:hover {
    background: #f1f5f9;
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 15px;
}

.close-drawer {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

#paper-content {
    flex: 1;
    overflow: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.paper {
    width: 210mm;
    min-height: 297mm;
    background: #fff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transform-origin: top center;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 15mm;
    box-sizing: border-box;
    margin-bottom: 50px;
    /* Space for scaling */
}

/* Range Slider Styling */
#zoom-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 6px;
    background: #475569;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

#zoom-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
}

#zoom-value {
    min-width: 40px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #e2e8f0;
}

/* FORM STYLES (Keep existing but refined) */
.doc-header {
    text-align: center;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.doc-title {
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 0.2rem;
}

.dev-form-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 20px;
}

.dev-form-table th,
.dev-form-table td {
    border: 1px solid #000;
    padding: 6px;
}

.label-col {
    background: #f8f9fa;
    font-weight: bold;
    text-align: center;
}

/* FILTER MENU */
.filter-menu {
    position: absolute;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-top: 2px solid var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    width: 200px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.filter-menu-header {
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.filter-menu-header button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 18px;
    color: #94a3b8;
}

.filter-menu-actions {
    padding: 8px;
    display: flex;
    gap: 5px;
    border-bottom: 1px solid #f1f5f9;
}

.filter-menu-actions button {
    flex: 1;
    font-size: 11px;
    padding: 4px;
    cursor: pointer;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
}

.filter-menu-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
}

.filter-menu-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 13px;
    cursor: pointer;
}

.filter-menu-list label:hover {
    background: #f8fafc;
}

.filter-menu-footer {
    padding: 8px;
    border-top: 1px solid #f1f5f9;
}

/* Tree Filter Styles */
.filter-group-header {
    padding: 4px 8px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    border-radius: 4px;
}

.filter-group-header:hover {
    background: #f1f5f9;
}

.tree-icon {
    font-size: 10px;
    width: 12px;
    color: #94a3b8;
}

.filter-item-leaf {
    padding-left: 20px !important;
}

/* 계층적 필터 선택/해제 버튼 (Cascading Filter Buttons) */
.tree-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tree-toggle:hover {
    color: var(--primary);
}

.btn-group-select,
.btn-group-deselect {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-group-select {
    background: #dcfce7;
    color: #16a34a;
    border-color: #86efac;
}

.btn-group-select:hover {
    background: #22c55e;
    color: white;
    border-color: #16a34a;
}

.btn-group-deselect {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

.btn-group-deselect:hover {
    background: #ef4444;
    color: white;
    border-color: #dc2626;
}

.section-title {
    font-weight: bold;
    margin: 10px 0;
    font-size: 14px;
}

.footer-notice {
    margin-top: 20px;
    font-size: 11px;
    color: #444;
}

.inspect-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.inspect-table th,
.inspect-table td {
    border: 1px solid #000;
    padding: 8px;
    text-align: center;
}

.inspect-table th {
    background: #f8f9fa;
    width: 15%;
}

.paper input {
    width: 100%;
    border: 1px solid transparent;
    padding: 4px;
    font-family: inherit;
    font-size: inherit;
    outline: none;
}

.paper input:hover,
.paper input:focus {
    border-color: var(--border);
    background: #fffcf0;
}

.paper textarea {
    width: 100%;
    min-height: 100px;
    resize: none;
    padding: 10px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13px;
    background: transparent;
    box-sizing: border-box;
}

/* Layout Editor Mode Styles */
.modal-content.layout-editing .paper [contenteditable="true"] {
    outline: 1px dashed #2196F3;
    background: rgba(33, 150, 243, 0.05);
    cursor: text;
    min-height: 1.2em;
}

.modal-content.layout-editing .paper [contenteditable="true"]:hover {
    background: rgba(33, 150, 243, 0.1);
}

.modal-content.layout-editing .paper [contenteditable="true"]:focus {
    outline: 2px solid #2196F3;
    background: #fff;
}

.modal-content.layout-editing .paper input,
.modal-content.layout-editing .paper textarea {
    border: 1px dashed #ccc !important;
    background: #f9f9f9 !important;
    pointer-events: none;
}

.modal-content.layout-editing .row-tools {
    position: absolute;
    right: -35px;
    top: 0;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 100;
    padding: 5px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Show row-tools on tr hover or when row-tools itself is hovered */
.modal-content.layout-editing tr:hover .row-tools,
.modal-content.layout-editing .row-tools:hover {
    display: flex;
}

.modal-content.layout-editing .btn-layout-tool {
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 10px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.modal-content.layout-editing .btn-layout-tool:hover {
    background: #f0f0f0;
    border-color: #2196F3;
}

.layout-hint {
    background: #fff3cd;
    color: #856404;
    padding: 10px 15px;
    margin: 10px;
    border-radius: 4px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #ffeeba;
}

/* Cell Resize Tool */
.cell-resize-toolbar {
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px;
    border-radius: 6px;
    display: none;
    gap: 8px;
    align-items: center;
    font-size: 12px;
}

.cell-resize-toolbar.visible {
    display: flex;
}

.cell-resize-toolbar input {
    width: 50px;
    padding: 2px 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.cell-resize-toolbar button {
    padding: 2px 6px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.cell-resize-toolbar button:hover {
    background: #e0e0e0;
}

.modal-content.layout-editing td:hover,
.modal-content.layout-editing th:hover {
    outline: 2px solid #ff9800 !important;
    cursor: alias;
}

@keyframes flash-highlight {
    0% {
        background-color: rgba(33, 150, 243, 0.5);
    }

    100% {
        background-color: transparent;
    }
}

.flash-highlight {
    animation: flash-highlight 1s ease-out;
}

@media print {

    /* 1. Global Reset for Print */
    @page {
        size: auto;
        margin: 10mm !important;
        /* Safety margin for printers */
    }

    html,
    body {
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        background: white !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Remove all box shadows and outlines during print to prevent "ghost" boxes */
    * {
        box-shadow: none !important;
        text-shadow: none !important;
        outline: none !important;
        -webkit-filter: none !important;
        filter: none !important;
    }

    /* 2. Hide everything except the print target */
    body>*:not(#preview-modal) {
        display: none !important;
    }

    #preview-modal.modal {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        width: 100% !important;
        height: auto !important;
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        overflow: visible !important;
        transform: none !important;
    }

    /* Hide modal UI elements from print output */
    .modal-backdrop,
    .modal-header,
    .modal-footer,
    .close-modal,
    #qty-control-container,
    #qty-control-container *,
    #print-controls,
    .zoom-controls,
    #layout-hint-area,
    .no-print,
    .no-print *,
    .header-tools {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    /* 3. Reset internal modal structure for print flow */
    #preview-modal .modal-dialog,
    #preview-modal .modal-content,
    #preview-modal .modal-body,
    #paper-content,
    #paper-actual,
    .preview-container {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: white !important;
        overflow: visible !important;
        transform: none !important;
    }

    /* 4. Page Break Controls */
    .preview-page-wrapper {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        page-break-after: always !important;
        break-after: page !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }

    .preview-page-wrapper:last-of-type {
        page-break-after: auto !important;
        break-after: auto !important;
    }

    /* 5. Input elements styling for print */
    /* 모든 요소의 리사이즈 핸들 및 브라우저 컨트롤 제거 */
    * {
        resize: none !important;
    }

    ::-webkit-resizer {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

    input,
    textarea,
    select {
        border: none !important;
        background: transparent !important;
        color: black !important;
        font-family: inherit !important;
        font-size: inherit !important;
        padding: 0 !important;
        margin: 0 !important;
        appearance: none !important;
        -webkit-appearance: none !important;
        resize: none !important;
    }

    /* 부품폐기/거래명세서 등 A4 한 페이지 규격 강제 및 빈페이지 방지 */
    .print-container {
        width: 100% !important;
        max-width: 210mm !important;
        height: auto !important;
        max-height: 295mm !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 2mm 5mm !important;
        /* 상단 여백 축소 */
        position: relative !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* 단일 페이지 출력물인 경우 강제 페이지 넘김 무효화 */
    .preview-page-wrapper {
        page-break-after: auto !important;
        break-after: auto !important;
        height: auto !important;
        width: 100% !important;
        max-height: 297mm !important;
        /* A4 Height limit */
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .preview-page-wrapper:not(:last-child) {
        page-break-after: always !important;
        break-after: page !important;
    }

    /* Ensure no content leaks after the main paper */
    .paper {
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }
}

/* Table styling for print - Match Screen */
.dev-form-table {
    width: 100% !important;
    border-collapse: collapse !important;
    border: 2px solid #000 !important;
    table-layout: fixed !important;
}

.dev-form-table td,
.dev-form-table th {
    border: 1px solid #000 !important;
    background: transparent !important;
    /* Fix border clipping */
    color: black !important;
}

/* Ensure inputs/textareas are visible and clean in print */

/* Increase visibility of label columns in print */
.label-col {
    background-color: #eee !important;
    font-weight: 900 !important;
    /* Extra bold for print */
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

/* Ensure text is sharp and dark */
.paper * {
    color: black !important;
    border-color: black !important;
}

/* Hide input decorations during print */
.paper input,
.paper textarea,
.paper select {
    border: none !important;
    background: transparent !important;
    padding: 2px !important;
    appearance: none;
    -webkit-appearance: none;
    color: black !important;
    font-weight: bold !important;
    width: 100% !important;
}

.paper textarea {
    height: auto !important;
    overflow: visible !important;
}

/* Ensure background colors/images print */
* {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

/* Inspector Opinion box specific fix */
.inspector-opinion-table {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    border: 2px solid #000 !important;
    overflow: visible !important;
}

.inspector-opinion-table td {
    border: 2px solid #000 !important;
}

/* Multi-print 50% height split */
.half-page {
    height: 148.5mm !important;
    /* Half of A4 (297mm) */
    min-height: 148.5mm !important;
    max-height: 148.5mm !important;
    page-break-inside: avoid;
    page-break-after: auto;
    border-bottom: none !important;
    overflow: hidden !important;
    position: relative;
}

.half-page .doc-header {
    margin-bottom: 8px !important;
    padding-bottom: 5px !important;
}

.half-page .doc-title {
    font-size: 1.5rem !important;
}

.half-page .section-title {
    margin: 10px 0;
    font-size: 14px !important;
}

.half-page .dev-form-table {
    margin-bottom: 8px !important;
    font-size: 14px !important;
}

.half-page .dev-form-table td {
    padding: 5px;
    /* Slightly more breathable than 4px */
}

/* CRITICAL: Ensure nested table containers have NO padding */
.half-page .dev-form-table td.no-padding {
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.half-page .dev-form-table td table {
    border: none !important;
    margin: 0 !important;
    border-collapse: collapse !important;
}

.half-page .footer-notice {
    margin-top: 10px;
}

/* === 스크롤바 숨김 및 추가 인쇄 스타일 (통합됨) === */

/* Hide all browser scrollbars during print */
::-webkit-scrollbar {
    display: none !important;
}

html,
body {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
    width: 100% !important;
}

#preview-modal .modal,
#preview-modal .modal-content {
    overflow: visible !important;
}

/* Change detail boxes in print */
.change-detail-box {
    height: auto !important;
    min-height: 240px;
    overflow: visible !important;
    max-width: 100% !important;
}

.change-detail-box img {
    max-width: 100% !important;
    height: auto !important;
}

/* Remove fixed height constraint for landscape prints */
#paper-actual {
    height: auto !important;
    min-height: auto !important;
}


/* 택배주소 탭 인쇄 시 추가 스타일 (Merged from bottom) */
.paper.landscape {
    width: 277mm !important;
    /* A4 landscape width (297mm - 20mm margin) */
    min-height: 190mm !important;
    /* A4 landscape height (210mm - 20mm margin) */
}

.delivery-invoice-grid {
    grid-gap: 0;
}

.invoice-label {
    page-break-inside: avoid;
}

/* 다중 인쇄 시 각 항목을 개별 A4 페이지로 강제 분리 */
.preview-page-wrapper {
    page-break-after: always !important;
    page-break-inside: avoid !important;
    break-after: page !important;
    display: block !important;
    width: 100% !important;
    /* 기존 양식 높이(절반)를 유지하되 다음 페이지로 넘김 */
    margin-bottom: 0 !important;
    overflow: hidden !important;
    /* Prevent extra page triggers */
}

/* 마지막 항목은 다음 페이지를 생성하지 않음 */
.preview-page-wrapper:last-of-type {
    page-break-after: auto !important;
    break-after: auto !important;
}

/* 다중 인쇄 시 메인 컨테이너는 높이 제한을 하지 않아야 여러 장이 나옴 */
#paper-content.preview-item {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Fix for unnaturally large checkboxes due to generic input styling */
.data-grid input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    padding: 0 !important;
    margin: 0 auto !important;
    display: block !important;
    cursor: pointer;
    box-shadow: none !important;
}

.data-grid th input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    cursor: pointer;
    margin: 0 auto;
    display: block;
}

.half-page {
    position: relative;
    border-bottom: none;
    background: #fff;
}

/* Ensure input modals are always above preview modal */
#inspection-modal,
#change-content-modal {
    z-index: 20000 !important;
}

/* --- Image Resizing in Change Content Modal --- */
.editable-area img,
.change-detail-box img {
    cursor: nwse-resize;
    transition: outline 0.2s;
    user-select: none;
    -webkit-user-drag: none;
    display: inline-block;
    vertical-align: top;
    position: relative;
    max-width: 100% !important;
    /* Ensure image never exceeds container width */
}

.editable-area img:hover {
    outline: 2px solid #3b82f6;
}

.editable-area img.selected-img {
    outline: 3px solid #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    z-index: 10;
}

/* Print refinements - 첫 번째 @media print 블록에 통합됨 */

/* Delivery Invoice Labels */
/* 택배주소 탭: A4 가로(landscape) 출력 설정 - @page 규칙은 전역 스코프에서 정의 */
@page landscape-page {
    size: A4 landscape;
    margin: 5mm;
}

.paper.landscape {
    page: landscape-page;
}

.delivery-invoice-grid {
    display: grid;
    gap: 0;
    width: 100%;
    margin: 0;
    padding: 0;
}

.delivery-invoice-grid.split-4 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 5mm;
    width: 100%;
    height: auto;
    min-height: 180mm;
    margin: 0;
    align-content: stretch;
    justify-content: stretch;
    box-sizing: border-box;
}

/* ... split-8 removed or kept if needed, but focusing on split-4 optimization ... */
.delivery-invoice-grid.split-8 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(4, auto);
}

.invoice-label {
    border: none;
    padding: 0.5mm;
    /* Small buffer to prevent table border clipping */
    box-sizing: border-box;
    overflow: visible;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Adjust sizes for A4 splits (Landscape A4: 297x210) */
.split-4 .invoice-label {
    width: 100%;
    height: 100%;
    margin: 0;
}

.invoice-table {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    border: 2px solid #000;
}

/* Landscape Paper Mode */
.paper.landscape {
    width: 297mm !important;
    min-height: 210mm !important;
    padding: 10mm !important;
    /* Increased padding to prevent edge clipping */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}


.invoice-table td,
.invoice-table th {
    border: 1px solid #000;
    padding: 8px;
    word-break: keep-all;
    overflow-wrap: break-word;
    vertical-align: middle;
}

.label-header-side {
    width: 45px !important;
    background: #f1f5f9;
    font-size: 18px;
    font-weight: 900;
    text-align: center;
    vertical-align: middle;
    line-height: 1.4;
    white-space: pre-wrap;
    border-right: 2px solid #000 !important;
}

.receiver-company {
    font-size: 23px;
    /* Further reduced from 25px */
    /* Reduced by 10% (28px -> 25px) */
    /* Reduced by ~10% for optimization */
    font-weight: 900;
    text-align: center;
    line-height: 1.2;
    word-break: keep-all;
}

.receiver-addr {
    font-size: 18px;
    /* Further reduced from 20px */
    /* Reduced by 10% (22px -> 20px) */
    /* Base size, auto-sized by JS */
    font-weight: 700;
    line-height: 1.3;
    word-break: keep-all;
    overflow-wrap: break-word;
    max-height: 22mm;
    /* Constraint for auto-fitting */
    overflow: hidden;
}

.receiver-phone,
.receiver-contact {
    font-size: 22px;
    /* Reduced from 24px */
    font-weight: 800;
    text-align: center;
}

/* Sender Info slightly smaller but still clear */
.sender-company {
    font-size: 20px;
    font-weight: 800;
    text-align: center;
}

.sender-addr {
    font-size: 16px;
    text-align: left;
    padding-left: 10px !important;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.sender-phone,
.sender-name {
    font-size: 18px;
    text-align: center;
    font-weight: 600;
}

.receiver-phone,
.receiver-contact {
    font-size: 1em;
    text-align: center;
}

/* 8-split specific font size adjustments to prevent clipping */
.split-8 .receiver-company {
    font-size: 1.1em;
}

.split-8 .receiver-addr {
    font-size: 0.85em;
}

.split-8 td,
.split-8 th {
    font-size: 12px;
}

.divider-line td {
    border: none !important;
    padding: 0 !important;
    height: 2px !important;
    background: #000;
}


/* 개별 인쇄 수량 설정 패널 스타일 */
.print-qty-panel {
    margin: 15px;
    padding: 15px 20px;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: block;
    /* 화면에서 보이도록 설정 */
}

.print-qty-panel h4 {
    margin: 0 0 15px 0;
    font-size: 15px;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.print-qty-item {
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
    transition: all 0.2s;
}

.print-qty-item:hover {
    border-color: #4a90d9;
    background: #f0f7ff;
}

.print-qty-item .name {
    font-weight: 700;
    font-size: 13.5px;
    color: #334155;
    flex: 1;
}

.print-qty-item input {
    width: 60px;
    padding: 6px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    text-align: center;
    font-weight: 800;
    color: #2563eb;
}

/* Toast Notification */
.toast-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    opacity: 0;
    font-weight: 500;
}

.toast-message.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}


/* 화면에서 보이는 설정 패널 디자인 (더 작고 깔끔하게) */
.print-qty-panel {
    margin: 10px;
    padding: 10px 15px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: block;
}

.print-qty-panel h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #475569;
    font-weight: 700;
}

.print-qty-item {
    background: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 150px;
}

.print-qty-item .name {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
}

.print-qty-item input {
    width: 45px;
    padding: 3px;
    font-size: 13px;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    text-align: center;
    font-weight: 700;
    color: #2563eb;
}


/* 상태 뱃지 스타일 (모든 탭 공통 컴팩트 크기 적용) */
.status-badge {
    width: 55px !important;
    min-width: 55px !important;
    max-width: 55px !important;
    height: 20px !important;
    padding: 0 4px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 20px !important;
    border-radius: 10px !important;
    border: none !important;
    color: #000 !important;
    text-align: center !important;
    display: inline-block !important;
    box-sizing: border-box !important;
    letter-spacing: -0.5px;
    box-shadow: none !important;
}

/* 메일발송 (완료됨 - 초록/에메랄드 계열) */
.status-mail-sent {
    background: #059669;
    /* 에메랄드 그린 */
}

/* 발주작성 (회색 - 구분감 확보) */
.status-draft {
    background: #64748b;
    /* 슬레이트 그레이 */
}

/* 사진에서 붉은색 배경은 row 자체의 배경색(선택됨/지연됨 등)일 가능성이 큼. 뱃지는 파란색 유지. */

/* 입고완료 (녹색) */
.status-received {
    background: #16a34a;
}

/* 입고요청 (주황색) */
.status-request {
    background: #ea580c;
}

.status-default {
    background: #64748b;
}

/* ======================= */
/* 로그인/인증 관련 스타일 */
/* ======================= */

/* 로그인 영역 (탭 좌측) */
.login-area {
    display: flex;
    align-items: center;
    padding-right: 16px;
    border-right: 1px solid #e2e8f0;
    margin-right: 16px;
}

.btn-login {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    padding: 8px 20px;
    font-weight: 700;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-login:hover {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* 사용자 정보 영역 */
.user-info-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 16px;
    border-right: 1px solid #e2e8f0;
    margin-right: 16px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    padding: 6px 14px;
    border-radius: 50px;
    border: 1px solid #bbf7d0;
}

.user-icon {
    font-size: 18px;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-weight: 700;
    font-size: 13px;
    color: #166534;
}

.user-role-text {
    font-size: 10px;
    color: #22c55e;
    font-weight: 600;
}

.btn-logout {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

/* 로그인 모달 */
.login-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.login-modal-content {
    background: white;
    border-radius: 16px;
    padding: 0;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: loginSlideIn 0.3s ease-out;
    overflow: hidden;
}

.login-modal {
    z-index: 5000 !important;
}

#change-password-modal {
    z-index: 6000 !important;
}

@keyframes loginSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-modal-header {
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    padding: 28px 32px;
    text-align: center;
}

.login-modal-header h2 {
    margin: 0;
    color: white;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.login-form {
    padding: 32px;
}

.login-input-group {
    margin-bottom: 20px;
}

.login-input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
    color: #475569;
}

.login-input-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s;
    box-sizing: border-box;
}

.login-input-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.login-input-group input::placeholder {
    color: #94a3b8;
}

.btn-login-submit {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.btn-login-submit:hover {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3);
}

.btn-login-submit:active {
    transform: translateY(0);
}

.login-modal-footer {
    padding: 16px 32px 24px;
    text-align: center;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.login-modal-footer p {
    margin: 0;
    font-size: 13px;
    color: #64748b;
}

/* 권한 없음 비활성화 스타일 */
.permission-denied {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.permission-denied::after {
    content: '🔒';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
}

/* 수정/삭제 요청 버튼 */
.btn-request {
    background: #fef3c7 !important;
    color: #92400e !important;
    border: 1px solid #f59e0b !important;
    font-size: 11px !important;
}

.btn-request:hover {
    background: #fde68a !important;
}

/* 로그아웃 상태에서 메인 컨텐츠 숨김 */
.main-layout.hidden {
    display: none !important;
}

/* 로그인 필요 안내 오버레이 */
.login-required-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(241, 245, 249, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.login-required-overlay .icon {
    font-size: 64px;
    margin-bottom: 24px;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.login-required-overlay .message {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.login-required-overlay .sub-message {
    font-size: 14px;
    color: #64748b;
}

/* =========================================
   Filter Menu Styles (Improved Visibility)
   ========================================= */
.filter-menu {
    position: absolute;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    min-width: 280px;
    /* 너비 확장 */
    font-size: 13px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-menu-header {
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-menu-header strong {
    color: #0f172a;
    font-size: 14px;
    font-weight: 700;
}

.filter-menu-header button {
    background: none;
    border: none;
    font-size: 20px;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.filter-menu-header button:hover {
    color: #ef4444;
}

.filter-menu-actions {
    padding: 10px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #f1f5f9;
    background: white;
}

.filter-menu-actions button {
    flex: 1;
    padding: 8px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    transition: all 0.2s;
}

.filter-menu-actions button:hover {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #cbd5e1;
}

/* Group Checkbox (Custom Toggle) */
.group-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.custom-checkbox-label {
    display: block;
    position: relative;
    padding-left: 24px;
    cursor: pointer;
    font-size: 0;
    user-select: none;
    height: 24px;
    width: 24px;
}

/* Hide the browser's default checkbox */
.custom-checkbox-label input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Create a custom checkbox */
.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 24px;
    width: 24px;
    background-color: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    transition: all 0.2s;
}

/* On mouse-over, add a grey background color */
.custom-checkbox-label:hover input~.checkmark {
    background-color: #f1f5f9;
    border-color: #94a3b8;
}

/* When the checkbox is checked, add a blue background */
.custom-checkbox-label input:checked~.checkmark {
    background-color: #3b82f6;
    border-color: #2563eb;
}

/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

/* Show the checkmark when checked */
.custom-checkbox-label input:checked~.checkmark:after {
    display: block;
}

/* Style the checkmark/indicator */
.custom-checkbox-label .checkmark:after {
    left: 9px;
    top: 5px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.filter-menu-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px 0;
}

.filter-menu-list::-webkit-scrollbar {
    width: 8px;
}

.filter-menu-list::-webkit-scrollbar-track {
    background: transparent;
}

.filter-menu-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.filter-item-leaf {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    gap: 10px;
    transition: background 0.15s;
    user-select: none;
}

.filter-item-leaf:hover {
    background: #f1f5f9;
}

.filter-item-leaf input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #3b82f6;
    cursor: pointer;
}

.filter-item-leaf span {
    font-size: 13px;
    color: #334155;
    font-weight: 500;
}

.filter-group-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #f8fafc;
    margin-bottom: 2px;
    border-radius: 6px;
    margin: 4px 12px;
    /* 여백 조정 */
    border: 1px solid #f1f5f9;
}

.year-group>.filter-group-header {
    background-color: #f1f5f9;
    border-color: #e2e8f0;
}

.month-group>.filter-group-header {
    background-color: #ffffff;
    border-color: #f1f5f9;
    margin-left: 20px;
    /* 들여쓰기 */
}

.tree-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1e293b;
    font-size: 13px;
    font-weight: 600;
}

.tree-toggle:hover {
    color: #3b82f6;
}

.tree-icon {
    font-size: 10px;
    color: #94a3b8;
    width: 14px;
    text-align: center;
    transition: transform 0.2s;
}

.filter-menu-footer {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.filter-menu-footer .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 800;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.filter-menu-footer .btn-primary:hover {
    background: #2563eb;
}

/* ==========================================
   신규 5개 그룹 탭 및 탭 선택 모달 스타일
   ========================================== */

.main-tabs {
    display: flex;
    gap: 4px;
    background: transparent;
    padding: 0;
}

.main-tab-btn {
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 600;
    color: #475569;
    font-size: 12px;
    transition: all 0.2s;
    display: inline-block;
}

.main-tab-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.main-tab-btn.active {
    background: #4a90e2;
    color: #fff;
    border-color: #4a90e2;
}

/* 탭 선택 모달 (드롭다운 형태로 변경) */
.tab-select-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent; /* 투명하게 하여 드롭다운 외부 클릭 감지용으로만 사용 */
    display: none;
    z-index: 9999;
}

.tab-select-modal-content {
    background: #ffffff;
    width: 320px; /* 드롭다운 형태에 맞게 너비 축소 */
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    position: absolute;
    animation: tabDropdownSlideDown 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top left;
}

@keyframes tabDropdownSlideDown {
    from {
        transform: translateY(-8px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.tab-select-modal-header {
    display: none; /* 드롭다운에서 불필요한 헤더 숨김 */
}

.tab-select-modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.5px;
}

.tab-select-close {
    background: none;
    border: none;
    font-size: 26px;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    padding: 0 4px;
}

.tab-select-close:hover {
    color: #0f172a;
}

.tab-select-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.tab-select-item {
    padding: 16px 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.tab-select-item:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.tab-select-item.active {
    background: #0c3d9c;
    color: #ffffff;
    border-color: #0c3d9c;
    box-shadow: 0 4px 12px rgba(12, 61, 156, 0.3);
}

@keyframes progress-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinner-icon {
    display: inline-block;
    animation: progress-spin 1.5s linear infinite;
}
.row-discarded td,
.row-discarded input,
.row-discarded select,
.row-discarded span,
.row-discarded div {
    text-decoration: line-through !important;
    color: #94a3b8 !important;
}

