:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f5f7fb;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent-bg: #eff6ff;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo {
  display: flex;
  align-items: center;
  align-self: stretch;
  text-decoration: none;
}
.logo-img { height: 100%; width: auto; display: block; }
.site-header nav a {
  margin-left: 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
}
.site-header nav a:hover { color: var(--primary); }

main.wrap { padding-top: 12px; padding-bottom: 24px; }

.calc-card, .info-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

h1 { font-size: 19px; margin: 0 0 2px; }
.sub { color: var(--text-muted); margin: 0 0 10px; font-size: 12.5px; }

.field-group { margin-bottom: 8px; }
.field-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; }

.btn-toggle { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-toggle button {
  flex: 1;
  min-width: 100px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  transition: all .15s;
}
.btn-toggle button.active {
  background: #93c6ff;
  border: 4px double #fff;
  color: #000;
}
.btn-toggle button:hover:not(.active) { border-color: var(--primary); }

.amount-row { margin-bottom: 3px; }
.amount-row label { font-size: 13px; font-weight: 600; color: var(--text-muted); }

.amount-split { display: flex; gap: 8px; margin-bottom: 6px; align-items: stretch; }
.amount-half { flex: 1 1 50%; min-width: 0; }
.amount-half:first-child { display: flex; align-items: center; gap: 6px; }
.amount-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
}
.amount-half .unit { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.amount-korean {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-dark);
  overflow-x: auto;
  white-space: nowrap;
  text-align: center;
}

.checkbox-line, .radio-line { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; margin-bottom: 2px; }
#customRateInput { margin-top: 5px; display: flex; align-items: center; gap: 8px; }
#customRateInput input { width: 100px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; }
.hidden { display: none !important; }
.full-text { display: inline; }
.short-text { display: none; }
.mobile-block { display: inline; }

.calc-btn {
  width: 100%;
  padding: 9px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.calc-btn:hover { background: var(--primary-dark); }

.result {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--accent-bg);
  border-radius: 10px;
}
.result .headline { font-size: 12.5px; color: var(--text-muted); margin-bottom: 1px; text-align: center; }
.amount-dual { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-bottom: 5px; flex-wrap: wrap; text-align: center; }
.amount-dual .amount { font-size: 24px; font-weight: 700; color: var(--primary-dark); }
.amount-dual .amount-kr { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.result table { width: 100%; border-collapse: collapse; font-size: 13px; }
.result table td { padding: 3px 0; border-top: 1px solid #dbeafe; }
.result table td:nth-child(2) { text-align: center; font-weight: 600; }
.result table td.kr { text-align: center; font-weight: 500; color: var(--text-muted); font-size: 11.5px; padding-left: 10px; }
.result table tr.total-row td { border-top: 2px solid var(--primary); padding-top: 5px; }
.result table tr.total-row td:first-child { font-weight: 700; }
.result table tr.total-row td:nth-child(2) { font-weight: 800; color: var(--primary-dark); font-size: 14px; }
.result .warn { margin-top: 6px; font-size: 12px; color: #b45309; }

.explain-box {
  background: var(--accent-bg);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 18px 20px;
  margin: 16px 0;
}
.explain-box h3 { margin-top: 0; font-size: 16px; }
.explain-box p { font-size: 14px; margin: 8px 0; }
.explain-box ul { font-size: 14px; margin: 8px 0; padding-left: 20px; }
.explain-box .example {
  background: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px dashed #93c5fd;
}
.explain-box .law-basis {
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px solid #bfdbfe;
  padding-top: 10px;
  margin-top: 12px;
}

.info-card h2 { font-size: 18px; margin-top: 0; }
.info-card ul { padding-left: 20px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
th, td { border: 1px solid var(--border); padding: 8px 10px; text-align: center; word-break: keep-all; }
th { background: #f9fafb; }
.note { font-size: 13px; color: var(--text-muted); }

.rate-table { table-layout: fixed; min-width: 480px; }
.rate-table .col-org { width: 17%; }
.rate-table .col-type { width: 21%; }
.rate-table .col-amount { width: 34%; }
.rate-table .col-rate { width: 28%; }

.loan-table { table-layout: fixed; width: 100%; font-size: 12px; }
.loan-table th, .loan-table td { padding: 6px 4px; }
.loan-table .col-name { width: 26%; }
.loan-table .col-eligible { width: 12%; }
.loan-table .col-deposit { width: 16%; }
.loan-table .col-limit { width: 16%; }
.loan-table .col-rate { width: 15%; }
.loan-table .col-interest { width: 15%; }
.loan-table td.ineligible { color: var(--text-muted); }
.loan-table td.ok { color: #15803d; font-weight: 700; }
.loan-table td.cash { color: #b45309; font-weight: 700; }
.loan-table td.no { color: #b91c1c; }
.loan-table tr.group-row td { background: #f9fafb; font-weight: 700; text-align: left; }

@media (max-width: 480px) {
  /* 좁은 화면에서는 표 대신 상품별 카드로 쌓아서, 숫자 길이가 얼마든 옆 칸과 겹치지 않게 한다. */
  .loan-table { font-size: 12.5px; border: none; }
  .loan-table thead { display: none; }
  .loan-table, .loan-table tbody, .loan-table tr, .loan-table td { display: block; width: 100%; }
  .loan-table tr:not(.group-row):not(.reason-row) {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 6px;
    padding: 6px 8px;
    background: #fff;
  }
  .loan-table tr:not(.group-row):not(.reason-row) td {
    border: none;
    text-align: right;
    padding: 3px 0 3px 46%;
    position: relative;
    min-height: 16px;
  }
  .loan-table tr:not(.group-row):not(.reason-row) td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 3px;
    width: 44%;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
  }
  .loan-table tr:not(.group-row):not(.reason-row) td[data-label="상품명"] {
    text-align: left;
    padding-left: 0;
    font-weight: 700;
  }
  .loan-table tr:not(.group-row):not(.reason-row) td[data-label="상품명"]::before { content: none; }
  .loan-table tr.group-row td { padding: 6px 4px; }
  .loan-table tr.reason-row td { padding: 0 0 6px; margin-top: -4px; }
}

.simple-input-row { display: flex; align-items: center; gap: 8px; }
.simple-input { width: 100px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; text-align: center; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  font-size: 13px;
  color: var(--text-muted);
}
.site-footer a { color: var(--text-muted); }

@media (max-width: 480px) {
  .site-header .wrap {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    padding: 0 20px 6px;
    gap: 3px;
  }
  .logo { white-space: nowrap; align-self: auto; }
  .logo-img { height: 44px; }
  .site-header nav { display: flex; gap: 8px; }
  .site-header nav a { margin-left: 0; font-size: 11.5px; white-space: nowrap; }

  .full-text { display: none; }
  .short-text { display: inline; }
  .mobile-block { display: block; margin-top: 1px; font-size: 0.78em; font-weight: 400; color: var(--text-muted); }

  .calc-card, .info-card { padding: 10px 12px; }
  h1 { font-size: 16px; margin-bottom: 1px; }
  .sub { margin-bottom: 8px; font-size: 12px; }

  .field-group { margin-bottom: 6px; }
  .field-label { margin-bottom: 3px; font-size: 12px; }

  #contractType, #vatOption { flex-wrap: nowrap; }
  #contractType button, #vatOption button { min-width: 0; padding: 7px 2px; font-size: 12.5px; }
  .btn-toggle button { font-size: 12px; padding: 6px 4px; }
  .btn-toggle button.active { border-width: 3px; }

  .amount-row { margin-bottom: 2px; }
  .amount-split { margin-bottom: 5px; gap: 6px; }
  .amount-input, .amount-korean { padding: 6px 8px; font-size: 13px; }

  .checkbox-line, .radio-line { margin-bottom: 1px; font-size: 12px; }
  .calc-btn { padding: 8px; font-size: 14px; }

  .result { margin-top: 8px; padding: 8px 10px; }
  .result .amount { font-size: 20px; }
  .amount-dual { margin-bottom: 3px; }
  .result table td { padding: 2px 0; }
  .result table td.val { display: none; }
  .result table td.kr { font-weight: 700; color: var(--text); font-size: 13px; text-align: center; padding-left: 0; }
  .result table tr.total-row td.kr { font-weight: 800; color: var(--primary-dark); font-size: 14.5px; }

  .info-card table { font-size: 10.5px; }
  .info-card th { white-space: nowrap; padding: 5px 3px; }
  .info-card td { padding: 5px 3px; }
}
