.cost-page {
  padding-bottom: 1.5rem;
}

.estimate-notice {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid #d69b2d;
  border-radius: 12px;
  background: #fff9e9;
  color: #543b0d;
  font-weight: 700;
}

.cost-tool-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cost-tool-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
}

.cost-tool-heading h1 {
  margin: 0.15rem 0 0;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.08;
}

.privacy-note {
  flex: 0 0 auto;
  padding: 0.55rem 0.75rem;
  border-radius: 999px;
  background: #edf7ef;
  color: var(--green-dark);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.cost-workbench {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(440px, 1.05fr);
  align-items: start;
}

.cost-inputs,
.cost-results {
  min-width: 0;
  padding: 1.1rem 1.25rem 1.3rem;
}

.cost-results {
  border-left: 1px solid var(--line);
  background: #f7faf7;
}

.cost-section + .cost-section {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.cost-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.cost-section-heading h2,
.cost-results h2 {
  margin: 0;
  font-size: 1.15rem;
}

.cost-section-heading p,
.result-intro,
.rate-source,
.field-hint {
  color: var(--muted);
}

.cost-section-heading p,
.result-intro {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
}

.project-settings {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  align-items: end;
  gap: 0.8rem;
}

.project-settings .field-hint {
  margin: 0 0 0.55rem;
  font-size: 0.86rem;
}

.cost-area-list {
  display: grid;
  gap: 0.75rem;
}

.cost-area {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfb;
}

.cost-area [hidden] {
  display: none !important;
}

.cost-area-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.cost-area-title h3 {
  margin: 0;
  font-size: 1rem;
}

.remove-area {
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border: 0;
  background: transparent;
  color: #9a3030;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.area-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.area-fields .field {
  min-width: 0;
}

.area-fields input,
.area-fields select,
.rate-row input,
.project-settings select {
  min-height: 46px;
}

.field.full-row {
  grid-column: 1 / -1;
}

.cost-button {
  min-height: 44px;
}

.rate-grid {
  display: grid;
  gap: 0.75rem;
}

.rate-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.rate-row label {
  font-weight: 800;
}

.rate-input {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  border: 1px solid #cbdcd3;
  border-radius: 10px;
  background: var(--surface);
}

.rate-input:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39, 115, 65, 0.12);
}

.rate-input span {
  padding: 0 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.rate-input input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding-inline: 0.2rem;
}

.rate-source {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.rate-source a {
  font-weight: 700;
}

.result-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.result-topline .privacy-note {
  background: #e8f0e9;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.9rem 0;
}

.summary-card {
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.summary-card span {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--green-dark);
  font-size: 1.25rem;
  line-height: 1.2;
}

.result-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.79rem;
}

.result-table th,
.result-table td {
  padding: 0.65rem 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: top;
  white-space: nowrap;
}

.result-table th:first-child,
.result-table td:first-child {
  text-align: left;
}

.result-table th {
  background: #edf4ee;
  color: var(--green-dark);
  font-size: 0.74rem;
}

.result-table tbody tr:last-child td {
  border-bottom: 0;
}

.result-table small {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.68rem;
  white-space: normal;
}

.missing-value {
  color: #8c5d08;
  font-weight: 800;
}

.result-note {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.reference-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.9rem;
}

.reference-table th,
.reference-table td {
  padding: 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.reference-table th {
  background: #edf4ee;
}

.formula-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0;
  list-style: none;
}

.formula-list li {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfb;
}

.formula-list strong {
  display: block;
  margin-bottom: 0.25rem;
}

.quote-checklist {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.quote-checklist div {
  padding: 0.9rem;
  border-left: 4px solid var(--green);
  background: #f7faf7;
}

.quote-checklist strong {
  display: block;
  margin-bottom: 0.2rem;
}

@media (max-width: 980px) {
  .cost-workbench {
    grid-template-columns: 1fr;
  }

  .cost-results {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 680px) {
  .cost-tool-heading,
  .result-topline {
    display: block;
  }

  .cost-tool-heading .privacy-note,
  .result-topline .privacy-note {
    display: inline-block;
    margin-top: 0.65rem;
  }

  .cost-inputs,
  .cost-results {
    padding-inline: 0.85rem;
  }

  .project-settings,
  .area-fields,
  .rate-row,
  .formula-list,
  .quote-checklist {
    grid-template-columns: 1fr;
  }

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

  .result-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .result-table,
  .result-table tbody,
  .result-table tr,
  .result-table td {
    display: block;
    width: 100%;
  }

  .result-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .result-table tr {
    margin-bottom: 0.75rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
  }

  .result-table td,
  .result-table td:first-child {
    display: grid;
    grid-template-columns: minmax(90px, 0.8fr) minmax(0, 1.2fr);
    gap: 0.65rem;
    padding: 0.52rem 0;
    text-align: right;
    white-space: normal;
  }

  .result-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-align: left;
  }

  .reference-table,
  .reference-table tbody,
  .reference-table tr,
  .reference-table th,
  .reference-table td {
    display: block;
    width: 100%;
  }

  .reference-table thead {
    display: none;
  }

  .reference-table tr {
    margin-bottom: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
  }

  .reference-table td {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .reference-table td:last-child {
    border-bottom: 0;
  }
}

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

  .site-nav[style] {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 560px) {
  .site-nav a[href="/"] {
    background: transparent;
    color: var(--muted);
    box-shadow: none;
  }

  .site-nav a[aria-current="page"] {
    background: var(--green-dark);
    color: #fff;
    box-shadow: 0 4px 10px rgba(31, 89, 55, 0.16);
  }
}
