:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6560;
  --border: #e4ddd4;
  --primary: #1f5c4a;
  --primary-hover: #174839;
  --shadow: 0 12px 40px rgba(26, 26, 26, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #ebe5dc 0%, var(--bg) 240px);
  min-height: 100vh;
}

.container {
  width: min(960px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  padding: 1.25rem 0 0.5rem;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-start {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-auth {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-user {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.logout-form {
  margin: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}

.brand-icon {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: white;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

main { padding-bottom: 3rem; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-meta {
  margin-top: 0.35rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.hero {
  display: grid;
  gap: 2rem;
  padding: 2rem 0 1rem;
}

.hero-copy h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.1;
  margin: 0 0 1rem;
}

.hero-copy p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 52ch;
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
}

.field input,
.field select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #faf8f5;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0 1.25rem;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.2rem;
  border-radius: 10px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: #efeae3;
  color: var(--text);
}

.btn-sm { padding: 0.55rem 0.9rem; font-size: 0.9rem; }

.field-error,
.form-errors {
  color: #b42318;
  font-size: 0.85rem;
}

.results-layout {
  display: grid;
  grid-template-columns: 30% 70%;
  min-height: calc(100vh - 120px);
  gap: 0;
}

.results-panel {
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  padding: 1rem;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
}

.map-panel {
  position: sticky;
  top: 0;
  height: calc(100vh - 120px);
}

#results-map,
#detail-map {
  width: 100%;
  height: 100%;
  min-height: 320px;
}

.results-header h1 {
  margin: 0.4rem 0;
  font-size: 1.5rem;
}

.results-count {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.results-meta {
  color: var(--muted);
  margin: 0 0 1rem;
}

.back-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.92rem;
}

.result-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1rem;
}

.result-card.is-focused {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 6px 20px rgba(26, 92, 70, 0.14);
}

.result-card h2 {
  font-size: 1rem;
  margin: 0.75rem 0;
  line-height: 1.35;
}

.result-card h2 a {
  color: inherit;
  text-decoration: none;
}

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.relevance-badge {
  background: #e8f5ef;
  color: var(--primary);
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.result-card--unlocalized {
  border-left: 3px solid #9aa3ad;
}

.unlocalized-badge {
  display: inline-block;
  margin: -0.35rem 0 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  background: #eef1f4;
  color: #4a5560;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.result-location-hint {
  font-weight: 500;
  color: var(--muted);
}

.dpe-address--unknown {
  color: #4a5560;
}

.location-unknown {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.grade-pills { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.grade-pill {
  color: #111;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}

.grade-pill.sm { font-size: 0.72rem; }

.result-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.result-details dt {
  font-size: 0.75rem;
  color: var(--muted);
}

.result-details dd {
  margin: 0;
  font-weight: 600;
  font-size: 0.88rem;
}

.street-view {
  width: 100%;
  height: 160px;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  background: #ebe7df;
}

.street-view-trigger {
  width: 100%;
  height: 160px;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  border: 2px dashed #c8c2b8;
  background: #f7f4ef;
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 0.45rem;
  padding: 1rem;
  color: var(--muted);
  font: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.street-view-trigger:hover {
  background: #ebe7df;
  border-color: #9a9388;
  color: var(--text);
}

.street-view-trigger:focus-visible {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 2px;
}

.street-view-trigger.is-loading {
  cursor: wait;
  opacity: 0.75;
}

.street-view-trigger-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  position: relative;
}

.street-view-trigger-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.street-view-trigger-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.street-view-unavailable {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0 1rem;
}

.street-view-message {
  margin: 0;
  line-height: 1.4;
}

.street-view-placeholder {
  display: grid;
  place-items: center;
  min-height: 120px;
  background: #f7f4ef;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.empty-state { text-align: center; }

.breadcrumb {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted);
  margin: 1rem 0;
  font-size: 0.92rem;
}

.breadcrumb a { color: var(--primary); }

.dpe-header {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

.dpe-header h1 { margin: 0.35rem 0; font-size: 1.8rem; }

.dpe-address { margin: 0; color: var(--muted); }

.dpe-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.grade-scale-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.grade-scale-block {
  display: grid;
  gap: 0.35rem;
}

.grade-scale-heading {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.field-label-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.field-label-row label {
  margin-bottom: 0;
}

.scale-info-btn {
  position: relative;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  color: var(--muted);
}

.scale-info-btn-inline {
  vertical-align: middle;
}

.scale-tooltip-panel {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  z-index: 30;
  width: min(280px, 80vw);
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow);
  text-align: left;
  font-weight: 400;
  color: var(--text);
}

.scale-info-btn:hover .scale-tooltip-panel,
.scale-info-btn:focus-visible .scale-tooltip-panel {
  display: block;
}

.scale-tooltip-panel strong {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
}

.scale-tooltip-unit {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.scale-tooltip-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.3rem;
}

.scale-tooltip-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.scale-tooltip-grade {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #111;
  flex-shrink: 0;
}

.scale-tooltip-note {
  margin: 0.55rem 0 0;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--muted);
}

.grade-bar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.grade-step {
  position: relative;
  text-align: center;
  padding: 0.35rem 0;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.82rem;
  opacity: 0.45;
  cursor: help;
}

.grade-step-tooltip {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  z-index: 10;
  padding: 0.3rem 0.45rem;
  border-radius: 6px;
  background: #1a1a1a;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}

.grade-step:hover .grade-step-tooltip,
.grade-step:focus-visible .grade-step-tooltip {
  display: block;
}

.grade-step.active {
  opacity: 1;
  outline: 2px solid #111;
  outline-offset: 2px;
}

.grade-value {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table .total-row td { border-top: 2px solid var(--border); }

.map-section #detail-map {
  height: 280px;
  border-radius: 12px;
}

.dpe-panels-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.dpe-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.panel-note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0 0 1rem;
}

.subsection-title {
  font-size: 0.92rem;
  margin: 1.25rem 0 0.75rem;
  font-weight: 600;
}

.envelope-quality {
  color: var(--primary);
  text-transform: capitalize;
}

.loss-diagram {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0 0;
}

.loss-house-svg {
  width: 100%;
  max-width: 460px;
  height: auto;
  display: block;
}

.loss-house-svg .loss-label {
  fill: #555;
  font-size: 11px;
  font-family: "DM Sans", system-ui, sans-serif;
}

.loss-house-svg .loss-value {
  fill: #d64545;
  font-size: 15px;
  font-weight: 700;
  font-family: "DM Sans", system-ui, sans-serif;
}

.loss-house-svg .loss-callout text {
  pointer-events: none;
}

.comfort-scale {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.comfort-option {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.5rem;
  text-align: center;
  opacity: 0.55;
  background: #faf8f5;
  color: #666;
}

.comfort-option.active {
  opacity: 1;
  border-color: #d4a017;
  background: #fff8e6;
  box-shadow: inset 0 0 0 1px #f0c040;
  color: #8a6400;
}

.comfort-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-top: 0.35rem;
}

.dpe-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
}

.icon-sm { width: 20px; height: 20px; }
.icon-md { width: 28px; height: 28px; }
.icon-lg { width: 36px; height: 36px; }

.comfort-face-icon {
  display: block;
  margin: 0 auto;
}

.comfort-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

.comfort-features li {
  display: grid;
  grid-template-columns: 28px 1fr 24px;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.88rem;
}

.feature-status.yes { color: #1f7a4a; }
.feature-status.no { color: #b42318; }

.insulation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.insulation-item {
  text-align: center;
  font-size: 0.75rem;
}

.insulation-icon {
  display: block;
  margin: 0 auto 0.35rem;
  color: #555;
}

.insulation-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: #fff;
}

.badge-poor { background: #c0392b; }
.badge-average { background: #e67e22; }
.badge-good { background: #52ae32; }
.badge-excellent { background: #1f7a4a; }
.badge-unknown { background: #888; }

.insulation-name {
  display: block;
  color: var(--muted);
  line-height: 1.3;
}

.energy-section-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.energy-section h2 { margin: 0 0 0.35rem; }

.annual-cost-box {
  background: #f3efe8;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  text-align: right;
  min-width: 220px;
}

.annual-cost-box strong {
  display: block;
  font-size: 1rem;
}

.annual-cost-box span {
  color: var(--muted);
  font-size: 0.82rem;
}

.energy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.energy-table th,
.energy-table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.energy-table th {
  text-align: left;
  font-size: 0.82rem;
  color: var(--muted);
}

.energy-table tfoot td {
  background: #f3efe8;
  border-top: 2px solid var(--border);
}

.energy-row-empty td { color: #bbb; }

.usage-icon,
.energy-icon {
  margin-right: 0.35rem;
  color: #4a4a4a;
}

.feature-icon,
.insulation-icon {
  color: #4a4a4a;
}

.energy-type-cell {
  min-width: 130px;
  font-size: 0.82rem;
}

.share-cell {
  min-width: 120px;
}

.share-bar {
  height: 8px;
  background: #ece7e0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.share-bar span {
  display: block;
  height: 100%;
  background: #e07a5f;
  border-radius: 999px;
}

.related-section h2 { margin-top: 0; }

.related-table .mono {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
}

.empty-related {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 960px) {
  .results-layout,
  .dpe-header,
  .form-grid,
  .dpe-panels-grid,
  .insulation-grid {
    grid-template-columns: 1fr;
  }

  .energy-section-header {
    flex-direction: column;
  }

  .annual-cost-box {
    text-align: left;
    width: 100%;
  }

  .results-layout { display: flex; flex-direction: column; }

  .results-panel,
  .map-panel {
    max-height: none;
    height: auto;
  }

  .map-panel { min-height: 360px; }
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 20% 10%, rgba(31, 92, 74, 0.08), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(31, 92, 74, 0.05), transparent 40%),
    linear-gradient(180deg, #ebe5dc 0%, var(--bg) 320px);
}

.login-shell {
  width: min(440px, 100%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 2.25rem 2rem 2rem;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-logo {
  width: 3.25rem;
  height: 3.25rem;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-size: 1.35rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 24px rgba(31, 92, 74, 0.22);
}

.login-brand h1 {
  margin: 0 0 0.4rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.login-lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 28ch;
}

.login-alert {
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  color: #b42318;
  font-size: 0.88rem;
}

.login-alert p {
  margin: 0;
}

.login-form {
  display: grid;
  gap: 1.15rem;
}

.login-field label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.login-input {
  width: 100%;
  padding: 0.82rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  color: var(--text);
  background: #faf8f5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.login-input::placeholder {
  color: #a39e98;
}

.login-input:hover {
  border-color: #d4ccc2;
}

.login-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 92, 74, 0.14);
}

.login-field-error {
  margin: 0.4rem 0 0;
  color: #b42318;
  font-size: 0.84rem;
}

.login-submit {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.9rem 1.2rem;
  font-size: 1rem;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(31, 92, 74, 0.18);
}

.login-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(31, 92, 74, 0.22);
}

.login-submit:active {
  transform: translateY(0);
}

.login-footnote {
  margin: 1.1rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}
