/* ================================================================ 기본 */
:root {
  --nav: #1c3452;
  --nav-2: #24426a;
  --bg: #eef1f5;
  --panel: #ffffff;
  --line: #dde2ea;
  --line-2: #c8d0dc;
  --text: #1c2433;
  --muted: #687386;
  --accent: #2459d6;
  --accent-soft: #e8efff;
  --danger: #c62f2f;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --calc: #fffbe6;
  --st-review: #2f6fde;
  --st-hold: #b7791f;
  --st-done: #1f8a4c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", system-ui, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.muted { color: var(--muted); }
.neg { color: var(--danger); }
.hidden { display: none !important; }
.boot { padding: 40px; color: var(--muted); }

#app { display: grid; grid-template-columns: 208px 1fr; height: 100vh; }
#print-root { display: none; }

/* ================================================================ 사이드 메뉴 */
#nav { background: var(--nav); color: #cfdbec; display: flex; flex-direction: column; overflow-y: auto; }
#nav .brand { display: flex; align-items: center; gap: 10px; padding: 16px 14px 14px; border-bottom: 1px solid rgba(255,255,255,.08); text-decoration: none; }
#nav .brand img { width: 40px; height: 40px; flex: none; border-radius: 8px; }
#nav .brand b { display: block; color: #fff; font-size: 17px; letter-spacing: -.3px; }
#nav .brand span { font-size: 12px; color: #8fa6c4; }
#nav a.brand:hover b { color: #ffd900; }
#nav .grp { padding: 14px 10px 4px; }
#nav .grp-t { font-size: 11.5px; color: #7f97b8; padding: 0 10px 6px; letter-spacing: .5px; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 1px 0;
  color: #d5e0ee; text-decoration: none; border-radius: 7px; font-size: 14px;
}
#nav a svg { width: 17px; height: 17px; flex: none; opacity: .85; }
#nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
#nav a.on { background: var(--nav-2); color: #fff; box-shadow: inset 3px 0 0 #7fb0ff; }
#nav .foot { margin-top: auto; padding: 12px 18px; font-size: 11.5px; color: #7f97b8; border-top: 1px solid rgba(255,255,255,.08); }

/* ================================================================ 메인 영역 */
#main { overflow: auto; position: relative; }
.page { padding: 18px 24px 40px; min-width: 980px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0 8px 0 0; letter-spacing: -.4px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.toolbar .sep { width: 1px; height: 24px; background: var(--line-2); margin: 0 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line-2); background: #fff; border-radius: 6px; cursor: pointer;
  white-space: nowrap; font-size: 13.5px; transition: background .12s, border-color .12s;
}
.btn:hover { background: #f4f6fa; border-color: #aeb8c8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #1c4bbd; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fdf0f0; border-color: #e4a5a5; }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12.5px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 4px; height: auto; }
.btn.link:hover { text-decoration: underline; background: none; }
.kbd { font-size: 11px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; margin-left: 2px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.card-h { padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-b { padding: 12px 14px; }

input.inp, select.inp, textarea.inp {
  height: 32px; border: 1px solid var(--line-2); border-radius: 6px; padding: 0 9px; background: #fff; min-width: 0;
}
textarea.inp { height: auto; padding: 7px 9px; resize: vertical; }
input.inp:focus, select.inp:focus, textarea.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36,89,214,.15); }
input.inp[type=date] { padding-right: 4px; }
label.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; white-space: nowrap; }
label.chk input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 0 11px; height: 30px; cursor: pointer; font-size: 13px; border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.seg button:disabled { color: #b3bac6; cursor: default; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.new { background: #e7f6ec; color: var(--ok); }
.badge.edit { background: #fff3dc; color: #9a6410; }
.st { display: inline-block; min-width: 38px; text-align: center; padding: 1px 7px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.st-검토 { background: #e9f0ff; color: var(--st-review); }
.st-보류 { background: #fff3dc; color: var(--st-hold); }
.st-확정 { background: #e5f5eb; color: var(--st-done); }

/* ================================================================ 검색 영역 */
.filters { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 12px 14px; }
.filters .f { display: flex; align-items: center; gap: 6px; }
.filters .f > span.l { color: var(--muted); font-size: 13px; white-space: nowrap; }
.quick { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.quick .btn { height: 26px; padding: 0 8px; font-size: 12.5px; }
.months { display: flex; gap: 2px; align-items: center; }
.months .btn { height: 24px; padding: 0 6px; font-size: 12px; min-width: 30px; justify-content: center; }
.months .yr { font-weight: 600; min-width: 44px; text-align: center; font-size: 13px; }

/* ================================================================ 표 */
.tbl-wrap { overflow: auto; max-height: calc(100vh - 230px); border-top: 1px solid var(--line); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.grid th {
  position: sticky; top: 0; z-index: 2; background: #f3f5f9; color: #3b4558; font-weight: 600;
  padding: 8px 8px; border-bottom: 1px solid var(--line-2); text-align: center; white-space: nowrap;
}
table.grid th.sortable { cursor: pointer; }
table.grid th.sortable:hover { background: #e8ecf3; }
table.grid th .arr { font-size: 10px; color: var(--accent); margin-left: 3px; }
table.grid td { padding: 6px 8px; border-bottom: 1px solid #edf0f4; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
table.grid tbody tr:hover td { background: #f6f9ff; }
table.grid tr.sel td { background: #e3ecff !important; }
table.grid tr.sep td { border-top: 2px solid #b7c1d0; }
table.grid tr.sub td { background: #f4f6f9; font-weight: 600; }
table.grid tr.cum td { background: #eef2f7; font-weight: 600; }
table.grid tr.total td { background: #e6ecf5; font-weight: 700; border-top: 1px solid #9aa7ba; position: sticky; bottom: 0; z-index: 1; }
table.grid td.acts { padding: 3px 6px; }
table.grid td.acts .btn { margin-right: 3px; }
table.grid tr.clickable { cursor: pointer; }
table.grid .grp-h th { top: 0; }
table.grid .grp-h + tr th { top: 34px; }
table.grid td.sticky1, table.grid th.sticky1 { position: sticky; left: 0; z-index: 3; background: inherit; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.result-bar { display: flex; align-items: center; gap: 14px; padding: 8px 14px; font-size: 13px; color: var(--muted); }
.result-bar b { color: var(--text); }

/* ================================================================ 견적서 작성 화면 */
.qe { display: grid; grid-template-columns: max-content 280px; gap: 18px; align-items: start; justify-content: center; }
.qe-bar { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: 14px 24px 10px; margin: -18px -24px 12px; border-bottom: 1px solid var(--line); }
.qe-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 92px); overflow: auto; padding-bottom: 8px; }
.qe-side .card-b { display: flex; flex-direction: column; gap: 10px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.opt-row > span { color: #47526a; }
.stat-list { display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; font-size: 13px; }
.stat-list .k { color: var(--muted); }
.stat-list .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.stat-list .k.indent { padding-left: 10px; }
.row-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.row-tools .btn { justify-content: center; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
/* 좁은 화면: 옵션 패널을 견적서 위쪽에 가로로 배치 */
@media (max-width: 1340px) {
  .qe { grid-template-columns: minmax(0, max-content); }
  .qe-side { order: -1; position: static; max-height: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
}

.doc-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; padding-bottom: 20px; }
.doc-wrap .doc-page { background: #fff; box-shadow: 0 1px 3px rgba(20,30,50,.12), 0 6px 18px rgba(20,30,50,.08); padding: 12mm 10mm; width: 210mm; position: relative; }
.doc-wrap .page-label { position: absolute; top: 4mm; right: 10mm; font-size: 11px; color: #9aa3b2; }
.page-add { display: flex; gap: 8px; }

/* 견적서 문서 (화면 편집 + 인쇄 공통) */
.doc { font-family: "Dotum", "돋움", "Malgun Gothic", sans-serif; color: #000; font-size: 9.6pt; line-height: 1.2; }
.doc table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.doc td, .doc th { padding: 0 1.3mm; height: 6.4mm; vertical-align: middle; overflow: hidden; white-space: nowrap; }
.doc .b-hair { border-bottom: 0.2mm solid #8a8a8a; }

.d-head { display: grid; grid-template-columns: 18.3% 1fr 18.3%; border-top: 0.6mm solid #000; border-bottom: 0.6mm solid #000; height: 12.8mm; }
.d-head .box { display: grid; grid-template-rows: 1fr 1fr; }
.d-head .box > div { display: flex; align-items: center; justify-content: center; }
.d-head .box .l { border-bottom: 0.2mm solid #8a8a8a; font-size: 9.4pt; }
.d-head .box.left { border-right: 0.2mm solid #8a8a8a; }
.d-head .box.right { border-left: 0.2mm solid #8a8a8a; }
.d-head .title { display: flex; align-items: center; justify-content: center; font-family: "Malgun Gothic", "맑은 고딕", sans-serif; font-size: 22pt; font-weight: 700; letter-spacing: 9mm; padding-left: 9mm; }
.d-info { display: grid; grid-template-columns: 1fr 1fr; gap: 3.7mm; margin-top: 1.8mm; }
.d-recv td.k { width: 19mm; }
.d-recv .r1 td { height: 14.3mm; border-bottom: 0.2mm solid #8a8a8a; font-size: 10.4pt; font-weight: 600; }
.d-recv .r1 td.k { font-weight: 600; }
.d-recv .r2 td { height: 6.9mm; border-bottom: 0.2mm solid #8a8a8a; }
.d-recv .r3 td { height: 6.9mm; border-bottom: 0.3mm solid #000; }
.d-recv .r2 td.k { padding-left: 4mm; }
.d-recv .msg { padding-top: 9mm; font-weight: 700; font-size: 10.4pt; }
.d-recv .gwiha { width: 11mm; text-align: right; font-weight: 600; }
.d-sup td { height: 6.9mm; border-bottom: 0.2mm solid #8a8a8a; }
.d-sup tr.h td { height: 7.6mm; font-weight: 700; border-bottom: 0.3mm solid #000; }
.d-sup tr:last-child td { border-bottom: 0.3mm solid #000; }
.d-sup td.k { width: 15.2mm; }
.d-sup td.k2 { width: 11mm; font-size: 8.4pt; border-left: 0.2mm solid #8a8a8a; }
.d-sup td.k2.big { font-size: 9.6pt; }
.d-sup td.addr, .d-sup td.addr input { font-size: 8.4pt; }
.d-sup td.v { font-weight: 600; }
.d-sup td.v.plain { font-weight: 400; }
.d-sup td.inn { width: 9mm; text-align: right; font-size: 8.4pt; position: relative; overflow: visible; }
.stamp { position: absolute; right: -1mm; top: 50%; transform: translateY(-50%); height: 15mm; width: auto; pointer-events: none; mix-blend-mode: multiply; opacity: .92; }

.d-sum { display: grid; grid-template-columns: 50mm 10mm 1fr 6mm 1fr; align-items: end; height: 9mm; margin-top: 1.5mm; }
.d-sum .t { font-weight: 700; font-size: 10pt; align-self: center; }
.d-sum .t span { font-weight: 400; }
.d-sum .il { align-self: center; color: #222; }
.d-sum .kor { border-bottom: 0.3mm solid #000; text-align: right; font-weight: 700; padding: 0 1mm 1mm 0; font-size: 10.4pt; white-space: nowrap; overflow: hidden; }
.d-sum .kor span { font-weight: 400; font-size: 9.6pt; margin-left: 1.5mm; }
.d-sum .won { border-bottom: 0.3mm solid #000; text-align: right; font-weight: 700; padding: 0 1mm 1mm 0; font-size: 10.4pt; grid-column: 5; }

.d-items { margin-top: 1.8mm; border-top: 0.6mm solid #000; border-bottom: 0.6mm solid #000; }
.d-items col.c1 { width: 24.6%; } .d-items col.c2 { width: 15.4%; } .d-items col.c3 { width: 9.1%; }
.d-items col.c4 { width: 11.1%; } .d-items col.c5 { width: 12.2%; } .d-items col.c6 { width: 12.3%; } .d-items col.c7 { width: 15.3%; }
.d-items th { height: 6.5mm; font-weight: 700; border-bottom: 0.3mm solid #000; border-left: 0.2mm solid #8a8a8a; text-align: center; }
.d-items td { border-bottom: 0.15mm solid #9a9a9a; border-left: 0.2mm solid #8a8a8a; }
.d-items th:first-child, .d-items td:first-child { border-left: 0; }
.d-items td.n { text-align: right; font-variant-numeric: tabular-nums; }
.d-items td.c { text-align: center; }
.d-items tfoot td { height: 6.6mm; border-top: 0.3mm solid #000; border-bottom: 0; font-weight: 700; text-align: center; }
.d-items tfoot td.n { text-align: right; }
.d-foot { border-bottom: 0.6mm solid #000; }
.d-foot td { height: 6.5mm; border-bottom: 0.2mm solid #8a8a8a; }
.d-foot td.k { text-align: center; width: 17mm; }
.d-foot td.k.bl { border-left: 0.2mm solid #8a8a8a; }
.d-foot tr:last-child td { border-bottom: 0; }

/* 편집용 입력칸 */
.doc input.ci {
  border: 0; background: transparent; width: 100%; height: 100%; padding: 0; margin: 0;
  font: inherit; color: inherit; outline: none; text-align: inherit; min-width: 0;
}
.doc td.ed { padding: 0; }
.doc td.ed input.ci { padding: 0 1.3mm; height: 6.2mm; }
.doc .d-recv .r1 td.ed input.ci { height: 9mm; }
.doc .pick { flex: none; padding-right: 1.3mm; }
.doc td.ed:focus-within, .doc .ed:focus-within { background: #eaf1ff; box-shadow: inset 0 0 0 1.5px var(--accent); }
.doc td.calc { background: var(--calc); }
.doc tr.cur td { background: #f3f7ff; }
.doc tr.cur td.calc { background: #f8f3d8; }
.doc .ed-h { cursor: text; }
.doc .pick { cursor: pointer; color: var(--accent); font-size: 8.5pt; margin-left: 1mm; user-select: none; }
.doc .pick:hover { text-decoration: underline; }
.doc .d-head .box .v input.ci { text-align: center; }
.doc .d-head .serial.auto { color: #9aa3ad; font-size: 8.5pt; }
.doc input[type=date].ci { text-align: center; }
.doc input[type=date].ci::-webkit-calendar-picker-indicator { opacity: .5; margin-left: 0; cursor: pointer; }
.doc .neg { color: #d00; }

/* ================================================================ 자동완성 */
.suggest {
  position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--line-2); border-radius: 7px;
  box-shadow: 0 8px 26px rgba(20,30,50,.18); max-height: 300px; overflow: auto; min-width: 280px; font-size: 13px;
}
.suggest .it { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 6px 10px; cursor: pointer; border-bottom: 1px solid #f1f3f6; }
.suggest .it:last-child { border-bottom: 0; }
.suggest .it.on, .suggest .it:hover { background: var(--accent-soft); }
.suggest .it .s { color: var(--muted); }
.suggest .it .p { text-align: right; font-variant-numeric: tabular-nums; min-width: 80px; }
.suggest .it.one { grid-template-columns: 1fr auto; }
.suggest mark { background: #fff1a8; color: inherit; padding: 0; }

/* ================================================================ 모달 / 토스트 / 메뉴 */
.ovl { position: fixed; inset: 0; background: rgba(16,24,40,.42); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; }
.mdl { background: #fff; border-radius: 11px; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: 460px; max-width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.mdl.w { width: 760px; } .mdl.xw { width: 980px; }
.mdl-h { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 15px; display: flex; align-items: center; }
.mdl-h .x { margin-left: auto; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.mdl-b { padding: 16px 18px; overflow: auto; }
.mdl-b p { margin: 0 0 8px; line-height: 1.55; white-space: pre-line; }
.mdl-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.mdl .tbl-wrap { max-height: 50vh; border: 1px solid var(--line); border-radius: 7px; }
.form-grid { display: grid; grid-template-columns: 110px 1fr; gap: 9px 12px; align-items: center; }
.form-grid > label { color: #47526a; font-size: 13px; }
.form-grid .req::after { content: " *"; color: var(--danger); }
.form-grid .full { grid-column: 1 / -1; }

#toast-root { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1d2738; color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 13.5px; animation: tin .18s ease-out; max-width: 640px; }
.toast.err { background: #a52a2a; }
.toast.ok { background: #1f6b43; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.ctx { position: fixed; z-index: 1500; background: #fff; border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 4px; min-width: 170px; }
.ctx button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 12px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.ctx button:hover { background: var(--accent-soft); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* 공급자/거래처/품목 관리 */
.master { display: grid; grid-template-columns: 1fr 400px; gap: 16px; align-items: start; }
.master .card-b.form { display: flex; flex-direction: column; gap: 12px; }
.stamp-prev { width: 120px; height: 120px; border: 1px dashed var(--line-2); border-radius: 8px; display: flex; align-items: center; justify-content: center; background: #fafbfc; }
.stamp-prev img { max-width: 110px; max-height: 110px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.col-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 14px; }

/* ================================================================ 인쇄 */
@media print {
  html, body { background: #fff; height: auto; }
  #app, #modal-root, #toast-root, .suggest, .ctx { display: none !important; }
  #print-root { display: block; }
  #print-root.bw { filter: grayscale(1); }
  .doc-page { width: auto; padding: 0; break-after: page; page-break-after: always; box-shadow: none; }
  .doc-page:last-child { break-after: auto; page-break-after: auto; }
  .print-list tr { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
/* 목록 인쇄 (#print-root 안에서만 쓰임 - 인쇄 전 크기 측정을 위해 화면용 규칙으로 둠) */
.print-list { font-family: "Malgun Gothic", "맑은 고딕", sans-serif; font-size: 8.5pt; color: #000; }
.print-list h2 { font-size: 14pt; margin: 0 0 1mm; }
.print-list .meta { font-size: 9pt; margin-bottom: 3mm; color: #333; }
.print-list table { border-collapse: collapse; width: 100%; }
.print-list thead { display: table-header-group; }
.print-list th { border-top: 0.4mm solid #000; border-bottom: 0.3mm solid #000; padding: 1.4mm 1.2mm; background: #eee; font-weight: 700; white-space: nowrap; }
.print-list td { border-bottom: 0.15mm solid #bbb; padding: 1.1mm 1.2mm; white-space: nowrap; }
.print-list td.num { text-align: right; }
.print-list td.center { text-align: center; }
.print-list tr.sub td, .print-list tr.cum td { background: #f2f2f2; font-weight: 700; }
.print-list tr.total td { border-top: 0.3mm solid #000; border-bottom: 0.5mm solid #000; font-weight: 700; background: #e6e6e6; }
.print-list tr.sep td { border-top: 0.3mm solid #666; }

/* ================================================================ 거래명세표 (양식 3종 - 화면 미리보기/인쇄 공통) */
.stmt-preview { display: flex; flex-direction: column; align-items: center; gap: 18px; padding-bottom: 30px; }
.stmt-preview .stp { background: #fff; width: 210mm; min-height: 297mm; padding: 10mm; box-shadow: 0 1px 3px rgba(20,30,50,.12), 0 6px 18px rgba(20,30,50,.08); }
.stp { color: #000; line-height: 1.2; }
.stp table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.stp td { padding: 0 1.2mm; overflow: hidden; white-space: nowrap; vertical-align: middle; }
.stp td.n { text-align: right; font-variant-numeric: tabular-nums; }
.stp td.c { text-align: center; }
.stp td.rel { position: relative; overflow: visible; }
.stp .stamp { height: 13mm; right: 0; }
.stp .pg { font-size: 8pt; font-weight: 400; margin-left: 2mm; color: #333; letter-spacing: 0; }
.stp .cut { border-top: 0.3mm dashed #999; margin: 5mm 0; }

/* 양식 1 : 표 형식 (굴림체) */
.st-t1 { font-family: "GulimChe", "굴림체", "Gulim", "굴림", "Dotum", sans-serif; font-size: 8.6pt; }
.st1 { border: 0.6mm solid #000; }
.st1 td { border: 0.2mm solid #000; }
.st1-title { height: 9.4mm; display: flex; align-items: center; justify-content: center; gap: 2mm; border-bottom: 0.4mm solid #000; position: relative; }
.st1-title .t { font-size: 19pt; font-weight: 700; letter-spacing: 1.5mm; }
.st1-title .s { font-size: 9pt; }
.st1-title .no { position: absolute; right: 2mm; bottom: 1mm; font-size: 7.5pt; color: #333; }
.st1-info td { height: 9.4mm; }
.st1-info td.vl { text-align: center; padding: 0; font-size: 8.4pt; line-height: 1.15; }
.st1-info td.lb { text-align: center; white-space: pre-line; font-size: 8.2pt; line-height: 1.15; }
.st1-info td.v.b { font-weight: 700; font-size: 9.6pt; }
.st1-info td.v.big { font-weight: 700; font-size: 11pt; letter-spacing: .3mm; }
.st1-info td.v.sm { font-size: 7.8pt; white-space: normal; line-height: 1.15; }
.st1-info td.v.amt { font-weight: 700; font-size: 11.5pt; text-align: right; }
.st1-info tr:last-child td { border-bottom-width: 0.4mm; }
.st1-items td { height: 5.1mm; font-size: 8.2pt; }
.st1-items tr.hd td { text-align: center; height: 4.8mm; border-bottom-width: 0.3mm; }
.st1-foot td { height: 9.4mm; border-top-width: 0.4mm; }
.st1-foot td.lb { text-align: center; letter-spacing: 1mm; }
.st1-foot td.sig { text-align: right; }
.st1-foot td.sig .who { float: left; }

/* 양식 2 : 깔끔한 형식 (나눔고딕) */
.st-t2 { font-family: "NanumGothic", "나눔고딕", "Malgun Gothic", "맑은 고딕", sans-serif; font-size: 8pt; }
.st2-top { display: grid; grid-template-columns: 1fr 93mm; gap: 6mm; align-items: start; }
.st2-top .ttl { font-size: 22pt; font-weight: 800; letter-spacing: .5mm; margin-top: 1mm; }
.st2-top .ttl small { font-size: 7pt; font-weight: 400; vertical-align: top; margin-left: 3mm; letter-spacing: 0; }
.st2-top .to { font-size: 11pt; font-weight: 700; height: 7mm; margin-top: 3mm; }
.st2-top .dt { font-size: 9pt; margin-top: 4mm; }
.st2-top .dt .no { font-size: 7.5pt; color: #555; }
.st2-top .sum { margin-top: 2mm; font-size: 14pt; display: flex; align-items: baseline; gap: 2mm; }
.st2-top .sum small { font-size: 8.5pt; }
.st2-top .sum .amt { margin-left: auto; padding-right: 2mm; }
.st2-sup td { height: 6.3mm; border-bottom: 0.15mm solid #c8c8c8; font-size: 8pt; }
.st2-sup tr.gh td { background: #e6e6e6; font-weight: 800; border-top: 0.4mm solid #9a9a9a; }
.st2-sup tr.tall td { height: 9mm; }
.st2-sup tr.last td { border-bottom: 0.5mm solid #000; }
.st2-sup td.k { font-weight: 800; }
.st2-sup td.wrap { white-space: normal; line-height: 1.2; }
.st2-sup .in { position: absolute; right: 1.5mm; top: 50%; transform: translateY(-50%); }
.st2-items { margin-top: 3mm; border-top: 0.5mm solid #000; border-bottom: 0.5mm solid #000; }
.st2-items td { height: 6.3mm; font-size: 7.6pt; }
.st2-items tr.gh td { background: #e6e6e6; font-weight: 800; font-size: 8pt; }
.st2-items tr.tot td { border-top: 0.2mm solid #999; }
.st2-sign { display: flex; justify-content: flex-end; align-items: center; gap: 3mm; margin-top: 3mm; font-size: 9pt; }
.st2-sign .line { width: 50mm; }

/* 양식 3 : 전통 형식 (돋움) */
.st-t3 { font-family: "Dotum", "돋움", "Malgun Gothic", sans-serif; font-size: 9.4pt; }
.st3 { border: 0.6mm solid #000; }
.st3-head { height: 20mm; display: grid; grid-template-columns: 55mm 1fr 55mm; align-items: center; border-bottom: 0.3mm solid #000; white-space: nowrap; }
.st3-head .no { padding-left: 4mm; align-self: end; margin-bottom: 4mm; }
.st3-head .no span { display: inline-block; min-width: 32mm; border-bottom: 0.2mm solid #000; padding-left: 2mm; }
.st3-head .t { text-align: center; font-size: 18pt; font-weight: 700; letter-spacing: 1mm; }
.st3-mid { display: grid; grid-template-columns: 77mm 1fr; border-bottom: 0.4mm solid #000; }
.st3-mid .l { display: flex; flex-direction: column; justify-content: space-between; padding: 4mm 4mm 3mm; border-right: 0.3mm solid #000; }
.st3-mid .date { text-align: center; letter-spacing: .5mm; }
.st3-mid .to { display: flex; justify-content: space-between; border-bottom: 0.2mm solid #000; padding: 0 1mm 1mm; font-size: 10.5pt; }
.st3-mid .to span { font-weight: 700; }
.st3-sup td { height: 8.7mm; border: 0.2mm solid #000; }
.st3-sup tr:first-child td { border-top: 0; }
.st3-sup tr:last-child td { border-bottom: 0; }
.st3-sup td:last-child { border-right: 0; }
.st3-sup td.vl { text-align: center; padding: 0; line-height: 1.6; border-left: 0; }
.st3-sup td.k { text-align: center; font-size: 8.8pt; }
.st3-sup td.b { font-weight: 700; }
.st3-sup td.big { font-size: 11pt; letter-spacing: .3mm; }
.st3-sup td.sm { font-size: 8.4pt; }
.st3-sup .in { position: absolute; right: 1.5mm; top: 50%; transform: translateY(-50%); }
.st3-amt { height: 13mm; display: grid; grid-template-columns: 34mm 10mm 1fr 52mm; align-items: center; padding: 0 3mm; border-bottom: 0.4mm solid #000; }
.st3-amt .kor { font-weight: 700; text-align: right; padding-right: 3mm; white-space: nowrap; overflow: hidden; }
.st3-amt .won { text-align: right; font-weight: 700; }
.st3-items td { height: 6.2mm; border: 0.15mm solid #000; }
.st3-items td:first-child { border-left: 0; }
.st3-items td:last-child { border-right: 0; }
.st3-items tr.hd td { height: 8.9mm; text-align: center; border-bottom: 0.3mm solid #000; }
.st3-items tr.tot td { height: 10.6mm; border-top: 0.4mm solid #000; font-weight: 700; }
.st3-items td:nth-child(4) { border-right: 0.4mm solid #000; }
.st3-items td:nth-child(5) { border-right: 0.4mm solid #000; }
.st3-note { border-top: 0.4mm solid #000; padding: 2mm 3mm; font-size: 8.8pt; line-height: 1.6; font-family: "Gulim", "굴림", "Dotum", sans-serif; }

@media print {
  .stp { padding: 0 !important; box-shadow: none !important; min-height: 0 !important; width: auto !important; }
}
.badge.locked { background: #fde8e8; color: #b42318; margin-left: 6px; }
.btn.accent { background: #0f7b5f; border-color: #0f7b5f; color: #fff; font-weight: 600; }
.btn.accent:hover { background: #0b634c; }
#nav .foot .ver { display: block; border: 0; background: none; color: #b9c9de; font: inherit; font-size: 12px; padding: 0 0 4px; cursor: pointer; text-align: left; }
#nav .foot .ver:hover { color: #fff; text-decoration: underline; }
#nav .foot .ver span { color: #7f97b8; }
#nav .foot .ver.warn, #nav .foot .ver.warn b { color: #ffb4a8; }
/* 업데이트 알림 */
#update-bar { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 2500; display: flex; align-items: center; gap: 10px;
  background: #fff8e1; border: 1px solid #f0c36d; color: #5c4400; border-radius: 10px; padding: 8px 10px 8px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.15); font-size: 13.5px; white-space: nowrap; }
#update-bar .dot { width: 9px; height: 9px; border-radius: 50%; background: #e6a100; flex: none; }
#update-bar .x { border: 0; background: none; font-size: 18px; cursor: pointer; color: #8a6d1f; padding: 0 4px; }
.spin { width: 34px; height: 34px; margin: 0 auto; border: 3px solid #dfe5ee; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media print { #update-bar { display: none !important; } }

/* ================================================================ 로그인 (온라인 모드) */
#login-root { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% 0%, #2a4a74 0%, var(--nav) 55%, #0f1d30 100%); }
.login-card { width: 400px; max-width: 100%; background: #fff; border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.35); padding: 28px 30px 26px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-brand img { width: 52px; height: 52px; border-radius: 10px; }
.login-brand b { display: block; font-size: 19px; letter-spacing: -.3px; }
.login-brand span { color: var(--muted); font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form h2 { font-size: 17px; margin: 4px 0 0; }
.login-form p { margin: 0; font-size: 13px; line-height: 1.5; }
.login-form > label:not(.chk) { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #47526a; }
.login-form .inp { height: 38px; font-size: 14px; }
.login-form .btn.primary { height: 40px; justify-content: center; font-size: 14.5px; margin-top: 4px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; white-space: pre-line; }
#nav .who { margin-top: auto; padding: 12px 18px 8px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; color: #dbe4f0; }
#nav .who span { color: #8fa6c4; font-size: 12px; }
#nav .who-btns { display: flex; gap: 6px; margin-top: 6px; }
#nav .who-btns button { white-space: nowrap; border: 1px solid rgba(255,255,255,.18); background: none; color: #cfdbec; border-radius: 5px; font-size: 11.5px; padding: 3px 7px; cursor: pointer; }
#nav .who-btns button:hover { background: rgba(255,255,255,.08); color: #fff; }
#nav .foot.nomargin { margin-top: 0; border-top: 0; }
/* 다른 사람이 수정 중 (읽기 전용) */
.ro-bar { display: inline-flex; align-items: center; gap: 8px; background: #fdecec; border: 1px solid #f1b5b5; color: #9b1c1c;
  border-radius: 8px; padding: 3px 6px 3px 10px; font-size: 13px; font-weight: 600; margin-right: 8px; }
.ro-bar.free { background: #e7f6ec; border-color: #a8dcb9; color: #1f6b43; }
.doc-wrap.ro .pick { display: none; }
.doc-wrap.ro .doc td.ed:focus-within { background: none; box-shadow: none; }
.doc-wrap.ro input.ci { cursor: default; }
.badge.editing { background: #fdecec; color: #9b1c1c; margin-right: 4px; }
