:root {
  --bg: #f4f7f4;
  --panel: #ffffff;
  --ink: #1a2a1f;
  --muted: #5f6e63;
  --line: #d8e0d9;
  --brand: #1f7a45;
  --brand-soft: #e4f3ea;
  --warn: #b64732;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  background: linear-gradient(180deg, #eef5ef 0%, #f7faf7 45%, #f4f7f4 100%);
  color: var(--ink);
  line-height: 1.5;
}

a {
  color: #0a5c86;
}

.container {
  width: min(980px, 100% - 24px);
  margin: 0 auto;
  padding: 16px 0 40px;
}

header.page-head {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(244, 247, 244, 0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.page-head .container {
  padding: 14px 0;
}

h1 {
  margin: 0;
  font-size: 1.3rem;
}

h2 {
  font-size: 1.1rem;
  margin-top: 0;
}

.card,
section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

.label-inline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.loan-ratio {
  color: #0a5c86;
  font-weight: 700;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #b7c4bb;
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  background: #fff;
}

/* Hide native increment/decrement controls on the months number input */
#months::-webkit-outer-spin-button,
#months::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#months {
  -moz-appearance: textfield;
  appearance: textfield;
}

button,
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

button.secondary,
.btn.secondary {
  background: #3e6d50;
}

button.ghost,
.btn.ghost {
  background: #eef5f0;
  color: var(--ink);
  border: 1px solid var(--line);
}

.actions,
.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-switch button.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

#jeonseSection,
#wolseSection {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fbfdfb;
}

.field-group {
  margin-bottom: 12px;
}

.management-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.management-includes {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.management-includes legend {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0 4px;
}

.management-includes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 10px;
  margin-bottom: 6px;
  font-weight: 500;
}

.management-includes input {
  width: 18px;
  height: 18px;
}

small.help,
.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

small.help {
  display: block;
  margin-top: 4px;
}

.error {
  color: var(--warn);
  font-weight: 700;
  margin-top: 8px;
}

.error-inline {
  color: var(--warn);
  font-size: 0.88rem;
  font-weight: 700;
  margin: 6px 0 0;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.result-grid.single-result {
  grid-template-columns: 1fr;
}

#resultBox {
  margin-top: 12px;
}

.result-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fbfdfb;
}

#saveHomeBtn {
  margin-top: 12px;
}

.result-amount {
  margin: 8px 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.is-cheap {
  color: var(--brand);
}

.compare-highlight {
  font-size: 1.05rem;
}

.home-card,
.compare-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  margin-bottom: 10px;
}

.home-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  font-size: 0.9rem;
  font-weight: 500;
}

.home-card h3 {
  margin: 0 0 4px;
}

.home-card .memo {
  margin: 4px 0 8px;
}

.home-card .summary {
  margin: 4px 0;
  font-size: 1rem;
}

.home-card .time {
  margin: 6px 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.compare-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 500;
}

.compare-check input {
  width: 18px;
  height: 18px;
}

dialog {
  width: min(520px, 92vw);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

dialog::backdrop {
  background: rgba(20, 30, 22, 0.45);
}

.rating-stars {
  position: relative;
  display: inline-block;
  font-size: 1.6rem;
  line-height: 1;
  letter-spacing: 2px;
  cursor: pointer;
  user-select: none;
}

.rating-stars-bg {
  color: #d0d7d1;
}

.rating-stars-fill {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  overflow: hidden;
  color: #f1b634;
  white-space: nowrap;
  pointer-events: none;
}

.rating-inline {
  position: relative;
  display: inline-block;
  line-height: 1;
  letter-spacing: 1px;
  vertical-align: middle;
  color: #d0d7d1;
}

.rating-inline::before {
  content: "★★★★★";
  color: #d0d7d1;
}

.rating-inline::after {
  content: "★★★★★";
  position: absolute;
  left: 0;
  top: 0;
  width: var(--rating-width, 0%);
  overflow: hidden;
  color: #f1b634;
  white-space: nowrap;
}

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

.compare-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.compare-table th,
.compare-table td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  background: #fff;
}

footer {
  color: var(--muted);
  font-size: 0.85rem;
  padding-top: 8px;
}

@media (min-width: 900px) {
  .result-grid {
    grid-template-columns: 1fr 1fr;
  }

  .result-grid.single-result {
    grid-template-columns: 1fr;
  }
}
