:root {
  color-scheme: light;
  --page: #f5f6f1;
  --card: #fff;
  --ink: #192e28;
  --muted: #50635b;
  --line: #dbe3da;
  --green: #215848;
  --deep: #163b31;
  --danger: #a13228;
  --deposit: #28644f;
  --progress: #7fae86;
  --final: #e8ba75;
  --focus: #3c7f69;
  --body: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--page); }
body { margin: 0; font: 1rem/1.6 var(--body); color: var(--ink); }
[hidden] { display: none !important; }
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.shell { max-width: 72.25rem; width: calc(100% - 4rem); margin-inline: auto; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link { position: absolute; top: -5rem; left: 1rem; z-index: 2; padding: .65rem 1rem; color: #fff; background: var(--deep); }
.skip-link:focus { top: .5rem; }

.site-header { color: #f7f9f2; background: var(--deep); }
.header-inner { min-height: 4.25rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .68rem; text-decoration: none; font-weight: 800; letter-spacing: -.035em; font-size: 1.12rem; white-space: nowrap; }
.brand-mark { display: grid; align-content: center; gap: .23rem; width: 1.95rem; height: 1.95rem; padding: .43rem; border: 1px solid #739489; border-radius: .44rem; }
.brand-mark i { height: .125rem; background: #e8ebdb; border-radius: 1rem; }
.brand-mark i:nth-child(2) { width: 76%; }
.brand-mark i:nth-child(3) { width: 57%; background: #e8ba75; }
.site-header nav { display: flex; align-items: center; gap: 1.75rem; }
.site-header nav a { color: #d1dfd5; text-decoration: none; padding-block: .7rem; font-size: .9rem; white-space: nowrap; }
.site-header nav a:hover, .site-header nav .nav-current { color: #fff; }
.site-header nav .nav-current { box-shadow: 0 2px 0 #b9d8b6; font-weight: 700; }

.intro { padding: 3.05rem 0 2.1rem; }
.intro h1 { font-size: clamp(2rem, 5vw, 3.8rem); line-height: 1.18; letter-spacing: -.067em; font-weight: 850; word-break: keep-all; }
.intro p { color: var(--muted); font-size: clamp(.99rem, 2vw, 1.16rem); margin-top: .85rem; word-break: keep-all; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(0, 1fr); gap: 1.375rem; align-items: stretch; scroll-margin-top: 1rem; }
.panel { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 1rem; overflow: hidden; box-shadow: 0 12px 30px #1b392109; }
.input-panel { padding: 1.6rem 1.7rem 1.35rem; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: .7rem; min-height: 2.3rem; }
.panel-heading h2, .guide h2 { font-size: 1.24rem; font-weight: 800; letter-spacing: -.04em; }
.text-button { padding: .35rem .55rem; background: transparent; border: 0; border-radius: .35rem; color: var(--green); font-size: .9rem; font-weight: 700; white-space: nowrap; min-height: 2.35rem; }
.text-button:hover { background: #edf3e8; }
.amount-field { margin: 1.12rem 0 1.325rem; }
.amount-field label { display: block; font-size: .94rem; font-weight: 750; margin-bottom: .42rem; }
.input-frame { display: flex; align-items: center; min-width: 0; border: 1px solid #c8d5cb; border-radius: .55rem; background: #fcfdfa; }
.input-frame:focus-within { border-color: var(--focus); box-shadow: 0 0 0 2px #e2eee2; }
.input-frame:has([aria-invalid="true"]), input[aria-invalid="true"] { border-color: var(--danger); }
.input-frame input { min-width: 0; width: 100%; border: 0; color: var(--ink); background: transparent; padding: .59rem .75rem; outline: none; font-variant-numeric: tabular-nums; }
#total { font-size: 1.28rem; font-weight: 800; padding: .67rem .83rem; letter-spacing: -.02em; }
.unit { padding-inline: .65rem; border-left: 1px solid var(--line); color: var(--muted); font-size: .86rem; flex-shrink: 0; }
.stage-fields { margin: 0; min-width: 0; padding: 0; border: 0; }
.stage-grid { display: grid; grid-template-columns: minmax(3.75rem, .7fr) minmax(4.35rem, .82fr) minmax(8.35rem, 1.4fr); gap: .72rem; align-items: center; }
.stage-labels { padding-bottom: .34rem; color: var(--muted); font-size: .875rem; font-weight: 700; }
.stage-labels small { font-size: .81rem; font-weight: 400; }
.stage-row { border-bottom: 1px solid #ecf0ea; min-height: 3.42rem; padding-block: .3rem; }
.stage-row label { font-size: .95rem; font-weight: 700; }
.stage-row input[type="date"] { min-width: 0; width: 100%; padding: .58rem .51rem .58rem .63rem; border: 1px solid #c8d5cb; border-radius: .55rem; background: #fcfdfa; color: var(--ink); font-size: .9rem; min-height: 2.58rem; }
.stage-row input[type="date"][aria-invalid="true"] { border-color: var(--danger); }
.stage-row input[type="date"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.ratio-summary { display: flex; justify-content: space-between; align-items: center; padding: .45rem .7rem; margin-top: .7rem; border-radius: .4rem; background: #f1f5ec; color: #42564c; font-size: .87rem; }
.ratio-summary strong { color: #765129; font-size: 1rem; }
.ratio-summary .sum-complete { color: var(--green); }
.field-error { color: var(--danger); font-size: .86rem; margin: .27rem 0 0; line-height: 1.45; }
.input-footer { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .72rem; }
.input-footer p { color: var(--muted); font-size: .86rem; word-break: keep-all; }
.quiet { color: var(--muted); }

.result-panel { display: flex; flex-direction: column; }
.result-top { padding: 1.6rem 1.7rem 1.2rem; background: #edf3e8; border-bottom: 1px solid #dbe7da; }
.example-tag { font-size: .79rem; border: 1px solid #adc8af; border-radius: .3rem; color: #335d47; padding: .13rem .5rem; white-space: nowrap; }
.total-result { margin-top: 1rem; display: flex; flex-direction: column; }
.total-result span { color: #3a594b; font-size: .92rem; font-weight: 700; }
.total-result output { font-size: clamp(1.64rem, 3.2vw, 2.5rem); line-height: 1.2; margin-top: .12rem; font-weight: 850; font-variant-numeric: tabular-nums; letter-spacing: -.055em; overflow-wrap: anywhere; }
.stage-bar { display: flex; gap: .16rem; width: 100%; height: .55rem; margin-top: 1.13rem; border-radius: 1rem; overflow: hidden; background: #d9e5da; }
.stage-bar span { flex: 0 1 0; }
.bar-empty span { visibility: hidden; }
.bar-deposit, .deposit { background: var(--deposit); }
.bar-progress, .progress { background: var(--progress); }
.bar-final, .final { background: var(--final); }
.schedule-table { border-collapse: collapse; width: calc(100% - 3.4rem); margin: .72rem 1.7rem 0; font-variant-numeric: tabular-nums; table-layout: fixed; }
.schedule-table th, .schedule-table td { padding: .67rem 0 .67rem .35rem; border-bottom: 1px solid #e8ede6; text-align: left; overflow-wrap: anywhere; }
.schedule-table th:first-child { width: 26%; padding-left: 0; }
.schedule-table th:nth-child(2) { width: 32%; }
.schedule-table thead th { font-size: .88rem; color: var(--muted); }
.schedule-table tbody th { font-size: .96rem; }
.schedule-table td { font-size: .94rem; }
.schedule-table .right { text-align: right; }
.schedule-table .money { font-weight: 750; }
.stage-dot { display: inline-block; width: .51rem; height: .51rem; margin-right: .38rem; border-radius: .1rem; vertical-align: .09em; }
.result-message { color: var(--muted); font-size: .86rem; margin: .68rem 1.7rem .55rem; }
.result-actions { display: flex; gap: .62rem; flex-wrap: wrap; margin: auto 1.7rem 1.35rem; }
.button { min-height: 2.66rem; border: 1px solid transparent; border-radius: .5rem; padding: .5rem .92rem; font-weight: 750; font-size: .91rem; min-width: 7.25rem; }
.primary { color: #fff; background: var(--green); }
.primary:hover:not(:disabled) { background: var(--deep); }
.secondary { color: var(--green); background: #fff; border-color: #afc5b7; }
.secondary:hover:not(:disabled) { background: #eef4ed; }
.button:disabled { color: #697973; background: #eef1ee; border-color: #e2e8e2; }

.guide { margin-top: 2.2rem; border-top: 1px solid var(--line); padding-top: 1.42rem; padding-bottom: 2.2rem; scroll-margin-top: 1rem; }
.guide-intro { margin-bottom: .82rem; }
.guide-intro p, .guide article p { color: var(--muted); font-size: .93rem; word-break: keep-all; }
.guide-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.375rem; }
.guide article { padding: .1rem 1.35rem .12rem 0; border-right: 1px solid var(--line); }
.guide article:last-child { border-right: 0; padding-right: 0; }
.guide article h3 { font-size: 1rem; font-weight: 800; margin-bottom: .25rem; }
.site-footer { border-top: 1px solid var(--line); }
.footer-inner { display: flex; gap: 1.35rem; padding-block: 1rem; align-items: baseline; width: calc(100% - 4rem); }
.footer-brand { font-weight: 800; white-space: nowrap; }
.footer-inner p { font-size: .86rem; color: var(--muted); }
.no-script { position: fixed; inset: auto 1rem 1rem; background: #fff7dc; border: 1px solid #bb9352; border-radius: .5rem; padding: 1rem; }

@media (max-width: 54rem) {
  .shell { width: calc(100% - 2.7rem); }
  .workspace { gap: 1rem; }
  .input-panel, .result-top { padding-inline: 1.16rem; }
  .schedule-table { width: calc(100% - 2.32rem); margin-inline: 1.16rem; }
  .result-message, .result-actions { margin-inline: 1.16rem; }
  .stage-grid { gap: .45rem; grid-template-columns: minmax(3.2rem, .64fr) minmax(4rem, .83fr) minmax(8.15rem, 1.45fr); }
}

@media (max-width: 44.5rem) {
  .shell { width: calc(100% - 2rem); }
  .header-inner { min-height: 3.7rem; }
  .site-header nav { gap: .8rem; }
  .site-header nav a { font-size: .83rem; }
  .intro { padding: 2rem 0 1.33rem; }
  .intro p { margin-top: .5rem; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .input-panel { padding-top: 1rem; padding-bottom: .86rem; }
  .result-top { padding-top: 1rem; padding-bottom: 1rem; }
  .amount-field { margin: .7rem 0 1rem; }
  .guide-grid { grid-template-columns: minmax(0, 1fr); gap: .72rem; }
  .guide article { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 .62rem; }
  .guide article:last-child { border-bottom: 0; }
}

@media (max-width: 23rem) {
  .shell { width: calc(100% - 1.25rem); }
  .intro h1 { font-size: 1.75rem; }
  .input-panel, .result-top { padding-inline: .8rem; }
  .schedule-table { width: calc(100% - 1.6rem); margin-inline: .8rem; }
  .result-message, .result-actions { margin-inline: .8rem; }
  .stage-grid { gap: .36rem; grid-template-columns: minmax(3rem, .66fr) minmax(4rem, .85fr) minmax(7.65rem, 1.48fr); }
  .stage-labels small { display: none; }
  .stage-row input[type="date"] { padding-inline: .35rem; }
}

@media print {
  @page { size: A4 portrait; margin: 18mm; }
  html, body { background: #fff; color: #000; }
  .site-header, .site-footer, .input-panel, .guide, .result-message, .result-actions, .stage-bar, .skip-link, .intro p, .no-script { display: none !important; }
  .shell { width: 100%; }
  .intro { padding: 0 0 1rem; }
  .intro h1 { font-size: 24pt; }
  .workspace { display: block; }
  .result-panel { box-shadow: none; border: 1px solid #8f978e; border-radius: 0; break-inside: avoid; }
  .result-top { padding: .75rem 1rem; background: #fff; border-bottom: 1px solid #8f978e; }
  .total-result output { font-size: 20pt; }
  .schedule-table { width: calc(100% - 2rem); margin: .5rem 1rem 1rem; }
  .schedule-table th, .schedule-table td { border-color: #c9ceca; }
}
