/* 支払いチェック — 담백한 화면. 사각 칸, 모서리 8~12px, 고정폭 숫자. */
:root {
  --bg: #f4f5f6; --card: #ffffff; --ink: #1d2329; --sub: #5d6873; --faint: #8c96a0;
  --line: #dde1e5; --line2: #c9cfd5; --accent: #22445e; --accent-bg: #e8eef3;
  --warn-bg: #fff6e0; --warn-line: #e8d29a; --danger: #a33a2e; --done: #7d8892;
  --r: 10px; --tabh: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px; line-height: 1.45;
  padding-bottom: calc(var(--tabh) + var(--safe-b) + 12px);
}
:lang(ko) body, html:lang(ko) body { font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Hiragino Sans", sans-serif; }
body.sheet-open { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
input, textarea { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num, .amt, .big-amt input, .mrow .num, .pt td { font-variant-numeric: tabular-nums; }
main { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.empty { text-align: center; color: var(--sub); padding: 48px 0; }
.page-title { font-size: 20px; margin: 20px 0 8px; }

/* 상단 알림 */
#banner { position: sticky; top: 0; z-index: 20; background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); padding: 10px 16px; font-size: 14px; text-align: center; }

/* 월 이동 */
.nav { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: 12px 0 4px; }
.nav-title { margin: 0; font-size: 20px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.nav-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }

/* 합계 */
.summary { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin: 8px 0 12px; }
.sum-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; color: var(--sub); font-size: 15px; padding: 2px 0; }
.sum-line b { color: var(--ink); font-weight: 600; }
.sum-line.big { color: var(--ink); font-size: 15px; padding-bottom: 6px; }
.sum-line.big b { font-size: 26px; letter-spacing: .01em; }

.notice { display: flex; justify-content: space-between; align-items: center; width: 100%; margin: 0 0 8px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; font-size: 14px; }
.notice svg { width: 18px; height: 18px; color: var(--sub); }
.uninput { border: 1px solid var(--line2); border-radius: var(--r); background: var(--card); padding: 12px 14px; margin: 0 0 12px; }
.uninput p { margin: 0 0 10px; font-size: 15px; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 16px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--card); font-weight: 500; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #dcbab5; }
.btn.add svg { width: 18px; height: 18px; }
.btn:active, .choice:active, .row-main:active, .srow-main:active, .mrow:active { opacity: .7; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.foot-actions { margin: 16px 0 8px; }

/* 구분 묶음과 줄 */
.grp { margin: 16px 0 4px; }
.grp-h { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 6px; padding: 0 2px; font-size: 14px; font-weight: 600; color: var(--sub); border-bottom: 1px solid var(--line2); padding-bottom: 4px; }
.row { display: flex; align-items: stretch; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 6px; }
.row-main { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "nm amt" "sub sub"; column-gap: 10px; align-items: baseline; padding: 10px 6px 10px 12px; }
.row .due { font-weight: 600; color: var(--ink); }
.row .nm { grid-area: nm; font-weight: 500; overflow-wrap: anywhere; }
.row .amt { grid-area: amt; font-weight: 600; white-space: nowrap; }
.row .amt.est { color: var(--faint); font-weight: 400; }
.row .sub { grid-area: sub; font-size: 13px; color: var(--sub); margin-top: 2px; }
.row.done .nm, .row.done .amt { color: var(--done); }
.bd-toggle { display: flex; align-items: center; gap: 2px; font-size: 12px; color: var(--sub); padding: 0 4px; }
.bd-toggle svg { width: 14px; height: 14px; }
.chk { width: 52px; display: grid; place-items: center; border-left: 1px solid var(--line); }
.chk svg { width: 30px; height: 30px; padding: 4px; border: 2px solid var(--line2); border-radius: 8px; stroke: transparent; stroke-width: 2.6; }
.chk.on svg { background: var(--accent); border-color: var(--accent); stroke: #fff; }
.bd { list-style: none; margin: -2px 0 8px; padding: 6px 12px 6px 24px; background: var(--card); border: 1px dashed var(--line2); border-radius: 8px; font-size: 13px; color: var(--sub); }
.bd li { display: flex; justify-content: space-between; padding: 2px 0; }
.orphan { margin: 6px 0; font-size: 13px; color: var(--sub); }
.orphan p { margin: 0 0 4px; }

/* 계좌 */
.acc { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin: 12px 0; }
.acc .row { border-color: var(--line); }
.acc-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 0 10px; font-size: 17px; }
.acc-need { display: flex; flex-direction: column; align-items: flex-end; }
.acc-need small { font-size: 12px; color: var(--sub); font-weight: 400; }
.acc-need b { font-size: 18px; }
.acc .sum-line { padding: 6px 2px 10px; }

/* 연간 */
.months { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.mrow { display: grid; grid-template-columns: 3.2em 6.5em 1fr 3.6em; gap: 8px; align-items: center; width: 100%; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.mrow:last-child { border-bottom: 0; }
.mrow .num { text-align: right; font-weight: 500; }
.mrow .bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.mrow .bar i { display: block; height: 100%; background: var(--accent); }
.mrow.proj .bar i { background: var(--line2); }
.mrow.proj .num, .mrow.empty .num { color: var(--faint); }
.mrow .tag { font-size: 12px; color: var(--sub); text-align: right; }
.mrow.cur { background: var(--accent-bg); }
.fold { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 12px 2px; font-weight: 600; border-bottom: 1px solid var(--line2); }
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: grid; grid-template-columns: 1fr auto; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.items li small { grid-column: 1 / -1; color: var(--sub); font-size: 12px; text-align: right; }

/* 설정 */
.sgrp { margin: 18px 0; }
.sgrp h2 { font-size: 14px; color: var(--sub); margin: 0 0 6px; padding: 0 2px; }
.slist { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.srow { display: flex; border-bottom: 1px solid var(--line); }
.srow:last-child { border-bottom: 0; }
.srow-main { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 13px 12px; min-width: 0; }
.srow-r { display: flex; align-items: center; gap: 2px; color: var(--sub); font-size: 14px; white-space: nowrap; }
.srow-r svg { width: 18px; height: 18px; }
.mini { width: 42px; display: grid; place-items: center; border-left: 1px solid var(--line); color: var(--sub); }
.mini svg { width: 18px; height: 18px; }
.kv { display: flex; justify-content: space-between; margin: 4px 2px; font-size: 14px; color: var(--sub); }
.hint { font-size: 13px; color: var(--sub); margin: 8px 2px; }
.hint.pad { margin: 20px 2px; }
.sgrp > .btn.wide, .sgrp > .choices { margin-top: 8px; }

/* 큰 칸 선택 */
.choices { display: grid; gap: 8px; }
.choices.c1 { grid-template-columns: 1fr; }
.choices.c2 { grid-template-columns: 1fr 1fr; }
.choice { min-height: 48px; padding: 10px 12px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--card); text-align: left; font-size: 15px; overflow-wrap: anywhere; }
.choice.on { border: 2px solid var(--accent); background: var(--accent-bg); padding: 9px 11px; font-weight: 600; }
.choice.tall { display: flex; flex-direction: column; gap: 4px; }
.choice.tall span { font-size: 13px; color: var(--sub); font-weight: 400; }

/* 덮개 */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-back { position: absolute; inset: 0; background: rgba(20, 28, 36, .38); opacity: 0; transition: opacity .18s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 12px 12px 0 0; padding: 16px 16px calc(20px + var(--safe-b)); transform: translateY(24px); opacity: 0; transition: transform .2s, opacity .2s; }
.sheet.wide { max-width: 900px; }
.sheet-wrap.open .sheet-back { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; opacity: 1; }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sheet-head h2, .sheet-title { margin: 0 0 4px; font-size: 19px; }
.sheet-title { font-size: 16px; margin-bottom: 12px; }
.sheet-head .count { color: var(--sub); font-variant-numeric: tabular-nums; }
.sheet-sub { margin: 0 0 8px; color: var(--sub); font-size: 14px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.big-amt { display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--ink); margin: 10px 0 6px; padding: 4px 2px; }
.big-amt .cur { font-size: 22px; color: var(--sub); }
.big-amt input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 34px; font-weight: 600; outline: none; text-align: right; }
.big-amt input::placeholder { color: #b8c0c7; font-weight: 400; }
.err { color: var(--danger); font-size: 14px; margin: 4px 2px; }
.hints { margin: 8px 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 12px; }
.hints div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.hints dt { color: var(--sub); }
.hints dd { margin: 0; font-variant-numeric: tabular-nums; }
.bd-box { margin: 8px 0; font-size: 14px; }
.bd-box summary { cursor: pointer; color: var(--sub); padding: 4px 2px; }
.field { display: block; margin: 12px 0 0; }
.field > span { display: block; font-size: 13px; color: var(--sub); margin: 0 2px 4px; }
.field input, .field textarea, .season input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--card); }
.field textarea { min-height: 64px; resize: vertical; }
.pair { display: flex; gap: 8px; align-items: center; }
.pair input { flex: 1; min-width: 0; }
.pair .btn { flex: none; }
.pair-sep { color: var(--sub); }
.pair2 { display: grid; grid-template-columns: 6.5em 1fr; gap: 8px; }
.toggle-row { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--card); }
.toggle-row .box { display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--line2); border-radius: 8px; }
.toggle-row .box svg { width: 20px; height: 20px; stroke: transparent; stroke-width: 2.6; }
.toggle-row.on .box { background: var(--accent); border-color: var(--accent); }
.toggle-row.on .box svg { stroke: #fff; }
.adv { border-left: 2px solid var(--line2); padding-left: 12px; margin-top: 4px; }
.pick-btn { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--card); }
.mpick { margin-top: 8px; }
.mpick-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; text-align: center; margin-bottom: 8px; }
.mgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.mcell { min-height: 42px; border: 1px solid var(--line2); border-radius: 8px; background: var(--card); text-align: center; font-variant-numeric: tabular-nums; }
.mcell.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.season { border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 8px; background: var(--card); }
.season > input, .season > .pair { margin-bottom: 8px; }
.confirm-text { font-size: 16px; margin: 4px 0 8px; }

/* 하단 탭 */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line2); padding-bottom: var(--safe-b); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabh); font-size: 12px; color: var(--sub); border-top: 2px solid transparent; }
.tab.on { color: var(--accent); border-top-color: var(--accent); font-weight: 600; }

/* 되돌리기 알림 */
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabh) + var(--safe-b) + 10px); z-index: 60; max-width: 528px; margin: 0 auto;
  display: none; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 14px; background: var(--ink); color: #fff; border-radius: var(--r); font-size: 14px; }
#toast.show { display: flex; }
#toast .btn { background: transparent; color: #fff; border-color: #6b7782; }

/* 인쇄 미리보기 */
.paper-wrap { position: relative; width: 100%; overflow: hidden; border: 1px solid var(--line2); border-radius: 8px; background: #fff; margin-top: 8px; }
.paper { position: absolute; left: 0; top: 0; width: 210mm; height: 297mm; background: #fff; transform-origin: 0 0; }
.paper.landscape { width: 297mm; height: 210mm; }

/* 인쇄 양식(미리보기와 인쇄 공용) */
.pp { position: absolute; left: 10mm; top: 18mm; width: 190mm; height: 269mm; overflow: hidden; color: #000; font-size: 8.8pt; line-height: 1.3; font-family: inherit; }
.pp.landscape { width: 277mm; height: 182mm; font-size: 8pt; }
.pp-h { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5pt solid #000; padding-bottom: 1.5mm; margin-bottom: 3mm; }
.pp-h h1 { font-size: 14pt; margin: 0; }
.pp-h span { font-size: 8pt; }
.pp h2 { font-size: 9.5pt; margin: 2mm 0 .8mm; }
.pt { width: 100%; border-collapse: collapse; table-layout: fixed; }
.pt th, .pt td { border: .5pt solid #555; padding: .55mm 1.4mm; vertical-align: middle; }
.pt th { background: #eee; font-weight: 600; font-size: .92em; }
.pt .c-name { width: 34%; text-align: left; }
.pt .c-name small { display: block; font-size: .82em; color: #333; }
.pt .c-amt { width: 17%; text-align: right; }
.pt .c-amt.est { color: #555; }
.pt .c-due { width: 22%; }
.pt .c-acc { width: 19%; }
.pt .c-chk { width: 8%; text-align: center; }
.pt .bdrow td { font-size: .85em; color: #333; border-top: 0; }
.pt .blank td { height: 5.5mm; }
.pt .subt td { font-weight: 600; background: #f6f6f6; }
.pbox { display: inline-block; width: 3.6mm; height: 3.6mm; border: .7pt solid #000; vertical-align: middle; position: relative; }
.pbox.on::after { content: ""; position: absolute; left: .9mm; top: .1mm; width: 1.2mm; height: 2.2mm; border: solid #000; border-width: 0 .8pt .8pt 0; transform: rotate(45deg); }
.totals { margin-top: 4mm; }
.totals th, .totals td { text-align: right; }
.totals .grand { font-weight: 700; }
.pnote { font-size: 7.5pt; margin: 2mm 0 0; }
.ygrid th, .ygrid td { text-align: right; padding: .8mm 1mm; }
.ygrid .c-name { width: 15%; text-align: left; }
.ygrid .c-acc { width: 9%; text-align: left; }
.ygrid .rt { font-weight: 600; }

#print-root { display: none; }
@media print {
  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  .pp { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
