:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1b2330;
  --muted: #5f6b7d;
  --line: #e2e7ef;
  --brand: #2453d6;
  --brand-soft: #e8eefc;
  --accent: #0f9d74;
  --warn: #b26a00;
  --warn-soft: #fff5e1;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 6px 20px rgba(20, 30, 50, .06);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.hero {
  background: linear-gradient(135deg, #1d3fae 0%, #2f6bf0 60%, #3aa0f5 100%);
  color: #fff;
  padding: 36px 20px 28px;
}
.hero-inner { max-width: 1240px; margin: 0 auto; }
.hero h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -0.02em; }
.lead { margin: 0 0 18px; max-width: 860px; opacity: .95; }
.info-sample {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,.25); font-size: 12px; font-weight: 700; font-style: italic;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn {
  border: 0; border-radius: 10px; padding: 9px 16px; font: inherit; font-weight: 600;
  background: #fff; color: var(--brand); cursor: pointer;
}
.btn:hover { filter: brightness(.96); }
.btn-ghost { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.save-hint { font-size: 13px; opacity: .8; margin-left: 4px; }

/* Layout */
.layout {
  max-width: 1240px; margin: 24px auto 0; padding: 0 20px;
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start;
}
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; border: 1px solid var(--line);
}
.card h2 { margin: 0 0 14px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.card h2 small { color: var(--muted); font-weight: 500; font-size: 13px; }
.step-no {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: var(--brand-soft); color: var(--brand); font-size: 14px;
}
.hint { margin: -6px 0 14px; color: var(--muted); font-size: 13.5px; }
.mini { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }

.subcard { margin-top: 18px; padding: 16px; border-radius: 12px; background: #f8fafd; border: 1px dashed var(--line); }
.subcard h3 { margin: 0 0 10px; font-size: 15px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.span-2 { grid-column: span 2; }

.field label { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.req { font-style: normal; font-size: 11px; color: var(--danger); background: #fdecea; padding: 1px 6px; border-radius: 6px; }

input[type="text"], input[type="date"], input.num, select {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid #cfd7e3; border-radius: 10px; padding: 9px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(36, 83, 214, .15); }
input:disabled { background: #f1f3f7; color: #9aa4b2; }
input.invalid { border-color: var(--danger); background: #fff7f6; }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 38px; }
.input-wrap .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }

.ratio-box {
  min-height: 41px; padding: 8px 12px; border-radius: 10px; background: #f6f8fb; border: 1px solid var(--line);
  font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
}
.ratio-box b { font-variant-numeric: tabular-nums; }

.checks { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 14px; margin: 16px 0; display: grid; gap: 8px; }
.checks legend { font-weight: 600; font-size: 14px; padding: 0 6px; display: flex; align-items: center; gap: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check.inline { font-weight: 600; margin-bottom: 6px; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); flex: none; }

/* Year table */
.table-wrap { overflow-x: auto; margin-bottom: 16px; }
.year-table { width: 100%; border-collapse: collapse; min-width: 620px; }
.year-table th, .year-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.year-table thead th { font-size: 13.5px; color: var(--muted); font-weight: 600; vertical-align: bottom; }
.year-table thead th small { display: block; font-weight: 500; font-size: 11.5px; color: #8b96a8; }
.year-table thead th:first-child, .year-table tbody th { text-align: left; }
.year-table tbody th { font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.year-table tbody th .info { vertical-align: middle; }
.year-table td input { min-width: 140px; }
.calc-row td, .calc-row th { background: #f6f8fb; font-variant-numeric: tabular-nums; font-weight: 700; }
.calc-row td.neg { color: var(--danger); }

/* Info button + tooltip */
.info {
  flex: none; display: inline-grid; place-items: center;
  width: 18px; height: 18px; padding: 0; border-radius: 50%;
  border: 1px solid #b9c5d8; background: #fff; color: var(--brand);
  font: italic 700 11px/1 Georgia, "Times New Roman", serif; cursor: help;
}
.info:hover, .info:focus-visible, .info[aria-expanded="true"] { background: var(--brand); color: #fff; border-color: var(--brand); outline: none; }

.tooltip {
  position: fixed; z-index: 1000; max-width: min(420px, calc(100vw - 24px));
  background: #111a2b; color: #e9eef7; border-radius: 12px; padding: 14px 16px 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.28); font-size: 13.3px; line-height: 1.6;
  max-height: min(70vh, 520px); overflow-y: auto;
}
.tooltip h4 { margin: 0 0 8px; font-size: 14.5px; color: #fff; }
.tooltip dl { margin: 0; }
.tooltip dt { margin-top: 8px; font-size: 11.5px; letter-spacing: .04em; color: #8fb3ff; font-weight: 700; }
.tooltip dd { margin: 2px 0 0; }
.tooltip ul { margin: 2px 0 0; padding-left: 18px; }
.tooltip li { margin: 1px 0; }
.tooltip a { color: #9cc3ff; }
.tooltip .tip-close {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 6px;
  border: 0; background: transparent; color: #9aa7bd; font-size: 16px; cursor: pointer;
}
.tooltip .tip-close:hover { background: rgba(255,255,255,.08); color: #fff; }

/* Result panel */
.result { position: sticky; top: 16px; }
.result-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 20px 22px; overflow: hidden;
}
.result-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 14px; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.navonly { background: #fdf0e6; color: #b5541a; }
.badge.realestate { background: #e8f7f1; color: #0b7a5a; }

.big { background: linear-gradient(135deg, #eef3ff, #f6f9ff); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.big.sub { background: #f6f8fb; }
.big-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.big-value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--brand); }
.big.sub .big-value { font-size: 22px; color: var(--ink); }
.big-words { font-size: 12.5px; color: var(--muted); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 14px 0 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv .sep { grid-column: 1 / -1; border-top: 1px solid var(--line); margin: 4px 0; }
.kv dd.hl { color: var(--accent); }

.warnings { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; }
.warnings li { font-size: 12.8px; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); color: #6d4a00; }
.warnings li.err { background: #fdecea; color: #8e2a1f; }
.warnings li.ok { background: #e8f7f1; color: #0b5e46; }

/* Steps + method */
.steps-card, .method-card { max-width: 1240px; margin: 24px auto 0; }
.steps-card, .method-card { margin-left: max(20px, calc((100vw - 1240px) / 2 + 20px)); margin-right: max(20px, calc((100vw - 1240px) / 2 + 20px)); }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 12px; }
.steps li { padding-left: 4px; }
.steps .s-title { font-weight: 700; }
.steps .s-body { color: #334055; font-size: 14px; font-variant-numeric: tabular-nums; overflow-x: auto; overflow-wrap: anywhere; }
.steps code { font-family: inherit; background: #f2f5fa; border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.steps table { border-collapse: collapse; margin-top: 6px; font-size: 13.5px; }
.steps table th, .steps table td { border: 1px solid var(--line); padding: 4px 10px; text-align: right; }
.steps table th:first-child { text-align: left; }

.formula { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }
details summary { cursor: pointer; font-weight: 600; color: var(--brand); }

.footer { max-width: 1240px; margin: 24px auto 40px; padding: 0 20px; color: var(--muted); font-size: 13px; }
.footer a { color: var(--brand); }

/* Responsive */
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .result { position: static; order: -1; }
}
@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .card { padding: 18px 16px; }
  .hero h1 { font-size: 23px; }
}

/* Print */
@media print {
  body { background: #fff; font-size: 12px; }
  .hero { background: none; color: var(--ink); padding: 0 0 10px; }
  .toolbar, .info, .tooltip, .lead .info-sample, .method-card details summary { display: none !important; }
  .layout { display: block; padding: 0; }
  .result { position: static; margin-top: 16px; }
  .card, .result-card { box-shadow: none; break-inside: avoid; }
  .steps-card, .method-card { margin: 16px 0 0; }
}
