:root {
  --bg: #f4f2ec;
  --karte: #ffffff;
  --text: #1f2a1f;
  --leise: #6b7368;
  --linie: #d9d6cc;
  --gruen: #2f5d34;
  --gruen-hell: #e3eddf;
  --rot: #d0021b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
a { color: var(--gruen); }
h1 { font-size: 1.5rem; margin: 0; }
h1 small, h2 small { font-weight: 400; color: var(--leise); font-size: .8rem; margin-left: .4rem; }
main { max-width: 1200px; margin: 0 auto; padding: 18px 16px 40px; }

/* Kopf */
.top { background: var(--gruen); color: #fff; display: flex; align-items: center; gap: 18px; padding: 8px 16px; flex-wrap: wrap; }
.marke { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; line-height: 1.15; font-size: .85rem; }
.marke img { width: 44px; height: 44px; border-radius: 50%; background: #fff; padding: 2px; }
.marke b { font-size: 1rem; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { color: #fff; text-decoration: none; padding: 7px 12px; border-radius: 6px; opacity: .85; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.16); opacity: 1; }
.top .jahr { margin-left: auto; }
.top .jahr label { flex-direction: row; align-items: center; gap: 0; margin: 0; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.75);
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.28); border-radius: 999px; padding: 0 0 0 14px; cursor: pointer; transition: background .15s, border-color .15s; }
.top .jahr label:hover, .top .jahr label:focus-within { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.5); }
.top .jahr select { -webkit-appearance: none; appearance: none; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 13px center / 11px 8px;
  border: 0; color: #fff; font-size: 1.05rem; font-weight: 700; letter-spacing: .02em; padding: 6px 34px 6px 8px; border-radius: 999px; cursor: pointer; outline: none; }
.top .jahr select option { color: var(--text); background: #fff; font-weight: 400; }
.top .aus { color: #fff; opacity: .75; font-size: .85rem; }

/* Bausteine */
.kopfzeile { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.kopfzeile h1 { margin-right: auto; }
.karte { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.btn { display: inline-block; font: inherit; padding: 8px 16px; border-radius: 7px; border: 1px solid var(--linie); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--gruen); }
.btn.haupt { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.btn.haupt:hover { background: #244a29; }
.btn.klein { padding: 5px 10px; font-size: .85rem; }
.btn.gefahr { color: var(--rot); border-color: #efc2c2; background: #fff; }
.meldung { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--gruen-hell); border: 1px solid #b9d2b0; }
.meldung.fehler { background: #fde8e8; border-color: #f0b9b9; color: #8a1020; }
.hinweis, .legende { color: var(--leise); font-size: .85rem; }
.leer-text { color: var(--leise); font-style: italic; }
.kranz { color: var(--rot); }
.nd-marke { font-size: .7rem; background: #eee8d8; color: #6b5a2a; border-radius: 4px; padding: 1px 5px; margin-left: 3px; white-space: nowrap; }
.mitte { text-align: center; }
.rechts { text-align: right; }
input, select { font: inherit; }
label { display: flex; flex-direction: column; font-size: .8rem; color: var(--leise); gap: 3px; }
label input, label select { padding: 7px 9px; border: 1px solid var(--linie); border-radius: 6px; color: var(--text); font-size: 1rem; background: #fff; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: .95rem; color: var(--text); }

/* Login */
body.login main { max-width: 360px; padding-top: 60px; }
.login-karte { display: flex; flex-direction: column; gap: 14px; }

/* Liste */
.suche { width: 100%; padding: 10px 12px; border: 1px solid var(--linie); border-radius: 8px; font-size: 1rem; margin-bottom: 12px; }
.tabelle-scroll { overflow-x: auto; background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); }
table.liste { width: 100%; border-collapse: collapse; }
.liste th, .liste td { padding: 7px 10px; border-bottom: 1px solid #ece9e1; text-align: left; white-space: nowrap; }
.liste th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--leise); background: #faf9f5; position: sticky; top: 0; }
.liste th.mitte, .liste td.mitte { text-align: center; }
.liste th.rechts, .liste td.rechts { text-align: right; }
.liste tbody tr[data-href] { cursor: pointer; }
.liste tbody tr:hover { background: #f7f5ee; }
.liste tr.inaktiv { opacity: .45; }
.liste a { text-decoration: none; color: var(--text); }
.punkt { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; border: 1px solid rgba(0,0,0,.15); vertical-align: 0; }

/* Standblatt */
.stamm { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.stamm label { flex: 1 1 160px; }
.stamm label.jg { flex: 0 0 110px; }
.stamm label.check { flex: 0 0 auto; padding-bottom: 8px; }
.sprung { padding: 7px 9px; border: 1px solid var(--linie); border-radius: 6px; max-width: 260px; }
.stiche { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 540px), 1fr)); gap: 16px; }
.stich { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); overflow: hidden; scroll-margin-top: 10px; }
.stich h2 { font-size: 1.05rem; margin: 0; padding: 9px 14px; background: var(--farbe); border-bottom: 1px solid rgba(0,0,0,.08); }
.stich h2 small { color: #3d4339; }
form.res { padding: 10px 14px 12px; border-bottom: 1px dashed var(--linie); }
form.res.nd { background: #fbfaf6; }
.res-titel { font-weight: 600; font-size: .85rem; margin-bottom: 6px; }
.res-titel small { color: var(--leise); font-weight: 400; }
form.res.nd .res-titel { color: #6b5a2a; }
table.schuss { border-collapse: collapse; }
table.schuss th { text-align: left; font-weight: 400; font-size: .85rem; padding: 3px 10px 3px 0; color: var(--leise); min-width: 150px; }
table.schuss td { padding: 3px 0; }
.felder { white-space: nowrap; }
input.sch, input.mou { width: 42px; height: 40px; text-align: center; font-size: 1.1rem; font-weight: 600; border: 1px solid #c9c5b8; border-radius: 6px; margin: 0 2px 0 0; padding: 0; }
input.sch.breit { width: 54px; }
input.sch:focus, input.mou:focus { outline: 2px solid var(--gruen); border-color: var(--gruen); background: #f6fbf4; }
input.sch.ungueltig { border-color: var(--rot); background: #fde8e8; }
input.sch.x { background: #fff9c4; }
td.m { padding-left: 10px !important; }
td.m label { flex-direction: row; align-items: center; gap: 4px; font-weight: 600; }
input.mou { width: 36px; background: #f7f5ee; }
td.zw { padding-left: 12px !important; min-width: 40px; font-weight: 600; color: var(--leise); text-align: right; }
.res-fuss { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.res-fuss .total { font-size: 1rem; }
.res-fuss .total b { font-size: 1.25rem; }
.res-fuss .status { font-size: .8rem; font-weight: 600; }
.res-fuss .status.kranz { color: #fff; background: var(--rot); border-radius: 4px; padding: 1px 7px; }
.res-fuss .aktionen { margin-left: auto; display: flex; gap: 6px; }
form.res.gespeichert:not(.geaendert) .btn.haupt { background: #fff; color: var(--gruen); }
details.neu-nd { padding: 8px 14px 10px; }
details.neu-nd summary { cursor: pointer; color: var(--gruen); font-size: .9rem; font-weight: 600; }
details.neu-nd form.res { padding: 8px 0 0; border: 0; background: none; }

/* Gruppen */
.neu-gruppe { display: flex; gap: 12px; align-items: flex-end; }
.neu-gruppe label { flex: 1; }
form.gruppe { padding: 16px; }
.gname { max-width: 420px; margin-bottom: 14px; }
.gruppe-tab thead th { font-size: .75rem; text-transform: uppercase; padding-bottom: 6px; }
.gruppe-tab td { padding: 4px 6px 4px 0 !important; }
.gruppe-tab select { padding: 7px 8px; border: 1px solid var(--linie); border-radius: 6px; min-width: 220px; }

/* Ranglisten */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 6px 11px; border-radius: 6px; text-decoration: none; color: var(--text); background: #fff; border: 1px solid var(--linie); font-size: .88rem; }
.tabs a.on { background: var(--gruen); color: #fff; border-color: var(--gruen); }
.druckkopf { display: none; }
section.rl { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; break-inside: avoid; }
section.rl h2 { margin: 0; padding: 8px 14px; background: var(--farbe); font-size: 1.05rem; }
section.rl .leer-text { padding: 4px 14px; }
table.rang { width: 100%; border-collapse: collapse; }
.rang th, .rang td { padding: 5px 12px; border-bottom: 1px solid #ece9e1; text-align: left; }
.rang th { font-size: .75rem; text-transform: uppercase; color: var(--leise); }
.rang .r { width: 52px; text-align: right; font-weight: 700; }
.rang .rechts { text-align: right; } .rang .mitte { text-align: center; }
.rang .klein { font-size: .85rem; }
.rang tr.ohne { color: var(--leise); }
.rang tbody tr:nth-child(-n+3) td.r { color: var(--gruen); }
table.matrix { border-collapse: collapse; font-size: .82rem; width: 100%; }
.matrix th, .matrix td { border: 1px solid #bdb8aa; padding: 3px 6px; white-space: nowrap; }
.matrix th { font-size: .75rem; }
.matrix td.f { background: color-mix(in srgb, var(--farbe) 45%, white); text-align: right; }
.matrix td.f.mitte { text-align: center; }


.kranz-icon { width: 24px; height: 24px; vertical-align: middle; }
.nur-mobil { display: none; }
.rang td { vertical-align: middle; }

/* PDF-Knöpfe */
.pdf-knoepfe { display: flex; gap: 6px; align-items: flex-start; }
.pdf-menu { position: relative; }
.pdf-menu summary { list-style: none; }
.pdf-menu summary::-webkit-details-marker { display: none; }
.pdf-menu > div { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; background: #fff; border: 1px solid var(--linie); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 280px; padding: 6px; }
.pdf-menu > div a { display: block; padding: 7px 10px; border-radius: 5px; text-decoration: none; color: var(--text); }
.pdf-menu > div a:hover { background: var(--gruen-hell); }

/* Anleitung */
.anleitung { max-width: 860px; padding: 8px 24px 20px; }
.anleitung h2 { font-size: 1.1rem; margin: 22px 0 6px; color: var(--gruen); }
.anleitung li { margin-bottom: 4px; }
.anleitung p { margin: 6px 0; }
kbd { font: .85em/1 inherit; border: 1px solid #bbb; border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: #fafafa; }
.badge-kranz { color: #fff; background: var(--rot); border-radius: 4px; padding: 0 6px; font-size: .85em; font-weight: 600; }
.hilfe-tab { margin: 12px 0 4px; font-size: .9rem; }
.hilfe-tab td { vertical-align: top; }

/* Handy */
@media (max-width: 640px) {
  /* Kopf kompakt: Logo + Jahr + Abmelden oben, Navigation als wischbare Zeile */
  .top { gap: 6px 10px; padding: 8px 12px 0; }
  .marke { flex: 1 1 auto; min-width: 0; font-size: .78rem; }
  .marke img { width: 36px; height: 36px; }
  .marke b { font-size: .92rem; }
  .top .jahr { margin-left: 0; }
  .top .jahr label { padding-left: 10px; }
  .top .jahr select { font-size: .95rem; padding: 5px 28px 5px 6px; background-position: right 10px center; }
  .top nav { order: 5; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px; padding: 0 8px 6px; scrollbar-width: none; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { white-space: nowrap; padding: 7px 11px; }
  main { padding: 14px 12px 32px; }
  h1 { font-size: 1.4rem; }

  /* Standblatt */
  .sprung { flex: 1 1 160px; max-width: none; }
  table.schuss th { display: block; padding-top: 6px; min-width: 0; }
  table.schuss, table.schuss tbody { display: block; width: 100%; }
  table.schuss tr { display: block; }
  table.schuss td { display: inline-block; vertical-align: middle; }
  table.schuss td.felder { display: inline-flex; max-width: 100%; gap: 3px; }
  input.sch, input.mou { width: 38px; margin: 0; }
  td.felder input.sch { flex: 0 1 38px; min-width: 24px; }
  td.felder input.sch.breit { flex-basis: 54px; }
  .res-fuss .aktionen { margin-left: auto; }
  .gruppe-tab select { min-width: 160px; }

  /* Ranglisten: Tabelle wischbar, Positionsspalten Val Bever ausgeblendet */
  section.rl { overflow-x: auto; }
  .rang th, .rang td { padding: 5px 5px; white-space: nowrap; }
  .rang .vn { display: none; }
  .rang td.nm { white-space: normal; line-height: 1.2; }
  .rang td.nm .nur-mobil { display: block; font-size: .85rem; color: var(--leise); }
  .rang tbody td:nth-last-child(-n+2) { white-space: normal; }
  .top .aus { display: none; }
  .top nav a.nur-mobil { display: inline-block; opacity: .7; margin-left: auto; }
  .rang .r { width: 30px; }
  .rang th.klein, .rang td.klein { display: none; }
  .kranz-icon { width: 20px; height: 20px; }
  .pdf-knoepfe { flex-wrap: wrap; position: relative; flex: 1 0 100%; }
  .pdf-menu { position: static; }
  .pdf-menu > div { left: 0; right: 0; min-width: 0; }
  .hilfe-tab { display: block; overflow-x: auto; }
  .anleitung { padding: 6px 14px 16px; }
}

/* Druck */
@page { size: A4 portrait; margin: 12mm; }
@media print {
  body { background: #fff; font-size: 10.5pt; }
  .top, .keindruck, .tabs, script { display: none !important; }
  main { padding: 0; max-width: none; }
  .druckkopf { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; border-bottom: 2px solid #000; padding-bottom: 6px; font-size: 13pt; }
  .druckkopf img { width: 48px; height: 48px; }
  .druckkopf span { margin-left: auto; font-size: 9pt; }
  section.rl { border: 1px solid #000; border-radius: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rang th, .rang td { padding: 2px 8px; border-bottom: 1px solid #999; }
  .tabelle-scroll { border: 0; overflow: visible; }
  .matrix { font-size: 7.5pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .legende { font-size: 8pt; }
  .anleitung { border: 0; padding: 0; max-width: none; }
  .anleitung h2 { break-after: avoid; margin-top: 14px; }
  .badge-kranz, .punkt { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@page quer { size: A4 landscape; margin: 8mm; }
@media print { body.quer main { page: quer; } }
