/* Grundgestaltung – wird später nach deinen Vorlagen überarbeitet */
:root {
  --bg: #f2f4f1;
  --surface: #ffffff;
  --ink: #1d2620;
  --muted: #5d6a62;
  --line: #d3dbd5;
  --vine: #2e5b43;
  --vine-dark: #234733;
  --vine-soft: #e6eee9;
  --error: #a12a22;
  --error-soft: #fbecea;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--vine); }
a:hover { color: var(--vine-dark); }
:focus-visible { outline: 3px solid var(--vine); outline-offset: 2px; }
code { font-size: .9em; background: var(--vine-soft); padding: .1em .35em; border-radius: 4px; }

/* Kopfzeile */
.topbar { background: var(--vine-dark); color: #fff; }
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: .85rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.brand { color: #fff; text-decoration: none; font-weight: 650; letter-spacing: .01em; }
.brand:hover { color: #fff; }
.nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.nav a, .nav .linkbtn { color: #dbe7df; text-decoration: none; }
.nav a:hover, .nav .linkbtn:hover { color: #fff; }

/* Seitenbereich */
.page { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 2.5rem 1.25rem 3rem; }
.narrow .page { max-width: 460px; }
.wide .page { max-width: 1400px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.lead { color: var(--muted); margin: 0 0 1.75rem; font-size: 1.05rem; }
.muted { color: var(--muted); }
.custno { font-variant-numeric: tabular-nums; color: var(--ink); }
.footer {
  max-width: 1100px; width: 100%; margin: 0 auto; padding: 1.5rem 1.25rem;
  display: flex; gap: 1.25rem; font-size: .9rem;
}
.footer a { color: var(--muted); }

/* Hinweise */
.flash { padding: .85rem 1rem; border-radius: var(--radius); margin: 0 0 1.25rem; background: var(--vine-soft); }
.flash p { margin: 0 0 .5rem; }
.flash-error { background: var(--error-soft); color: var(--error); }
.deadline { padding: .75rem 1rem; border-left: 4px solid var(--vine); background: var(--surface); margin: 0 0 1.5rem; }
.deadline.is-locked { border-left-color: var(--error); }

/* Fortschritt */
.steps { list-style: none; display: flex; gap: .5rem; padding: 0; margin: 0 0 1.5rem; counter-reset: step; font-size: .9rem; }
.steps li { counter-increment: step; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.steps li::before {
  content: counter(step); width: 1.6rem; height: 1.6rem; border-radius: 50%;
  display: inline-grid; place-items: center; border: 1.5px solid var(--line); font-weight: 600;
}
.steps li + li::after { content: none; }
.steps li + li { padding-left: .75rem; border-left: 1px solid var(--line); }
.steps .current { color: var(--ink); font-weight: 600; }
.steps .current::before { background: var(--vine); border-color: var(--vine); color: #fff; }

/* Formulare */
.form fieldset { border: 0; padding: 0; margin: 0 0 2rem; }
.form legend { font-weight: 650; font-size: 1.05rem; margin-bottom: .9rem; padding: 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; }
.grid-address { grid-template-columns: 3fr 1fr 1fr 2fr; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.grid .field { margin-bottom: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-weight: 560; font-size: .95rem; }
.optional { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: .25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="date"], input[type="search"], input:not([type]) {
  font: inherit; color: inherit; width: 100%;
  padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
input:disabled { background: #f6f8f6; color: var(--ink); border-style: dashed; }
input:focus { border-color: var(--vine); outline: none; box-shadow: 0 0 0 3px var(--vine-soft); }
.has-error input { border-color: var(--error); }
.hint { margin: 0; color: var(--muted); font-size: .85rem; }
.error { margin: 0; color: var(--error); font-size: .88rem; font-weight: 500; }
.check label { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: .2rem; accent-color: var(--vine); flex-shrink: 0; }
.actions { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; margin-top: .5rem; }
.inline { display: inline; margin: 0; }
.inline-form { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.inline-form .field { margin: 0; min-width: 14rem; }
.inline-form .actions { margin: 0; }

/* Knöpfe */
.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--vine); color: #fff; border: 1px solid var(--vine);
  padding: .6rem 1.15rem; border-radius: var(--radius);
}
.btn:hover { background: var(--vine-dark); color: #fff; }
.btn-quiet { background: var(--surface); color: var(--vine); border-color: var(--line); }
.btn-quiet:hover { background: var(--vine-soft); color: var(--vine-dark); }
.linkbtn { font: inherit; background: none; border: 0; padding: 0; color: var(--vine); cursor: pointer; text-decoration: underline; }
.nav .linkbtn { text-decoration: none; }

/* Inhaltsblöcke */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
.panel p:last-child { margin-bottom: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.copy { display: flex; gap: .5rem; }
.copy input { flex: 1; }

/* Admin-Tabelle */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.count { font-size: 1rem; font-weight: 500; color: var(--muted); margin-left: .35rem; }
.search { display: flex; gap: .5rem; align-items: center; margin: 0 0 1rem; max-width: 640px; }
.empty { padding: 2rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.table-wrap { overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; }
.data th, .data td { padding: .5rem .75rem; border-bottom: 1px solid var(--line); border-right: 1px solid #e8ece9; text-align: left; vertical-align: top; }
.data th { position: sticky; top: 0; background: #f7f9f7; font-weight: 600; white-space: nowrap; z-index: 1; }
.data td:first-child, .data th:first-child { position: sticky; left: 0; background: inherit; }
.data th:first-child { z-index: 2; background: #f7f9f7; }
.data tbody tr { background: var(--surface); }
.data tbody tr:hover { background: #f4f8f5; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 640px) {
  .page { padding-top: 1.5rem; }
  .grid, .grid-address { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; gap: .15rem; }
  .facts dd { margin-bottom: .6rem; }
  .copy { flex-direction: column; }
}

/* ---------- Schritt 2: Flächenmeldung ---------- */
.medium .page { max-width: 1100px; }
.page-head > div { min-width: 0; }
.page-head .lead { margin-bottom: 0; }
.num { text-align: right; }
.data td.num, .data th.num { text-align: right; }
.mono-ish { font-variant-numeric: tabular-nums; letter-spacing: .02em; font-size: .85rem; color: var(--muted); }
.danger { color: var(--error); }
.row-actions { display: flex; gap: .9rem; align-items: center; }

select, textarea {
  font: inherit; color: inherit; width: 100%;
  padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
textarea { resize: vertical; line-height: 1.5; }
select:focus, textarea:focus { border-color: var(--vine); outline: none; box-shadow: 0 0 0 3px var(--vine-soft); }

.flash-warn { background: #fdf4dc; color: #6b4a00; border-left: 4px solid #d99a00; }
.confirm-box { background: #fdf4dc; padding: .75rem 1rem; border-radius: var(--radius); }

/* Status-Kennzeichen */
.badge { display: inline-block; padding: .3rem .7rem; border-radius: 999px; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.badge-open      { background: #eceeed; color: var(--muted); }
.badge-draft     { background: #fdf4dc; color: #6b4a00; }
.badge-submitted { background: var(--vine); color: #fff; }
.badge-changed   { background: var(--error-soft); color: var(--error); }
.tag { font-size: .8rem; padding: .1rem .45rem; border-radius: 4px; white-space: nowrap; }
.tag-found     { background: var(--vine-soft); color: var(--vine-dark); }
.tag-not_found { background: #fdf4dc; color: #6b4a00; }
.tag-unchecked { background: #eceeed; color: var(--muted); }

/* Eingabe Flurstück */
.grid-plot { grid-template-columns: 1.2fr .7fr 1fr .8fr 1.3fr; }
.checks { display: flex; flex-direction: column; gap: .5rem; justify-content: flex-end; }
.check-inline { display: inline-flex; align-items: center; gap: .5rem; font-weight: 400 !important; }
.check-inline input { width: 1.15rem; height: 1.15rem; accent-color: var(--vine); margin: 0; }
.panel-edit { border-color: var(--vine); }

/* Karte */
.map { width: 100%; height: 460px; border-radius: var(--radius); background: #dfe5e1; }
.map-missing { padding: 2rem; text-align: center; color: var(--muted); background: #f6f8f6; border: 1px dashed var(--line); border-radius: var(--radius); }
.map-note { font-size: .82rem; color: var(--muted); margin: .6rem 0 0; }
.legend { display: inline-block; width: .9rem; height: .9rem; border-radius: 3px; vertical-align: -2px; margin: 0 .25rem 0 .6rem; }
.legend:first-child { margin-left: 0; }
.legend-normal { background: #7ee2a0; border: 2px solid #3aa866; }
.legend-near   { background: #f2b631; border: 2px solid #c48a00; }
.map-info { font: 14px/1.45 var(--font); color: #1d2620; max-width: 260px; }
.map-info strong { display: block; margin-bottom: .25rem; }

.next-step {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--vine-dark); color: #fff; padding: 1.1rem 1.5rem; border-radius: var(--radius);
}
.next-step p { margin: 0; }
.next-step .btn { background: #fff; color: var(--vine-dark); border-color: #fff; }

/* Abgabe */
.plot-summary { list-style: none; margin: 0; padding: 0; }
.plot-summary li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.plot-summary li:last-child { border-bottom: 0; }
.terms { max-height: 260px; overflow: auto; padding: 1rem; background: #f6f8f6; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; font-size: .93rem; }
.sig-wrap { position: relative; }
#sig { display: block; width: 100%; height: 190px; background: #fff; border: 1px solid var(--line); border-bottom: 2px solid var(--ink); border-radius: var(--radius) var(--radius) 0 0; touch-action: none; cursor: crosshair; }
.sig-clear { position: absolute; top: .5rem; right: .75rem; }
.signature-img { display: block; max-width: 100%; max-height: 160px; background: #fff; border-bottom: 2px solid var(--ink); margin-top: .75rem; }
.terms-details { margin-top: 1rem; }
.terms-details summary { cursor: pointer; color: var(--vine); }

/* Admin */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.two-col .panel { margin-bottom: 1.25rem; }
.filters { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin: 0 0 1rem; }
.filters label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; font-weight: 560; }
.filters select, .filters input:not([type="checkbox"]) { min-width: 9rem; width: auto; }
.filters .check-inline { flex-direction: row; padding-bottom: .6rem; }
.inline-note { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 0 0 1rem; padding: .6rem 1rem; background: #fdf4dc; border-radius: var(--radius); }
.pre { white-space: pre-wrap; word-break: break-all; font-size: .82rem; background: #f6f8f6; padding: 1rem; border-radius: var(--radius); margin: 0; }

@media (max-width: 900px) {
  .grid-plot { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-plot { grid-template-columns: 1fr 1fr; }
  .map { height: 340px; }
}
