* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Pretendard',
               'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: #f4f5f7;
  color: #1f2540;
  font-size: 13px;
}

/* ── 접근 게이트 ─────────────────────────── */
.auth-gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #152033 0%, #0c1322 100%);
  color: #e6ecff;
  z-index: 9999;
}
.auth-msg { text-align: center; padding: 32px; max-width: 420px; }
.auth-msg h2 { margin: 0 0 8px; font-size: 22px; }
.auth-msg p  { color: #9aa3c0; margin: 0 0 16px; }
.auth-msg code {
  display: inline-block;
  background: rgba(255,255,255,0.08);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #cfd6f0;
}

/* ── 상단 바 ─────────────────────────────── */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: #152033;
  color: #fff;
  border-bottom: 3px solid #2b3b66;
}
.topbar .brand h1 { margin: 0; font-size: 18px; line-height: 1.2; display:flex; align-items:center; gap:8px; }
.env-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: #6b7299;
  color: #fff;
  letter-spacing: 0.5px;
}
.env-badge.env-prod { background: #1e7a4f; }
.env-badge.env-dev  { background: #c87a1c; }
.topbar .brand .muted { color: #9aa3c0; font-size: 12px; margin: 2px 0 0; }
.topbar .toolbar { display: flex; gap: 8px; margin-left: 16px; }
.topbar .status { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn {
  background: #2b3b66;
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: #3a4d80; }
.btn.ghost { background: transparent; border: 1px solid #3a4d80; }
.btn.ghost:hover { background: rgba(255,255,255,0.06); }
.btn.danger { background: #a53737; }
.btn.danger:hover { background: #c44141; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.pill {
  display: inline-block;
  padding: 5px 12px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.pill.ok  { background: #1e7a4f; }
.pill.err { background: #a53737; }
.pill.warn{ background: #c87a1c; }
.pill.user{ background: #3a4d80; }

/* ── 선택 합계 패널 ─────────────────────────── */
.selection-panel {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 20px;
  background: #fff;
  border-bottom: 1px solid #e3e7f0;
  flex-wrap: wrap;
}
.selection-panel .sp-left {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: #2b3b66;
  min-width: 90px;
}
.selection-panel .sp-left strong {
  font-size: 16px;
  color: #1e7a4f;
  min-width: 28px;
  text-align: right;
}
.selection-panel .sp-sums {
  display: flex; gap: 6px; flex-wrap: wrap;
  align-items: center;
  flex: 1 1 auto;
}
.sum-chip {
  display: inline-block;
  padding: 3px 10px;
  background: #eef3ff;
  border: 1px solid #d6deef;
  border-radius: 999px;
  font-size: 12px;
  color: #1f2540;
}
.sum-chip b {
  font-weight: 700;
  color: #2b3b66;
  margin-right: 4px;
}

/* ── 모달 ────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 30, 60, 0.55);
  display: none;
  align-items: center; justify-content: center;
  z-index: 10000;
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: #fff;
  border-radius: 12px;
  padding: 22px 26px;
  width: min(480px, 92vw);
  box-shadow: 0 24px 64px rgba(20, 30, 60, 0.32);
  color: #1f2540;
}
.modal-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
  color: #2b3b66;
}
.modal-card h3.danger-title { color: #a53737; }
.modal-card .modal-form {
  display: flex; flex-direction: column; gap: 10px;
  margin: 14px 0;
}
.modal-card .modal-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: #627188;
}
.modal-card .modal-form input {
  padding: 8px 10px;
  border: 1px solid #c9d5e7;
  border-radius: 6px;
  font-size: 14px;
}
.modal-card .modal-form input:focus {
  outline: 2px solid #2b6cb0;
  border-color: #2b6cb0;
}
.modal-card .modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 14px;
}
/* 모달은 흰 배경이므로 ghost 버튼은 어두운 텍스트 + 옅은 외곽선으로 재정의 */
.modal-card .btn {
  background: #2b3b66;
  color: #fff;
  border: 1px solid transparent;
}
.modal-card .btn:hover { background: #3a4d80; }
.modal-card .btn.ghost {
  background: #f4f5f7;
  color: #2b3b66;
  border: 1px solid #c9d5e7;
}
.modal-card .btn.ghost:hover { background: #e5ebf5; }
.modal-card .btn.danger { background: #a53737; color: #fff; }
.modal-card .btn.danger:hover { background: #c44141; }
.modal-card .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.modal-card .confirm-label {
  display: block;
  margin-top: 14px;
  font-size: 13px;
  color: #627188;
}
.modal-card .confirm-label input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1.5px solid #a53737;
  border-radius: 6px;
  font-size: 14px;
}
/* ── 커스텀 체크박스 컬럼 ──────────────────── */
.tabulator .tabulator-cell.col-selector,
.tabulator .tabulator-col.col-selector .tabulator-col-content {
  padding: 0;
}
.tabulator .erp-row-check,
.tabulator .erp-check-all {
  cursor: pointer;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #2b6cb0;
}
.tabulator .tabulator-row.tabulator-selected {
  background-color: #e3f0ff !important;
}
.tabulator .tabulator-row.tabulator-selected:hover {
  background-color: #d4e6ff !important;
}

/* ── 커스텀 우클릭 컨텍스트 메뉴 ──────────────── */
.erp-ctx-menu {
  position: fixed;
  z-index: 99999;
  background: #fff;
  border: 1px solid #c9d5e7;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(20,30,60,0.22);
  padding: 6px 0;
  min-width: 220px;
  font-size: 13px;
  color: #1f2540;
  user-select: none;
}
.erp-ctx-menu.hidden { display: none; }
.erp-ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 16px;
  border: 0;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  color: #1f2540;
  font-family: inherit;
}
.erp-ctx-menu button:hover {
  background: #eef3ff;
  color: #1d4ed8;
}
.erp-ctx-menu .erp-ctx-sep {
  height: 1px;
  background: #e3e7f0;
  margin: 4px 0;
}

/* 수정자 pill — 미확인 시 클릭 가능 표시 */
.pill.warn { background: #c87a1c; }
.pill.warn u { text-decoration: underline; }

.delete-preview {
  background: #fbf2f2;
  border: 1px solid #f2c7c7;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 10px 0 0;
  font-size: 12px;
  color: #6b2222;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: -apple-system, 'Segoe UI', 'Pretendard', sans-serif;
}

/* ── 본문 ─────────────────────────────── */
main {
  padding: 12px 20px;
}
#grid {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(20,30,60,0.08);
  overflow: hidden;
}

/* Tabulator 한국어 친화 미세조정 */
.tabulator { font-size: 12.5px; }
.tabulator .tabulator-header .tabulator-col {
  background: #f0f2f7;
  border-right: 1px solid #e3e7f0;
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  font-weight: 600; color: #2b3b66;
}
.tabulator .tabulator-row.tabulator-row-even { background: #fafbfd; }
.tabulator .tabulator-row:hover { background: #eef3ff !important; }

/* ── 편집 셀 ─────────────────────────────── */
.tabulator .tabulator-cell.cell-editable {
  cursor: cell;
  background-image: linear-gradient(135deg, transparent 0 calc(100% - 6px), #cfd6f0 calc(100% - 6px) 100%);
}
.tabulator .tabulator-cell.cell-editable:hover {
  background-color: #fffbe8;
}
.tabulator .tabulator-cell.tabulator-editing {
  outline: 2px solid #2b6cb0;
  background: #fff !important;
}

/* 저장 상태 — 짧게 깜빡 */
.tabulator .tabulator-cell.cell-saving {
  background-color: #fff5cc !important;
  transition: background-color 0.2s;
}
.tabulator .tabulator-cell.cell-saved {
  background-color: #d6f5e3 !important;
  transition: background-color 1.2s;
}
.tabulator .tabulator-cell.cell-error {
  background-color: #fbd6d6 !important;
  transition: background-color 2.2s;
}

/* ── 푸터 ─────────────────────────────── */
.footer {
  display: flex; gap: 16px; justify-content: space-between;
  padding: 10px 20px;
  color: #6b7299;
  font-size: 12px;
}
