/* style.css — 2421 SAVINGS_CALC 이자계산소
 * kit-dashboard 변형: 조밀한 KPI 타일 + 차트 카드 중심, 평면·1px 헤어라인·단색 액센트(블루).
 * 기피 요소(글래스·블러·그라디언트·글로우·다색 코딩·큰 그림자) 없음.
 * 차트 2계열 색(원금/이자)은 dataviz 레퍼런스 팔레트 slot1·slot2(검증 통과값). */
:root {
  --bg: #f4f5f2; --surface: #ffffff; --surface-2: #f0f1ed; --border: #dcdfd8; --border-2: #c9cdc5;
  --text: #1a1e1c; --text-2: #4f5652; --text-3: #767d79;
  --primary: #1f5ea8; --primary-2: #174c8a; --primary-ink: #ffffff; --primary-soft: #e6eef8;
  --s1: #2a78d6; --s2: #eb6834; --target: #4f5652;
  --ok: #0c7a3e; --warn: #a14b12;
  --r: 6px; --r-lg: 10px;
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121413; --surface: #1a1c1b; --surface-2: #222524; --border: #2f3331; --border-2: #3d4240;
    --text: #edf0ee; --text-2: #b9c0bc; --text-3: #8b938f;
    --primary: #6ea4ec; --primary-2: #8ab6f0; --primary-ink: #0d1520; --primary-soft: #1c2a3b;
    --s1: #3987e5; --s2: #d95926; --target: #b9c0bc; --ok: #4cc27d; --warn: #f0a068;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121413; --surface: #1a1c1b; --surface-2: #222524; --border: #2f3331; --border-2: #3d4240;
  --text: #edf0ee; --text-2: #b9c0bc; --text-3: #8b938f;
  --primary: #6ea4ec; --primary-2: #8ab6f0; --primary-ink: #0d1520; --primary-soft: #1c2a3b;
  --s1: #3987e5; --s2: #d95926; --target: #b9c0bc; --ok: #4cc27d; --warn: #f0a068;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.6; font-feature-settings: 'tnum' 1; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
.sr-only, .sr-title { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--primary-ink); padding: 8px 12px; z-index: 99; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ── header ── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.site-header .wrap { display: flex; align-items: center; gap: 12px; height: 56px; }
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); font-weight: 750; letter-spacing: -0.02em; font-size: 17px; }
.logo svg { width: 26px; height: 26px; flex: none; }
.logo small { font-weight: 500; color: var(--text-3); font-size: 12.5px; letter-spacing: 0; }
.hnav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.hnav a { text-decoration: none; color: var(--text-2); padding: 6px 10px; border-radius: var(--r); font-size: 14px; }
.hnav a:hover, .hnav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.theme-btn { width: 36px; height: 36px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r); cursor: pointer; display: grid; place-items: center; margin-left: 4px; }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (max-width: 560px) { .logo small { display: none; } .hnav a.opt { display: none; } }

/* ── tabs (계산기 전환) ── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin: 18px 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; text-decoration: none; color: var(--text-2); padding: 10px 14px 11px; font-weight: 600; font-size: 14.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-selected="true"], .tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--primary); }

/* ── tool layout ── */
.tool { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 940px) { .tool { grid-template-columns: 340px 1fr; align-items: start; } .panel.inputs { position: sticky; top: 72px; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; }
.panel h2 { font-size: 13px; font-weight: 700; color: var(--text-3); letter-spacing: .04em; margin: 0 0 12px; text-transform: uppercase; }
.fld { margin-bottom: 14px; }
.fld > label, .fld > .lbl { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.inp { display: flex; align-items: center; border: 1px solid var(--border-2); border-radius: var(--r); background: var(--surface); padding: 0 10px; height: 42px; }
.inp:focus-within { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.inp input { border: 0; background: transparent; outline: 0; width: 100%; min-width: 0; font-size: 16.5px; font-weight: 650; text-align: right; padding: 0; }
.inp .unit { color: var(--text-3); font-size: 14px; margin-left: 6px; flex: none; }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: 4px; min-height: 1em; text-align: right; }
.quick, .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.quick button, .chips button { border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.quick button:hover, .chips button:hover { border-color: var(--primary); color: var(--primary); }
.seg { display: flex; border: 1px solid var(--border-2); border-radius: var(--r); overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--surface); padding: 8px 6px; font-size: 13.5px; cursor: pointer; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border-2); }
.seg button[aria-checked="true"] { background: var(--primary); color: var(--primary-ink); font-weight: 650; }
select { width: 100%; height: 42px; border: 1px solid var(--border-2); border-radius: var(--r); background: var(--surface); padding: 0 10px; font-size: 14.5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel-foot { display: flex; gap: 8px; margin-top: 4px; }
.btn { border: 1px solid var(--border-2); background: var(--surface); border-radius: var(--r); padding: 8px 12px; font-size: 13.5px; cursor: pointer; color: var(--text-2); }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 650; }
.btn.primary:hover { background: var(--primary-2); color: var(--primary-ink); }
.local { font-size: 12px; color: var(--text-3); margin: 10px 0 0; }

/* 자유적립 */
.free-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; margin-bottom: 8px; }
.free-row { display: grid; grid-template-columns: 58px auto 1fr auto 30px; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); }
.free-row input { height: 34px; border: 1px solid var(--border-2); border-radius: var(--r); background: var(--surface); padding: 0 8px; text-align: right; width: 100%; min-width: 0; font-weight: 600; color: var(--text); }
.free-row .x { height: 30px; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--r); cursor: pointer; color: var(--text-3); }
.free-hint { font-size: 12px; color: var(--text-3); margin: 6px 0 0; }

/* ── results ── */
.results { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
@media (min-width: 700px) { .kpis { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
.kpi { background: var(--surface); padding: 14px 16px; min-width: 0; }
.kpi .k { display: block; font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.kpi strong { display: block; font-size: 19px; font-weight: 750; letter-spacing: -0.02em; margin-top: 4px; overflow-wrap: anywhere; }
.kpi.main strong { font-size: 25px; color: var(--primary); }
@media (max-width: 699px) { .kpi.main { grid-column: 1 / -1; } .kpis .kpi:nth-child(even):last-child { grid-column: 1 / -1; } }
.sechead { font-size: 15px; font-weight: 750; margin: 6px 0 -4px; }
.msg { font-size: 14px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: var(--r); padding: 10px 14px; margin: 0; }
.msg:empty { display: none; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; min-width: 0; }
.card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 8px; }
.card-head h3 { font-size: 14px; margin: 0; font-weight: 700; }
.legend { display: flex; gap: 12px; font-size: 12.5px; color: var(--text-2); }
.legend i, .chart-tip i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.card-head .btn { margin-left: auto; padding: 5px 10px; font-size: 12.5px; }
.chart { position: relative; min-height: 220px; }
.chart svg { display: block; overflow: visible; }
.c-axis text, .c-xl, .c-tl { font-size: 11px; fill: var(--text-3); }
.c-grid { stroke: var(--border); stroke-width: 1; }
.c-base { stroke: var(--border-2); stroke-width: 1; }
.c-bar.c-s1, .sw.c-s1, .legend .c-s1 { fill: var(--s1); background: var(--s1); }
.c-bar.c-s2, .sw.c-s2, .legend .c-s2 { fill: var(--s2); background: var(--s2); }
.c-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.c-line.c-s1 { stroke: var(--s1); } .c-line.c-s2 { stroke: var(--s2); }
.c-dot.c-s1 { fill: var(--s1); } .c-dot.c-s2 { fill: var(--s2); }
.c-dot.ring { stroke: var(--surface); stroke-width: 2; }
.c-target { stroke: var(--target); stroke-width: 1.25; stroke-dasharray: 5 4; }
.c-cross { stroke: var(--text-3); stroke-width: 1; }
.c-hit { fill: transparent; cursor: crosshair; }
.c-hit.on { fill: var(--text); fill-opacity: .05; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r); padding: 8px 10px; font-size: 12.5px; min-width: 150px; box-shadow: 0 2px 6px rgb(0 0 0 / .08); z-index: 5; }
.chart-tip b { display: block; margin-bottom: 3px; }
.chart-tip div { display: flex; align-items: center; color: var(--text-2); }
.chart-tip span { margin-left: auto; padding-left: 12px; color: var(--text); font-weight: 650; }
.chart-tip .tot { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.tbl-wrap { max-height: 360px; overflow: auto; }
table.data, table.breakdown { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { position: sticky; top: 0; background: var(--surface); color: var(--text-3); font-weight: 600; font-size: 12.5px; }
table.breakdown th, table.breakdown td { padding: 8px 2px; border-bottom: 1px solid var(--border); }
table.breakdown th { text-align: left; font-weight: 500; color: var(--text-2); }
table.breakdown td { text-align: right; font-weight: 650; }
table.breakdown tr.sub th { padding-left: 14px; color: var(--text-3); }
table.breakdown tr.sub td { color: var(--text-3); font-weight: 500; }
table.breakdown tr.total th, table.breakdown tr.total td { border-bottom: 0; font-size: 15px; color: var(--text); font-weight: 750; }
.card-foot { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.card-foot .note { font-size: 12px; color: var(--text-3); }

/* 72법칙·실질금리: 두 블록 */
.tool[data-tool="rate"] .inputs h2 + .fld { margin-top: 0; }
.subhead { font-size: 13px; font-weight: 700; color: var(--text-3); margin: 18px 0 12px; padding-top: 14px; border-top: 1px solid var(--border); letter-spacing: .04em; }

/* ── 광고 (애드핏 규정: 래퍼 border-radius·overflow 금지) ── */
.ad-wrap { margin: 22px auto 0; }
.ad-grid { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 672px; margin: 0 auto; }
.ad-grid[data-ad-layout="mixed"] { max-width: 780px; }
.ad-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
.ad-cell { max-width: 100%; }
.ad-row.ad-mo { display: none; }
.ad-row.ad-pc, .ad-row.ad-any { display: flex; }
@media (max-width: 719px) { .ad-row.ad-pc { display: none; } .ad-row.ad-mo { display: flex; } }

/* ── 문서형 페이지 ── */
.crumb { font-size: 12.5px; color: var(--text-3); margin: 18px 0 0; }
.crumb a { color: var(--text-3); text-decoration: none; }
.crumb a:hover { color: var(--primary); }
.doc { max-width: 760px; margin: 0 auto; padding: 8px 0 20px; }
.doc h1 { font-size: 27px; line-height: 1.35; letter-spacing: -0.025em; margin: 14px 0 8px; }
.doc .meta { font-size: 13px; color: var(--text-3); margin: 0 0 22px; }
.doc h2 { font-size: 20px; letter-spacing: -0.02em; margin: 34px 0 10px; padding-top: 18px; border-top: 1px solid var(--border); }
.doc h3 { font-size: 16.5px; margin: 24px 0 8px; }
.doc p, .doc li { font-size: 16px; line-height: 1.8; }
.doc ul, .doc ol { padding-left: 1.3em; }
.doc li + li { margin-top: 4px; }
.doc .note { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: var(--r); padding: 12px 16px; margin: 18px 0; }
.doc .note p:first-child { margin-top: 0; } .doc .note p:last-child { margin-bottom: 0; }
.doc pre.formula { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 14px; white-space: pre-wrap; overflow-x: auto; line-height: 1.65; }
.doc table.tbl { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14.5px; display: block; overflow-x: auto; }
.doc table.tbl th, .doc table.tbl td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.doc table.tbl td:first-child, .doc table.tbl th:first-child { white-space: nowrap; }
.doc table.tbl thead th { background: var(--surface-2); font-weight: 650; border-bottom: 1px solid var(--border-2); white-space: nowrap; }
.doc .sources { font-size: 13.5px; color: var(--text-2); }
.doc .faq dt { font-weight: 700; margin-top: 16px; }
.doc .faq dd { margin: 4px 0 0; color: var(--text-2); line-height: 1.75; }
.tool-doc { margin-top: 26px; }
.tool-doc .doc { max-width: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 6px 22px 20px; }
@media (max-width: 560px) { .tool-doc .doc { padding: 4px 14px 16px; } .doc h1 { font-size: 23px; } }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin: 14px 0; padding: 0; list-style: none; }
.cards li { margin: 0; }
.cards a { display: block; height: 100%; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; }
.cards a:hover { border-color: var(--primary); }
.cards b { display: block; font-size: 15.5px; line-height: 1.45; }
.cards span { display: block; font-size: 13.5px; color: var(--text-3); margin-top: 6px; line-height: 1.6; }
.cards .cat { display: inline-block; font-size: 11.5px; color: var(--primary); font-weight: 700; margin-bottom: 6px; }
.related { margin-top: 28px; }
.related h2 { font-size: 16px; border: 0; padding: 0; margin: 0 0 4px; }

/* ── footer ── */
.site-footer { margin-top: 48px; border-top: 1px solid var(--border); background: var(--surface); padding: 26px 0 30px; font-size: 13px; color: var(--text-3); }
.fcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px; margin-bottom: 18px; }
.fcols b { display: block; color: var(--text-2); margin-bottom: 6px; font-size: 13px; }
.fcols a { display: block; color: var(--text-3); text-decoration: none; padding: 2px 0; }
.fcols a:hover { color: var(--primary); }
.site-footer p { margin: 6px 0; line-height: 1.65; }
.doc.wide { max-width: none; margin: 0; padding-bottom: 0; }
