:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #112240;
  --muted: #4a5a70;
  --accent: #0b5fff;
  --border: #d8e1ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  width: min(1120px, 96%);
  margin: 0 auto;
}

.hero {
  background: linear-gradient(135deg, #0a2540, #173f73);
  color: #fff;
  padding: 40px 0 32px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
}

.hero p {
  margin: 0;
  color: #dce7ff;
}

.hero-note {
  margin-top: 10px;
  color: #f5f8ff;
  font-size: 0.95rem;
  max-width: 900px;
}

main {
  padding: 20px 0 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.hint {
  color: var(--muted);
  margin-top: 6px;
}

.grid {
  display: grid;
  gap: 12px;
}

.base-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.base-grid > label {
  min-width: 0;
}

.hidden {
  display: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.payment-label-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.payment-equal-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-size: 0.82rem;
}

.payment-equal-toggle input[type="checkbox"] {
  margin: 0;
}

input, select, button {
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 0.95rem;
}

input,
select {
  width: 100%;
  min-width: 0;
}

button {
  cursor: pointer;
  background: #fff;
}

button:hover {
  border-color: #b7c6df;
}

.scenario-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.scenario-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.scenario-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 8px;
  align-items: end;
}

.prepay-list {
  margin-top: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

.prepay-item {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-top: 8px;
  align-items: end;
}

.prepay-item button {
  height: 42px;
  padding: 8px 12px;
  white-space: nowrap;
  align-self: end;
}

.chart-wrap {
  margin-top: 16px;
}

canvas {
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.chart-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 20;
  background: #0f2240;
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  line-height: 1.3;
  box-shadow: 0 8px 20px rgba(10, 20, 40, 0.2);
  max-width: 240px;
  display: none;
}

.legend {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend-color {
  width: 16px;
  height: 3px;
  border-radius: 99px;
}

.table-wrap {
  overflow-x: auto;
}

.summary-table-outer[data-collapsed="true"] tbody tr:nth-child(n + 7) {
  display: none;
}

.summary-table-toggle {
  margin-top: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: #f6f9ff;
}

.seo-copy article {
  margin-top: 8px;
}

.footer-credit {
  margin: 12px 0 4px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.footer-credit a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.footer-credit a:hover {
  color: var(--accent);
}

@media (max-width: 720px) {
  .base-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scenario-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .prepay-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .scenario-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .base-grid {
    grid-template-columns: 1fr;
  }

  .scenario-grid {
    grid-template-columns: 1fr;
  }
}
