:root {
  --grund: #f4f3ef;
  --flaeche: #ffffff;
  --text: #1d2321;
  --leise: #5f6865;
  --linie: #d9d7cf;
  --gruen: #1f5a45;
  --gruen-hell: #e3eee8;
  --rot: #a6362b;
  --gold: #b8892b;
  --radius: 6px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--grund); color: var(--text); font: 15px/1.45 var(--schrift); }
a { color: var(--gruen); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }

.kopf { background: var(--gruen); color: #fff; }
.kopf-innen { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.kopf .kopf-innen { min-height: 54px; justify-content: space-between; }
.marke { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; }
.marke-ring { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #fff; box-shadow: inset 0 0 0 3px var(--gruen), inset 0 0 0 7px #fff; }
.kopf nav a { color: #d6e6de; text-decoration: none; margin-left: 18px; }
.kopf nav a.aktiv, .kopf nav a:hover { color: #fff; text-decoration: underline; text-underline-offset: 5px; }

.unterkopf { background: var(--flaeche); border-bottom: 1px solid var(--linie); }
.unterkopf .kopf-innen { justify-content: space-between; min-height: 52px; }
.v-titel span { color: var(--leise); margin-left: 8px; }
.tabs a { display: inline-block; padding: 15px 12px 13px; text-decoration: none; color: var(--leise); border-bottom: 3px solid transparent; }
.tabs a.aktiv { color: var(--text); border-bottom-color: var(--gruen); font-weight: 600; }
.tabs a:hover { color: var(--text); }

.inhalt { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }

.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; }
.karte > h2:first-child, .karte > h3:first-child { margin-top: 0; }
.zeile { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.zeile > * { flex: 0 1 auto; }
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.breit { grid-column: 1 / -1; }

label.feld { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--leise); }
input[type=text], input[type=date], input[type=number], input[type=password], input[type=search], select, textarea {
  font: inherit; color: var(--text); padding: 7px 9px; border: 1px solid #bdbab0; border-radius: 4px; background: #fff; width: 100%;
}
textarea { min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gruen); outline-offset: -1px; border-color: var(--gruen); }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; }

.knopf, button { font: inherit; padding: 7px 14px; border-radius: 4px; border: 1px solid var(--gruen); background: var(--gruen); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
.knopf:hover, button:hover { filter: brightness(1.1); }
.knopf.zweit, button.zweit { background: #fff; color: var(--gruen); }
.knopf.klein, button.klein { padding: 3px 8px; font-size: .85rem; }
button.gefahr, .knopf.gefahr { background: #fff; color: var(--rot); border-color: var(--rot); }
button.icon { background: none; border: 1px solid transparent; color: var(--leise); padding: 2px 6px; }
button.icon:hover { border-color: var(--linie); color: var(--text); }

table.liste { width: 100%; border-collapse: collapse; background: var(--flaeche); }
table.liste th, table.liste td { padding: 7px 8px; border-bottom: 1px solid var(--linie); text-align: left; vertical-align: middle; }
table.liste th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--leise); font-weight: 600; background: #faf9f6; }
table.liste td.zahl, table.liste th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
table.liste tr:hover td { background: #fbfbf8; }
table.liste input[type=text], table.liste input[type=number], table.liste select { padding: 5px 7px; }
.tabelle-scroll { overflow-x: auto; border: 1px solid var(--linie); border-radius: var(--radius); }
.tabelle-scroll table.liste { border: 0; }

.meldung { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.meldung-ok { background: var(--gruen-hell); border-color: #b5d3c3; }
.meldung-fehler { background: #f8e7e4; border-color: #e3b6af; color: #6d1f17; }
.leise { color: var(--leise); }
.klein { font-size: .85rem; }
.rechts { text-align: right; }
.abstand-oben { margin-top: 16px; }

/* Ergebniserfassung */
.wk-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.wk-tabs a { padding: 7px 12px; border: 1px solid var(--linie); border-radius: 999px; background: #fff; text-decoration: none; color: var(--text); font-size: .9rem; }
.wk-tabs a.aktiv { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.wk-tabs a small { opacity: .7; margin-left: 4px; }
table.liste th.mitte, table.erfassung td.schuss { text-align: center; }
table.erfassung td.schuss input { width: 3.4em; text-align: center; padding: 5px 2px; font-variant-numeric: tabular-nums; }
table.erfassung td.summe { font-weight: 700; font-size: 1.05rem; min-width: 3.5em; }
table.erfassung td.rang { color: var(--leise); }
table.erfassung input.ungueltig { background: #f8e7e4; border-color: var(--rot); }
table.erfassung tr.leer td.name { color: var(--leise); }
.leiste-unten { flex-wrap: wrap; position: sticky; bottom: 0; background: rgba(244,243,239,.95); padding: 12px 0; display: flex; gap: 12px; align-items: center; border-top: 1px solid var(--linie); margin-top: 12px; }

/* Druckmenü */
.druckmenue { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.druckmenue a { display: block; background: #fff; border: 1px solid var(--linie); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text); }
.druckmenue a:hover { border-color: var(--gruen); }
.druckmenue a strong { display: block; color: var(--gruen); }
.druckmenue a span { font-size: .85rem; color: var(--leise); }

.statistik { display: flex; gap: 28px; flex-wrap: wrap; }
.statistik div strong { display: block; font-size: 1.4rem; }
.statistik div span { color: var(--leise); font-size: .85rem; }

@media (max-width: 700px) {
  .kopf .kopf-innen { padding-top: 10px; padding-bottom: 10px; gap: 6px 24px; }
  .kopf nav a { margin-left: 0; margin-right: 12px; font-size: 14px; }
  .unterkopf .kopf-innen { gap: 0; padding-top: 8px; }
  .tabs a { padding: 12px 8px 10px; }
  .inhalt { padding: 16px 12px 48px; }
  .karte { padding: 14px; }
  h1 { font-size: 1.3rem; }
  /* iOS zoomt bei Eingabefeldern unter 16px automatisch hinein */
  input[type=text], input[type=date], input[type=number], input[type=password], input[type=search], select, textarea { font-size: 16px; }
  .nur-gross { display: none; }

  /* Tabellen als Karten: jede Zeile ein Block, jede Zelle "Beschriftung | Wert" */
  .tabelle-scroll:has(table.stapeln) { overflow: visible; border: 0; }
  table.stapeln, table.stapeln tbody, table.stapeln tfoot { display: block; background: none; }
  table.stapeln thead { display: none; }
  table.stapeln tr { display: block; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 6px 12px; margin-bottom: 10px; }
  table.stapeln tr:hover td { background: none; }
  table.stapeln td, table.stapeln tfoot th { display: flex; align-items: center; gap: 10px; border: 0; padding: 4px 0; text-align: left !important; width: auto !important; min-height: 0; }
  table.stapeln td[data-label]::before, table.stapeln tfoot th[data-label]::before {
    content: attr(data-label); flex: 0 0 38%; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--leise); font-weight: 600;
  }
  table.stapeln td > input[type=text], table.stapeln td > input[type=number], table.stapeln td > select { flex: 1; min-width: 0; }
  table.stapeln td:empty, table.stapeln tfoot th:empty { display: none; }
  table.stapeln td.rechts { justify-content: flex-end; }
  table.stapeln tfoot tr { background: var(--gruen-hell); }
  table.stapeln tfoot th { text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--text); background: none; }

  /* Ergebniserfassung: Name + Summe oben, Schüsse darunter in einer Reihe */
  .tabelle-scroll:has(table.erfassung) { overflow: visible; border: 0; }
  table.erfassung, table.erfassung tbody { display: block; background: none; }
  table.erfassung thead { display: none; }
  table.erfassung tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; }
  table.erfassung td { border: 0; padding: 0; }
  table.erfassung td:first-child { order: 1; color: var(--leise); min-width: 1.6em; }
  table.erfassung td.name { order: 2; flex: 1 1 auto; font-weight: 600; }
  table.erfassung td.summe { order: 3; }
  table.erfassung td.rang { order: 4; min-width: 2.6em; }
  table.erfassung tr::after { content: ""; order: 5; flex-basis: 100%; height: 0; }
  table.erfassung td.schuss { order: 6; flex: 1 1 0; min-width: 0; position: relative; padding-top: 14px; }
  table.erfassung td.schuss::before { content: attr(data-nr) "."; position: absolute; top: 0; left: 0; right: 0; text-align: center; font-size: .7rem; color: var(--leise); }
  table.erfassung td.schuss input { width: 100%; padding: 8px 2px; font-size: 18px; }
  .leiste-unten { gap: 8px; }
  .leiste-unten button { flex: 1 1 auto; }

  .wk-tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 16px; padding: 0 12px 4px; }
  .wk-tabs a { white-space: nowrap; }
  .zeile > .feld, .zeile > label.feld { flex: 1 1 100%; }
  .statistik { gap: 18px; }
}


/* Urkunden-Einstellungen */
.urkunde-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.urkunde-vorschau { position: sticky; top: 16px; }
.vorschau-rahmen { width: 300px; height: 424px; overflow: hidden; border: 1px solid var(--linie); border-radius: var(--radius); background: #fff; }
.vorschau-rahmen iframe { width: 820px; height: 1160px; border: 0; transform: scale(.3659); transform-origin: 0 0; pointer-events: none; }
code { background: #ebe9e2; padding: 1px 4px; border-radius: 3px; font-size: .85em; }
@media (max-width: 900px) { .urkunde-layout { grid-template-columns: 1fr; } .urkunde-vorschau { position: static; } }
