:root {
  --color-primary: #2f6b3a;
  --color-primary-dark: #234f2b;
  --color-accent: #b5651d;
  --color-bg: #f7f6f2;
  --color-surface: #ffffff;
  --color-border: #dcd8ce;
  --color-text: #23261f;
  --color-text-muted: #5b5f54;
  --color-danger: #b3261e;
  --color-success: #2f6b3a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-size: 17px;
}

* { box-sizing: border-box; }

/* Stellt sicher, dass das hidden-Attribut immer gewinnt, auch bei Elementen mit
   einer display:grid/flex-Klasse wie .form-grid (sonst gewinnt bei gleicher
   Spezifität die Autoren-Regel gegen die UA-Regel [hidden]{display:none}). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

a { color: var(--color-primary-dark); }

.site-header {
  background: var(--color-primary);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.site-header a { color: #fff; text-decoration: none; font-weight: 600; }
.site-header .brand { font-size: 1.2rem; }
.site-header nav a { margin-left: 16px; opacity: 0.92; }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 18px;
}

h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 4px; }
h3 { font-size: 1.0rem; }

.lead { color: var(--color-text-muted); margin: 0 0 14px; font-size: 0.92rem; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin: 0 0 5px;
}

label .hint { font-weight: 400; color: var(--color-text-muted); font-size: 0.9em; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: #fff;
  color: var(--color-text);
  font-family: inherit;
  line-height: 1.3;
}

textarea { resize: vertical; min-height: 70px; }

fieldset {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin: 0 0 14px;
  padding: 10px 14px 14px;
}

legend { font-weight: 600; padding: 0 6px; font-size: 0.92rem; }

/* Zweispaltiges Formular-Raster: zusammengehörige, kurze Felder nebeneinander
   statt jedes Feld über die volle Kartenbreite zu ziehen. */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.form-grid .field { margin-bottom: 14px; }
.form-grid .field.full { grid-column: 1 / -1; }
.form-grid .field label { margin: 0 0 5px; }

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

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
}
@media (max-width: 480px) {
  .checkbox-grid { grid-template-columns: 1fr; }
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 6px 0;
  font-weight: 400;
}
.checkbox-row input { width: auto; margin-top: 4px; }

.btn {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 13px 22px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:hover { background: var(--color-primary-dark); }
.btn.secondary { background: #fff; color: var(--color-primary-dark); border: 1px solid var(--color-primary); }
.btn.secondary:hover { background: #eef5ee; }
.btn.danger { background: var(--color-danger); }
.btn.small { padding: 8px 14px; font-size: 0.9rem; }
.btn.large { padding: 18px 28px; font-size: 1.15rem; border-radius: 10px; box-shadow: var(--shadow); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.actions { margin-top: 24px; display: flex; gap: 12px; flex-wrap: wrap; }

.draw-cta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
}
.alert.error { background: #fbe9e7; color: var(--color-danger); border: 1px solid #f3c2bd; }
.alert.success { background: #eaf3ea; color: var(--color-success); border: 1px solid #c6e0c6; }
.alert.info { background: #eef3fb; color: #1d4c7a; border: 1px solid #c7dcf2; }

#map {
  height: 420px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  margin: 10px 0;
}

.map-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0;
}

.area-readout {
  font-weight: 600;
  color: var(--color-primary-dark);
}

.search-bar-wrap { position: relative; }
.search-bar {
  display: flex;
  align-items: stretch;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 4px;
}
.search-bar input[type="text"] {
  border: none;
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
}
.search-bar input[type="text"]:focus { outline: none; }
.search-bar-icon-btn {
  flex: 0 0 auto;
  width: 40px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.search-bar-icon-btn:hover { background: #eef5ee; }
.search-bar .btn.small { flex: 0 0 auto; }

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}
.search-results:empty { border: none; box-shadow: none; }
.search-results li {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}
.search-results li:last-child { border-bottom: none; }
.search-results li:hover { background: #f1efe9; }

.leaflet-tooltip.parcel-label {
  background: rgba(255, 255, 255, 0.85);
  border: none;
  box-shadow: none;
  font-size: 0.7rem;
  padding: 1px 4px;
  color: var(--color-text);
}

table { width: 100%; border-collapse: collapse; margin: 10px 0; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--color-border); font-size: 0.95rem; }
th { color: var(--color-text-muted); font-weight: 600; }
tr:hover td { background: #fafaf7; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge.neu { background: #fdf0d5; color: #8a5a00; }
.badge.in_bearbeitung { background: #e3edfb; color: #1d4c7a; }
.badge.erledigt { background: #e6f2e6; color: var(--color-success); }
.badge.aktiv { background: #e6f2e6; color: var(--color-success); }
.badge.abgelaufen { background: #f1efe9; color: var(--color-text-muted); }

.site-footer {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 30px 16px 40px;
}

.storage-bar {
  height: 10px;
  border-radius: 6px;
  background: #eee;
  overflow: hidden;
  margin: 6px 0;
}
.storage-bar-fill { height: 100%; background: var(--color-primary); }

.file-list { list-style: none; padding: 0; }
.file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.file-meta { color: var(--color-text-muted); font-size: 0.85rem; }

.steps {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.steps span {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  background: #eee;
  padding: 4px 10px;
  border-radius: 999px;
}

.field-copy {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.field-copy code {
  background: #f1efe9;
  padding: 6px 10px;
  border-radius: 6px;
  word-break: break-all;
}

@media (max-width: 480px) {
  :root { font-size: 16px; }
  .container { padding: 16px 10px 40px; }
  .card { padding: 16px; }
  #map { height: 320px; }
}
