/* 선납이연계산기 (prepay.leunkim.com) — 화면 스타일
   예적금 장부(savings.leunkim.com) app.css 에서 색·글꼴·머리말과 계산기(.book) 부분을 그대로 옮기고,
   이 페이지에만 쓰는 것은 맨 아래 "이 페이지만"에 더했다. 장부 쪽 계산기 모양을 바꾸면 여기도 맞춘다. */
:root{
  --bg:#f3f5f8; --surface:#ffffff; --surface-2:#f7f9fb;
  --ink:#12161c; --ink-2:#465061; --muted:#768092;
  --line:#dfe4eb; --line-strong:#c4ccd8;
  --accent:#2a78d6; --accent-strong:#1c5fb4; --on-accent:#ffffff; --accent-soft:#e3eefb;
  --hover-col:#eef2f7; --warn-bg:#fff4dc; --warn-ink:#6b4a00;
  --neg:#c0392b; --neg-bg:#fdecea; --neg-line:#f1c5bf;
  --pos:#1b7a4b; --pos-bg:#e4f3ea; --pos-line:#b9dcc7;
  --corp-row:#fffaea; --flash:#ffeeb0;
  --series-1:#b7791f; --series-2:#2a78d6; --series-3:#1b8a5a; --series-4:#8250c4;
  --own-2-ink:#6b3fa8; --own-2-bg:#efe6fa;
  --font:"IBM Plex Sans KR","Apple SD Gothic Neo","Malgun Gothic","Noto Sans KR",system-ui,sans-serif;
  --r:10px;
  --float-shadow:0 8px 30px rgba(0,0,0,.16);

  /* 예전 이름. 스크립트 안의 인라인 스타일이 아직 이 이름을 쓴다. */
  --white:var(--surface); --paper:var(--surface); --paper-dark:var(--surface-2);
  --ink-soft:var(--ink-2); --ink-faint:var(--muted);
  --gold:var(--accent-strong); --gold-soft:var(--accent);
  --mint:var(--pos); --danger:var(--neg);
  --grid-line:var(--line); --paper-line:var(--line); --rule:var(--line-strong);
  --stamp-red:var(--neg); --gain-green:var(--pos); --gain-green-bg:var(--pos-bg); --gain-bg:var(--pos-bg);
  --corp:var(--warn-bg); --corp-bg:var(--corp-row); --cover-navy:var(--ink);
}
/* 어두운 화면: 제목 아래의 화면 단추로 고르면 <html data-theme="dark"> 가 붙는다. 고르기 전에는 기기 설정과 상관없이 밝은 화면이다. */
:root{color-scheme:light;}
:root[data-theme="dark"]{
    color-scheme:dark;
    --bg:#0e1114; --surface:#161a1f; --surface-2:#1b2026;
    --ink:#eef1f4; --ink-2:#bcc4cf; --muted:#8a94a3;
    --line:#272e37; --line-strong:#3a434f;
    --accent:#3987e5; --accent-strong:#6da7ec; --on-accent:#0b121b; --accent-soft:#16283f;
    --hover-col:#1d232b; --warn-bg:#3a2d0c; --warn-ink:#f3d58a;
    --neg:#ff8576; --neg-bg:#3a1c18; --neg-line:#5e2c26;
    --pos:#62d093; --pos-bg:#13301f; --pos-line:#25553c;
    --corp-row:#221d0d; --flash:#4a3d10;
    --series-1:#e3b53a; --series-2:#5e9ffa; --series-3:#62d093; --series-4:#b794f4;
    --own-2-ink:#c9aef5; --own-2-bg:#2a1f3d;
    --float-shadow:0 8px 30px rgba(0,0,0,.5);
}

*{box-sizing:border-box;}
html{-webkit-text-size-adjust:100%;}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:var(--font); font-size:15px; line-height:1.55;
}
button, input, select, textarea{font-family:inherit;}
button{color:inherit;}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px;}
input[type=checkbox], input[type=radio]{accent-color:var(--accent);}

#app{min-height:100vh;}
.wrap{
  max-width:1680px; margin:0 auto; padding-block:28px 56px;
  padding-left:max(16px, env(safe-area-inset-left)); padding-right:max(16px, env(safe-area-inset-right));
  display:flex; flex-direction:column; gap:18px;
}

/* ---------- 머리말 ---------- */
.head h1{
  font-size:clamp(24px,4vw,32px); font-weight:700; letter-spacing:-.02em; line-height:1.2;
  margin:0 0 6px; text-wrap:balance;
}
.lede{margin:0; color:var(--ink-2); max-width:60ch;}
.status{display:flex; align-items:center; gap:10px 12px; flex-wrap:wrap; margin-top:12px; font-size:13.5px;}
.stamp{
  display:inline-flex; align-items:center; gap:7px; padding:4px 10px;
  border:1px solid var(--line-strong); border-radius:999px; background:var(--surface); font-weight:600;
}
.stamp i{width:8px; height:8px; border-radius:50%; background:var(--pos); flex-shrink:0;}
.stamp[data-state="dirty"] i, .stamp[data-state="saving"] i{background:var(--accent);}
.stamp[data-state="error"]{border-color:var(--neg); color:var(--neg); cursor:pointer;}
.stamp[data-state="error"] i{background:var(--neg);}
.linkbtn{
  color:var(--accent-strong); text-decoration:underline; text-underline-offset:3px;
  background:none; border:none; padding:0; font-size:inherit; cursor:pointer;
}
.status .board{margin-inline-start:auto;}
.status .blog{margin-inline-start:0;}
.theme-btn{
  display:inline-flex; align-items:center; gap:7px; font-size:13.5px; padding:5px 11px; border-radius:8px; cursor:pointer;
  /* 바꿔 갈 화면의 색으로 칠한다: 밝은 화면에서는 어두운 단추(다크모드), 어두운 화면에서는 밝은 단추(라이트모드) */
  border:1px solid var(--ink); background:var(--ink); color:var(--bg); font-weight:600;
}
.theme-btn:hover{opacity:.88;}
.theme-btn i{width:10px; height:10px; border-radius:50%; border:1px solid currentColor; background:linear-gradient(90deg, currentColor 50%, transparent 50%);}
.guest-note{margin:10px 0 0; font-size:13px; color:var(--muted); max-width:80ch;}
.guest-note.member-hint{font-size:14px; color:var(--ink); background:var(--accent-soft); border-radius:8px; padding:9px 12px;}

input.invalid{border-color:var(--neg) !important; background:var(--neg-bg) !important;}
.foot{font-size:12px; color:var(--muted); padding:4px 2px 0;}

.book{max-width:1080px; margin:0 auto;}
.book .cover{padding:0 250px 16px 0; min-height:74px;}
.book .cover-eyebrow{font-size:12.5px; font-weight:600; color:var(--accent-strong); margin-bottom:4px;}
.book .cover h1{font-size:clamp(22px,3.4vw,28px); font-weight:700; letter-spacing:-.02em; line-height:1.2; margin:0 0 6px;}
.book .cover p{margin:0; color:var(--ink-2); font-size:14px; max-width:70ch;}
.book .pages{display:flex; flex-direction:column; gap:18px;}
.book .section{background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:14px 16px 16px;}
.book .section-head{display:flex; align-items:center; gap:8px; margin:0 0 12px;}
.book .section-head.export-head{flex-wrap:wrap;}
.book .section-head .num{
  display:inline-flex; align-items:center; justify-content:center; width:20px; height:20px; flex-shrink:0;
  border-radius:50%; background:var(--accent-soft); color:var(--accent-strong); font-size:12px; font-weight:700; line-height:1;
}
.book .section-head h2{font-size:17px !important; font-weight:700; letter-spacing:-.01em; margin:0;}
.book .export-actions{margin-left:auto; display:flex; gap:8px; flex-wrap:wrap;}
.book .export-actions.export-actions-centered{margin-left:0; justify-content:center;}
.book .btn-chip{
  display:inline-flex; align-items:center; justify-content:center; white-space:nowrap;
  border:1px solid var(--line-strong); background:var(--surface); color:var(--ink); border-radius:8px;
  padding:6px 12px; font-size:13.5px; cursor:pointer; line-height:1.4;
}
.book .btn-chip:hover{background:var(--hover-col);}
.book .btn-chip:disabled{opacity:.55; cursor:default;}
.book .field-grid{display:grid; grid-template-columns:repeat(3, 1fr); gap:14px 16px;}
.book .field-grid.two{grid-template-columns:repeat(2, 1fr);}
.book .field{display:flex; flex-direction:column; gap:5px; min-width:0;}
.book .field label{font-size:13px; color:var(--ink-2); font-weight:600;}
.book .field .input-line{
  display:flex; align-items:center; gap:6px; padding:6px 9px;
  border:1px solid var(--line-strong); border-radius:8px; background:var(--surface);
}
.book .field .input-line:focus-within{outline:2px solid var(--accent); outline-offset:2px;}
.book .field .input-line:has(input:disabled){background:var(--surface-2);}
.book .field input[type="number"], .book .field input[type="text"]{
  border:none; background:transparent !important; outline:none; font-size:14px; color:var(--ink) !important;
  width:100%; padding:0; font-variant-numeric:tabular-nums;
}
.book .field .unit{font-size:13px; color:var(--muted); white-space:nowrap;}
.book .toggle-row{display:flex; gap:8px; flex-wrap:wrap; margin-top:0;}
.book .toggle-row-tax{gap:6px; flex-wrap:nowrap;}
.book .toggle-pill{
  display:flex; align-items:center; gap:8px; flex:1; min-width:120px; cursor:pointer;
  border:1px solid var(--line-strong); border-radius:8px; padding:7px 11px;
  font-size:13.5px; color:var(--ink-2); background:var(--surface); font-weight:400;
}
.book .toggle-pill.toggle-pill-compact{min-width:0; padding:6px 8px; gap:6px;}
.book .toggle-pill.toggle-pill-compact span:not(.box){font-size:12px; line-height:1.35; white-space:nowrap;}
.book .toggle-pill input{display:none;}
.book .toggle-pill .box{
  width:14px; height:14px; border-radius:50%; border:1px solid var(--line-strong);
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.book .toggle-pill .box::after{content:""; width:8px; height:8px; border-radius:50%; background:var(--accent-strong); transform:scale(0);}
.book .toggle-pill input:checked ~ .box{border-color:var(--accent-strong);}
.book .toggle-pill input:checked ~ .box::after{transform:scale(1);}
.book .toggle-pill:has(input:checked){border-color:var(--accent-strong); background:var(--accent-soft); color:var(--ink);}
.book .toggle-pill strong{font-weight:600;}
.book .summary-top{
  background:var(--surface-2); border:1px solid var(--line); border-radius:8px;
  padding:12px 14px; margin-bottom:12px; font-size:14px; line-height:1.7;
}
.book .result-grid{display:grid; grid-template-columns:repeat(4, 1fr); gap:10px;}
.book .card{border:1px solid var(--line); border-radius:8px; padding:11px 14px; background:var(--surface-2);}
.book .card .label{font-size:12.5px; color:var(--ink-2); font-weight:600; margin-bottom:2px;}
.book .card .value{font-weight:700; font-size:22px; letter-spacing:-.01em; font-variant-numeric:tabular-nums;}
.book .card .value.small{font-size:15px;}
.book .card .sub{font-size:12px; color:var(--muted); margin-top:2px;}
.book .card.highlight, .book .card.highlight-warn, .book .card.highlight-safe, .book .card.highlight-zero{grid-column:span 2;}
.book .card.highlight .value, .book .card.highlight-warn .value, .book .card.highlight-safe .value, .book .card.highlight-zero .value{font-size:26px;}
.book .card.highlight, .book .card.highlight-zero{background:var(--pos-bg); border-color:var(--pos-line);}
.book .card.highlight .value, .book .card.highlight-zero .value, .book .card.highlight-zero .label{color:var(--pos);}
.book .card.highlight-warn{background:var(--neg-bg); border-color:var(--neg-line);}
.book .card.highlight-warn .value, .book .card.highlight-warn .label{color:var(--neg);}
.book .card.highlight-safe{background:var(--accent-soft); border-color:var(--accent);}
.book .card.highlight-safe .value, .book .card.highlight-safe .label{color:var(--accent-strong);}
.book .plain-rows{margin-top:10px;}
.book .plain-row{display:flex; justify-content:space-between; padding:8px 2px; border-bottom:1px solid var(--line); font-size:14px;}
.book .plain-row:last-child{border-bottom:none;}
.book .plain-row .l{color:var(--ink-2);}
.book .plain-row .v{font-weight:600; font-variant-numeric:tabular-nums;}
.book .table-wrap{overflow-x:auto; border:1px solid var(--line); border-radius:8px;}
.book table{width:100%; border-collapse:collapse; font-size:13.5px; font-variant-numeric:tabular-nums;}
.book .table-wrap table{min-width:700px;}
.book thead th{
  background:var(--surface-2); color:var(--ink-2); font-weight:600; font-size:12.5px; text-align:right;
  padding:8px 10px; border-bottom:1px solid var(--line-strong); white-space:nowrap;
}
.book .table-wrap thead th:nth-child(2), .book .table-wrap thead th:nth-child(3), .book .table-wrap thead th:nth-child(4),
.book .table-wrap tbody td:nth-child(2), .book .table-wrap tbody td:nth-child(3), .book .table-wrap tbody td:nth-child(4){text-align:left;}
.book .table-wrap tbody td{padding:4px 10px; text-align:right; border-bottom:1px solid var(--line); white-space:nowrap;}
.book .table-wrap tbody tr:hover td{background:var(--hover-col);}
.book th.chk-col, .book td.chk-col{width:34px; text-align:center !important;}
.book input.row-check, .book #checkAll{width:15px; height:15px; cursor:pointer;}
.book td.round-idx{font-weight:700; color:var(--ink-2);}
.book td.actual-cell{display:flex; align-items:center; gap:6px;}
.book input.actual-date{
  border:1px solid var(--line-strong); border-radius:6px; padding:4px 7px; font-size:13px;
  color:var(--ink); background:var(--surface); width:108px; font-variant-numeric:tabular-nums;
}
.book .fill-down-btn, .book .fill-up-btn{
  display:inline-flex; align-items:center; justify-content:center; flex-shrink:0;
  border:1px solid var(--line-strong); background:var(--surface); color:var(--ink-2); border-radius:6px;
  width:24px; height:24px; font-size:12px; line-height:1; cursor:pointer; padding:0;
}
.book .fill-down-btn:hover, .book .fill-up-btn:hover{background:var(--hover-col); color:var(--ink);}
.book th.col-emphasis{background:var(--neg-bg); color:var(--neg);}
.book th.col-emphasis.col-emphasis-safe{background:var(--accent-soft); color:var(--accent-strong);}
.book th.col-emphasis.col-emphasis-zero{background:var(--pos-bg); color:var(--pos);}
.book .table-wrap td.col-emphasis, .book .table-wrap tbody tr:hover td.col-emphasis{background:var(--neg-bg); color:var(--neg); font-weight:700;}
.book .table-wrap td.col-emphasis.col-emphasis-safe, .book .table-wrap tbody tr:hover td.col-emphasis.col-emphasis-safe{background:var(--accent-soft); color:var(--accent-strong);}
.book .table-wrap td.col-emphasis.col-emphasis-zero, .book .table-wrap tbody tr:hover td.col-emphasis.col-emphasis-zero{background:var(--pos-bg); color:var(--pos);}
.book .tag{display:inline-block; min-width:26px; text-align:center; padding:0 7px; border-radius:999px; font-size:12px; font-weight:600;}
.book .tag.zero{color:var(--muted);}
.book .tag.early{background:var(--accent-soft); color:var(--accent-strong);}
.book .tag.late{background:var(--neg-bg); color:var(--neg);}
.book .bulk-bar{
  display:flex; align-items:flex-end; gap:10px; flex-wrap:wrap; margin-bottom:12px;
  background:var(--surface-2); border:1px solid var(--line); border-radius:8px; padding:10px 12px;
}
.book .bulk-field{min-width:160px;}
.book .payment-summary{border:1px solid var(--line); border-radius:8px; background:var(--surface-2); padding:12px 14px; margin-top:14px;}
.book .payment-summary-title{font-size:13.5px; font-weight:600; margin-bottom:8px;}
.book .payment-summary-title .hint{font-weight:400; color:var(--muted); font-size:12.5px;}
.book .chart-tooltip, .cashproj-tooltip{
  position:absolute; pointer-events:none; background:var(--ink); color:var(--bg);
  padding:5px 8px; border-radius:6px; font-size:12.5px; line-height:1.45; white-space:nowrap;
  z-index:10; opacity:0; font-variant-numeric:tabular-nums;
}
.book .chart-tooltip.show, .cashproj-tooltip.show{opacity:1;}
.cashproj-tooltip .t-date{font-weight:700; display:block;}
.cashproj-legend{display:flex; gap:14px; flex-wrap:wrap; margin-top:4px;}
.cashproj-legend label{display:flex; align-items:center; gap:6px; font-size:13.5px; cursor:pointer; user-select:none; margin:0; font-weight:400;}
.cashproj-legend input{width:auto;}
.cashproj-dot{display:inline-block; width:10px; height:10px; border-radius:50%; flex-shrink:0;}
.book .foot-note{font-size:12.5px; color:var(--muted); line-height:1.65; padding:12px 2px 0;}
.book .hint-strong{font-size:13px; font-weight:600; color:var(--accent-strong); margin-top:8px;}

/* ---------- 이 페이지만 ---------- */
.wrap{max-width:1112px;}
/* .book 은 margin:0 auto 라 세로 flex(.wrap) 안에서 폭이 내용에 맞춰진다. 그대로 두면 회차 표의 최소 폭(700px)만큼
   폰 화면이 옆으로 늘어나서, 폭을 부모에 맞추고 표는 .table-wrap 안에서 옆으로 밀리게 한다. */
.book{width:100%;}
.book .pages > *{min-width:0;}
.head .eyebrow{font-size:12.5px; font-weight:600; color:var(--accent-strong); margin:0 0 4px;}
.once-note{
  margin:14px 0 0; padding:11px 14px; border:1px solid var(--line); border-radius:var(--r);
  background:var(--surface); font-size:13.5px; line-height:1.65; color:var(--ink-2); word-break:keep-all;
}
.once-note b{color:var(--ink);}
.once-note .go{display:block; margin-top:4px;}
.once-note a{color:var(--accent-strong); font-weight:700; text-underline-offset:3px;}
.to-ledger{
  display:flex; align-items:center; justify-content:space-between; gap:10px 16px; flex-wrap:wrap;
  padding:14px 16px; border:1px solid var(--accent); border-radius:var(--r); background:var(--accent-soft);
  font-size:14px; line-height:1.6; word-break:keep-all;
}
.to-ledger .btn-go{
  display:inline-flex; align-items:center; padding:8px 14px; border-radius:8px; white-space:nowrap;
  background:var(--accent-strong); color:var(--on-accent); font-weight:600; text-decoration:none;
}
.to-ledger .btn-go:hover{opacity:.9;}
.book input.invalid{border-color:var(--neg) !important; background:var(--neg-bg) !important;}

/* ---------- 좁은 화면 ---------- */
@media (max-width:720px){
  .book .field-grid, .book .field-grid.two{grid-template-columns:1fr 1fr;}
  .book .result-grid{grid-template-columns:1fr 1fr;}
  .book .section{padding:12px 12px 14px;}
}
@media (max-width:600px){
  body{font-size:14px;}
  .status .board{margin-inline-start:0;}
}
@media (max-width:460px){
  .book .field-grid, .book .field-grid.two{grid-template-columns:1fr;}
  .book .result-grid{grid-template-columns:1fr;}
  .book .card.highlight, .book .card.highlight-warn, .book .card.highlight-safe, .book .card.highlight-zero{grid-column:span 1;}
  .book .field[style*="span 2"]{grid-column:auto !important;}
}

/* ---------- 인쇄: 밝은 색으로, 단추와 안내는 빼고 ---------- */
@media print{
  @page{size:A4 portrait; margin:10mm;}
  :root, :root[data-theme="dark"]{
    color-scheme:light;
    --bg:#fff; --surface:#fff; --surface-2:#f1f3f5; --ink:#000; --ink-2:#333; --muted:#555;
    --line:#bbb; --line-strong:#888; --accent:#1c5fb4; --accent-strong:#1c5fb4; --on-accent:#fff; --accent-soft:#e8eef8;
    --hover-col:#fff; --neg:#b00020; --neg-bg:#fff; --neg-line:#ccc; --pos:#0a6b3b; --pos-bg:#fff; --pos-line:#ccc;
    --series-1:#9a6200; --series-2:#1c5fb4;
  }
  body{background:#fff;}
  .wrap{max-width:none; padding:0; gap:8px;}
  .status, .once-note, .to-ledger, .foot, .reset-btn, #csvBtn, .bulk-bar, .fill-down-btn, .fill-up-btn, .chk-col input{display:none !important;}
  .book .section{break-inside:avoid-page;}
}
