/* 스피드장부 스타일 (Windows XP 업무 프로그램 느낌) */
:root {
  --face: #ece9d8; --face-2: #f5f4ea; --win: #fff; --line: #a5acb5; --line-2: #d4d0c8; --dark: #716f64;
  --title-1: #0a5fd8; --title-2: #3d8ff3; --title-3: #0749b8;
  --sel: #c7dcf6; --sel-line: #6f9bd8; --hdr-1: #fbfbf9; --hdr-2: #e4e2d6;
  --peach: #fde8cc; --peach-line: #e6b97a; --red: #d0021b; --blue: #1b49b8; --green: #1d7a2c;
  --text: #000; --muted: #5d6268;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "굴림", Gulim, "돋움", Dotum, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; font-size: 12px; color: var(--text); background: #6b7f99; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }

/* ───── 프로그램 틀 ───── */
.app { display: flex; flex-direction: column; height: 100vh; background: var(--face); }
.titlebar { height: 26px; display: flex; align-items: center; gap: 6px; padding: 0 8px; color: #fff; font-weight: bold; font-size: 13px;
  background: linear-gradient(180deg, var(--title-2) 0%, var(--title-1) 45%, var(--title-3) 100%); text-shadow: 1px 1px 0 #003; user-select: none; flex: none; }
.titlebar .logo { width: 16px; height: 16px; border-radius: 3px; background: #f37021; color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; text-shadow: none; }
.titlebar .grow { flex: 1; }
.titlebar .tb-user { font-weight: normal; font-size: 12px; opacity: .9; }
.titlebar .tb-x { width: 21px; height: 21px; border: 1px solid #fff; border-radius: 3px; background: linear-gradient(#e7765b, #c3401f); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 12px; }

.menubar { height: 22px; display: flex; align-items: stretch; background: var(--face); border-bottom: 1px solid #fff; flex: none; position: relative; z-index: 60; user-select: none; }
.menubar > div { position: relative; }
.menubar .mtop { padding: 3px 9px; cursor: default; height: 100%; }
.menubar .mtop:hover, .menubar .open > .mtop { background: #316ac5; color: #fff; }
.dropdown { position: absolute; top: 100%; left: 0; min-width: 190px; background: #fff; border: 1px solid #8a8a8a; box-shadow: 2px 2px 3px rgba(0,0,0,.35); padding: 2px 0; display: none; }
.menubar .open > .dropdown { display: block; }
.mi { display: flex; align-items: center; gap: 8px; padding: 4px 22px 4px 8px; cursor: default; white-space: nowrap; }
.mi .ic { width: 16px; height: 16px; flex: none; display: inline-flex; }
.mi .ic svg { width: 16px; height: 16px; }
.mi .k { margin-left: auto; padding-left: 20px; color: #444; }
.mi:hover { background: #316ac5; color: #fff; }
.mi:hover .k { color: #fff; }
.mi.dis { color: #aaa; }
.mi.dis:hover { background: none; color: #aaa; }
.msep { height: 1px; background: #c5c5c5; margin: 3px 2px; }

.toolbar { display: flex; align-items: center; gap: 1px; padding: 4px 6px; background: linear-gradient(#fbfbf8, #e9e6d7); border-bottom: 1px solid var(--line-2); flex: none; user-select: none; }
.tool { display: flex; align-items: center; gap: 3px; padding: 3px 6px 3px 4px; border: 1px solid transparent; border-radius: 3px; cursor: pointer; line-height: 1.15; font-size: 12px; }
.tool:hover { border-color: #b9b5a2; background: linear-gradient(#fff, #f1efe4); }
.tool.on { border-color: #d0021b; box-shadow: inset 0 0 0 1px #f3b1b8; background: #fff8f3; }
.tool svg { width: 28px; height: 28px; flex: none; }
.tool span { white-space: pre; }
.tsep { width: 1px; height: 32px; background: #c5c2b2; border-right: 1px solid #fff; margin: 0 5px; }

.body { flex: 1; display: flex; min-height: 0; }
.workarea { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 8px 6px 6px 8px; background: #aca899; background: linear-gradient(#f0eee3, #e4e1d2); }
.statusbar { height: 22px; border-top: 1px solid #fff; box-shadow: 0 -1px 0 var(--line-2); display: flex; align-items: center; padding: 0 6px; gap: 10px; background: var(--face); flex: none; }
.statusbar div { border: 1px solid; border-color: var(--line-2) #fff #fff var(--line-2); padding: 1px 8px; }
.statusbar .grow { flex: 1; }

/* 바로가기 */
.shortcut { flex: none; display: flex; border-left: 1px solid var(--line); }
.shortcut .vtab { width: 20px; background: var(--face); display: flex; flex-direction: column; align-items: center; padding-top: 8px; cursor: pointer; border-left: 1px solid #fff; user-select: none; }
.shortcut .vtab .dot { width: 14px; height: 14px; border-radius: 50%; background: #d0021b; color: #fff; font-size: 9px; display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.shortcut .vtab .lbl { writing-mode: vertical-rl; letter-spacing: 2px; }
.shortcut .panel { width: 132px; background: #dad6c7; padding: 0; display: flex; flex-direction: column; }
.shortcut .panel .ph { background: linear-gradient(var(--title-2), var(--title-1)); color: #fff; padding: 2px 6px; display: flex; justify-content: space-between; }
.shortcut .panel .ph span { cursor: pointer; }
.shortcut .panel .pt { margin: 6px; padding: 3px; text-align: center; font-weight: bold; background: linear-gradient(#fff, #e3e0d1); border: 1px solid var(--line); }
.shortcut .panel .list { padding: 4px 8px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.shortcut .panel .list button { width: 100%; }

/* ───── 탭 ───── */
.tabs { display: flex; align-items: flex-end; gap: 1px; padding-left: 4px; flex: none; position: relative; z-index: 1; }
.tab { padding: 4px 12px 3px; border: 1px solid #919b9c; border-bottom: 0; background: linear-gradient(#fff, #ece9d8); border-radius: 3px 3px 0 0; cursor: pointer; margin-bottom: -1px; user-select: none; }
.tab.on { background: #fcfcfe; border-top: 2px solid #e68b2c; padding-top: 3px; padding-bottom: 4px; font-weight: bold; }
.tabpage { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 1px solid #919b9c; background: #fcfcfe; padding: 6px; }

/* 조회 바 */
.qbar { display: flex; align-items: center; gap: 4px; padding: 4px 6px; background: linear-gradient(#e2dfd1, #cdc9b7); border: 1px solid #b2ae9c; flex: none; flex-wrap: wrap; }
.qbar .lab { color: #333; margin: 0 2px 0 10px; }
.qbar .grow { flex: 1; }
.qbar input[type=text], .qbar input[type=search] { width: 150px; }

/* ───── 컨트롤 ───── */
input[type=text], input[type=date], input[type=password], input[type=number], input[type=search], select, textarea {
  border: 1px solid #7f9db9; background: #fff; padding: 2px 4px; height: 21px; border-radius: 0; min-width: 0; }
textarea { height: auto; resize: vertical; width: 100%; }
select { padding: 1px 2px; }
input:focus, select:focus, textarea:focus { outline: 1px solid #f6b33c; outline-offset: 0; }
input[readonly] { background: #f3f2ea; }
input.money, .money { text-align: right; }
input.ro-yellow { background: #fff8e0; }
input.ro-blue { background: #e9eefb; }
input.ro-pink { background: #fde8e3; }
.xbtn, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 23px; padding: 0 10px; border: 1px solid #003c74; border-radius: 3px; cursor: pointer; white-space: nowrap;
  background: linear-gradient(#fff 0%, #f0efe8 60%, #d6d0c0 100%); color: #000; text-decoration: none; }
.xbtn:hover, .btn:hover { box-shadow: inset 0 0 0 2px #f8b636; }
.xbtn:active { background: linear-gradient(#d6d0c0, #f0efe8); }
.xbtn:disabled { color: #999; border-color: #aaa; cursor: default; box-shadow: none; }
.xbtn.big { height: 28px; min-width: 110px; font-size: 12.5px; }
.xbtn.ok { background: linear-gradient(#fff, #eef6df 60%, #cfe4ad); border-color: #4c7a19; }
.xbtn.close { background: linear-gradient(#fff, #f6ecef 60%, #e6ccd3); border-color: #8a3e4f; }
.xbtn.sm { height: 19px; padding: 0 6px; font-size: 11.5px; }
.xbtn.menu { border-color: #888; }
.btn.primary { border-color: #003c74; font-weight: bold; }
.chk { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; white-space: nowrap; user-select: none; }
.chk input { margin: 0; }
.rgrp { display: inline-flex; gap: 10px; align-items: center; padding: 2px 8px; border: 1px solid var(--peach-line); background: var(--peach); height: 23px; }
.rgrp label { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; white-space: nowrap; }
.rgrp input { margin: 0; }
.rgrp.plain { background: #fff; border-color: #7f9db9; }
.req { color: var(--red); }
fieldset { border: 1px solid #d0d0bf; border-radius: 4px; margin: 0; padding: 6px 10px 10px; background: transparent; min-width: 0; }
legend { color: #0046d5; padding: 0 4px; }
.frm { display: grid; grid-template-columns: 78px 1fr; gap: 5px 6px; align-items: center; }
.frm > label { text-align: right; color: #222; white-space: nowrap; }
.frm .wide { grid-column: 2 / -1; }
.frm4 { grid-template-columns: 78px 1fr 70px 1fr; }
.row { display: flex; gap: 6px; align-items: center; }
.row .grow { flex: 1; }
.hint { color: var(--muted); font-size: 11.5px; }
.ib { display: inline-flex; }
.ib input { flex: 1; }
.ib .dd-btn { width: 22px; height: 21px; border: 1px solid #7f9db9; border-left: 0; background: linear-gradient(#e8eefb, #c1d3fb); cursor: pointer; padding: 0; font-size: 9px; }
.won { margin-left: 4px; }

/* ───── 그리드 ───── */
.grid-wrap { flex: 1; min-height: 60px; overflow: auto; border: 1px solid #7f9db9; background: #fff; position: relative; }
.grid-wrap:focus { outline: none; }
table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; table-layout: fixed; }
.grid th { position: sticky; top: 0; z-index: 2; background: linear-gradient(var(--hdr-1), var(--hdr-2)); border-right: 1px solid #c7c5b2; border-bottom: 2px solid #c7c5b2; font-weight: normal; padding: 3px 4px; text-align: center; white-space: nowrap; overflow: hidden; height: 22px; }
.grid.dark th { background: linear-gradient(#7d8aa7, #5f6c8c); color: #fff; border-right-color: #8892aa; border-bottom-color: #46516c; }
.grid td { border-right: 1px solid #e3e3e3; border-bottom: 1px solid #e3e3e3; padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 22px; }
.grid td.r { text-align: right; }
.grid td.c { text-align: center; }
.grid td.sel-col, .grid th.sel-col { width: 18px; padding: 0; text-align: center; background: linear-gradient(90deg, #fbfbf9, #ecebe3); border-right: 1px solid #c7c5b2; color: #000; font-size: 9px; }
.grid tbody tr { cursor: default; }
.grid tbody tr.on td { background: var(--sel); }
.grid tbody tr.on td.sel-col { background: linear-gradient(90deg, #fbfbf9, #ecebe3); }
.grid td input[type=checkbox] { margin: 0; vertical-align: middle; }
.grid td.edit { padding: 0; }
.grid td.edit input { width: 100%; height: 22px; border: 0; background: transparent; padding: 2px 5px; }
.grid td.edit input:focus { background: #fffbe0; outline: 1px solid #f6b33c; }
.grid .neg { color: var(--red); } .grid .pos { color: var(--blue); }
.grid tfoot td { position: sticky; bottom: 0; background: #f3f1e6; font-weight: bold; border-top: 1px solid #c7c5b2; }
.gfoot { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border: 1px solid #b2ae9c; border-top: 0; background: var(--face-2); flex: none; flex-wrap: wrap; }
.gfoot .grow { flex: 1; }
.sumbox { display: inline-flex; align-items: center; border: 1px solid #b6b29f; background: #fff; height: 19px; }
.sumbox b { padding: 0 6px; font-weight: normal; color: var(--red); background: #faf5e6; height: 100%; display: flex; align-items: center; border-right: 1px solid #b6b29f; }
.sumbox b.blue { color: var(--blue); }
.sumbox span { padding: 0 6px; min-width: 60px; text-align: right; }
.sumbox span + span { border-left: 1px solid #ddd; min-width: 90px; }
.split-head { display: flex; align-items: center; gap: 6px; height: 21px; padding: 0 6px; margin-top: 6px; color: #fff; flex: none;
  background: linear-gradient(#9fb6d8, #7a97c4); border: 1px solid #5c7bab; }
.split-head::before { content: "⁞"; color: #dfe7f3; }
.lower { height: 34%; min-height: 150px; display: flex; flex-direction: column; flex: none; }
.lower .qbar { border-top: 0; }
.empty-msg { color: var(--muted); text-align: center; padding: 30px; }
.tag { display: inline-block; padding: 0 4px; border-radius: 2px; }
.t-매출, .t-출고 { color: #1b49b8; } .t-매입, .t-입고 { color: #b94a00; }
.t-반입, .t-반출 { color: #7a2ab8; } .t-수금, .t-입금 { color: #1d7a2c; } .t-지급, .t-출금 { color: #d0021b; }

/* ───── 대화상자(창) ───── */
.dlg-layer { position: fixed; inset: 0; background: rgba(40,48,60,.18); z-index: 100; }
.dlg { position: fixed; background: var(--face); border: 1px solid #0831d9; border-top: 0; border-radius: 6px 6px 0 0; box-shadow: 3px 4px 14px rgba(0,0,0,.4); display: flex; flex-direction: column; max-height: 96vh; max-width: 98vw; }
.dlg-title { height: 25px; display: flex; align-items: center; padding: 0 3px 0 8px; color: #fff; font-weight: bold; border-radius: 6px 6px 0 0; cursor: move; user-select: none; flex: none;
  background: linear-gradient(180deg, var(--title-2) 0%, var(--title-1) 45%, var(--title-3) 100%); text-shadow: 1px 1px 0 #003; }
.dlg-title .grow { flex: 1; }
.dlg-title .x { width: 20px; height: 20px; border: 1px solid #fff; border-radius: 3px; background: linear-gradient(#e7765b, #c3401f); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.dlg-body { padding: 8px; overflow: auto; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.dlg-foot { padding: 6px 8px 8px; display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex: none; }
.dlg-foot .left { margin-right: auto; }
.dlg-banner { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; margin-bottom: 6px; background: linear-gradient(90deg, #fff, #c6d7f5); border: 1px solid #a8bbe0; }
.dlg-banner .t { padding: 2px 8px; background: #fff; border: 1px solid #a8bbe0; }

/* 전표등록 */
.vbox { border: 1px solid #919b9c; background: #fcfcfe; padding: 8px; }
.listbar { display: flex; align-items: center; gap: 6px; padding: 2px 6px; background: linear-gradient(#a3a3a3, #7d7d7d); color: #fff; font-weight: bold; height: 22px; }
.listbar::before { content: ""; width: 10px; height: 10px; background: #fff; border: 1px solid #555; }
.listbar .grow { flex: 1; }
.sidebtns { display: flex; flex-direction: column; gap: 4px; padding: 4px; border: 1px solid #d0021b; background: #f5f4ea; }
.sidebtn { width: 44px; height: 52px; border: 1px solid #a5a5a5; border-radius: 3px; background: linear-gradient(#fff, #e6e3d6); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; padding: 0; }
.sidebtn:hover { box-shadow: inset 0 0 0 2px #f8b636; }
.sidebtn b { font-size: 18px; line-height: 1; }
.paybox { border: 1px solid #d0021b; background: #fdf0e0; padding: 6px; }
.totbox .frm { grid-template-columns: 80px 1fr 16px; }
.totbox label.red { color: var(--red); }
.totbox label.blue { color: var(--blue); }
.opbox { border: 1px solid #919b9c; background: #fff; padding: 6px; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.opbox > * { flex: none; }
.opbox > .grid-wrap { flex: 1; }
.opbox .obar { background: linear-gradient(#d9d6c8, #c9c5b3); padding: 4px 8px; margin-bottom: 6px; }
.info-list { margin: 6px 0 0; padding: 0 0 0 4px; list-style: none; line-height: 1.8; }
.info-list li::before { content: "• "; color: #888; }

/* 품목 추가 팝업 */
.pp { display: grid; grid-template-columns: 150px minmax(0, 1fr) 250px; gap: 6px; flex: 1; min-height: 0; }
.pp .groups { border: 1px solid #7f9db9; background: #fff; overflow: auto; }
.pp .groups div { padding: 3px 6px; cursor: pointer; border-bottom: 1px dotted #eee; }
.pp .groups div.on { background: #dbe7fa; border: 1px solid #9eb9e6; }
.pp .detail { border: 1px solid #919b9c; background: #f7f6ef; padding: 8px; overflow: auto; }
.pp .detail h4 { margin: 2px 0 8px; font-size: 12px; }
.pp .detail h4::before { content: "▶ "; color: #f37021; }

/* 컨텍스트 메뉴 */
.ctx { position: fixed; z-index: 1000; background: #fff; border: 1px solid #8a8a8a; box-shadow: 2px 2px 4px rgba(0,0,0,.35); padding: 2px 0; min-width: 200px; }

#toast { position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%); z-index: 1100; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast div { background: #ffffe1; color: #000; padding: 7px 14px; border: 1px solid #000; box-shadow: 2px 2px 3px rgba(0,0,0,.3); }
#toast div.err { background: #fde8e3; border-color: #d0021b; color: #a00; }

/* 로그인 */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(#5a7edc, #3a63c4); }
.login .dlg { position: static; width: 380px; }
.login .dlg-body { padding: 16px 18px; gap: 8px; }
.login input { height: 24px; }

/* 보고서 막대 */
.bar { height: 10px; background: #e7e5da; border: 1px solid #c5c2b2; min-width: 80px; }
.bar i { display: block; height: 100%; background: linear-gradient(#7ea4e0, #3c6fc8); }
.bar.buy i { background: linear-gradient(#f2b07a, #d9773a); }
.stamp-prev { width: 80px; height: 80px; border: 1px dashed #999; background: #fff; display: flex; align-items: center; justify-content: center; }
.stamp-prev img { max-width: 100%; max-height: 100%; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; margin-bottom: 6px; flex: none; }
.card { border: 1px solid #b2ae9c; background: #fff; padding: 6px 8px; }
.card .l { color: var(--muted); }
.card .v { font-size: 15px; font-weight: bold; margin-top: 2px; text-align: right; }

/* ───────── 거래명세표 인쇄 ───────── */
body.print-mode { background: #e9ebee; }
.print-bar { position: sticky; top: 0; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 8px; align-items: center; z-index: 5; }
.sheet { width: 210mm; min-height: 297mm; margin: 16px auto; background: #fff; padding: 10mm 11mm; box-shadow: 0 2px 10px rgba(0,0,0,.12); color: #000; }
.stmt { border: 2px solid #1f3b57; padding: 0; font-size: 11.5px; color: #111; }
.stmt + .cut { border-top: 1px dashed #999; margin: 6mm 0; position: relative; }
.stmt .t { display: flex; align-items: center; border-bottom: 2px solid #1f3b57; }
.stmt .t h2 { flex: 1; text-align: center; margin: 0; padding: 7px 0; font-size: 20px; letter-spacing: 10px; color: #1f3b57; }
.stmt .t .who { width: 34mm; text-align: center; font-size: 11px; color: #1f3b57; }
.stmt .t .no { width: 34mm; font-size: 11px; padding-left: 8px; color: #333; }
.stmt .top { display: grid; grid-template-columns: 1fr 1.25fr; border-bottom: 1px solid #1f3b57; }
.stmt .buyer { padding: 8px 10px; border-right: 1px solid #1f3b57; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.stmt .buyer .nm { font-size: 16px; font-weight: 700; }
.stmt .buyer .sum { border-top: 1px solid #bbb; padding-top: 6px; }
.stmt .buyer .sum b { font-size: 14px; }
.stmt table { width: 100%; border-collapse: collapse; }
.stmt .sup td { border: 1px solid #1f3b57; padding: 3px 5px; height: 22px; }
.stmt .sup tr:first-child td { border-top: 0; } .stmt .sup tr:last-child td { border-bottom: 0; }
.stmt .sup td:last-child { border-right: 0; }
.stmt .sup td.k { background: #eef3f8; text-align: center; width: 15mm; font-size: 10.5px; color: #1f3b57; }
.stmt .sup td.vlabel { writing-mode: vertical-rl; text-align: center; background: #eef3f8; width: 7mm; border-left: 0; color: #1f3b57; letter-spacing: 3px; }
.stmt .sup .stampbox { position: relative; }
.stmt .sup .stampbox img { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); height: 15mm; opacity: .85; }
.stmt .items th { background: #eef3f8; color: #1f3b57; font-weight: 600; border: 1px solid #1f3b57; border-top: 0; padding: 4px; font-size: 11px; }
.stmt .items td { border: 1px solid #9fb0c2; padding: 3px 5px; height: 20px; }
.stmt .items th:first-child, .stmt .items td:first-child { border-left: 0; }
.stmt .items th:last-child, .stmt .items td:last-child { border-right: 0; }
.stmt .items td.r { text-align: right; font-variant-numeric: tabular-nums; }
.stmt .items td.c { text-align: center; }
.stmt .items tfoot td { background: #f6f8fb; font-weight: 700; border-top: 1px solid #1f3b57; }
.stmt .bottom { display: grid; grid-template-columns: repeat(4, 1fr) 1.6fr; border-top: 1px solid #1f3b57; }
.stmt .bottom div { padding: 4px 6px; border-right: 1px solid #9fb0c2; font-size: 11px; }
.stmt .bottom div:last-child { border-right: 0; }
.stmt .bottom div span { color: #1f3b57; display: block; font-size: 10px; }
.stmt .bottom div b { font-variant-numeric: tabular-nums; }
.stmt .note { border-top: 1px solid #9fb0c2; padding: 4px 8px; font-size: 10.5px; color: #333; min-height: 18px; }

@media print {
  @page { size: A4; margin: 0; }
  body.print-mode { background: #fff; }
  .print-bar, .no-print { display: none !important; }
  .sheet { margin: 0; box-shadow: none; }
  body:not(.print-mode) .side, body:not(.print-mode) .page-head .btns, body:not(.print-mode) .filters { display: none !important; }
  body:not(.print-mode) .shell { display: block; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

body.print-mode { overflow: auto; }
body.print-mode .print-bar .btn { height: 26px; }
