/* 물류 데이터 관리 — 공통 스타일
   규칙: 요소 간격 10px / 표 전체 중앙정렬·세로줄 / 전환 150~250ms ease-out / transform·opacity 만 애니메이션 */

:root {
  --accent: #4f46e5;
  --accent-600: #4338ca;
  --accent-50: #eef0fd;
  --accent-100: #e0e3fb;
  --ok: #0f9d6b;
  --warn: #c98a0b;
  --bad: #d64545;
  --info: #2f6fd6;
  --ink: #1b2130;
  --ink-2: #4a5263;
  --ink-3: #7c8496;
  --line: #dde1e8;
  --line-2: #eceef2;
  --bg: #f4f5f8;
  --panel: #ffffff;
  --head: #f1f3f7;
  --radius: 10px;
  --radius-sm: 7px;
  --gap: 10px;
  --shadow: 0 1px 2px rgba(27, 33, 48, .06), 0 2px 8px rgba(27, 33, 48, .04);
  --shadow-lg: 0 12px 32px -8px rgba(27, 33, 48, .22), 0 2px 6px rgba(27, 33, 48, .06);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --z-pop: 1070; --z-toast: 1090; --z-tour: 1080; --z-login: 1100;
  --bs-primary: #4f46e5; --bs-primary-rgb: 79, 70, 229;
  --bs-success: #0f9d6b; --bs-success-rgb: 15, 157, 107;
  --bs-danger: #d64545; --bs-danger-rgb: 214, 69, 69;
  --bs-warning: #e3a21a; --bs-warning-rgb: 227, 162, 26;
  --bs-info: #2f6fd6; --bs-info-rgb: 47, 111, 214;
  --bs-body-color: #1b2130;
  --bs-border-color: #dde1e8;
}

* { font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; }
html { -webkit-font-smoothing: antialiased; }
body {
  background: var(--bg); color: var(--ink);
  height: 100vh; height: 100dvh; margin: 0; overflow: hidden;
  display: flex; flex-direction: column;
  font-size: 14px; letter-spacing: -0.01em;
}
.table, .stat-card h3, .ui-pag, .badge, .cs-label, input { font-variant-numeric: tabular-nums; }
.bi { line-height: 1; vertical-align: -0.125em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 새로고침 잔상 방지: 저장된 탭이 적용되기 전까지 콘텐츠 숨김 */
html.booting .tab-content { visibility: hidden; }

/* ---------- 10px 간격 규칙 ---------- */
.mb-1, .mb-2, .mb-3, .mb-4 { margin-bottom: var(--gap) !important; }
.mt-1, .mt-2, .mt-3, .mt-4 { margin-top: var(--gap) !important; }
.me-1, .me-2 { margin-right: 6px !important; }
.gap-1, .gap-2, .gap-3 { gap: var(--gap) !important; }
.row.g-1, .row.g-2, .row.g-3, .row.g-4 { --bs-gutter-x: var(--gap); --bs-gutter-y: var(--gap); }
.py-4 { padding-top: var(--gap) !important; padding-bottom: var(--gap) !important; }
body > .container { max-width: 1440px; padding-left: var(--gap); padding-right: var(--gap); }

/* ---------- 상단 바 ---------- */
.navbar-custom { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 0; flex-shrink: 0; }
.navbar-custom .container { max-width: 1440px; padding: 0 var(--gap); }
.navbar-custom .navbar-brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); display: flex; align-items: center; gap: 10px; letter-spacing: -0.02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }
.version-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--head); padding: 5px 10px; border-radius: 6px; font-size: .75rem; color: var(--ink-2); font-weight: 500; line-height: 1; }

/* ---------- 메인 탭 ---------- */
/* 메인 탭은 상단 바 안에 한 줄로 배치 (넘치면 가로 스크롤) */
.nav-modern { flex: 1; min-width: 0; gap: 2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.nav-modern::-webkit-scrollbar { display: none; }
.navbar-custom .navbar-brand { flex-shrink: 0; margin: 0; }
.nav-modern .nav-link { white-space: nowrap; }
.nav-modern .nav-link {
  color: var(--ink-2); border-radius: var(--radius-sm); padding: 8px 13px; font-weight: 500; font-size: .86rem;
  border: none; display: flex; align-items: center; gap: 6px;
  transition: background-color .18s ease-out, color .18s ease-out, transform .15s ease-out;
}
.nav-modern .nav-link:hover { background: var(--head); color: var(--ink); }
.nav-modern .nav-link:active { transform: scale(.97); }
.nav-modern .nav-link.active { background: var(--accent); color: #fff; }

.nav-tabs-modern { border: none; gap: 4px; flex-shrink: 0; }
.nav-tabs-modern .nav-link {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); border-radius: var(--radius-sm);
  padding: 5px 10px; font-weight: 500; font-size: .83rem; display: inline-flex; align-items: center; gap: 6px;
  transition: background-color .18s ease-out, color .18s ease-out, border-color .18s ease-out;
}
.nav-tabs-modern .nav-link:hover { background: var(--head); color: var(--ink); }
.nav-tabs-modern .nav-link.active { background: var(--accent-50); color: var(--accent-600); border-color: var(--accent-100); }

/* ---------- 카드 ---------- */
.card-modern, .chart-card, .filter-card, .stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-modern { overflow: hidden; }
.card-modern .card-header, .chart-card .card-header {
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 12px;
  font-weight: 600; font-size: .88rem; color: var(--ink);
}
.card-modern .card-body, .chart-card .card-body { padding: 12px; }
.filter-card { padding: 10px 12px; margin-bottom: var(--gap); }
/* 필터바: 라벨을 입력칸 왼쪽에 붙여 한 줄로 (위아래 배치 금지) */
.filter-card .row > [class*="col"], #statCross .card-body > .row > [class*="col"] { display: flex; align-items: center; gap: 8px; }
.filter-card .form-label, #statCross .card-body .form-label { margin: 0; white-space: nowrap; flex-shrink: 0; }
.filter-card .row > [class*="col"] > .form-control, .filter-card .row > [class*="col"] > .cs, .filter-card .row > [class*="col"] > .dp-wrap,
#statCross .card-body > .row > [class*="col"] > .cs, #statCross .card-body > .row > [class*="col"] > .form-control { flex: 1; min-width: 0; }
.filter-card .row > [class*="col"] > .btn, #statCross .card-body > .row > [class*="col"] > .btn { flex: 1; }
.filter-card .form-check { margin: 0; display: flex; align-items: center; gap: 6px; }

/* 한 줄 필터 (라벨 · 컨트롤 · 구분선 · 토글 · 결과 배지) */
.filter-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-line > .form-label { margin: 0; white-space: nowrap; color: var(--ink-3); }
.fl-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.input-suffix { display: flex; align-items: center; width: 150px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); transition: border-color .18s ease-out, box-shadow .18s ease-out; }
.input-suffix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.input-suffix .form-control { border: 0; box-shadow: none !important; min-width: 0; flex: 1; text-align: right; }
.input-suffix span { padding: 0 10px 0 2px; color: var(--ink-3); font-size: .8rem; white-space: nowrap; }
.toggle-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 33px; padding: 0 12px; margin: 0 0 0 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink-2); font-size: .82rem; font-weight: 500; cursor: pointer; user-select: none; transition: background-color .18s ease-out, border-color .18s ease-out, color .18s ease-out, transform .15s ease-out; }
.toggle-chip:hover { border-color: #c6ccd7; color: var(--ink); }
.toggle-chip:active { transform: scale(.97); }
.toggle-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-chip:has(input:checked) { background: #fdf1f1; border-color: #f1c9c9; color: var(--bad); }
.toggle-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.result-pill { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; height: 33px; padding: 0 12px; border-radius: var(--radius-sm); background: var(--head); color: var(--ink-3); font-size: .8rem; white-space: nowrap; }
.result-pill b { color: var(--ink); font-size: .9rem; font-variant-numeric: tabular-nums; }
.stat-card { padding: 14px; text-align: center; transition: transform .2s ease-out, box-shadow .2s ease-out; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card h3 { font-size: 1.35rem; font-weight: 700; margin-bottom: 2px; letter-spacing: -0.02em; }
.stat-card small { color: var(--ink-3); font-size: .78rem; font-weight: 500; }

/* 페이지 제목 줄: 제목 · 하위 탭 · 버튼을 한 줄에 */
.page-head { justify-content: flex-start !important; gap: var(--gap); flex-wrap: wrap; }
.page-head > .nav-tabs-modern { margin-right: auto; flex-wrap: nowrap; }
.page-head > .section-title { margin-right: 6px; }

/* 요약 수치 카드 (app.js 에서 생성) — 라벨·값 한 줄 컴팩트 */
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 12px; height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; animation: toastIn .3s var(--ease) both; animation-delay: var(--d, 0ms); }
.kpi b { order: 2; font-size: .98rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); white-space: nowrap; }
.kpi small { order: 1; color: var(--ink-3); font-size: .76rem; font-weight: 500; white-space: nowrap; }
.kpi.t-ok b { color: var(--ok); } .kpi.t-bad b { color: var(--bad); } .kpi.t-acc b { color: var(--accent); } .kpi.t-warn b { color: var(--warn); } .kpi.t-info b { color: var(--info); }

/* ---------- 업로드 카드 ---------- */
.upload-card { background: var(--panel); border: 1.5px dashed var(--line); border-radius: var(--radius); transition: border-color .2s ease-out, background-color .2s ease-out, transform .2s ease-out; cursor: pointer; min-height: 170px; position: relative; }
.upload-card:hover { border-color: var(--accent); background: #fbfbff; }
.upload-card.file-ready { border-color: var(--warn); border-style: solid; background: #fffbf1; }
.upload-card.uploaded { border-color: var(--ok); border-style: solid; background: #f3fbf8; }
.upload-card.drag-over { border-color: var(--accent); border-width: 2px; background: var(--accent-50); transform: scale(1.01); }
.card-upload-overlay { position: absolute; inset: 0; background: rgba(255, 255, 255, .94); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 10; border-radius: inherit; opacity: 0; pointer-events: none; transition: opacity .2s ease-out; }
.card-upload-overlay.show { opacity: 1; pointer-events: auto; }
.upload-icon { width: 46px; height: 46px; background: var(--head); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; color: var(--ink-2); margin-bottom: 8px; transition: background-color .2s ease-out, color .2s ease-out; }
.upload-card:hover .upload-icon { background: var(--accent); color: #fff; }
.upload-card.file-ready .upload-icon { background: var(--warn); color: #fff; }
.upload-card.uploaded .upload-icon { background: var(--ok); color: #fff; }

/* ---------- 버튼 ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 500; font-size: .85rem; padding: 7px 13px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; transition: background-color .18s ease-out, border-color .18s ease-out, color .18s ease-out, transform .15s ease-out, box-shadow .18s ease-out; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus { background: var(--accent-600); border-color: var(--accent-600); }
.btn-success { background: var(--ok); border-color: var(--ok); }
.btn-success:hover { background: #0b8a5d; border-color: #0b8a5d; }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-outline-primary { border-color: var(--accent-100); color: var(--accent); background: var(--panel); }
.btn-outline-primary:hover { background: var(--accent-50); border-color: var(--accent); color: var(--accent-600); }
.btn-outline-secondary { border-color: var(--line); color: var(--ink-2); background: var(--panel); }
.btn-outline-secondary:hover { background: var(--head); border-color: var(--line); color: var(--ink); }
.btn-outline-danger { border-color: #f1c9c9; color: var(--bad); background: var(--panel); }
.btn-outline-danger:hover { background: #fdf1f1; border-color: var(--bad); color: var(--bad); }
.btn-icon { width: 30px; height: 30px; padding: 0; }

/* 사용 설명서 버튼 */
.help-btn { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; padding: 0; margin-left: 4px; transition: background-color .18s ease-out, color .18s ease-out, transform .18s ease-out, border-color .18s ease-out; }
.help-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; transform: rotate(-8deg) scale(1.06); }

/* ---------- 폼 ---------- */
.form-control, .form-select { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; font-size: .86rem; color: var(--ink); transition: border-color .18s ease-out, box-shadow .18s ease-out; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.form-control-sm { padding: 6px 10px; font-size: .82rem; min-height: 33px; }
.form-label { font-weight: 600; font-size: .78rem; color: var(--ink-2); margin-bottom: 5px; }
.form-control.is-invalid { border-color: var(--bad); }
.req::after { content: ' *'; color: var(--bad); }
/* 숫자 스피너 금지 */
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.form-check-input { cursor: pointer; margin: 0; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.input-group-text { background: var(--head); border-color: var(--line); font-size: .85rem; }

/* ---------- 표 (모든 표 공통) ---------- */
.tbl-box { overflow: auto; background: var(--panel); position: relative; }
.tbl-box::-webkit-scrollbar { width: 10px; height: 10px; }
.tbl-box::-webkit-scrollbar-track { background: var(--panel); }
.tbl-box::-webkit-scrollbar-thumb { background: #cfd4dd; border-radius: 10px; border: 2px solid var(--panel); }
.tbl-box::-webkit-scrollbar-thumb:hover { background: #b3bac7; }

.table { margin: 0; width: 100%; border-collapse: separate; border-spacing: 0; font-size: .8rem; --bs-table-bg: var(--panel); --bs-table-hover-bg: #f6f7fe; }
/* 모든 셀: 오른쪽·아래 선만 그리고 첫 열은 왼쪽, 헤더는 위쪽 선 → 헤더/본문 선 굵기·색 동일, 마지막 행 선 항상 표시 */
.table > :not(caption) > * > * {
  border: 0 !important;
  border-right: 1px solid var(--line) !important;
  border-bottom: 1px solid var(--line) !important;
  text-align: center !important;
  vertical-align: middle !important;
  padding: 8px 10px;
  white-space: nowrap;
}
.table > :not(caption) > tr > *:first-child { border-left: 1px solid var(--line) !important; }
.table > thead > tr:first-child > * { border-top: 1px solid var(--line) !important; }
/* 카드에 꽉 찬 표: 바깥 테두리는 카드가 그리므로 표의 좌·우·위 외곽선 제거 (이중선 방지) */
.card-modern > .tbl-box .table > :not(caption) > tr > *:first-child,
.card-body.p-0 > .tbl-box .table > :not(caption) > tr > *:first-child { border-left: 0 !important; }
.card-modern > .tbl-box .table > :not(caption) > tr > *:last-child,
.card-body.p-0 > .tbl-box .table > :not(caption) > tr > *:last-child { border-right: 0 !important; }
.card-modern > .tbl-box .table > thead > tr:first-child > *,
.card-body.p-0 > .tbl-box .table > thead > tr:first-child > * { border-top: 0 !important; }
/* 표가 영역을 꽉 채우면 마지막 행 아래선은 페이지네이션 윗선이 대신 그림 (스크롤 끝 이중선 방지) */
.tbl-box.fills .table > tbody > tr:last-child > * { border-bottom: 0 !important; }
.table thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--head) !important; /* 불투명: 스크롤 시 비침 없음 */
  --bs-table-bg-state: var(--head);
  color: var(--ink-2); font-weight: 600; font-size: .78rem;
}
.table tbody th { font-weight: 600; }
.table tbody tr { transition: background-color .15s ease-out; }
.table input[type=checkbox] { display: block; margin: 0 auto; width: 16px; height: 16px; }
.table code { color: var(--accent-600); font-size: .78rem; }
.table .ui-empty td { color: var(--ink-3); padding: 42px 10px; white-space: normal; }
.table .ui-empty .bi { font-size: 1.6rem; display: block; margin-bottom: 6px; opacity: .6; }
.table-success { --bs-table-bg: #f1faf6; }
.table-danger { --bs-table-bg: #fdf3f3; }
.table-warning { --bs-table-bg: #fffaee; }
.map-matched > * { --bs-table-bg: #f1faf6; }
.map-unmatched > * { --bs-table-bg: #fdf3f3; }
.map-nocode > * { --bs-table-bg: #f8f9fb; }
.map-estimated > * { --bs-table-bg: #fffaee; }
.diff-plus { color: var(--ok); font-weight: 600; }
.diff-minus { color: var(--bad); font-weight: 600; }
.tbl-box .table tbody tr { animation: rowIn .28s var(--ease) both; }
.tbl-box .table tbody tr:nth-child(n+25) { animation: none; }
@keyframes rowIn { from { opacity: 0; transform: translateY(4px); } }

/* 페이지네이션 */
.ui-pag { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; min-height: 45px; }
.ui-pag:empty { display: none; }
.ui-pag-info { font-size: .78rem; color: var(--ink-3); }
.ui-pag-btns { display: flex; gap: 4px; align-items: center; }
.ui-pag-btns button { min-width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink-2); font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; transition: background-color .15s ease-out, color .15s ease-out; }
.ui-pag-btns button:hover:not(:disabled) { background: var(--head); color: var(--ink); }
.ui-pag-btns button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ui-pag-btns button:disabled { opacity: .4; }
.ui-pag-btns span { color: var(--ink-3); padding: 0 2px; }

/* 월별 통계 표: 첫 열 고정 */
#monthlyTable th, #monthlyTable td { padding: 6px 9px; }
#monthlyTable tbody th, #monthlyTable .col-name { position: sticky; left: 0; z-index: 2; background: var(--panel); min-width: 130px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
#monthlyTable thead th:first-child { left: 0; z-index: 4; }
#monthlyTable .row-summary > * { --bs-table-bg: #f3f4fd; background: #f3f4fd; font-weight: 600; }
#monthlyTable .col-summary { --bs-table-bg: #f6f7f9; font-weight: 600; }
#monthlyTable .delta { font-size: .68rem; margin-left: 3px; }
#crossTableBox tbody th { position: sticky; left: 0; z-index: 2; background: var(--panel); }
#crossTableBox thead th:first-child { left: 0; z-index: 4; }

/* ---------- 칩/배지: 글자 정중앙 ---------- */
.badge, .ms-chip, .chip {
  display: inline-flex !important; align-items: center; justify-content: center; gap: 4px;
  line-height: 1 !important; vertical-align: middle;
  font-weight: 600; padding: 0 8px; height: 22px; border-radius: 6px; font-size: .72rem;
}
.badge.fs-6 { height: 30px; padding: 0 12px; font-size: .85rem !important; }
.badge small { font-size: .65rem; line-height: 1; }
.chip-stack { flex-direction: column; gap: 2px; height: auto !important; padding: 4px 8px !important; }
.num-dot { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; font-size: .7rem; line-height: 1; font-weight: 700; background: var(--accent); color: #fff; }
.badge.bg-primary { background: var(--accent) !important; }
.badge.bg-light { background: var(--head) !important; }

/* ---------- 알림 ---------- */
.alert { border: 1px solid transparent; border-radius: var(--radius); padding: 10px 14px; font-size: .84rem; display: flex; align-items: center; gap: 6px; }
.alert-info { background: #eef4fd; color: #214f9c; border-color: #d8e5fa; }
.alert-warning { background: #fff8e8; color: #8a5d05; border-color: #f6e5b8; }
.alert-danger { background: #fdf1f1; color: #a83232; border-color: #f4d3d3; }
.alert-success { background: #edf8f3; color: #0b7550; border-color: #cdebdd; }

.section-title { font-size: 1.05rem; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; letter-spacing: -0.02em; }
.section-title > .bi { color: var(--accent); }

/* ---------- 모달 ---------- */
.modal-content { border: none; border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--line); padding: 12px 16px; }
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-body { padding: 16px; }
.modal-footer { border-top: 1px solid var(--line); padding: 10px 16px; gap: 6px; }
.modal-footer > * { margin: 0; }
.modal.fade .modal-dialog { transform: translateY(12px) scale(.98); opacity: 0; transition: transform .24s var(--ease), opacity .2s ease-out; }
.modal.show .modal-dialog { transform: none; opacity: 1; }
.modal-backdrop.show { opacity: .35; }

/* ---------- 토스트 ---------- */
#toastBox { position: fixed; right: 16px; bottom: 16px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.ui-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 8px; max-width: 360px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .84rem; line-height: 1.45; animation: toastIn .26s var(--ease) both; }
.ui-toast .bi { font-size: 1rem; margin-top: 1px; }
.ui-toast.ok .bi { color: #5fd6a6; }
.ui-toast.err .bi { color: #ff9a9a; }
.ui-toast.out { animation: toastOut .2s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ---------- 로더 (콘텐츠 영역만) ---------- */
.ui-loader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 48px 10px; color: var(--ink-3); animation: fadeIn .2s ease-out both; }
.ui-loader-logo { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; animation: truck 1.1s ease-in-out infinite; }
.ui-loader-bar { width: 120px; height: 3px; border-radius: 3px; background: var(--line-2); overflow: hidden; position: relative; }
.ui-loader-bar::after { content: ''; position: absolute; inset: 0; width: 40%; background: var(--accent); border-radius: 3px; animation: bar 1.1s ease-in-out infinite; }
.ui-loader small { font-size: .78rem; }
@keyframes truck { 50% { transform: translateX(4px); } }
@keyframes bar { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- 로그인 ---------- */
#loginOverlay { position: fixed; inset: 0; background: var(--bg); z-index: var(--z-login); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { background: var(--panel); padding: 36px 30px; border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow-lg); width: 360px; max-width: 100%; text-align: center; animation: toastIn .35s var(--ease) both; }
.login-icon { width: 56px; height: 56px; background: var(--accent); border-radius: 14px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 1.5rem; color: #fff; }
.login-box h4 { font-weight: 700; color: var(--ink); margin-bottom: 4px; font-size: 1.2rem; }
.login-box p { color: var(--ink-3); font-size: .86rem; margin-bottom: 18px; }
.login-box input { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 9px; font-size: 1rem; text-align: center; margin-bottom: 10px; transition: border-color .18s ease-out, box-shadow .18s ease-out; }
.login-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.login-box button { width: 100%; padding: 11px; background: var(--accent); color: #fff; border: none; border-radius: 9px; font-size: .95rem; font-weight: 600; transition: background-color .18s ease-out, transform .15s ease-out; }
.login-box button:hover { background: var(--accent-600); }
.login-box button:active { transform: scale(.98); }

/* ---------- 커스텀 드롭다운 ---------- */
.cs { position: relative; min-width: 110px; }
.cs-native { position: absolute !important; opacity: 0; pointer-events: none; width: 1px !important; height: 1px; left: 0; bottom: 0; }
.cs-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px 8px 12px; font-size: .86rem; color: var(--ink); text-align: left; min-height: 38px;
  transition: border-color .18s ease-out, box-shadow .18s ease-out;
}
.cs-sm .cs-btn { padding: 5px 8px 5px 10px; font-size: .82rem; min-height: 33px; }
.cs-btn:hover { border-color: #c6ccd7; }
.cs.open .cs-btn { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.cs-btn:disabled { background: var(--head); color: var(--ink-3); }
.cs-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-label.is-empty { color: var(--ink-3); }
.cs-arrow { color: var(--ink-3); font-size: .75rem; transition: transform .2s var(--ease); }
.cs.open .cs-arrow { transform: rotate(180deg); }
.cs-pop, .dp-pop {
  position: fixed; z-index: var(--z-pop); background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top center;
  transition: opacity .16s ease-out, transform .2s var(--ease);
}
.cs-pop.up { transform-origin: bottom center; transform: translateY(4px) scale(.98); }
.cs-pop.show, .dp-pop.show { opacity: 1; transform: none; }
.cs-pop { display: flex; flex-direction: column; max-height: 330px; max-width: min(420px, calc(100vw - 16px)); overflow: hidden; }
.cs-search { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); color: var(--ink-3); }
.cs-search input { border: 0; outline: 0; flex: 1; font-size: .84rem; min-width: 0; background: transparent; }
.cs-list { overflow-y: auto; padding: 4px; flex: 1; }
.cs-opt { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px; font-size: .84rem; cursor: pointer; color: var(--ink); animation: optIn .2s var(--ease) both; animation-delay: var(--d); transition: background-color .12s ease-out; }
.cs-opt:hover, .cs-opt.act { background: var(--head); }
.cs-opt.on { color: var(--accent-600); font-weight: 600; }
.cs-opt.dis { opacity: .4; pointer-events: none; }
.cs-txt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-tick { color: var(--accent); }
.cs-chk { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid #c3c9d4; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background-color .15s ease-out, border-color .15s ease-out; }
.cs-chk .bi { font-size: .75rem; color: #fff; opacity: 0; transform: scale(.5); transition: opacity .15s ease-out, transform .18s var(--ease); }
.cs-opt.on .cs-chk { background: var(--accent); border-color: var(--accent); }
.cs-opt.on .cs-chk .bi { opacity: 1; transform: none; }
.cs-new { color: var(--accent); }
.cs-empty { padding: 16px; text-align: center; color: var(--ink-3); font-size: .82rem; }
.cs-foot { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--line-2); }
.cs-foot button { flex: 1; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px; font-size: .78rem; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; gap: 4px; transition: background-color .15s ease-out, color .15s ease-out; }
.cs-foot button:hover { background: var(--accent-50); color: var(--accent-600); }
@keyframes optIn { from { opacity: 0; transform: translateY(-3px); } }

/* ---------- 달력 ---------- */
.dp-wrap { position: relative; }
.dp-wrap .form-control { padding-right: 32px; }
.dp-ico { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--ink-3); width: 26px; height: 26px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; transition: background-color .15s ease-out, color .15s ease-out; }
.dp-ico:hover { background: var(--head); color: var(--accent); }
.dp-pop { width: 280px; padding: 10px; }
.dp-head { display: flex; align-items: center; gap: 2px; margin-bottom: 8px; }
.dp-head button { border: 0; background: transparent; width: 28px; height: 28px; border-radius: 6px; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; transition: background-color .15s ease-out; }
.dp-head button:hover { background: var(--head); }
.dp-title { flex: 1; text-align: center; font-weight: 700; font-size: .9rem; display: flex; align-items: center; justify-content: center; gap: 2px; }
.dp-year { width: 48px; border: 1px solid transparent; border-radius: 5px; text-align: right; font-weight: 700; padding: 1px 3px; font-size: .9rem; transition: border-color .15s ease-out; }
.dp-year:hover, .dp-year:focus { border-color: var(--line); outline: 0; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: .72rem; color: var(--ink-3); padding: 4px 0; font-weight: 600; }
.dp-day { border: 0; background: transparent; height: 34px; border-radius: 7px; font-size: .82rem; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; transition: background-color .12s ease-out, transform .12s ease-out; }
.dp-day:hover { background: var(--head); }
.dp-day:active { transform: scale(.94); }
.sun { color: var(--bad) !important; } .sat { color: var(--info) !important; }
.dp-day.today { box-shadow: inset 0 0 0 1px var(--accent-100); font-weight: 700; }
.dp-day.on { background: var(--accent) !important; color: #fff !important; font-weight: 700; }
.dp-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-2); }
.dp-foot button { border: 0; background: transparent; color: var(--accent); font-size: .8rem; font-weight: 600; padding: 4px 8px; border-radius: 5px; transition: background-color .15s ease-out; }
.dp-foot button:hover { background: var(--accent-50); }

/* ---------- 담당자 멀티셀렉트 (기존) ---------- */
.manager-multiselect { position: relative; }
.manager-multiselect .ms-control { display: flex; align-items: center; justify-content: space-between; cursor: pointer; min-height: 38px; padding: 5px 8px; background: var(--panel); transition: border-color .18s ease-out; }
.manager-multiselect .ms-control:hover { border-color: #c6ccd7; }
.manager-multiselect .ms-chips { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.manager-multiselect .ms-chip { background: var(--accent-50); color: var(--accent-600); }
.manager-multiselect .ms-chip-x { cursor: pointer; opacity: .7; transition: opacity .15s ease-out; }
.manager-multiselect .ms-chip-x:hover { opacity: 1; }
.manager-multiselect .ms-placeholder { font-size: .86rem; }
.manager-multiselect .ms-arrow { color: var(--ink-3); margin-left: 6px; }
.ms-dropdown { position: fixed; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: var(--z-pop); max-height: 360px; flex-direction: column; overflow: hidden; animation: fadeIn .16s ease-out; }
.ms-search { padding: 8px; border-bottom: 1px solid var(--line-2); }
.ms-options { flex: 1; overflow-y: auto; max-height: 220px; padding: 4px; }
.ms-option { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px; cursor: pointer; font-size: .84rem; margin: 0; transition: background-color .12s ease-out; }
.ms-option:hover { background: var(--head); }
.ms-option.is-checked { color: var(--accent-600); font-weight: 600; }
.ms-option .ms-opt-label { flex: 1; }
.ms-empty { padding: 12px; text-align: center; color: var(--ink-3); font-size: .82rem; }
.ms-footer { padding: 6px 8px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 6px; }

/* ---------- 100vh 고정 레이아웃 (페이지 스크롤 없음, 표만 스크롤) ---------- */
body > .container { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#mainTab { flex-shrink: 0; }
body > .container > .tab-content { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.tab-content > .tab-pane.show.active { flex: 1; min-height: 0; display: flex !important; flex-direction: column; overflow: hidden; }
.tab-pane.fade { transition: opacity .2s ease-out; }
.tab-pane > .d-flex, .tab-pane > .section-title, .tab-pane > .filter-card, .tab-pane > .row, .tab-pane > .alert, .tab-pane > ul.nav, .tab-pane > .text-muted { flex-shrink: 0; }
.tab-pane > .card-modern, .tab-pane > .tab-content, .tab-content > .tab-pane > .card-modern { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.card-modern > .card-body.p-0 { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.card-modern > .tbl-box, .card-body.p-0 > .tbl-box { flex: 1; min-height: 0; max-height: none !important; }
.tab-pane > .tab-content { overflow: hidden; }
.tab-pane > .tab-content > .tab-pane.show.active { flex: 1; min-height: 0; display: flex !important; flex-direction: column; overflow: hidden; }
#statChart { overflow-y: auto !important; }
#statCross > .card-modern > .card-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#crossTableBox { flex: 1; min-height: 0; max-height: none !important; }
#t9 > .row { flex: 1; min-height: 0; flex-wrap: nowrap !important; }
#t9 > .row > .col-md-4 { overflow-y: auto; min-height: 0; }
#t9 > .row > .col-md-8 { display: flex; flex-direction: column; min-height: 0; }
#t9 > .row > .col-md-8 > .card-modern { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#t9 #managerTbl { flex: 1; min-height: 0; max-height: none !important; }
#t1.show.active, #t7.show.active { overflow-y: auto !important; }
#existingModalBody { max-height: 60vh; }

/* ---------- 고정 노선 ---------- */
.route-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.route-pill .bi-arrow-right { color: var(--ink-3); }
.addr-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: middle; }
.addr-row { display: flex; gap: 6px; }
.addr-row .form-control { flex: 1; min-width: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .form-label { margin-bottom: 4px; }
.field-err { color: var(--bad); font-size: .74rem; margin-top: 3px; display: none; }
.field-err.show { display: block; animation: fadeIn .15s ease-out; }
#postcodeLayer { position: fixed; inset: 0; z-index: calc(var(--z-pop) + 5); background: rgba(27, 33, 48, .35); display: none; align-items: center; justify-content: center; padding: 16px; }
#postcodeLayer.show { display: flex; animation: fadeIn .18s ease-out; }
#postcodeLayer .pc-box { background: var(--panel); border-radius: 12px; overflow: hidden; width: 480px; max-width: 100%; height: 520px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: toastIn .24s var(--ease) both; }
#postcodeLayer .pc-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
#postcodeLayer .pc-body { flex: 1; }

/* ---------- 가이드 모달 ---------- */
#guideModal .modal-dialog { max-width: 980px; }
#guideModal .modal-body { padding: 0; display: flex; height: min(640px, 78vh); }
.g-side { width: 250px; flex-shrink: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: #fafbfc; }
.g-search { padding: 10px; border-bottom: 1px solid var(--line); position: relative; }
.g-search .bi { position: absolute; left: 21px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: .8rem; }
.g-search input { padding-left: 30px; }
.g-nav { overflow-y: auto; flex: 1; padding: 6px; }
.g-grp { font-size: .72rem; font-weight: 700; color: var(--ink-3); padding: 10px 8px 4px; display: flex; align-items: center; gap: 6px; }
.g-item { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; text-align: left; padding: 7px 9px; border-radius: 6px; font-size: .83rem; color: var(--ink-2); transition: background-color .15s ease-out, color .15s ease-out; }
.g-item:hover { background: var(--head); color: var(--ink); }
.g-item.on { background: var(--accent-50); color: var(--accent-600); font-weight: 600; }
.g-item mark { padding: 0 1px; background: #fff1b8; border-radius: 2px; }
.g-main { flex: 1; overflow-y: auto; padding: 20px 24px; min-width: 0; }
.g-main h3 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.g-main .g-lead { color: var(--ink-2); font-size: .88rem; margin-bottom: 14px; line-height: 1.6; max-width: 62ch; }
.g-sec { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: var(--gap); animation: toastIn .3s var(--ease) both; animation-delay: var(--d, 0ms); }
.g-sec h4 { font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.g-sec p, .g-sec li { font-size: .84rem; color: var(--ink-2); line-height: 1.6; margin-bottom: 4px; }
.g-sec ol { padding-left: 18px; margin: 0; }
.g-demo { position: relative; background: var(--head); border-radius: 8px; padding: 12px; margin: 8px 0 10px; display: flex; align-items: center; gap: 8px; overflow: hidden; flex-wrap: wrap; }
.g-step { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; font-size: .78rem; font-weight: 600; color: var(--ink-2); opacity: .45; animation: gStep var(--total) infinite; animation-delay: var(--delay); }
.g-step .bi { color: var(--accent); }
.g-arrow { color: var(--ink-3); font-size: .8rem; }
@keyframes gStep { 0%, 100% { opacity: .45; transform: none; } 5%, 20% { opacity: 1; transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 4px 12px rgba(79, 70, 229, .18); } 28% { opacity: .45; transform: none; } }
.g-empty { color: var(--ink-3); text-align: center; padding: 40px 10px; font-size: .85rem; }

/* 튜토리얼 스포트라이트 */
.tour-spot { position: fixed; z-index: var(--z-tour); border-radius: 8px; box-shadow: 0 0 0 9999px rgba(20, 24, 36, .55), 0 0 0 2px var(--accent); pointer-events: none; transition: left .35s var(--ease), top .35s var(--ease), width .35s var(--ease), height .35s var(--ease); }
.tour-tip { position: fixed; z-index: calc(var(--z-tour) + 1); width: 300px; max-width: calc(100vw - 20px); background: var(--panel); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 14px; transition: left .35s var(--ease), top .35s var(--ease); }
.tour-tip .tt-step { font-size: .72rem; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.tour-tip .tt-text { font-size: .86rem; color: var(--ink); line-height: 1.55; margin-bottom: 10px; }
.tour-tip .tt-btns { display: flex; gap: 6px; justify-content: flex-end; }
.tour-pulse { position: fixed; z-index: calc(var(--z-tour) + 1); width: 14px; height: 14px; border-radius: 50%; background: var(--accent); pointer-events: none; transition: left .35s var(--ease), top .35s var(--ease); }
.tour-pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { to { transform: scale(2.8); opacity: 0; } }

/* ---------- 모바일 ---------- */
@media (max-width: 767.98px) {
  body { font-size: 13px; }
  .navbar-custom { padding: 8px 0; }
  /* 모바일: 로고·설명서 한 줄, 메뉴는 아래 줄에서 가로 스크롤 */
  .navbar-custom .container { flex-wrap: wrap; row-gap: 8px !important; justify-content: space-between; }
  .nav-modern { order: 3; flex-basis: 100%; }
  /* 요약 카드: 한 줄 3개씩, 라벨 줄바꿈 없음 */
  #listSummary, #mapSummary, #marginSummary, #genBox, #routeSummary { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); margin: 0 0 var(--gap); }
  #listSummary > .col, #mapSummary > .col, #marginSummary > .col, #genBox > .col, #routeSummary > .col { padding: 0; margin: 0; width: auto; max-width: none; }
  /* 금액 요약은 자릿수가 커서 2열 */
  #genBox, #marginSummary, #mapSummary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 7px 6px; flex-direction: column; justify-content: center; gap: 1px; }
  .kpi b { order: 1; font-size: .95rem; }
  .kpi small { order: 2; }
  .fl-sep { display: none; }
  .filter-line > .cs { flex: 1 1 0; width: auto !important; min-width: 0; }
  .filter-line > .form-label { width: 38px; }
  .input-suffix { flex: 1 1 0; width: auto; }
  .result-pill { margin-left: auto; }
  .filter-card .dp-wrap .form-control { font-size: .76rem; padding-left: 7px; padding-right: 26px; }
  .page-head > .nav-tabs-modern { order: 5; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; }
  .btn-group .btn { white-space: nowrap; padding-left: 4px; padding-right: 4px; font-size: .74rem; }
  .kpi small { white-space: nowrap; font-size: .72rem; }
  .nav-modern .nav-link { padding: 7px 10px; }
  .filter-card { padding: 10px; }
  .tab-pane > .d-flex { flex-wrap: wrap; gap: var(--gap); }
  #t9 > .row { flex-wrap: wrap !important; overflow-y: auto; }
  #t9 > .row > .col-md-8 { min-height: 70vh; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  #guideModal .modal-body { flex-direction: column; height: 82vh; }
  .g-side { width: 100%; max-height: 38%; border-right: 0; border-bottom: 1px solid var(--line); }
  .g-main { padding: 14px; }
  /* 필터가 많은 화면: 탭 영역 안에서만 스크롤하고 표는 최소 높이 확보 (창 전체 스크롤 없음) */
  .tab-content > .tab-pane.show.active { overflow-y: auto; }
  .tab-pane > .card-modern, .tab-content > .tab-pane > .card-modern, .tab-pane > .tab-content { min-height: 62vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
