:root {
  --ink: #15181c;
  --ink-soft: #4b5563;
  --muted: #7a828c;
  --line: #e3e6ea;
  --line-strong: #c9ced6;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --accent: #1d4ed8;
  --accent-soft: #eef2ff;
  --ok: #0f6b4f;
  --ok-soft: #eaf5f0;
  --warn: #a3540a;
  --warn-soft: #fdf3e6;
  --radius: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.01em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #fff;
  padding: 8px 12px;
  z-index: 20;
}
.skip:focus { left: 8px; top: 8px; }

/* header */
.site-header {
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}
.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.brand span { color: var(--muted); font-weight: 500; }
.site-nav {
  display: flex;
  gap: 18px;
  font-size: 14px;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 0;
}
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* hero */
.hero {
  padding: 44px 20px 8px;
  max-width: 1040px;
}
.hero h1 {
  margin: 0 0 10px;
  font-size: 32px;
  line-height: 1.28;
  letter-spacing: -0.03em;
}
.hero p.lede {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  max-width: 720px;
}
.hero .stamp {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* panels */
section.block {
  padding: 26px 0;
}
.panel-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: #fff;
}
h2 {
  font-size: 20px;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}
h3 { letter-spacing: -0.02em; }
h4 { margin: 0 0 6px; font-size: 14px; color: var(--ink); }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

/* inputs */
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}
.preset-row .label {
  font-size: 13px;
  color: var(--muted);
  margin-right: 2px;
}
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  min-height: 38px;
}
.btn:hover { border-color: var(--muted); color: var(--ink); }
.btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.btn-ghost { border-style: dashed; }

.total-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
}
.total-line strong { font-size: 22px; color: var(--ink); font-variant-numeric: tabular-nums; }

.spend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
}
.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.field .hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.field .input-wrap { position: relative; }
.field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 30px 10px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
  background: #fff;
}
.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field .won-mark {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
}

/* results */
.results-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.result-summary {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}
.sum-item { display: inline-flex; align-items: baseline; gap: 6px; }
.sum-label { color: var(--muted); font-size: 12px; }
.result-summary strong { color: var(--ink); }
.sort-group { display: flex; gap: 6px; }
.sort-group .btn { padding: 6px 12px; font-size: 13px; min-height: 34px; }

.card-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}
.card-row.is-zero { background: var(--bg-soft); }
.card-main {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.card-id {
  display: flex;
  gap: 12px;
  min-width: 240px;
  flex: 1 1 320px;
}
.rank {
  flex: 0 0 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.card-row:first-child .rank { background: var(--ink); color: #fff; }
.card-id h3 { margin: 0 0 2px; font-size: 17px; }
.card-id .meta { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.badges { margin: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  display: inline-block;
  font-size: 11px;
  line-height: 1.5;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: #fff;
  white-space: nowrap;
}
.badge-ok { border-color: #bfe0d1; background: var(--ok-soft); color: var(--ok); }
.badge-warn { border-color: #f0d5b0; background: var(--warn-soft); color: var(--warn); }
.badge-none { border-color: var(--line-strong); background: var(--bg-soft); }
.badge-tag { color: var(--muted); }

.card-figures {
  display: flex;
  gap: 26px;
  align-items: flex-start;
}
.figure {
  display: flex;
  flex-direction: column;
  min-width: 118px;
}
.fig-label { font-size: 12px; color: var(--muted); }
.fig-rate, .fig-net {
  font-size: 24px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.fig-rate { color: var(--accent); }
.fig-net { color: var(--ink); }
.fig-net .unit, .fig-rate .unit { font-size: 13px; font-weight: 500; margin-left: 2px; color: inherit; }
.fig-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.more-btn {
  appearance: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  min-height: 36px;
}
.more-btn::after { content: " ▾"; font-size: 10px; }
.more-btn[aria-expanded="true"] { background: #fff; border-color: var(--line-strong); }
.more-btn[aria-expanded="true"]::after { content: " ▴"; }
.official {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 2px;
}

.card-panel { margin-top: 14px; }
.perf-line {
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
}
.table-scroll { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table caption {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 6px;
}
.table-caption {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px 8px;
  text-align: left;
  vertical-align: top;
}
thead th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
tbody th { font-weight: 500; width: 24%; }
td.why { width: 42%; }
.basis-table td:nth-child(2) { width: 24%; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num.muted { color: var(--muted); }
td.why { font-size: 12px; color: var(--ink-soft); }
.panel-block { margin-top: 14px; }
.panel-block p { font-size: 13px; color: var(--ink-soft); }
ul.plain { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-soft); }
ul.plain li { margin-bottom: 4px; }

.note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

/* basis section */
.assumption-list {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  color: var(--ink-soft);
}
.assumption-list li { margin-bottom: 8px; }
.formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

/* data table */
.data-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.data-table { min-width: 720px; font-size: 13px; }
.data-table th, .data-table td { padding: 10px; }
.data-table thead th { background: var(--bg-soft); }
.data-table td.num { white-space: nowrap; }

/* faq */
.faq details {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: " +"; color: var(--muted); font-weight: 400; }
.faq details[open] summary::after { content: " −"; }
.faq .answer { font-size: 14px; color: var(--ink-soft); padding-top: 8px; }

/* article pages */
.prose { max-width: 760px; }
.prose h2 { margin-top: 28px; }
.prose h3 { font-size: 16px; margin: 20px 0 8px; }
.prose p, .prose li { font-size: 15px; color: var(--ink-soft); }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.prose .updated { font-size: 13px; color: var(--muted); }

/* footer */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 30px;
  padding: 24px 0 40px;
  font-size: 13px;
  color: var(--muted);
}
.site-footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 10px;
}
.site-footer a {
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 1px 0;
}
.site-footer p { margin: 0 0 6px; }

/* responsive */
@media (max-width: 720px) {
  .hero { padding-top: 30px; }
  .hero h1 { font-size: 25px; }
  .card-figures { gap: 18px; width: 100%; justify-content: space-between; }
  .figure { min-width: 0; }
  .fig-rate, .fig-net { font-size: 21px; }
  .card-main { flex-direction: column; gap: 12px; }
  .card-id { flex: 0 0 auto; min-width: 0; width: 100%; }
  .spend-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field input { font-size: 16px; }
  tbody th { width: auto; }
  .card-actions { justify-content: space-between; }
}

@media (max-width: 400px) {
  .wrap { padding: 0 14px; }
  .hero { padding-left: 14px; padding-right: 14px; }
  .card-row { padding: 14px; }
  .fig-rate, .fig-net { font-size: 19px; }
  .site-nav { gap: 12px; font-size: 13px; }
}

/* 표 안 링크 터치 영역 */
.data-table td a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 1px 2px;
}

/* 계산 근거 표 합계 행 */
table tfoot th, table tfoot td {
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  font-variant-numeric: tabular-nums;
}
table tfoot tr.total-row th, table tfoot tr.total-row td {
  border-top: 1px solid var(--line-strong);
  border-bottom: none;
  font-weight: 600;
  color: var(--ink);
}
table tfoot td.why { font-weight: 400; }

/* 모바일: 계산 근거 표를 블록으로 */
@media (max-width: 720px) {
  .basis-table, .basis-table thead, .basis-table tbody, .basis-table tfoot,
  .basis-table tr, .basis-table th, .basis-table td { display: block; width: auto; }
  .basis-table thead { display: none; }
  .table-caption { padding-bottom: 2px; }
  .basis-table tr {
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
  }
  .basis-table th, .basis-table td {
    border: none;
    padding: 1px 0;
    word-break: keep-all;
  }
  .basis-table tbody th { font-weight: 600; font-size: 14px; color: var(--ink); }
  .basis-table td.num { text-align: left; font-weight: 600; font-size: 14px; }
  .basis-table td.why { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .basis-table tfoot th, .basis-table tfoot td { background: none; }
  .basis-table tfoot tr.total-row { border-top: 1px solid var(--line-strong); }
}
