/* ══════════ 매입장 관리 플랫폼 — Modern Minimal ══════════ */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e5e9f0;
  --text: #1f2937;
  --text-sub: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff4ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ── 시인성: Placeholder(연회색+기울임) vs 실제 입력값(검정+정자체) ── */
input::placeholder, textarea::placeholder {
  color: #a9a9a9 !important;
  font-style: italic;
  opacity: 1;
}
input, select, textarea { color: #000; font-style: normal; }
html, body { height: 100%; }
body {
  font-family: "Pretendard", "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--text-sub); }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 500; cursor: pointer;
  background: var(--surface); color: var(--text);
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { border-color: var(--border); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-sub); }
.btn-ghost:hover { color: var(--text); background: rgba(0,0,0,.04); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }

/* ── 스플래시 ── */
.splash {
  position: fixed; inset: 0; z-index: 999;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .5s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-word { text-align: center; animation: splashIn .9s ease-out; }
.splash-word b {
  display: block; font-size: 30px; font-weight: 600;
  letter-spacing: .3em; text-indent: .3em; color: #0F2B4D;
}
.splash-word span { display: block; margin-top: 12px; font-size: 13px; color: #6B7280; }
@keyframes splashIn {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}

/* ── 브랜드 로고 (앱 헤더) ── */
.header-logo { height: 30px; display: block; }

/* ══════════ 로그인 화면 (좌우 분할형) ══════════ */
.login-page { display: flex; min-height: 100vh; background: #fff; }

/* 좌측 브랜드 패널: 고정 폭 */
.brand-panel {
  width: 320px; flex: 0 0 320px; min-height: 100vh;
  background: #133471; /* 일러스트 배경과 동일 색 (경계선 없이 연결) */
  display: flex; flex-direction: column;
  padding: 56px 32px 48px;
  position: relative; overflow: hidden;
}
.brand-quote {
  border-left: 2px solid #C7A052;
  padding-left: 16px;
  margin-top: 7vh;
  position: relative; z-index: 1;
}
.brand-quote p {
  font-size: 15px; line-height: 1.85; font-weight: 400;
  color: #F3F6FA; white-space: nowrap;
}

/* 중앙: 업무 일러스트 (브라우저 창 + 문서 목록 + 업로드) */
.brand-illust {
  display: block; position: relative; z-index: 1;
  width: calc(100% + 36px); margin: auto -18px;
  transform: translateY(-5vh); /* 하단보다 중앙에 가깝게 */
}

/* 하단 로고 워터마크 (K 심볼) — 좌측 경계에 걸치도록 배치 */
.brand-mark {
  position: absolute; left: -64px; bottom: -60px;
  width: 250px; z-index: 0; pointer-events: none;
}
.brand-mark svg { display: block; width: 100%; height: auto; fill: #fff; opacity: .07; }
/* 우측 로그인 영역 */
.login-area {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #FCFCFD; padding: 48px 32px;
}
.login-form-wrap { width: 100%; max-width: 400px; margin-bottom: 6vh; }
.brand-word {
  font-size: 19px; font-weight: 600; letter-spacing: .18em;
  color: #0B1F36;
}
.login-title {
  font-size: 27px; font-weight: 700; color: #111827;
  margin: 28px 0 22px; letter-spacing: -.3px;
}

/* 거래처/관리자 segmented control */
.login-tabs {
  display: flex; width: 100%;
  background: #F1F4F8; border-radius: 10px; padding: 4px;
  margin-bottom: 24px;
}
.login-tab {
  flex: 1; padding: 11px 8px; border: none; border-radius: 8px;
  background: transparent; color: #6B7280;
  font-size: 14.5px; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s;
}
.login-tab.active { background: #0F2B4D; color: #fff; font-weight: 600; }

/* 로그인 입력 필드 */
.login-form-wrap .field { margin-bottom: 18px; }
.login-form-wrap .field > span { color: #374151; }
.login-form-wrap .field input {
  height: 50px; padding: 0 14px;
  border: 1px solid #DDE2EA; border-radius: 9px;
  font-size: 15px; background: #fff;
}
.login-form-wrap .field input:focus {
  border-color: #0F2B4D;
  box-shadow: 0 0 0 3px rgba(15, 43, 77, .08);
}

/* 비밀번호 보기/숨기기 */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 46px !important; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: none; border-radius: 8px;
  background: transparent; color: #9AA3B2; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pw-toggle:hover { color: #0F2B4D; background: #F1F4F8; }

/* 로그인 버튼 */
.btn-login {
  width: 100%; height: 51px; margin-top: 4px;
  border: none; border-radius: 9px;
  background: #0F2B4D; color: #fff;
  font-size: 15.5px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: background .15s;
}
.btn-login:hover { background: #17395F; }

/* 하단 안내문 */
.login-divider { border-top: 1px solid #EDF0F4; margin: 28px 0 14px; }
.login-help { font-size: 12.5px; color: #7A8494; line-height: 1.6; }

/* 반응형 */
@media (max-width: 1024px) {
  .brand-panel { width: 270px; flex-basis: 270px; padding: 44px 24px 40px; }
  .brand-quote p { font-size: 13px; }
  .brand-mark { width: 215px; left: -58px; bottom: -52px; }
}
@media (max-width: 768px) {
  .brand-panel { display: none; }
  .login-area { align-items: flex-start; padding: 12vh 22px 40px; }
  .login-form-wrap { margin: 0 auto; }
}

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-size: 13px; font-weight: 600; color: var(--text-sub); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.field .req { color: var(--danger); margin-left: 2px; }
.form-error {
  background: var(--danger-soft); color: var(--danger);
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
}
.check-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--text-sub); margin: -4px 0 16px; cursor: pointer;
}
.check-line input { width: auto; accent-color: var(--primary); }
.radio-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 10px; cursor: pointer; font-size: 14px;
}
.radio-row:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-row input { width: auto; margin-top: 3px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }

/* ── 상단 바 ── */
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.app-title { font-weight: 700; font-size: 16px; letter-spacing: -.3px; }
.main-nav { display: flex; gap: 4px; margin-left: 24px; }
.main-nav button {
  padding: 8px 14px; border: none; background: transparent; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--text-sub); cursor: pointer;
}
.main-nav button:hover { color: var(--text); background: var(--bg); }
.main-nav button.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-badge { font-size: 13px; color: var(--text-sub); }
.user-badge b { color: var(--text); }

/* ── 컨텐츠 ── */
.content { max-width: 1280px; margin: 0 auto; padding: 28px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-head h2 { font-size: 20px; letter-spacing: -.3px; }
.page-head .sub { font-size: 13px; color: var(--text-sub); margin-top: 2px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }

/* 요약 카드 */
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.summary-card { padding: 18px 20px; }
.summary-card .label { font-size: 12.5px; color: var(--text-sub); font-weight: 600; }
.summary-card .value { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -.4px; }
.summary-card .value small { font-size: 13px; font-weight: 500; color: var(--text-sub); }
.summary-card.accent .value { color: var(--primary); }

/* 월 탭 */
.month-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.month-tab {
  flex: 1; min-width: 56px; padding: 9px 4px; text-align: center;
  border: none; background: transparent; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--text-sub); cursor: pointer;
  position: relative;
}
.month-tab:hover { background: var(--bg); color: var(--text); }
.month-tab.active { background: var(--primary); color: #fff; font-weight: 600; }
.month-tab .lock { font-size: 10px; position: absolute; top: 3px; right: 6px; }

/* 연도 선택 */
.year-select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-weight: 600; background: var(--surface); color: var(--text); cursor: pointer;
}

/* ── 테이블 ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 11px 14px; background: #fafbfd;
  color: var(--text-sub); font-weight: 600; font-size: 12.5px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data tbody tr:hover { background: #fafbff; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-sub); }
.empty-state .icon { font-size: 34px; margin-bottom: 10px; }

/* 상태 뱃지 & 토글 */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge.confirmed { background: var(--success-soft); color: var(--success); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.closed { background: var(--danger-soft); color: var(--danger); }
.badge.open { background: var(--primary-soft); color: var(--primary); }

.status-toggle {
  position: relative; width: 40px; height: 22px; border-radius: 999px;
  background: #d1d5db; border: none; cursor: pointer; transition: background .18s;
  flex-shrink: 0;
}
.status-toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: left .18s; box-shadow: var(--shadow);
}
.status-toggle.on { background: var(--success); }
.status-toggle.on::after { left: 20px; }
.status-toggle:disabled { opacity: .45; cursor: not-allowed; }
.status-cell { display: flex; align-items: center; gap: 8px; }

.row-actions { display: flex; gap: 4px; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; padding: 5px 7px;
  border-radius: 6px; font-size: 14px; color: var(--text-sub);
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── 테이블 직접 입력 모드 (엑셀형 그리드) ── */
table.data.edit td { padding: 0; }
table.data.edit td .cell {
  width: 100%; border: none; background: transparent;
  padding: 10px 12px; font-size: 13.5px; font-family: inherit; color: #000;
}
table.data.edit td .cell:focus {
  outline: 2px solid var(--primary); outline-offset: -2px;
  background: #fff; border-radius: 4px;
}
table.data.edit td .num-cell { text-align: right; font-variant-numeric: tabular-nums; }
table.data.edit td.c-total { padding: 10px 12px; }
table.data.edit td.center-cell { padding: 10px 12px; text-align: center; }
tr.edit-row.row-invalid td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.edit-row.row-saved td { background: var(--success-soft); transition: background .8s; }
tr.edit-row .row-state { font-size: 11px; color: var(--text-sub); }

/* ── 거래처명 검색형 드롭다운 (테이블 직접 입력 모드) ── */
.ac-list {
  position: fixed; z-index: 130;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); max-height: 248px; overflow-y: auto; padding: 4px;
}
.ac-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
  padding: 8px 12px; border-radius: 7px;
  font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.ac-item .bn { color: var(--text-sub); font-size: 12px; font-variant-numeric: tabular-nums; }
.ac-item.active { background: var(--primary-soft); color: var(--primary); }
.ac-item.active .bn { color: var(--primary); }
.ac-empty { padding: 10px 14px; color: var(--text-sub); font-size: 13px; }

/* 사업자번호 자동 채움 셀: 읽기 전용 톤 */
table.data.edit td.c-bizno {
  padding: 10px 12px; background: #F8FAFC; color: #64748B;
  font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ── 품명 콤보박스 (직접 입력 + 드롭다운 선택) ── */
.combo { position: relative; display: flex; align-items: stretch; width: 100%; }
.combo > input { flex: 1; padding-right: 30px !important; }
.combo-btn {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; cursor: pointer;
  padding: 4px 8px; color: var(--text-sub); font-size: 12px; border-radius: 6px;
}
.combo-btn:hover { color: var(--primary); background: var(--primary-soft); }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); overflow: hidden; white-space: nowrap;
}
.combo-list button {
  display: block; width: 100%; text-align: left;
  padding: 9px 14px; border: none; background: transparent;
  font-size: 13.5px; cursor: pointer; color: var(--text);
}
.combo-list button:hover { background: var(--primary-soft); color: var(--primary); }
.combo-list button small { color: var(--text-sub); margin-left: 6px; }

/* ── 마감 현황 뱃지 (관리자 거래처 목록) ── */
.closing-chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; }
.closing-chips .badge { font-size: 11.5px; }

/* ── 모달 ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 20px; z-index: 100; overflow-y: auto;
}
.modal-box {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 560px; max-width: 100%; padding: 28px;
  animation: modalIn .18s ease-out;
}
.modal-box.wide { width: 880px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h3 { font-size: 17px; letter-spacing: -.3px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

/* ── 토스트 ── */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2937; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow-lg); animation: modalIn .18s ease-out;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ── 업로드 결과 ── */
.upload-result { background: var(--bg); border-radius: 10px; padding: 14px 16px; font-size: 13px; margin-top: 14px; max-height: 240px; overflow-y: auto; }
.upload-result li { margin-left: 18px; }

/* ══════════ 세금계산서 (흑백 단색, 국세청 표준 양식 구조) ══════════ */
.invoice-sheet {
  background: #fff; color: #000; width: 780px; max-width: 100%;
  padding: 30px; margin: 0 auto;
  font-family: "Malgun Gothic", "맑은 고딕", sans-serif; font-size: 12px;
}
.invoice-sheet * { color: #000; }
.invoice-title {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 3px double #000; padding-bottom: 8px; margin-bottom: 12px;
}
.invoice-title h2 { font-size: 24px; letter-spacing: 12px; text-align: center; flex: 1; font-weight: 700; }
.invoice-title .doc-meta { font-size: 11px; text-align: right; min-width: 150px; line-height: 2; }
/* 승인번호/일련번호 수기 기입 여백 */
.invoice-sheet .wline {
  display: inline-block; width: 110px; height: 13px;
  border-bottom: 1px solid #000; vertical-align: bottom;
}
table.inv { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.inv th, table.inv td { border: 1px solid #000; padding: 6px 8px; font-size: 12px; }
table.inv th { background: #f0f0f0; font-weight: 600; text-align: center; }
table.inv td.center { text-align: center; }
table.inv td.num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-party-label {
  width: 26px; text-align: center; background: #f0f0f0; font-weight: 700;
  vertical-align: middle; letter-spacing: 2px;
}
.invoice-total-row td { font-weight: 700; background: #fafafa; }
.invoice-note { margin-top: 10px; font-size: 11px; text-align: center; }

/* 인쇄: 세금계산서만 출력 */
.invoice-print-root { display: none; }
@media print {
  body > *:not(.invoice-print-root) { display: none !important; }
  .invoice-print-root { display: block !important; }
  .invoice-sheet { width: 100%; padding: 0; }
  @page { size: A4 portrait; margin: 15mm; }
}

/* ── 반응형 ── */
@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .main-nav { margin-left: 8px; }
}
