/* Sporttermin- und Teilnehmerverwaltung – Stylesheet (Mobile First, Dark Mode) */

:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --text: #142033;
  --muted: #5b6b82;
  --border: #d9e1ec;
  --primary: #0b5fff;
  --primary-strong: #0047cc;
  --primary-soft: #e3ecff;
  --accent: #ff6b1a;
  --ok: #138a4b;
  --ok-soft: #dcf5e7;
  --warn: #a35a00;
  --warn-soft: #fff1d6;
  --danger: #c62828;
  --danger-soft: #fde3e3;
  --past: #7b8794;
  --past-soft: #e8ecf1;
  --future: #0b5fff;
  --future-soft: #dfe9ff;
  --cancelled: #d32f2f;
  --cancelled-soft: #fde4e4;
  --today: #ff6b1a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 32, 51, .06), 0 6px 20px rgba(20, 32, 51, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1420;
    --surface: #152033;
    --surface-2: #1c2a40;
    --text: #e8eef7;
    --muted: #9aabc3;
    --border: #2a3a54;
    --primary: #5b93ff;
    --primary-strong: #82adff;
    --primary-soft: #1d3260;
    --ok: #4cd38a;
    --ok-soft: #133826;
    --warn: #ffc46b;
    --warn-soft: #3b2c10;
    --danger: #ff7b7b;
    --danger-soft: #431c1f;
    --past: #8d99a8;
    --past-soft: #242f40;
    --future: #6da0ff;
    --future-soft: #1b3159;
    --cancelled: #ff7b7b;
    --cancelled-soft: #47202a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-top: 18px; padding-bottom: 32px; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; display: flex; align-items: center; gap: .45em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; word-break: break-word; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-line; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-danger { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--primary); color: #fff; padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.inline { display: inline; margin: 0; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------------ Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(120deg, #0b5fff 0%, #0a3fb8 60%, #102a6b 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(11, 95, 255, .25);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: .01em; }
.brand img { border-radius: 10px; background: #fff; padding: 2px; }
.mainnav { display: flex; align-items: center; gap: 4px; }
.mainnav a, .navbtn {
  display: inline-flex; align-items: center; gap: 6px;
  color: rgba(255, 255, 255, .92); text-decoration: none; font-weight: 600; font-size: .95rem;
  padding: 9px 12px; border-radius: 999px; border: 0; background: transparent; cursor: pointer; font-family: inherit;
  transition: background .15s ease;
}
.mainnav a:hover, .navbtn:hover { background: rgba(255, 255, 255, .14); }
.mainnav a.active { background: rgba(255, 255, 255, .22); color: #fff; }
@media (max-width: 720px) {
  .brand span { display: none; }
  .mainnav span { display: none; }
  .mainnav a, .navbtn { padding: 10px; }
  .mainnav .icon { width: 1.4em; height: 1.4em; }
}

/* ------------------------------------------------------------------ Fußzeile */
.footer { border-top: 1px solid var(--border); background: var(--surface); padding: 16px 0 calc(16px + env(safe-area-inset-bottom)); color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.footer a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------------ Karten, Hero, Kennzahlen */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
  animation: rise .25s ease both;
}
.card.narrow { max-width: 560px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 18px; }
.hero h1 { margin-bottom: 4px; }
.hero p { margin: 0; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); text-decoration: none;
}
.stat-pill .icon { color: var(--primary); }
.stat-pill-warn { border-color: var(--warn); background: var(--warn-soft); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 8px 0 14px; }
.page-head h1 { margin-bottom: 2px; }
.page-head p { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); text-decoration: none;
  border-left: 5px solid var(--primary); transition: transform .15s ease;
}
a.stat:hover { transform: translateY(-2px); }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 1.55rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: .875rem; }
.stat-ok { border-left-color: var(--ok); }
.stat-warn { border-left-color: var(--warn); }
.stat-danger { border-left-color: var(--danger); }
.stats-compact .stat-value { font-size: 1.3rem; }

/* ------------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer;
  transition: transform .1s ease, background .15s ease, box-shadow .15s ease; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(11, 95, 255, .25); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-success { background: var(--ok); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
.btn-icon { width: 44px; padding: 0; background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell .btn, .actions-cell form { margin-left: 4px; }

/* ------------------------------------------------------------------ Meldungen */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid; font-weight: 500; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.alert-error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert-warning { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert-info { background: var(--primary-soft); border-color: var(--primary); color: var(--text); }

/* ------------------------------------------------------------------ Badges */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.badge-event-planned, .badge-participation-none, .badge-attendance-unknown { background: var(--future-soft); color: var(--future); border-color: transparent; }
.badge-event-cancelled, .badge-participation-declined, .badge-attendance-absent, .badge-payment-open, .badge-overdue { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-event-completed, .badge-payment-not_required, .badge-muted { background: var(--past-soft); color: var(--past); border-color: transparent; }
.badge-participation-accepted, .badge-attendance-present, .badge-payment-paid, .badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-payment-partial { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-participation-none { background: var(--surface-2); color: var(--muted); }

/* ------------------------------------------------------------------ Kalender */
.calendar-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; list-style: none; margin: 0 0 0 auto; padding: 0; font-size: .85rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot-future { background: var(--future); }
.dot-past { background: var(--past); }
.dot-cancelled { background: var(--cancelled); }
.dot-today { background: transparent; border: 2px solid var(--today); }

.months { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 860px) { .months { grid-template-columns: 1fr 1fr; } }
.month-title { justify-content: center; font-size: 1.1rem; margin-bottom: 8px; }
.month-grid { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.month-grid th { font-size: .78rem; color: var(--muted); font-weight: 700; padding: 4px 0; text-transform: uppercase; }
.month-grid td { height: 52px; padding: 0; text-align: center; vertical-align: middle; border-radius: 10px; background: var(--surface-2); position: relative; }
.month-grid td.empty { background: transparent; }
.month-grid td.weekend { background: color-mix(in srgb, var(--surface-2) 70%, var(--border)); }
.day-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.day-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 100%; height: 100%; min-height: 52px; border-radius: 10px; text-decoration: none; color: inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}
.day-link:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0, 0, 0, .12); }
.day-dots { display: flex; gap: 3px; }
.day-dots .dot { width: 7px; height: 7px; }
td.state-future { background: var(--future-soft); }
td.state-future .day-num { color: var(--future); font-weight: 800; }
td.state-past { background: var(--past-soft); }
td.state-past .day-num { color: var(--past); }
td.state-cancelled { background: var(--cancelled-soft); }
td.state-cancelled .day-num { color: var(--cancelled); text-decoration: line-through; }
td.state-future .day-dots .dot-future { background: var(--future); }
td.today { box-shadow: inset 0 0 0 2px var(--today); }
td.today .day-num { color: var(--today); font-weight: 800; }

/* ------------------------------------------------------------------ Termindetails / Dialog */
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; }
@media (max-width: 520px) { .detail-list { grid-template-columns: 1fr; gap: 2px; } .detail-list dd { margin-bottom: 8px; } }
.event-detail { border-left: 5px solid var(--primary); }

.dialog {
  border: 0; padding: 0; border-radius: var(--radius); width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.dialog::backdrop { background: rgba(8, 15, 30, .55); backdrop-filter: blur(2px); }
.dialog[open] { animation: rise .2s ease both; }
.dialog-body { padding: 20px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; }
.event-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.personal-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 14px; }
.personal-box .detail-list { gap: 4px 14px; }
.dialog-msg { margin-top: 10px; font-weight: 600; min-height: 1.5em; }

/* ------------------------------------------------------------------ Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px; border-bottom: 2px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td { border-bottom: 0; border-top: 2px solid var(--border); }
.row-past td { color: var(--muted); }
.row-cancelled td:first-child { box-shadow: inset 4px 0 0 var(--cancelled); }
.row-future td:first-child { box-shadow: inset 4px 0 0 var(--future); }
.row-overdue td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.row-reversal td { color: var(--muted); font-style: italic; }
.row-inactive td { opacity: .65; }
.table select { min-height: 38px; padding: 4px 8px; }
.participants select { min-width: 170px; }

@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td, .table.responsive tfoot { display: block; width: 100%; }
  .table.responsive tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 6px 10px; background: var(--surface); }
  .table.responsive td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 6px 0; text-align: right; box-shadow: none !important; }
  .table.responsive td::before { content: attr(data-label); font-weight: 700; color: var(--muted); font-size: .8rem; text-transform: uppercase; text-align: left; }
  .table.responsive td:not([data-label])::before { content: none; }
  .table.responsive td.actions-cell { justify-content: flex-end; flex-wrap: wrap; }
  .table.responsive tr.row-future { border-left: 4px solid var(--future); }
  .table.responsive tr.row-cancelled { border-left: 4px solid var(--cancelled); }
  .table.responsive tr.row-overdue { border-left: 4px solid var(--danger); }
  .table.responsive td[colspan] { justify-content: flex-start; }
}

/* ------------------------------------------------------------------ Formulare */
.form { display: flex; flex-direction: column; gap: 14px; }
.grid-form { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 700px) { .grid-form { grid-template-columns: 1fr 1fr; } .span-2 { grid-column: span 2; } }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; flex-direction: row; }
.inline-form .field { flex: 1 1 260px; }
.inline-form.compact { gap: 6px; align-items: center; }
.inline-form.compact input { min-height: 36px; width: 140px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.field-check { align-self: end; min-height: 46px; align-items: center; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-weight: 700; margin-bottom: 8px; }
.radio-card { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.copy-field { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-field input { flex: 1 1 260px; font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }
.howto { margin-top: 14px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 16px; }
.howto summary { cursor: pointer; font-weight: 700; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.empty-state { color: var(--muted); text-align: center; padding: 18px 0; margin: 0; }

/* ------------------------------------------------------------------ Tabs & Chips */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 4px 0 18px; padding-bottom: 4px; scrollbar-width: thin; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 999px; text-decoration: none;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); font-weight: 700; white-space: nowrap;
}
.tabs a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 600; }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }

/* ------------------------------------------------------------------ Login */
.page-login main { display: flex; align-items: flex-start; justify-content: center; }
.login-card { width: 100%; max-width: 420px; margin: 24px auto; }
.login-head { text-align: center; margin-bottom: 16px; }
.login-head img { margin-bottom: 6px; }
.login-head h1 { margin-bottom: 2px; }

/* ------------------------------------------------------------------ Hilfsklassen für JS */
.js .js-hide { display: none; }
.saved-flash { animation: savedflash 1.2s ease; }
@keyframes savedflash { 0% { background: var(--ok-soft); } 100% { background: transparent; } }
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 999px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 50; animation: rise .2s ease both;
}

@media print {
  .topbar, .footer, .actions, .tabs, .chips, .actions-cell, #abo { display: none !important; }
  .card { box-shadow: none; border: 1px solid #999; }
}
