/* Sportamt digital – Gestaltung angelehnt an marl.de (Grün, klare Struktur). Keine externen Schriften oder CDNs. */
:root {
  --gruen: #00703c;
  --gruen-dunkel: #00532c;
  --gruen-hell: #e7f2ec;
  --gruen-mittel: #8dc63f;
  --text: #1d2a24;
  --text-2: #55625c;
  --rand: #d5ddd8;
  --hg: #f4f6f5;
  --weiss: #fff;
  --rot: #b3261e;
  --rot-hell: #fbeaea;
  --gelb: #9a6a00;
  --gelb-hell: #fff6dc;
  --blau: #1f5f99;
  --blau-hell: #e8f0f8;
  --radius: 6px;
  --schatten: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--hg); line-height: 1.5; }
a { color: var(--gruen-dunkel); }
a:hover { color: var(--gruen); }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; color: var(--gruen-dunkel); }
h2 { font-size: 1.25rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
h4 { font-size: .95rem; margin: .8rem 0 .4rem; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px; z-index: 10; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Kopf */
.site-header { background: var(--weiss); box-shadow: var(--schatten); }
.topbar { background: var(--gruen-dunkel); color: #fff; font-size: .82rem; }
.topbar .wrap { display: flex; justify-content: space-between; gap: 1rem; padding-top: 6px; padding-bottom: 6px; flex-wrap: wrap; }
.topbar a, .topbar .linklike { color: #fff; }
.brandbar .wrap { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand-mark { color: var(--gruen); display: inline-flex; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.3rem; color: var(--gruen-dunkel); }
.brand-text small { color: var(--text-2); }
.mainnav { background: var(--gruen); }
.mainnav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.mainnav a { display: block; color: #fff; text-decoration: none; padding: 12px 16px; font-weight: 600; }
.mainnav a:hover, .mainnav a[aria-current] { background: var(--gruen-dunkel); }
.mainnav a[aria-current] { box-shadow: inset 0 -4px 0 var(--gruen-mittel); }
.subnav { background: var(--gruen-hell); border-bottom: 1px solid var(--rand); }
.subnav .wrap { display: flex; flex-wrap: wrap; gap: 4px 18px; padding-top: 8px; padding-bottom: 8px; font-size: .9rem; }
.subnav a { text-decoration: none; }
.subnav a[aria-current] { font-weight: 700; text-decoration: underline; }
.nav-toggle { display: none; }
.main { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }

/* Fuß */
.site-footer { background: var(--gruen-dunkel); color: #e3efe8; font-size: .9rem; }
.site-footer a { color: #fff; margin-right: 18px; }
.footer-grid { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 24px; padding-bottom: 24px; }

/* Bausteine */
.card { background: var(--weiss); border: 1px solid var(--rand); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--schatten); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--weiss); border: 1px solid var(--rand); border-left: 5px solid var(--gruen); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text); display: block; }
.stat strong { display: block; font-size: 1.8rem; color: var(--gruen-dunkel); line-height: 1.1; }
.stat.warn { border-left-color: #d9a400; }
.stat.bad { border-left-color: var(--rot); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin-bottom: .6rem; }
.btn { display: inline-block; background: var(--gruen); color: #fff; border: 0; border-radius: var(--radius); padding: 9px 16px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--gruen-dunkel); color: #fff; }
.btn-ghost { background: var(--weiss); color: var(--gruen-dunkel); border: 1px solid var(--gruen); }
.btn-ghost:hover { background: var(--gruen-hell); color: var(--gruen-dunkel); }
.btn-danger { background: var(--rot); }
.btn-danger:hover { background: #8c1d17; }
.btn-small { padding: 5px 10px; font-size: .88rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.linklike { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; color: var(--gruen-dunkel); }
.inline-form { display: inline; }
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.alert ul { margin: 0; padding-left: 1.2rem; }
.alert-ok { background: var(--gruen-hell); border-color: #9ccbb1; }
.alert-error { background: var(--rot-hell); border-color: #e3a3a0; }
.alert-info { background: var(--blau-hell); border-color: #a9c4e0; }
.alert-warn { background: var(--gelb-hell); border-color: #e8cf86; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #e5e8e6; white-space: nowrap; }
.badge-eingereicht, .badge-in_pruefung { background: var(--blau-hell); color: var(--blau); }
.badge-rueckfrage, .badge-eingeladen, .badge-reserviert { background: var(--gelb-hell); color: var(--gelb); }
.badge-genehmigt, .badge-aktiv { background: var(--gruen-hell); color: var(--gruen-dunkel); }
.badge-abgelehnt, .badge-gesperrt { background: var(--rot-hell); color: var(--rot); }

/* Tabellen */
.table-wrap { overflow-x: auto; background: var(--weiss); border: 1px solid var(--rand); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; background: var(--weiss); }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid #e6ebe8; text-align: left; vertical-align: top; }
.table th { background: #eef3f0; font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: #f8fbf9; }
.table tr.sum td { font-weight: 700; background: #f2f6f3; }
.table.compact th, .table.compact td { padding: 4px 8px; }
.table .actions { white-space: nowrap; text-align: right; }
.row-warn { background: var(--gelb-hell) !important; }
.row-bad { background: var(--rot-hell) !important; }

/* Formulare */
.form .grid, fieldset .grid, .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-wide { grid-column: 1 / -1; }
.field-s { max-width: 180px; }
.field-check { flex-direction: row; align-items: center; }
.field small { color: var(--text-2); }
label { font-weight: 600; font-size: .9rem; }
.field-check label { font-weight: 400; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=time], input[type=number], input[type=password], input[type=search], input:not([type]), select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #b9c4be; border-radius: var(--radius); background: #fff; width: 100%; color: var(--text);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid var(--gruen-mittel); outline-offset: 1px; }
input:disabled, select:disabled, textarea:disabled { background: #f1f3f2; color: #333; }
.req { color: var(--rot); }
.form-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-section { border: 1px solid var(--rand); border-radius: var(--radius); background: var(--weiss); padding: 16px 20px 20px; margin: 0 0 18px; }
.form-section legend { font-weight: 700; font-size: 1.05rem; padding: 0 6px; color: var(--gruen-dunkel); }
.sec-nr { display: inline-block; background: var(--gruen); color: #fff; border-radius: 50%; width: 1.6em; height: 1.6em; text-align: center; line-height: 1.6em; font-size: .85rem; margin-right: 4px; }
.hilfe { color: var(--text-2); font-size: .9rem; margin-top: 0; }
.bedingungen { background: var(--hg); border-left: 4px solid var(--gruen); padding: 10px 14px; margin-bottom: 12px; font-size: .9rem; }
.repeat { grid-column: 1 / -1; margin: 12px 0; }
.repeat-row { display: flex; gap: 10px; align-items: flex-start; border-top: 1px dashed var(--rand); padding: 10px 0; }
.repeat-row .grid { flex: 1; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.rep-nr { background: var(--gruen-hell); color: var(--gruen-dunkel); font-weight: 700; border-radius: 4px; padding: 2px 8px; margin-top: 26px; }
.js .rep-hidden { display: none; }
.js [data-hidden-by-show] { display: none !important; }
.filter { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; background: var(--weiss); border: 1px solid var(--rand); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.filter .field { min-width: 150px; }
.filter input[type=search] { max-width: 320px; }
dl.kv { display: grid; grid-template-columns: minmax(180px, 34%) 1fr; gap: 4px 16px; margin: 0 0 8px; }
dl.kv dt { color: var(--text-2); }
dl.kv dd { margin: 0; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid var(--gruen-hell); padding: 4px 0 10px 12px; }
.timeline li.intern { border-left-color: #d9a400; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--hg); padding: 2px 6px; border-radius: 4px; word-break: break-all; }

/* Wochenplan */
.plan { display: grid; grid-template-columns: 56px repeat(7, 1fr); border: 1px solid var(--rand); background: var(--weiss); border-radius: var(--radius); overflow: hidden; min-width: 900px; }
.plan-head { background: #eef3f0; font-weight: 700; text-align: center; padding: 6px 0; border-bottom: 1px solid var(--rand); }
.plan-times { position: relative; border-right: 1px solid var(--rand); }
.plan-time { position: absolute; left: 0; right: 4px; font-size: .72rem; color: var(--text-2); text-align: right; transform: translateY(-50%); }
.plan-day { position: relative; border-right: 1px solid #edf1ee; background-image: linear-gradient(#edf1ee 1px, transparent 1px); background-size: 100% 48px; }
.plan-block { position: absolute; border-radius: 4px; padding: 2px 4px; font-size: .72rem; line-height: 1.2; overflow: hidden; background: var(--gruen-hell); border: 1px solid #8fc1a5; color: var(--text); text-decoration: none; }
.plan-block:hover { z-index: 3; overflow: visible; background: #d3eadb; min-height: max-content; }
.plan-block.kj { background: #e5f1fb; border-color: #9cc2e6; }
.plan-block.schule { background: #f2f2f2; border-color: #c4c4c4; }
.plan-block.kollision { background: var(--rot-hell); border-color: var(--rot); }
.plan-block strong { display: block; }
.plan-sperr { position: absolute; left: 0; right: 0; top: 0; background: repeating-linear-gradient(45deg, #f3f3f3, #f3f3f3 6px, #e9e9e9 6px, #e9e9e9 12px); opacity: .9; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; margin: 8px 0 14px; }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; border: 1px solid #8fc1a5; background: var(--gruen-hell); }
.legend .l-kj::before { background: #e5f1fb; border-color: #9cc2e6; }
.legend .l-schule::before { background: #f2f2f2; border-color: #c4c4c4; }
.legend .l-sperr::before { background: #e9e9e9; border-color: #ccc; }
.legend .l-koll::before { background: var(--rot-hell); border-color: var(--rot); }

/* Login */
.auth-box { max-width: 440px; margin: 24px auto; }

/* Druck */
.print-only { display: none; }
.print-head { border-bottom: 3px solid var(--gruen); margin-bottom: 16px; padding-bottom: 8px; }
.print-section { break-inside: avoid; margin-bottom: 12px; }
@media print {
  .site-header, .site-footer, .no-print, .btn, .filter, .alert { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; font-size: 10.5pt; }
  .main { padding: 0; }
  .card, .table-wrap { box-shadow: none; border: 0; padding: 0; }
  .plan { min-width: 0; font-size: 8pt; }
  a { color: inherit; text-decoration: none; }
  @page { margin: 14mm; }
}

@media (max-width: 760px) {
  .nav-toggle { display: inline-block; background: var(--gruen); color: #fff; border: 0; border-radius: var(--radius); padding: 8px 14px; font: inherit; font-weight: 600; }
  .js .mainnav { display: none; }
  .js .mainnav.open { display: block; }
  .mainnav ul { flex-direction: column; }
  .two-col { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; }
  dl.kv dd { margin-bottom: 6px; }
  h1 { font-size: 1.35rem; }
  .brand-text small { display: none; }
}

/* Ergänzungen Abrechnung, Einstellungen, Protokoll */
.table.num-right td:not(:first-child), .table.num-right th:not(:first-child) { text-align: right; white-space: nowrap; }
.table tfoot th { border-top: 2px solid var(--gruen); background: var(--gruen-hell); }
label.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin-right: 14px; }
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset.field legend { font-weight: 600; margin-bottom: 4px; padding: 0; }
.details-json { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; white-space: pre-wrap; word-break: break-word; max-width: 46ch; }
.import-log { max-height: 340px; overflow: auto; font-size: .85rem; }
.sum-box { font-size: 1.05rem; }
.sum-box td, .sum-box th { padding: 4px 10px; }

/* ---------- UX-Feinschliff ---------- */
html { scroll-behavior: smooth; }
:focus-visible { outline: 3px solid var(--gruen-mittel); outline-offset: 2px; }
.table tbody tr:hover { background: #f7faf8; }
.pager { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0; color: var(--text-2); font-size: .92rem; }

/* Lange Formulare: Aktionsleiste bleibt sichtbar */
.antrag-form .form-actions, .form-actions.sticky {
  position: sticky; bottom: 0; z-index: 5; background: rgba(255,255,255,.96); backdrop-filter: blur(4px);
  border-top: 1px solid var(--rand); margin: 16px -4px 0; padding: 12px 4px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.dirty-hint { color: var(--gelb); font-size: .88rem; display: none; }
form.is-dirty .dirty-hint { display: inline; }

/* Fehlerhinweise */
.alert-error { border-left: 5px solid var(--rot); }
.alert-ok { border-left: 5px solid var(--gruen); }
.alert-warn { border-left: 5px solid var(--gelb); }
.alert:focus { outline: 3px solid var(--gruen-mittel); }

/* Knöpfe während des Absendens */
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
.btn[aria-busy="true"]::after { content: ""; display: inline-block; width: .8em; height: .8em; margin-left: .5em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -1px; animation: drehen .7s linear infinite; }
@keyframes drehen { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .btn[aria-busy="true"]::after { animation: none; } }

/* Entscheidungsspalte bleibt beim Scrollen sichtbar (Desktop) */
@media (min-width: 1000px) {
  .aside-sticky { position: sticky; top: 12px; align-self: start; max-height: calc(100vh - 24px); overflow: auto; }
  .two-col { align-items: start; }
}

/* Handy */
@media (max-width: 760px) {
  .topbar .wrap > span:first-child { display: none; }
  .topbar .wrap { justify-content: flex-end; }
  .subnav .wrap { flex-wrap: nowrap; overflow-x: auto; gap: 18px; -webkit-overflow-scrolling: touch; scrollbar-width: none; white-space: nowrap; }
  .subnav .wrap::-webkit-scrollbar { display: none; }
  .mainnav a { padding: 12px 4px; border-bottom: 1px solid rgba(255,255,255,.12); }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .btn-row { flex-wrap: wrap; }
  input, select, textarea { font-size: 16px; } /* verhindert Zoom auf iOS */
  .btn { padding: 11px 16px; }

  /* Tabellen werden zu Karten */
  .js .table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .js .table.stack, .js .table.stack tbody, .js .table.stack tr, .js .table.stack td { display: block; width: 100%; }
  .js .table.stack tr { border: 1px solid var(--rand); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 10px; background: var(--weiss); }
  .js .table.stack td { border: 0; padding: 3px 0; display: grid; grid-template-columns: 40% 1fr; gap: 8px; text-align: left !important; }
  .js .table.stack td::before { content: attr(data-label); color: var(--text-2); font-size: .85rem; }
  .js .table.stack td[data-label=""] { grid-template-columns: 1fr; }
  .js .table.stack td[data-label=""]::before { display: none; }
  .js .table.stack td:empty { display: none; }
  .js .table.stack tfoot { display: block; }
  .js .table.stack tfoot tr { display: flex; flex-wrap: wrap; gap: 4px 12px; }
  .table-wrap { box-shadow: none; border: 0; background: transparent; }
}
.filter-toggle { margin: 0 0 12px; }
[hidden] { display: none !important; }
@media (max-width: 760px) {
  .antrag-form .form-actions { gap: 8px; padding: 8px 4px; }
  .antrag-form .form-actions .btn { flex: 1 1 40%; padding: 10px 8px; text-align: center; }
  .antrag-form .form-actions a, .antrag-form .form-actions .dirty-hint { flex-basis: 100%; font-size: .82rem; }
  .antrag-form .form-actions a { display: none; }
}
