:root {
  --bg: #f4f6f9; --panel: #fff; --line: #dde2ea; --text: #1d2433; --muted: #6b7486;
  --blue: #2563eb; --blue-l: #e8efff; --red: #d6293e; --green: #12805c; --orange: #d97706;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Malgun Gothic', '맑은 고딕', system-ui, sans-serif; font-size: 15px; color: var(--text); background: var(--bg); display: flex; min-height: 100vh; }
#nav { width: 210px; flex-shrink: 0; background: #17213a; color: #cfd6e4; padding: 12px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
#nav .brand { font-size: 19px; font-weight: 700; color: #fff; padding: 6px 18px 16px; }
#nav a { display: flex; justify-content: space-between; align-items: center; color: inherit; text-decoration: none; padding: 11px 18px; font-size: 15px; }
#nav a:hover { background: #22305a; }
#nav a.on { background: var(--blue); color: #fff; }
kbd { font-size: 11px; background: rgba(255,255,255,.15); border-radius: 4px; padding: 1px 5px; font-family: inherit; }
main { flex: 1; padding: 20px 26px 60px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h2 { font-size: 17px; margin: 0 0 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.muted { color: var(--muted); font-size: 13px; }
.red { color: var(--red); } .blue { color: var(--blue); } .green { color: var(--green); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.big { font-size: 26px; font-weight: 700; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #c5ccd8; border-radius: 6px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
button { font: inherit; padding: 8px 14px; border: 1px solid #c5ccd8; border-radius: 6px; background: #fff; cursor: pointer; white-space: nowrap; }
button:hover { background: #f0f3f8; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
button.primary:hover { background: #1d4fd0; }
button.danger { color: var(--red); border-color: #f0b8c0; }
button.sm { padding: 4px 9px; font-size: 13px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.f input, label.f select, label.f textarea { color: var(--text); font-size: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.form-grid .full { grid-column: 1 / -1; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 7px 9px; text-align: left; font-size: 14px; }
th { background: #f1f4f9; font-weight: 600; color: #3b4457; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
tbody tr:hover { background: #f7f9fd; }
tr.click { cursor: pointer; }
tfoot td { font-weight: 700; background: #f8fafc; }
.table-wrap { max-height: 62vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card .t { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.card .v { font-size: 22px; font-weight: 700; }
.tag { display: inline-block; font-size: 12px; padding: 2px 7px; border-radius: 10px; background: #eef1f6; color: #4b5568; }
.tag.sale { background: #e8efff; color: var(--blue); } .tag.buy { background: #fdecee; color: var(--red); }
.tag.ok { background: #e3f5ee; color: var(--green); } .tag.wait { background: #fff4e0; color: var(--orange); }

/* 장기 입력 그리드 */
.entry td { padding: 3px 4px; }
.entry input { width: 100%; border-color: transparent; background: transparent; padding: 7px 6px; }
.entry input:hover { border-color: #d5dbe5; }
.entry input:focus { background: #fff; }
.entry td.no { width: 36px; text-align: center; color: var(--muted); }
.entry .c-name { width: 26%; } .entry .c-note { width: 22%; } .entry .c-qty { width: 11%; } .entry .c-price { width: 14%; } .entry .c-amt { width: 16%; }
.entry td.amt { text-align: right; font-weight: 600; padding-right: 10px; }
.totals { display: flex; gap: 24px; justify-content: flex-end; align-items: baseline; padding: 14px 6px 4px; flex-wrap: wrap; }
.totals .k { color: var(--muted); font-size: 13px; margin-right: 6px; }
.totals .v { font-size: 20px; font-weight: 700; }
.totals .v.total { font-size: 28px; color: var(--blue); }

/* 자동완성 */
.ac { position: absolute; z-index: 50; background: #fff; border: 1px solid #b9c3d3; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 300px; overflow-y: auto; min-width: 260px; }
.ac div { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 14px; }
.ac div.on, .ac div:hover { background: var(--blue-l); }
.ac small { color: var(--muted); }

#modal { position: fixed; inset: 0; background: rgba(15,22,40,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding-top: 6vh; }
.modal-box { background: #fff; border-radius: 12px; padding: 20px 22px; width: min(720px, 94vw); max-height: 86vh; overflow-y: auto; }
.hidden { display: none !important; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #17213a; color: #fff; padding: 12px 20px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 200; font-size: 15px; }
#toast.show { opacity: 1; } #toast.err { background: var(--red); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.hint { background: #f3f7ff; border: 1px solid #d6e2ff; color: #33476e; padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.6; margin-bottom: 12px; }

@media (max-width: 1200px) {
  .cols { grid-template-columns: minmax(0, 1fr) !important; }
  #nav { width: 170px; }
}

/* 작성 중(확정 안 됨) = 주황, 확정 = 초록 */
.wipbox { background: #fff4e0; border: 1px solid #f3c77a; border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; color: #7a4a00; }
.wipbox table { background: transparent; } .wipbox td { border-bottom-color: #f6dcae; }
tr.okrow td:first-child { border-left: 4px solid #3aa86b; color: #1d5c3a; }

/* 재고 실사 */
.countpanel { border-color: #cfe3d6; background: #f6fbf8; }
.cbig { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 260px; padding: 12px 16px; text-align: left; background: #fff; }
.cbig b { font-size: 16px; } .cbig small { color: var(--muted); }
tr.cdone td { background: #f2fbf6; } input.cin { width: 130px; font-size: 16px; }
.wtag { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 2px 8px; margin-top: 4px; background: #f2f4f7; color: var(--muted); }
.wtag.before { background: #fff1d6; color: #8a5a00; } .wtag.new { background: #fdecee; color: var(--red); }
.rst { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 99px; padding: 2px 9px; background: #f2f4f7; color: var(--muted); }
.rst.ok { background: #e3f5ee; color: var(--green); } .rst.miss { background: #fdecee; color: var(--red); } .rst.short { background: #e8efff; color: var(--blue); } .rst:empty { display: none; }
tr.oin td:first-child { box-shadow: inset 3px 0 var(--blue); } tr.oout td:first-child { box-shadow: inset 3px 0 var(--red); }
table.irep td { padding: 4px 8px; } table.irep tr.ig td { padding-top: 14px; font-size: 15px; border-bottom: 1px solid #222; }
table.irep tr.ik td { padding-left: 24px; color: var(--muted); border-bottom: 1px solid #ccc; } table.irep tr.ir td:first-child { padding-left: 48px; }
table.irep tr.ir td { border-bottom: 1px dashed #ddd; } table.irep tr.is td:first-child { padding-left: 48px; } table.irep tr.is td { font-weight: 700; }
table.irep tr.igs td:first-child { padding-left: 24px; } table.irep tr.igs td { font-weight: 700; background: #f7f9fc; } table.irep tr.itot td { font-weight: 800; border-top: 2px solid #222; font-size: 15px; }
.cquick textarea { width: 100%; font-size: 15px; margin-top: 6px; } .cbulkbtn { margin: 6px 0; }
.elist.pc { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; } .elist-empty { color: var(--muted); padding: 14px 0; text-align: center; }
.erow { display: grid; grid-template-columns: 1fr auto auto auto 30px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.erow .eq { font-size: 16px; } .erow .es { font-size: 12px; color: var(--green); } .erow .et { font-size: 12px; color: var(--muted); } .erow .edel { padding: 2px 6px; }
.nsugw { position: relative; } .nsugw input { width: 100%; }
.nsug { display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 260px; overflow: auto; }
.nsug.on { display: block; } .nsug div { padding: 7px 10px; cursor: pointer; } .nsug div:hover { background: #f2f6ff; } .nsug small { color: var(--muted); }
.eqin { width: 70px; text-align: right; font-weight: 700; font-size: 15px; }
.dsearch { align-self: flex-end; } .dsearch.pending { animation: dsp 1s ease-in-out infinite; } @keyframes dsp { 50% { box-shadow: 0 0 0 4px #ffd27a; } }
.nnote { width: 100%; margin-top: 6px; } .erow .enote { color: var(--muted); }
.leftlist { max-height: 60vh; overflow: auto; margin-top: 8px; } .lcat { font-weight: 700; color: var(--blue); margin: 10px 0 2px; }
.lrow { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.lqty { width: 70px; text-align: right; } .lrow { grid-template-columns: 1fr auto auto auto !important; }
.lrow small, .lbook { color: var(--muted); } .lbook b { color: #222; } .lsame { display: flex; gap: 4px; align-items: center; font-weight: 700; }
.noteadd { display: grid; grid-template-columns: 1fr 90px auto; gap: 6px; }
#pclogin { position: fixed; inset: 0; background: rgba(20,30,50,.55); display: grid; place-items: center; z-index: 100; }
.pclogin-box { background: #fff; border-radius: 12px; padding: 28px; width: 320px; display: grid; gap: 10px; }
table.cbook tr.cday td { background: #f6f8fb; font-weight: 700; font-size: 12px; border-bottom: 2px solid var(--line); }
.ihint { background: #fffaf0; border: 1px solid #f3dfb0; color: #6b4a00; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 8px 0; }
.pager { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.cfind { margin-left: auto; background: #fdecee; color: var(--red); padding: 12px 16px; border-radius: 8px; font-weight: 700; text-decoration: none; }
td.flowc { font-size: 12px; white-space: nowrap; } td.flowc span { background: #f2f4f7; border-radius: 99px; padding: 2px 8px; } td.flowc span.now { background: #fdecee; color: var(--red); }
table.ctl tr.tover td { background: #fdecee; } table.ctl tr.tsoon td { background: #eef3ff; }
table.moves { margin-top: 6px; } table.moves td { padding: 4px 6px; font-size: 12px; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 4px; }

/* 메모 */
.memo { display: flex; gap: 10px; align-items: flex-start; padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
.memo:hover { background: #f7f9fd; } .memo .mdone { margin-top: 4px; width: 18px; height: 18px; }
.mday { font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 0 4px; padding-bottom: 4px; border-bottom: 2px solid var(--line); }
.memo.done .mtext { text-decoration: line-through; color: var(--muted); }
/* 재무제표 */
table.fin td { padding: 9px 10px; } table.fin tr.sum td { background: #f5f7fb; } table.fin tr.total td { background: #e8efff; font-size: 16px; }
table.fin tr.sec td { background: #eef1f6; font-weight: 700; color: #3b4457; font-size: 13px; }
.trend .bar1 { height: 7px; background: #2563eb; border-radius: 4px; margin-bottom: 3px; } .trend .bar2 { height: 7px; background: #12805c; border-radius: 4px; } .trend .bar2.neg { background: #d6293e; }
/* 세금 */
table.taxt tr.tsoon td { background: #fff7e6; } table.taxt tr.tover td { background: #fdecee; } table.taxt tr.tdone td { color: var(--muted); }
.taxalert { border-color: #f3c77a; background: #fffbf2; }

/* 작성 순서 */
table.written tr.daysep td { background: #eef2f8; font-weight: 700; color: #3b4457; font-size: 13px; }
table.written tr.laterow td { background: #fffaf0; }

/* 거래처 원장 */
table.ledger tr.sliphead td { background: #f3f6fb; border-top: 1px solid #cfd8e6; }
table.ledger tr.itemrow td { font-size: 13px; color: #4b5568; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #eef1f5; }
table.ledger tr.itemrow td:nth-child(3) { padding-left: 22px; }
table.ledger tr.payrow td { background: #f2fbf6; }
.pastlock { background: #fff4e0 !important; border-color: #f3c77a !important; color: #7a4a00 !important; }
input:disabled, select:disabled { background: #f3f4f6; color: #555; }

/* 인쇄 */
#print { display: none; }
@media print {
  body > *:not(#print) { display: none !important; }
  body { background: #fff; display: block; }
  #print { display: block; }
  .page { page-break-after: always; padding: 6mm 4mm; font-size: 12px; }
  .page:last-child { page-break-after: auto; }
  @page { size: A4; margin: 10mm; }
}
.page h1 { justify-content: center; font-size: 22px; letter-spacing: 6px; margin-bottom: 10px; }
.page table { width: 100%; } .page th, .page td { border: 1px solid #555; padding: 4px 6px; font-size: 12px; position: static; }
.page th { background: #eee; }
.page .head { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.page .sum { margin-top: 8px; }
.page .day td { background: #f5f5f5; font-weight: 700; }
/* 입금·지급 내역: 반영 대기 줄 강조 */
tr.swait td { background: #fffbea; }
.hint.flow b { white-space: nowrap; }
@media print { .noprint { display: none !important; } }
/* 오늘이 아닌 날짜 장기 경고 · 메모 이름표 */
.hint.datewarn { background: #fff1e0; border-color: #f3a64a; color: #8a4b00; font-weight: 600; }
a.mref { cursor: pointer; background: #eef4ff; color: #1d4f99; border-radius: 6px; padding: 1px 6px; text-decoration: none; }
/* 장기와 같이 적는 입금·DC */
.paybox { margin: 10px 4px 0; padding: 10px 12px; border: 1.5px dashed #c9d6ea; border-radius: 10px; background: #f8fbff; }
.paytbl { width: 100%; margin-top: 6px; }
.paytbl td { padding: 3px 4px; }
/* 이상 거래 확인: 사입 vs 판매 */

tr.traderow td { border-top: 0; padding-top: 0; }
.trade { background: #f6f7f9; border-radius: 8px; padding: 6px 10px; font-size: 13px; line-height: 1.9; }
.trade a.tline { cursor: pointer; color: inherit; text-decoration: none; margin-right: 10px; padding: 1px 6px; border-radius: 6px; background: #fff; border: 1px solid #e3e5ea; }
.trade a.tline.hit { color: #c0392b; border-color: #f0b3ad; background: #fff3f2; }
/* 그날 거래한 거래처 */

.dayslips { width: 100%; margin-top: 8px; }
.dayslips td { padding: 4px 8px; }
.dayp h2 a { color: inherit; text-decoration: none; }
/* 입출금 내역 출처 표시 */


.tag.src-bank { background: #e3efff; color: #1d4f99; }
.tag.src-manual { background: #fff1d6; color: #8a5a00; }
.tag.src-direct { background: #eceff3; color: #444; }
.tag.src-card { background: #f3e6ff; color: #6a2ca0; }
button.warnbtn { background: #fff4e0; border-color: #f3c77a; color: #8a5a00; }
/* 입출금 내역: 여기서 바로 적기 */
.qadd { background: #f8fbff; border: 1.5px dashed #c9d6ea; }
