:root {
  --bg: linear-gradient(140deg, #f3f6ff, #fff4f2);
  --card: #ffffffcc;
  --text: #111827;
  --accent: #111827;
  --muted: #475569;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  padding-bottom: 5rem;
}

.page { width: min(1050px, 100% - 2rem); margin: 1rem auto; }
.card { padding: 1rem; background: var(--card); border-radius: 12px; margin-bottom: 1rem; box-shadow: 0 8px 18px rgb(15 23 42 / 10%); }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.login-toggle { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }
input, button, select {
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 0.95rem;
}
input.field-required,
select.field-required,
textarea.field-required {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgb(220 38 38 / 12%);
  background: #fff7f7;
}
button { background: #111827; color: white; border-color: #111827; cursor: pointer; }
button.active { background: #0f172a; }
button.secondary { background: #475569; border-color: #475569; }
button:disabled,
button[disabled] { opacity: 0.45; cursor: not-allowed; }
.icon-btn { padding: 0.35rem 0.5rem; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; display: block; }
.match-actions { display: inline-flex; gap: 0.4rem; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 45%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 40;
}
.modal-card {
  width: min(980px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  padding: 1rem;
  box-shadow: 0 18px 38px rgb(15 23 42 / 25%);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.modal-head h3 { margin: 0; }
.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.modal-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: #334155;
}
.modal-grid label.required::after {
  content: 'Pflichtfeld';
  font-size: 0.72rem;
  font-weight: 700;
  color: #b91c1c;
}
.availability-card {
  width: min(250px, 100%);
  padding: 0.6rem;
  border-radius: 8px;
  position: fixed;
  margin: 0;
  z-index: 60;
}
.availability-card .modal-head {
  margin-bottom: 0.45rem;
}
.availability-card .modal-head h3 {
  font-size: 1rem;
}
.availability-card .icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}
.availability-menu {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.availability-option {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  font-weight: 600;
}
.availability-can {
  background: #16a34a;
  border-color: #15803d;
  color: #ffffff;
}
.availability-maybe {
  background: rgb(255, 225, 150);
  border-color: rgb(230, 200, 125);
  color: #111827;
}
.availability-no {
  background: #dc2626;
  border-color: #b91c1c;
  color: #ffffff;
}
.availability-option:hover {
  filter: brightness(0.95);
}
.availability-backdrop {
  background: transparent;
  padding: 0;
  z-index: 50;
}
.admin-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.admin-nav {
  background: #f8fafc;
  padding: 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  position: sticky;
  top: 1rem;
}
.admin-nav button { width: 100%; text-align: left; background: #1f2937; border-color: #1f2937; }
.admin-nav button.active { background: #0f172a; }
.admin-meta { margin: 0 0 0.5rem; color: var(--muted); }
#whoami { display: block; margin-bottom: 0.75rem; word-break: break-word; }
#whoamiRef { display: block; margin-bottom: 0.75rem; word-break: break-word; }
.public-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.public-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.public-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.public-tabs button {
  background: #1f2937;
  border-color: #1f2937;
}
.public-tabs button.active {
  background: #0f172a;
}
.public-view { display: none; }
.public-view.active { display: block; }
.match-filter { margin-bottom: 1rem; }
.admin-content {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  padding: 0.9rem;
  min-height: 260px;
  min-width: 0;
}
.admin-view { display: none; }
.admin-view.active { display: block; }
.admin-view h2 { margin-top: 0; }
.stats-view { display: none; }
.stats-view.active { display: block; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { position: static; }
}

#result {
  background: #0f172a;
  color: #f8fafc;
  border-radius: 8px;
  padding: .8rem;
  white-space: pre-wrap;
  max-height: 260px;
  overflow: auto;
  margin-top: 1rem;
}

.muted { color: var(--muted); }
.is-hidden { display: none; }
.mb-07 { margin-bottom: 0.7rem; }
.mb-09 { margin-bottom: 0.9rem; }
.mb-05 { margin-bottom: 0.5rem; }
.mt-05 { margin-top: 0.5rem; }
.mt-06 { margin-top: 0.6rem; }
.mt-07 { margin-top: 0.7rem; }
.mt-08 { margin-top: 0.8rem; }
.mt-09 { margin-top: 0.9rem; }
.table-wrap-spaced { margin-top: 0.9rem; }
.club-logo-nav {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  padding: 0.35rem;
}
.club-logo-profile {
  max-width: 120px;
  max-height: 120px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  padding: 0.5rem;
}
.logs-output {
  margin-top: 0.9rem;
  max-height: 32rem;
  overflow: auto;
}
.modal-card-medium {
  width: min(700px, 100%);
}
.modal-card-narrow {
  width: min(480px, 100%);
}
.password-rules {
  margin-top: 0.55rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid #d9e2ec;
  border-radius: 10px;
  background: #f8fafc;
}
.password-status {
  margin-top: 0.5rem;
  font-weight: 700;
}
.password-status.valid {
  color: #15803d;
}
.password-status.invalid {
  color: #b91c1c;
}
.password-rules strong {
  display: block;
  margin-bottom: 0.35rem;
}
.password-rules ul {
  margin: 0;
  padding-left: 1.1rem;
}
.password-rules li {
  color: #64748b;
  margin: 0.18rem 0;
}
.password-rules li.valid {
  color: #15803d;
}
.password-rules li.invalid {
  color: #b91c1c;
}

.referee-toolbar {
  justify-content: space-between;
  align-items: center;
}

.referee-form-panel {
  margin-top: 0.9rem;
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.5rem;
  padding: 0.85rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.table-wrap {
  border: 1px solid #d9e2ec;
  border-radius: 10px;
  overflow: auto;
  background: #fff;
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.ref-table th,
.ref-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 0.6rem 0.7rem;
  text-align: left;
}

.ref-table th { background: #f8fafc; font-size: 0.85rem; color: #334155; }
.ref-table tr:nth-child(even) { background: #fbfdff; }
.ref-table .hall-group-row td {
  background: #eaf2ff;
  color: #1e3a8a;
  font-weight: 700;
}
.ref-table .hall-entry-row td:first-child {
  padding-left: 1.6rem;
}
.hall-link,
.hall-link:visited,
.hall-link:hover,
.hall-link:active {
  color: #0f172a;
  text-decoration: underline;
}

.site-footer {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding: 0.25rem 0 1.5rem;
}

.site-footer a,
.legal-links-bar a,
.legal-topbar a {
  color: #0f172a;
  font-weight: 600;
}

.legal-links-bar {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  width: min(100% - 1.5rem, 32rem);
  padding: 0.7rem 0.9rem;
  border: 1px solid rgb(148 163 184 / 35%);
  border-radius: 999px;
  background: rgb(255 255 255 / 88%);
  box-shadow: 0 14px 32px rgb(15 23 42 / 14%);
  backdrop-filter: blur(12px);
  z-index: 70;
}

.legal-links-bar a {
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

.legal-links-bar a[aria-current='page'] {
  background: #0f172a;
  color: #fff;
}

.legal-page {
  width: min(860px, 100% - 2rem);
  padding: 1rem 0 2rem;
}

.legal-topbar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.legal-card {
  background: rgba(255, 255, 255, 0.96);
}

.legal-card h1 {
  margin-top: 0.1rem;
  margin-bottom: 1rem;
}

.legal-card h2 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.legal-card p,
.legal-card li {
  line-height: 1.6;
}

.legal-kicker {
  margin: 0;
  color: #475569;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.legal-note {
  color: #475569;
  background: #f8fafc;
  border: 1px solid #d9e2ec;
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
}

.legal-list {
  padding-left: 1.25rem;
}

@media (max-width: 640px) {
  body {
    padding-bottom: 6.2rem;
  }

  .legal-links-bar {
    bottom: 0.75rem;
    width: calc(100% - 1rem);
    padding: 0.75rem;
  }
}
