* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #ffffff;
  color: #1f2937;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: #1e40af; }
header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  justify-content: space-between;
}
.logo {
  font-size: 20px;
  font-weight: 700;
  color: #1e40af;
  text-decoration: none;
  letter-spacing: -0.01em;
}
nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 0;
  padding: 0;
}
nav a {
  display: inline-block;
  padding: 8px 12px;
  color: #374151;
  text-decoration: none;
  font-size: 14px;
  border-radius: 6px;
  font-weight: 500;
}
nav a:hover, nav a.active {
  background: #eff6ff;
  color: #1e40af;
}
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
h1 {
  font-size: 30px;
  line-height: 1.2;
  margin: 12px 0 12px;
  color: #111827;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 20px;
  margin: 24px 0 12px;
  color: #111827;
}
h3 {
  font-size: 16px;
  margin: 18px 0 8px;
  color: #111827;
}
.intro {
  color: #4b5563;
  font-size: 16px;
  max-width: 820px;
}
.calculator {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px;
  margin: 20px 0;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  color: #374151;
}
.field .hint {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}
.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 15px;
  background: #fff;
  color: #111827;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: #1e40af;
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
}
.field input[type="range"] {
  width: 100%;
  accent-color: #1e40af;
}
.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.range-row input[type="range"] { flex: 1; }
.range-value {
  min-width: 64px;
  text-align: right;
  font-weight: 700;
  color: #1e40af;
  font-size: 15px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
  .header-inner { gap: 8px; }
  nav a { padding: 6px 10px; font-size: 13px; }
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #1e40af;
}
.toggle-row label {
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}
button.calc-btn {
  background: #1e40af;
  color: #fff;
  border: 0;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
button.calc-btn:hover { background: #1e3a8a; }
button.calc-btn:active { transform: translateY(1px); }
.results {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px 24px;
  margin: 20px 0;
}
.results h2 { margin-top: 0; }
.result-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 15px;
}
.result-row:last-child { border-bottom: 0; }
.result-row .label { color: #4b5563; }
.result-row .value { font-weight: 600; color: #111827; }
.result-row.total {
  padding-top: 14px;
  margin-top: 6px;
  border-top: 2px solid #e5e7eb;
  border-bottom: 0;
}
.result-row.total .label,
.result-row.total .value {
  font-size: 18px;
  color: #1e40af;
  font-weight: 700;
}
.range-results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}
@media (max-width: 540px) {
  .range-results { grid-template-columns: 1fr; }
}
.range-card {
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.range-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #1e40af;
  font-weight: 700;
}
.range-card .value {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin-top: 6px;
}
.disclaimer {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  padding: 14px 16px;
  color: #78350f;
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.55;
}
.disclaimer strong { color: #78350f; }
.tooltip {
  display: inline-block;
  margin-left: 6px;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  background: #e5e7eb;
  color: #374151;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  position: relative;
}
.tooltip:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 24px;
  top: -4px;
  background: #1f2937;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  width: 240px;
  z-index: 10;
  line-height: 1.4;
  white-space: normal;
}
.pay-direction {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 12px 16px;
  border-radius: 6px;
  margin: 12px 0;
  font-weight: 600;
  font-size: 15px;
}
.warning {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 6px;
  margin: 12px 0;
  font-size: 14px;
}
.section-info {
  background: #f9fafb;
  border-left: 4px solid #1e40af;
  padding: 16px 20px;
  margin: 24px 0;
  border-radius: 4px;
  color: #374151;
  font-size: 14px;
}
.section-info h3 { margin-top: 0; color: #1e40af; }
.section-info p { margin: 8px 0; }
footer {
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  padding: 24px 20px;
  margin-top: 48px;
  color: #6b7280;
  font-size: 13px;
  text-align: center;
}
footer .footer-inner { max-width: 1100px; margin: 0 auto; }
