/* ============================================
   FreeFinancialToolkit 공통 디자인 시스템 (절충안)
   ============================================ */
:root {
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --ink: #1B2740;
  --ink-soft: #64748F;
  --line: #E1E7F0;
  --primary: #3563E9;
  --primary-soft: #EDF2FE;
  --warm: #F59CA9;
  --money: #0E8A5F;
  --danger: #D06565;
  --radius: 18px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, system-ui, "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
a { color: var(--primary); }

/* ===== 3단 레이아웃 + 사이드 광고 레일 ===== */
.page {
  display: grid;
  grid-template-columns: 1fr minmax(0, 680px) 1fr;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
}
.rail { padding-top: 96px; }
.rail-inner {
  position: sticky; top: 24px;
  width: 160px; height: 600px;
  border: 2px dashed var(--line); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #AEB9CC; font-size: 0.75rem; text-align: center;
  background: rgba(255,255,255,0.6);
}
.ad-slot__content { display: grid; gap: 2px; justify-items: center; }
.ad-slot__label { font-weight: 600; }
.ad-slot__size { color: inherit; font-size: 0.9em; }
.rail.left .rail-inner { margin-left: auto; }

.partner-disclosure {
  margin: 12px 0 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.75rem;
  line-height: 1.55;
}@media (max-width: 1160px) { .rail { display: none; } .page { grid-template-columns: 1fr; } }

/* ===== 전역 카테고리 내비게이션 ===== */
.gnav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244, 246, 250, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  margin: 12px -4px 0; padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}
.gnav-cats { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.gnav-cats::-webkit-scrollbar { display: none; }
.gnav-chip {
  flex: 0 0 auto; font: inherit; font-size: 0.85rem; font-weight: 700;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  text-decoration: none; white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.gnav-chip:hover { border-color: var(--primary); color: var(--primary); }
.gnav-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.gnav-chip.cur:not(.on) { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.gnav-chip:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.gnav-panel {
  display: none; flex-wrap: wrap; gap: 8px;
  padding-top: 10px;
}
.gnav-panel a {
  font-size: 0.83rem; font-weight: 600;
  padding: 7px 13px; border-radius: 999px;
  background: #fff; color: var(--ink-soft);
  border: 1px solid var(--line);
  text-decoration: none; white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.gnav-panel a:hover { color: var(--primary); border-color: var(--primary); }
.gnav-panel a.now { background: var(--ink); border-color: var(--ink); color: #fff; }

header.site { padding: 18px 0 0; }
.logo { font-weight: 800; font-size: 1.02rem; text-decoration: none; color: var(--ink); }
.logo em { color: var(--primary); font-style: normal; }
nav.crumb { font-size: 0.78rem; color: var(--ink-soft); padding: 16px 0 0; }
nav.crumb a { color: var(--ink-soft); text-decoration: none; }
nav.crumb a:hover { color: var(--primary); }

.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 999px; padding: 3px 12px; margin: 12px 0 8px;
}
h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 3px; }
.sub { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 20px; }

/* ===== 계산기 카드 ===== */
.calc {
  background: var(--card);
  border-radius: var(--radius);
  padding: 26px 24px;
  box-shadow: 0 4px 20px rgba(27, 39, 64, 0.07);
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--ink-soft); font-size: 0.77rem; margin-left: 4px; }
.input-row { position: relative; }
.input-row input, .input-row select {
  width: 100%; font: inherit; font-size: 1.1rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 13px 52px 13px 15px;
  border: 1.5px solid var(--line); border-radius: 13px;
  color: var(--ink); background: #FAFBFE;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
.input-row input[type="date"] { padding-right: 15px; }
.input-row select { padding-right: 15px; }
.input-row input:focus, .input-row select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft); background: #fff;
}
.input-row .unit {
  position: absolute; right: 15px; top: 50%; transform: translateY(-50%);
  font-size: 0.9rem; color: var(--ink-soft); font-weight: 600;
}
.seg { display: flex; background: #EBF0F8; border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.seg button {
  flex: 1; font: inherit; font-size: 0.88rem; font-weight: 700;
  padding: 9px; border: none; border-radius: 999px;
  background: transparent; color: var(--ink-soft); cursor: pointer;
  transition: all 0.18s;
}
.seg button.on { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(27,39,64,0.10); }
.seg button:focus-visible { outline: 2px solid var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wage-basis-fields .field { grid-column: 1 / -1; }
.stepper {
  display: flex; align-items: center;
  border: 1.5px solid var(--line); border-radius: 13px; background: #FAFBFE;
}
.stepper button {
  width: 44px; height: 48px; border: none; background: transparent;
  font-size: 1.25rem; font-weight: 700; color: var(--primary); cursor: pointer;
}
.stepper button:focus-visible { outline: 2px solid var(--ink); border-radius: 11px; }
.stepper span { flex: 1; text-align: center; font-weight: 700; font-size: 1.02rem; }

/* ===== 시그니처: 명세서 결과 + 영수증 톱니 ===== */
.stub {
  margin-top: 24px;
  background: var(--card);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 8px 26px rgba(27, 39, 64, 0.11);
  -webkit-mask: linear-gradient(#000 0 0) top/100% calc(100% - 12px) no-repeat,
    radial-gradient(circle 8px at 8px 100%, transparent 8px, #000 8.5px) bottom/16px 12px repeat-x;
          mask: linear-gradient(#000 0 0) top/100% calc(100% - 12px) no-repeat,
    radial-gradient(circle 8px at 8px 100%, transparent 8px, #000 8.5px) bottom/16px 12px repeat-x;
  padding-bottom: 12px;
}
.stub-head {
  background: var(--ink); color: #fff;
  padding: 13px 22px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.82rem;
  border-radius: 8px 8px 0 0;
}
.stub-head .title { font-weight: 800; letter-spacing: 0.16em; }
.stub-head .date { opacity: 0.65; }
.stub-body { padding: 16px 22px 4px; }
.row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0; font-size: 0.94rem; gap: 12px;
}
.row + .row { border-top: 1px dashed var(--line); }
.row .k { color: var(--ink-soft); }
.row .k small { display: block; font-size: 0.71rem; color: #9AA7BC; }
.row .v { font-weight: 700; text-align: right; }
.row.minus .v { color: var(--danger); }
.row.plus .v { color: var(--money); }
.row.total-line { border-top: 1.5px solid var(--ink); }
.row.total-line .k, .row.total-line .v { font-weight: 800; }
.stub-final {
  margin: 10px 22px 14px;
  padding: 16px 18px;
  background: linear-gradient(0deg, #F0F9F4, #F7FBF9);
  border-radius: 14px;
  text-align: center;
}
.stub-final .label { font-size: 0.81rem; font-weight: 700; color: var(--ink-soft); }
.stub-final .amount {
  font-size: 2.05rem; font-weight: 800; letter-spacing: -0.025em;
  color: var(--money); font-variant-numeric: tabular-nums;
}
.stub-final .yearly { font-size: 0.8rem; color: var(--ink-soft); }
.stub-final .cheer { font-size: 0.8rem; color: var(--warm); font-weight: 700; margin-top: 8px; }

/* ===== 비교 카드 (내 위치는 상위 몇 %?) ===== */
.compare-card { margin-top:14px; background:var(--card); border-radius:14px;
  padding:15px 18px; box-shadow:0 3px 14px rgba(27,39,64,.06);
  border-left:4px solid var(--warm); }
.compare-card .big { font-weight:800; font-size:1.05rem; }
.compare-card .big em { color:var(--primary); font-style:normal; font-size:1.3rem; }
.compare-card .src { font-size:.72rem; color:var(--ink-soft); margin-top:4px; }
.compare-bar { height:8px; background:#EBF0F8; border-radius:99px; margin-top:10px; overflow:hidden; }
.compare-bar i { display:block; height:100%; background:linear-gradient(90deg,var(--primary),var(--warm)); border-radius:99px; }

/* ===== 공유 버튼 ===== */
.share-bar { display: flex; gap: 10px; margin: 0 22px 18px; }
.share-bar button {
  flex: 1; font: inherit; font-size: 0.88rem; font-weight: 700;
  padding: 12px; border-radius: 12px; cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.share-bar button:active { transform: scale(0.98); }
.btn-share {
  border: none; background: var(--primary); color: #fff;
}
.btn-share:hover { background: #2b53c9; }
.btn-copy {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
}
.btn-copy:hover { border-color: var(--primary); color: var(--primary); }
.share-bar button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* 토스트 */
#toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff;
  padding: 11px 22px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 99;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 광고 ===== */
.ad-slot {
  margin: 26px 0;
  border: 2px dashed var(--line); border-radius: 13px;
  padding: 28px; text-align: center;
  color: #AEB9CC; font-size: 0.78rem;
  background: rgba(255,255,255,0.6);
}
.ad-slot[data-coupang-partners="true"] {
  min-height: 140px;
  padding: 0;
  border: 0;
  background: transparent;
}
.rail-inner[data-coupang-partners="true"] {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}
/* 광고 iframe이 고정폭이어도 레이아웃을 밀지 않도록 하는 안전망 */
.ad-slot, .rail-inner { overflow: hidden; }
.ad-slot iframe, .rail-inner iframe { max-width: 100%; }

/* ===== 콘텐츠 ===== */
section.content h2 {
  font-size: 1.14rem; font-weight: 800; letter-spacing: -0.01em;
  margin: 32px 0 10px;
  padding-left: 12px;
  border-left: 4px solid var(--primary);
}
section.content p, section.content li { font-size: 0.93rem; color: #37455F; margin-bottom: 12px; }
section.content ul { padding-left: 20px; }
section.content li { margin-bottom: 6px; }
section.content table {
  width: 100%; border-collapse: collapse; font-size: 0.87rem; margin: 12px 0;
  background: var(--card); border-radius: 13px; overflow: hidden;
  box-shadow: 0 2px 10px rgba(27,39,64,0.05);
}
section.content th, section.content td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
section.content th { background: var(--primary-soft); font-weight: 700; font-size: 0.81rem; }
section.content td.num { text-align: right; }
details.faq {
  background: var(--card); border-radius: 13px;
  margin-bottom: 8px; padding: 0 17px;
  box-shadow: 0 2px 10px rgba(27,39,64,0.05);
}
details.faq summary {
  cursor: pointer; font-weight: 700; font-size: 0.91rem; padding: 14px 0;
  list-style: none; position: relative; padding-right: 24px;
}
details.faq summary::after { content: "+"; position: absolute; right: 0; color: var(--primary); font-weight: 800; }
details.faq[open] summary::after { content: "−"; }
details.faq p { font-size: 0.89rem; color: #37455F; padding-bottom: 14px; }
.disclaimer {
  margin: 28px 0; padding: 14px 16px;
  background: #FFF8EC; border-radius: 13px;
  font-size: 0.79rem; color: #7A6335;
}

/* ===== 관련 도구 링크 ===== */
.related { margin-top: 30px; }
.related h2 { font-size: 1rem; font-weight: 800; margin-bottom: 10px; }
.related-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.related-grid a {
  display: block; background: var(--card); border-radius: 13px;
  padding: 13px 15px; text-decoration: none;
  font-size: 0.87rem; font-weight: 700; color: var(--ink);
  box-shadow: 0 2px 10px rgba(27,39,64,0.05);
  transition: box-shadow 0.15s, color 0.15s;
}
.related-grid a:hover { color: var(--primary); box-shadow: 0 4px 14px rgba(27,39,64,0.1); }
.related-grid a small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.76rem; }

/* ===== 메인(허브) 페이지 ===== */
.hero { text-align: center; padding: 36px 0 8px; }
.hero h1 { font-size: 1.8rem; }
.hero p { color: var(--ink-soft); font-size: 0.95rem; margin-top: 6px; }
.cat { margin-top: 30px; }
.cat-title { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.cat-title h2 { font-size: 1.15rem; font-weight: 800; }
.cat-title span { font-size: 0.8rem; color: var(--ink-soft); }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tool-card {
  display: block; background: var(--card); border-radius: var(--radius);
  padding: 18px; text-decoration: none; color: var(--ink);
  box-shadow: 0 3px 14px rgba(27,39,64,0.06);
  transition: transform 0.12s, box-shadow 0.15s;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(27,39,64,0.11); }
.tool-card .ico { font-size: 1.4rem; }
.tool-card .name { font-weight: 800; font-size: 0.98rem; margin: 6px 0 2px; }
.tool-card .desc { font-size: 0.79rem; color: var(--ink-soft); line-height: 1.5; }

footer.site {
  margin-top: 42px; padding: 24px 0 38px;
  border-top: 1px solid var(--line);
  font-size: 0.77rem; color: var(--ink-soft); text-align: center;
}
footer.site a { color: var(--ink-soft); }

@media (max-width: 480px) {
  h1 { font-size: 1.35rem; }
  .hero h1 { font-size: 1.5rem; }
  .grid2, .tool-grid, .related-grid { grid-template-columns: 1fr; }
  .stub-final .amount { font-size: 1.72rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
