:root {
  --primary: #5a7a3e;
  --primary-dark: #3f5a28;
  --accent: #d49a3e;
  --bg: #f7f5f0;
  --card: #ffffff;
  --text: #2a2a2a;
  --muted: #6b6b6b;
  --border: #e0ddd5;
  --error: #b14040;
  --success: #3f7a4a;
}

* { box-sizing: border-box; }

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

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

header {
  background: var(--primary);
  color: white;
  padding: 1.5rem 0;
  border-bottom: 4px solid var(--accent);
}
header h1 { margin: 0; font-size: 1.6rem; }
.subtitle { margin: 0.3rem 0 0; opacity: 0.9; font-size: 0.95rem; }

main { padding: 2rem 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card.hidden { display: none; }
.card h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.9rem;
}

.hint, .info-text {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.5rem 0;
}

/* Input mit Reset-Button (z.B. Volllaststunden ↻ Auto) ─────── */
.input-with-button {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}
.input-with-button input {
  flex: 1;
  min-width: 0;
}
.input-with-button .btn-mini {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.input-with-button .btn-mini:hover {
  background: white;
  border-color: var(--primary);
}

/* Verbrauchs-Eingabe (3 Jahre) ───────────────────────────── */
.verbrauch-fieldset {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.9rem 0.8rem;
  background: #fafaf3;
  margin: 0;
}
.verbrauch-fieldset legend {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary-dark);
  padding: 0 0.4rem;
}

/* GIS/GWR-Diagnose-Box ───────────────────────────────────── */
.gwr-debug {
  margin: 0.6rem 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #faf8ee;
  padding: 0.4rem 0.7rem;
}
.gwr-debug[open] { padding-bottom: 0.7rem; }
.gwr-debug summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: #6a5a20;
  font-weight: 500;
}
.gwr-debug-pre {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0.5rem 0 0.4rem;
  color: #333;
}
.gwr-debug-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.gwr-debug-actions span {
  font-size: 0.78rem;
  color: var(--success);
}

/* Adresssuche */
.search-wrap { position: relative; margin-bottom: 1rem; }
#adressSuche {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
#adressSuche:focus {
  outline: none;
  border-color: var(--primary);
}
.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  z-index: 1000;
}
.suggestions li {
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.suggestions li:hover { background: var(--bg); }
.suggestions:empty { display: none; }

/* Karte */
#map {
  height: 400px;
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.gebaeude-highlight {
  stroke: var(--accent);
  stroke-width: 3;
  fill: var(--accent);
  fill-opacity: 0.3;
}

/* Formular */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.form-grid input,
.form-grid select,
.form-grid textarea {
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  color: var(--text);
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.input-unit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.input-unit input { flex: 1; }
.input-unit .unit { color: var(--muted); }
.quelle {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}
.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.6rem !important;
  background: var(--bg);
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
}
.checkbox-row input { width: auto; flex: 0; cursor: pointer; }
.checkbox-row span { color: var(--text); font-size: 0.95rem; }

.badge-on, .badge-off {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.badge-on  { background: #e0ecd0; color: var(--primary-dark); }
.badge-off { background: #efe6d4; color: #8a6a20; }

/* ─── Responsive Layout ────────────────────────────────────
   Tablet  ≤900px: Container schmaler, Form-Grids 1 Spalte
   Mobile  ≤600px: alles 1 Spalte, kompakter, Karte niedriger
   Mobile  ≤480px: Header-Inhalte stacken */
@media (max-width: 900px) {
  .container { padding: 0 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  #map      { height: 360px; }
  .card     { padding: 1.2rem; }
  header h1 { font-size: 1.3rem; }
}
@media (max-width: 600px) {
  body          { font-size: 0.95rem; }
  header        { padding: 0.8rem 0; }
  header h1     { font-size: 1.1rem; }
  .container    { padding: 0 0.7rem; }
  .card         { padding: 1rem; margin-bottom: 1rem; }
  #map          { height: 280px; }
  .form-grid    { grid-template-columns: 1fr; gap: 0.7rem; }
  .step         { width: 22px; height: 22px; font-size: 0.85rem; }
  /* Adresssuche: Vorschläge dürfen nicht horizontal scrollen */
  .suggestions { max-width: 100%; }
  /* Verbrauchs-Eingabe: drei Jahre untereinander */
  .verbrauch-fieldset { padding: 0.5rem 0.7rem 0.6rem; }
  .verbrauch-fieldset .form-grid { grid-template-columns: 1fr 1fr 1fr; gap: 0.4rem; }
  /* Angebot-Anzeige: Werte unter dem Label statt rechts */
  .angebot-row { flex-wrap: wrap; gap: 0.2rem; }
  .angebot-row .label { flex: 1 1 100%; font-size: 0.85rem; color: var(--muted); }
  .angebot-row .value { flex: 1 1 100%; font-weight: 600; }
  /* Buttons: volle Breite statt nebeneinander */
  .btn-primary, .btn-secondary {
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    width: 100%;
    margin-top: 0.4rem;
  }
}
@media (max-width: 480px) {
  header .container { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  header h1 { font-size: 1rem; }
  .verbrauch-fieldset .form-grid { grid-template-columns: 1fr; }
}

/* Angebot-Anzeige */
.angebot {
  background: var(--bg);
  border-radius: 6px;
  padding: 1.2rem;
  margin-bottom: 1rem;
}
.angebot-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--border);
}
.angebot-row:last-of-type { border-bottom: none; }
.angebot-row.total {
  font-weight: 600;
  font-size: 1.1rem;
  border-top: 2px solid var(--primary);
  border-bottom: none;
  padding-top: 0.7rem;
  margin-top: 0.4rem;
}
.angebot-row .label { color: var(--text); }
.angebot-row .value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.angebot h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
  color: var(--primary-dark);
}
.angebot h3:first-child { margin-top: 0; }

.disclaimer {
  font-size: 0.85rem;
  color: var(--muted);
  background: #fdf6e7;
  border-left: 3px solid var(--accent);
  padding: 0.7rem 1rem;
  border-radius: 4px;
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:disabled {
  background: var(--muted);
  cursor: not-allowed;
}

#sendStatus.success { color: var(--success); font-weight: 500; }
#sendStatus.error { color: var(--error); font-weight: 500; }

footer {
  background: var(--text);
  color: #c0c0c0;
  padding: 1rem 0;
  font-size: 0.85rem;
  margin-top: 2rem;
}
footer p { margin: 0; }
