:root {
  --roof-navy: #1e2b3c;
  --roof-green: #1d8068;
  --roof-green-soft: #eaf5f1;
  --roof-orange: #e8650a;
  --roof-line: #e2e1dc;
  --roof-muted: #69717b;
  --roof-warm: #fff8ed;
}

.roof-page { background: #f4f3ef; }

.roof-hero { padding-top: 30px; padding-bottom: 29px; }
.roof-hero p { max-width: 760px; }

.roof-app { max-width: 1240px; gap: 14px; padding-top: 18px; }
.roof-app .panel { padding: 18px; }
.roof-app .panel__title { margin-bottom: 14px; }

.roof-mode-panel { padding-bottom: 16px !important; }
.roof-mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.roof-mode-switch button,
.roof-type-switch button {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1.5px solid var(--roof-line);
  border-radius: 9px;
  background: #f8f8f6;
  color: var(--roof-navy);
  text-align: left;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.roof-mode-switch button > span {
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: #eceae6;
  color: #52606f;
  font-size: 15px;
  font-weight: 800;
}
.roof-mode-switch strong,
.roof-mode-switch small,
.roof-type-switch strong,
.roof-type-switch small { display: block; }
.roof-mode-switch strong,
.roof-type-switch strong { font-size: 12px; line-height: 1.25; }
.roof-mode-switch small,
.roof-type-switch small { margin-top: 2px; color: var(--roof-muted); font-size: 10px; line-height: 1.35; }
.roof-mode-switch button:hover,
.roof-type-switch button:hover { border-color: #b9c8c3; background: #fbfdfc; }
.roof-mode-switch button.active,
.roof-type-switch button.active {
  border-color: var(--roof-green);
  background: #f3faf7;
  box-shadow: 0 0 0 1px rgba(29, 128, 104, .08);
}
.roof-mode-switch button.active > span { background: var(--roof-green-soft); color: var(--roof-green); }

.roof-layout {
  display: grid;
  grid-template-columns: minmax(360px, 445px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.roof-controls { min-width: 0; }
.roof-results { position: sticky; top: 72px; min-width: 0; overflow: hidden; }

.roof-field { min-width: 0; margin-bottom: 15px; }
.roof-field:last-child { margin-bottom: 0; }
.roof-field > label,
.roof-label {
  display: block;
  margin-bottom: 5px;
  color: var(--roof-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .55px;
  line-height: 1.35;
  text-transform: uppercase;
}
.roof-fields-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.roof-fields-2 .roof-field { margin-bottom: 0; }

.roof-type-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.roof-type-switch button { align-items: center; padding: 10px; }
.roof-type-switch svg {
  flex: 0 0 43px;
  width: 43px;
  fill: none;
  stroke: #677484;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.roof-type-switch button.active svg { stroke: var(--roof-green); }

.roof-stepper {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  overflow: hidden;
  border: 1.5px solid var(--roof-line);
  border-radius: 8px;
  background: #f8f8f6;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.roof-stepper:focus-within { border-color: var(--roof-orange); background: #fff; box-shadow: 0 0 0 3px rgba(232, 101, 10, .1); }
.roof-stepper button {
  border: 0;
  background: transparent;
  color: #78818a;
  font-size: 18px;
  line-height: 1;
}
.roof-stepper button:hover { background: #efeee9; color: var(--roof-navy); }
.roof-input-wrap { position: relative; min-width: 0; border-right: 1px solid #e5e3de; border-left: 1px solid #e5e3de; }
.roof-input-wrap input {
  width: 100%;
  min-width: 0;
  height: 39px;
  padding: 8px 34px 8px 10px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--roof-navy);
  font: 600 13px/1.2 inherit;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.roof-input-wrap input::-webkit-inner-spin-button,
.roof-input-wrap input::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
.roof-input-wrap > span { position: absolute; top: 50%; right: 10px; transform: translateY(-50%); color: #818891; font-size: 10px; font-weight: 700; pointer-events: none; }
.roof-stepper.is-invalid { border-color: var(--c-red, #d93025); background: #fffafa; box-shadow: 0 0 0 2px rgba(217, 48, 37, .07); }

.roof-hint { margin: 5px 1px 0; color: #7a8087; font-size: 9.5px; line-height: 1.45; }
.roof-divider { height: 1px; margin: 16px 0; background: #ebe8e3; }
.roof-subheading { display: flex; align-items: center; margin-bottom: 10px; }
.roof-subheading strong,
.roof-subheading small { display: block; }
.roof-subheading strong { color: var(--roof-navy); font-size: 12px; }
.roof-subheading small { margin-top: 2px; color: var(--roof-muted); font-size: 9.5px; line-height: 1.4; }
.roof-controls .field-error { min-height: 0; margin-top: 11px; }
.roof-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.roof-presets button {
  min-width: 44px;
  padding: 6px 10px;
  border: 1px solid #d9ddd9;
  border-radius: 6px;
  background: #fafaf8;
  color: #5f6872;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}
.roof-presets button:hover,
.roof-presets button:focus-visible { border-color: var(--roof-green); background: var(--roof-green-soft); color: var(--roof-green); }

.roof-results-content { transition: filter .18s ease, opacity .18s ease; }
.roof-results.is-blocked .roof-results-content { filter: blur(2px); opacity: .34; pointer-events: none; }
.roof-error-overlay { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 20px; background: rgba(255, 255, 255, .58); backdrop-filter: blur(2px); }
.roof-error-overlay[hidden] { display: none; }
.roof-error-overlay > div { max-width: 330px; padding: 18px; border: 1px solid #efc2bd; border-radius: 11px; background: #fffafa; box-shadow: 0 12px 34px rgba(30, 43, 60, .12); text-align: center; }
.roof-error-overlay > div > span { display: grid; width: 30px; height: 30px; margin: 0 auto 8px; place-items: center; border-radius: 50%; background: #fbe5e2; color: var(--c-red, #d93025); font-weight: 800; }
.roof-error-overlay strong { display: block; color: var(--roof-navy); font-size: 13px; }
.roof-error-overlay p { margin: 4px 0 0; color: var(--roof-muted); font-size: 10px; }

.roof-result-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 10px;
  padding: 16px 18px;
  border-radius: 11px;
  background: linear-gradient(135deg, #1e2b3c, #284157);
  color: #fff;
}
.roof-result-hero::after { content: ''; position: absolute; top: -48px; right: -35px; width: 145px; height: 145px; border: 26px solid rgba(255, 255, 255, .05); border-radius: 50%; }
.roof-result-hero > * { position: relative; z-index: 1; display: block; }
.roof-result-hero > span { color: rgba(255, 255, 255, .68); font-size: 10px; font-weight: 700; letter-spacing: .55px; text-transform: uppercase; }
.roof-result-hero strong { margin: 2px 0 0; color: #fff; font-size: clamp(30px, 5vw, 42px); line-height: 1.05; font-variant-numeric: tabular-nums; }
.roof-result-hero strong b { font-weight: 700; }
.roof-result-hero small { margin-top: 6px; color: #bfe4d9; font-size: 10px; }

.roof-result-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.roof-result-grid article { position: relative; min-width: 0; padding: 10px 11px; border: 1px solid var(--roof-line); border-radius: 9px; background: #fff; }
.roof-result-grid article::before { content: ''; position: absolute; top: 9px; bottom: 9px; left: 0; width: 2px; border-radius: 2px; background: #b8c1ca; }
.roof-result-grid article.roof-result-highlight::before { background: var(--roof-green); }
.roof-result-grid small,
.roof-result-grid strong,
.roof-result-grid em { display: block; }
.roof-result-grid small { overflow: hidden; color: #747b84; font-size: 8.5px; font-weight: 700; letter-spacing: .3px; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.roof-result-grid strong { margin-top: 3px; color: var(--roof-navy); font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.roof-result-grid em { margin-top: 2px; color: #8b9096; font-size: 8px; font-style: normal; }

.roof-preview-card { margin-top: 10px; overflow: hidden; border: 1px solid var(--roof-line); border-radius: 10px; background: #f9faf9; }
.roof-preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 12px; border-bottom: 1px solid var(--roof-line); background: #fff; }
.roof-preview-heading strong,
.roof-preview-heading small { display: block; }
.roof-preview-heading strong { color: var(--roof-navy); font-size: 10px; }
.roof-preview-heading small { margin-top: 2px; color: #7b8187; font-size: 8.5px; }
.roof-preview-heading > span { flex: 0 0 auto; padding: 4px 8px; border-radius: 999px; background: var(--roof-green-soft); color: var(--roof-green); font-size: 10px; font-weight: 800; }
.roof-preview { min-height: 292px; padding: 4px 8px 0; }
.roof-preview svg { width: 100%; height: auto; max-height: 310px; }
.roof-preview svg text { font-family: 'DM Sans', Arial, sans-serif; }
.roof-preview-note { margin: 0; padding: 7px 11px 9px; color: #81868c; font-size: 8.5px; line-height: 1.45; text-align: center; }

.roof-breakdown { margin-top: 10px; overflow: hidden; border: 1px solid var(--roof-line); border-radius: 10px; background: #fff; }
.roof-breakdown h3 { margin: 0; padding: 9px 11px; border-bottom: 1px solid var(--roof-line); background: #faf9f7; color: var(--roof-navy); font-size: 10px; }
.roof-breakdown dl { margin: 0; }
.roof-breakdown dl > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 7px 11px; border-bottom: 1px solid #efebe7; font-size: 9.5px; }
.roof-breakdown dl > div:last-child { border-bottom: 0; }
.roof-breakdown dt { color: #707781; }
.roof-breakdown dd { margin: 0; color: var(--roof-navy); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.roof-formula,
.roof-note { display: flex; align-items: flex-start; gap: 9px; margin-top: 10px; padding: 9px 11px; border: 1px solid var(--roof-line); border-radius: 9px; background: #faf9f7; color: #646c75; font-size: 9px; line-height: 1.5; }
.roof-formula > span,
.roof-note > span { display: grid; flex: 0 0 24px; width: 24px; height: 24px; place-items: center; border-radius: 50%; background: #ece8e3; color: var(--roof-navy); font-weight: 800; }
.roof-note { border-color: #f0d8b4; background: var(--roof-warm); }
.roof-note > span { background: #ffe8c7; color: #a85a12; }
.roof-formula p,
.roof-note p { margin: 0; }
.roof-formula strong,
.roof-note strong { color: var(--roof-navy); }

.info-section { max-width: 1208px; margin: 0 auto 18px; padding: 24px; border: 1px solid var(--roof-line); border-radius: 11px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .05); }
.roof-section-heading { margin-bottom: 17px; }
.roof-section-heading > span { display: inline-block; margin-bottom: 5px; color: var(--roof-green); font-size: 9px; font-weight: 800; letter-spacing: .9px; text-transform: uppercase; }
.roof-section-heading h2 { margin: 0; color: var(--roof-navy); font-size: clamp(17px, 2.5vw, 22px); line-height: 1.3; }
.roof-section-heading p { max-width: 800px; margin: 6px 0 0; color: var(--roof-muted); font-size: 11px; line-height: 1.65; }

.roof-table-wrap { overflow-x: auto; border: 1px solid var(--roof-line); border-radius: 9px; }
.roof-table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.roof-table th { padding: 9px 12px; background: #f5f4f1; color: #626a73; font-size: 9px; letter-spacing: .45px; text-align: left; text-transform: uppercase; }
.roof-table td { padding: 9px 12px; border-top: 1px solid #ece9e4; color: #3f4853; font-variant-numeric: tabular-nums; }
.roof-table td:first-child { color: var(--roof-navy); font-weight: 750; }
.roof-table td:last-child { width: 1%; text-align: right; white-space: nowrap; }
.roof-table button { padding: 5px 9px; border: 1px solid #cbd8d4; border-radius: 6px; background: #f3faf7; color: var(--roof-green); font-size: 9px; font-weight: 700; }
.roof-table button:hover { border-color: var(--roof-green); background: var(--roof-green-soft); }
.roof-source { margin: 9px 2px 0; color: #767d84; font-size: 9px; line-height: 1.55; }
.roof-source a { color: var(--roof-green); text-decoration: underline; text-underline-offset: 2px; }

.roof-guide-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.roof-guide-grid article { position: relative; min-width: 0; padding: 15px; border: 1px solid var(--roof-line); border-radius: 9px; background: #fafaf8; }
.roof-guide-grid article > span { display: block; margin-bottom: 9px; color: #c9d2cf; font-size: 21px; font-weight: 800; line-height: 1; }
.roof-guide-grid h3 { margin: 0 0 5px; color: var(--roof-navy); font-size: 12px; }
.roof-guide-grid p { margin: 0; color: var(--roof-muted); font-size: 10px; line-height: 1.58; }

.roof-content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.roof-content-grid h2 { margin: 0 0 8px; color: var(--roof-navy); font-size: 16px; line-height: 1.35; }
.roof-content-grid p { margin: 0 0 9px; color: #5f6872; font-size: 11px; line-height: 1.7; }
.roof-content-grid p:last-child { margin-bottom: 0; }
.roof-content-grid strong { color: var(--roof-navy); }

.roof-faq .faq { margin-bottom: 0; }
.roof-faq .faq-q:focus-visible { outline: 2px solid var(--roof-green); outline-offset: -3px; }

.roof-related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.roof-related-grid a { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-width: 0; padding: 13px; border: 1px solid var(--roof-line); border-radius: 9px; background: #fafaf8; transition: border-color .18s ease, transform .18s ease; }
.roof-related-grid a:hover { border-color: var(--roof-green); transform: translateY(-1px); }
.roof-related-grid a > span { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 8px; background: #fff; font-size: 17px; }
.roof-related-grid strong { display: block; color: var(--roof-navy); font-size: 11px; }
.roof-related-grid p { margin: 3px 0 0; color: var(--roof-muted); font-size: 9px; line-height: 1.45; }
.roof-related-grid b { color: var(--roof-green); font-size: 16px; }

.roof-page .footer { margin-top: 26px; }

@media (max-width: 980px) {
  .roof-layout { grid-template-columns: 1fr; }
  .roof-results { position: relative; top: auto; }
  .roof-result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .roof-preview { min-height: 260px; }
  .roof-preview svg { max-height: 290px; }
}

@media (max-width: 760px) {
  .roof-mode-switch { grid-template-columns: 1fr; }
  .roof-mode-switch button { min-height: 58px; }
  .roof-guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .roof-related-grid { grid-template-columns: 1fr; }
  .info-section { width: calc(100% - 24px); margin-right: 12px; margin-left: 12px; padding: 19px; }
}

@media (max-width: 540px) {
  .roof-hero { padding: 25px 16px 24px; }
  .roof-app { padding: 12px 10px 26px; }
  .roof-app .panel { padding: 14px; }
  .roof-fields-2,
  .roof-type-switch,
  .roof-guide-grid,
  .roof-content-grid { grid-template-columns: 1fr; }
  .roof-fields-2 { gap: 14px; }
  .roof-type-switch button { min-height: 62px; }
  .roof-result-grid { gap: 7px; }
  .roof-result-grid article { padding: 9px; }
  .roof-result-grid strong { font-size: 13px; }
  .roof-preview { min-height: 225px; padding: 0; }
  .roof-preview svg { min-width: 0; max-height: 250px; }
  .roof-breakdown dl > div { align-items: flex-start; }
  .roof-breakdown dt { max-width: 65%; }
  .roof-table th,
  .roof-table td { padding: 8px 9px; }
  .info-section { width: calc(100% - 20px); margin-right: 10px; margin-left: 10px; padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .roof-page *,
  .roof-page *::before,
  .roof-page *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
