:root {
  --bg: #ffffff;
  --bg-soft: #faf4f4;
  --red: #c8102e;
  --red-dark: #8e0d22;
  --line: #e8dcdc;
  --ink: #1a1a1a;
  --muted: #7a7a7a;
  --up: #1f8a4c;
  --down: #c8102e;
  --even: #9a9a9a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Work Sans', sans-serif;
}

h1, h2 {
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 1rem;
  color: var(--ink);
}

a { color: var(--red); }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.wrap--admin { max-width: 620px; }

@media (min-width: 900px) {
  .wrap { max-width: 1140px; padding: 2rem 2.5rem 5rem; }
}
@media (min-width: 1400px) {
  .wrap { max-width: 1320px; }
}

/* --- Ticker / Signature Element --- */
.ticker {
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  border-bottom: 3px solid var(--ink);
}
.ticker-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.9rem 1.25rem;
}
@media (min-width: 900px) {
  .ticker-inner { max-width: 1140px; padding: 1.1rem 2.5rem; }
}
@media (min-width: 1400px) {
  .ticker-inner { max-width: 1320px; }
}
.ticker-block { display: flex; flex-direction: column; line-height: 1.1; }
.ticker-block--wide { flex: 1; min-width: 0; }
.ticker-label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.75);
}
.ticker-number {
  font-family: 'Oswald', sans-serif;
  font-size: 2.1rem;
  font-weight: 700;
  color: #ffffff;
}
.ticker-name {
  font-family: 'Oswald', sans-serif;
  font-size: 1.15rem;
  font-weight: 500;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticker-divider {
  width: 1px;
  align-self: stretch;
  background: rgba(255,255,255,0.3);
}

/* --- Haupttabellen: Gesamttabelle + Spieltag nebeneinander (Desktop) --- */
.haupt-spalten {
  display: block;
}
.haupt-spalte-spieltag .matchday { margin-top: 2.5rem; }

@media (min-width: 900px) {
  .haupt-spalten {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 2.5rem;
    align-items: start;
  }
  .haupt-spalte-spieltag .matchday { margin-top: 0; }
}

/* --- Standings table --- */
.standings-scroll {
  overflow-x: auto;
}
.standings {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-top: 0.5rem;
}
.standings thead th {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  height: 2.1rem;
  box-sizing: border-box;
  padding: 0 0.4rem 0.5rem;
  vertical-align: bottom;
  border-bottom: 2px solid var(--red);
}
.standings tbody tr {
  height: 2.2rem;
  border-bottom: 1px solid var(--line);
}
.standings tbody td {
  box-sizing: border-box;
  padding: 0 0.4rem;
  font-size: 0.88rem;
  line-height: 1;
  overflow: hidden;
  vertical-align: middle;
}
.col-rang { width: 9%; font-family: 'Oswald', sans-serif; font-weight: 600; color: var(--muted); }
.col-name { width: 42%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-punkte { width: 18%; text-align: right; font-family: 'Oswald', sans-serif; font-weight: 600; font-variant-numeric: tabular-nums; }
.col-trend { width: 15%; text-align: right; font-size: 0.72rem; white-space: nowrap; }
.col-erfolge { width: 16%; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trend-zahl { font-family: 'Work Sans', sans-serif; font-size: 0.72rem; font-weight: 600; }

@media (min-width: 900px) {
  .standings thead th { padding: 0 0.6rem 0.5rem; }
  .standings tbody tr { height: 2.4rem; }
  .standings tbody td { padding: 0 0.6rem; font-size: 0.9rem; }
}

tr.rang-gruen td { background: rgba(31,138,76,0.12); }
tr.rang-orange td { background: rgba(230,126,34,0.12); }
tr.rang-gelb td { background: rgba(241,196,15,0.15); }
tr.rang-rot td { background: rgba(200,16,46,0.10); }

.trend-auf { color: var(--up); }
.trend-ab { color: var(--down); }
.trend-gleich { color: var(--even); opacity: 0.7; }

/* --- Matchday detail --- */
.matchday h2 {
  height: 2.1rem;
  box-sizing: border-box;
  margin: 0.5rem 0 0;
  padding: 0 0 0.5rem;
  border-bottom: 2px solid var(--red);
  display: flex;
  align-items: flex-end;
  font-size: 0.95rem;
}
.matchday-columns {
  column-count: 1;
}
.matchday-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.2rem;
  box-sizing: border-box;
  border-bottom: 1px dashed var(--line);
  font-size: 0.9rem;
  break-inside: avoid;
}
@media (min-width: 900px) {
  .matchday-row { height: 2.4rem; }
}
.matchday-platz { color: var(--muted); font-family: 'Oswald', sans-serif; width: 1.4rem; flex-shrink: 0; }
.matchday-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matchday-punkte { font-family: 'Oswald', sans-serif; font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- Charts --- */
.charts {
  margin-top: 2.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
}
.chart-card h2 { font-size: 1rem; margin-bottom: 0.5rem; }
.chart-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1rem;
}
.chart-canvas-box {
  position: relative;
  width: 100%;
  height: 200px;
}
.chart-canvas-box canvas {
  width: 100% !important;
  height: 100% !important;
}

@media (min-width: 700px) {
  .chart-canvas-box { height: 260px; }
}

/* --- Punkte-Historie --- */
.historie { margin-top: 2.5rem; }
.historie-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.historie-table {
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
}
.historie-table th, .historie-table td {
  padding: 0.35rem 0.5rem;
  text-align: right;
  border-bottom: 1px solid var(--line);
}
.historie-table th {
  font-family: 'Oswald', sans-serif;
  color: var(--muted);
  font-weight: 500;
  background: var(--bg-soft);
}
.historie-table .sticky-col {
  position: sticky;
  left: 0;
  text-align: left;
  background: var(--bg);
  z-index: 1;
}
.historie-table th.sticky-col { background: var(--bg-soft); }
.historie-table td.kennzahl, .historie-table th.kennzahl {
  font-weight: 600;
  border-left: 1px solid var(--line);
}

.foot {
  margin-top: 3rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* --- Admin --- */
.admin-body { background: var(--bg); }
.msg { padding: 0.6rem 0.9rem; border-radius: 4px; font-size: 0.9rem; }
.msg-fehler { background: rgba(200,16,46,0.08); border: 1px solid var(--down); }
.msg-erfolg { background: rgba(31,138,76,0.08); border: 1px solid var(--up); }

.login-form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 280px; }
.login-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }

input[type="text"], input[type="password"], input[type="number"] {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  font-family: 'Work Sans', sans-serif;
  font-size: 0.95rem;
}
input[type="number"] { width: 5.5rem; text-align: right; }

button {
  background: var(--red);
  color: #ffffff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 4px;
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.75rem;
}
button:hover { background: var(--red-dark); }

.admin-block {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.admin-block--gefahr {
  border: 1px solid rgba(200,16,46,0.35);
  border-top: 1px solid rgba(200,16,46,0.35);
  background: rgba(200,16,46,0.04);
  border-radius: 4px;
  padding: 1.25rem;
}
.admin-block--gefahr h2 { color: var(--red); }
.admin-block--gefahr code {
  background: rgba(0,0,0,0.06);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
}
.checkbox-feld {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin: 0.75rem 0;
}
.checkbox-feld input { width: auto; }
.btn-gefahr { background: var(--red); }
.btn-gefahr:hover { background: var(--red-dark); }

.input-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.input-table th { text-align: left; font-size: 0.75rem; color: var(--muted); padding-bottom: 0.4rem; }
.input-table td { padding: 0.25rem 0; border-bottom: 1px solid var(--line); }
.input-table td:first-child { width: 60%; }

.spieltag-nr-feld { display: block; margin-bottom: 1rem; font-size: 0.85rem; color: var(--muted); }
.spieltag-nr-feld input { display: block; margin-top: 0.3rem; }
.spieltag-nr-feld textarea {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.5rem 0.6rem;
  border-radius: 4px;
  font-family: 'Work Sans', sans-serif;
  font-size: 0.9rem;
  resize: vertical;
}

.vorschau-titel { margin-top: 2rem; font-size: 1rem; }
.vorschau-table td:first-child { width: 30%; color: var(--muted); font-size: 0.85rem; }
.vorschau-table select { max-width: 100%; }
.vorschau-table input[type="number"] { width: 5rem; }
.vorschau-ignorieren { text-align: center; width: 4rem; }
tr.vorschau-unklar { background: rgba(200,16,46,0.06); }
tr.vorschau-unklar td:first-child { color: var(--red); font-weight: 600; }

.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form button { margin-top: 0; }

.hint { font-size: 0.85rem; color: var(--muted); }
