:root {
  /* Kickbase-Markenfarben (https://brand.kickbase.com/color, Stand 2026):
     KB Black #131417, KB Live Red #FF4600, KB White #DEE4EC,
     KB Dark Grey #474B4E, KB Grey #7E8187, KB Light Grey #A8ADB4.
     KB Live Red ist laut Guideline bewusst der EINZIGE Akzent ("sparingly
     and purposefully") - hier als --accent fuer Buttons/aktive Zustaende/
     Marke sowie als --danger fuer Kauf-/Kostenanzeigen wiederverwendet.
     --good (Gruen) ist KEINE Kickbase-Markenfarbe, sondern eine bewusste,
     funktionale Ausnahme fuer Verkauf/Einnahmen-Anzeigen - ohne sie waeren
     Kauf/Verkauf-Betraege farblich nicht mehr unterscheidbar. Warnhinweise
     nutzen KB Dark Grey statt eines erfundenen Gelb/Amber, da die Palette
     keinen dritten Farbton vorsieht. */
  --bg: #eef0f2;
  --surface: #ffffff;
  --border: #dee4ec;
  --text: #131417;
  --text-muted: #7e8187;
  --accent: #ff4600;
  --accent-soft: #ffe2d1;
  --danger: #ff4600;
  --danger-soft: #ffe2d1;
  --good: #16a34a;
  --good-soft: #dcfce7;
  --warning: #474b4e;
  --warning-soft: #f1f2f3;
  --sidebar-from: #131417;
  --sidebar-to: #202226;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; }

.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-from), var(--sidebar-to));
  color: #cbd5e1;
  padding: 1.25rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
  padding: 0.4rem 0.6rem 1.4rem;
}

.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.25);
}

.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; }

.nav-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin: 0.9rem 0.6rem 0.3rem;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.9rem;
  color: #cbd5e1;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar a .icon { flex-shrink: 0; opacity: 0.85; }

.sidebar a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.sidebar a.active {
  background: var(--accent);
  color: #fff;
}
.sidebar a.active .icon { opacity: 1; }

/* ---------- Main content ---------- */
main { flex: 1; min-width: 0; padding: 2rem 2.5rem; max-width: none; }

h1 { font-size: 1.5rem; margin: 0 0 1.1rem; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 0.8rem; }
h3 { font-size: 0.95rem; margin: 1rem 0 0.5rem; color: var(--text-muted); }

.icon { display: inline-block; vertical-align: -4px; }

/* ---------- Cards / tiles ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
}

.stat-row { display: flex; gap: 1rem; margin: 0 0 1.5rem; flex-wrap: wrap; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.4rem;
  min-width: 190px;
  flex: 1;
}
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; }

/* ---------- KPI-Kacheln (Transfermarkt) - drei Zeilen, nur der Wert
   traegt Farbe, Kachel selbst bleibt neutral. Beschriftung oben und
   Kennzahl unten jeweils linksbuendig. ---------- */
.kpi-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; margin-bottom: 0.9rem; }
.kpi-tile {
  display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start;
  text-align: left;
  min-width: 170px; flex: 1 0 170px;
}
.kpi-tile .stat-value { font-size: 1.3rem; }
.stat-value.kpi-good { color: var(--good); }
.stat-value.kpi-yellow { color: #ca8a04; }
.stat-value.kpi-orange { color: #ea580c; }
.stat-value.kpi-bad { color: var(--danger); }

.pos-kpi-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.pos-kpi {
  flex: 1; min-width: 60px; text-align: center;
  border-radius: 10px; padding: 0.4rem 0.3rem;
  background: var(--bg); border: 1px solid var(--border);
}
.pos-kpi .pos-kpi-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; }
.pos-kpi .pos-kpi-value { font-size: 1.15rem; font-weight: 700; }
.pos-kpi .pos-kpi-value.kpi-bad { color: var(--danger); }

/* ---------- Positions-Verteilungsbalken (100% gestapelt) ---------- */
.pos-dist-bar {
  display: flex; width: 100%; height: 30px; border-radius: 8px;
  overflow: hidden; background: var(--bg);
}
.pos-dist-seg {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.72rem; font-weight: 700;
  min-width: 2px; transition: filter 0.15s ease, transform 0.15s ease;
  cursor: default;
}
.pos-dist-seg:hover { filter: brightness(1.15); transform: scaleY(1.08); }
.pos-dist-1 { background: #6d28d9; }
.pos-dist-2 { background: #1d4ed8; }
.pos-dist-3 { background: #15803d; }
.pos-dist-4 { background: #b91c1c; }
.pos-dist-legend { display: flex; gap: 0.9rem; flex-wrap: wrap; margin-top: 0.4rem; font-size: 0.78rem; color: var(--text-muted); }
.pos-dist-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.pos-dist-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Tables ---------- */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 0 1.5rem;
}
table { border-collapse: collapse; width: 100%; min-width: max-content; }
th, td { padding: 0.65rem 1rem; text-align: left; vertical-align: middle; font-size: 0.9rem; }
th {
  background: #fafbfd;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
tbody tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #fafcff; }
tr.me { background: var(--accent-soft); }
tr.me:hover { background: var(--accent-soft); }

.good { color: var(--good); font-weight: 700; }
.bad { color: var(--danger); font-weight: 700; }

.standings-separator td {
  padding: 0.65rem 1rem; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--danger); background: var(--danger-soft, #fee2e2);
  border-top: 2px dashed var(--danger); border-bottom: none !important;
}
tr.standings-last { background: var(--danger-soft, #fee2e2); }
tr.standings-last:hover { background: var(--danger-soft, #fee2e2); }
.standings-relegation { color: var(--danger); margin-left: 0.3rem; vertical-align: middle; }

.rank-change { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; }
.rank-change-up { color: var(--good); }
.rank-change-down { color: var(--danger); }
.rank-change-flat {
  color: var(--text-muted); width: 10px; height: 10px; background: var(--border);
  border-radius: 2px; display: inline-block;
}

.badge-beta {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--accent);
  color: #fff;
  padding: 1px 5px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.15rem;
}
.feature-tile { position: relative; }
.feature-tile .badge-beta { position: absolute; top: 0.6rem; right: 0.6rem; margin: 0; }

/* ---------- Settings / Toggle-Schalter ---------- */
.toggle-row { display: flex; align-items: center; gap: 0.9rem; }
.toggle-switch {
  position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 999px; transition: 0.15s;
}
.toggle-slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge.pos-1 { background: #ede9fe; color: #6d28d9; }
.badge.pos-2 { background: #dbeafe; color: #1d4ed8; }
.badge.pos-3 { background: #dcfce7; color: #15803d; }
.badge.pos-4 { background: #fee2e2; color: #b91c1c; }
.badge.buy { background: var(--danger-soft); color: var(--danger); }
.badge.sell { background: var(--good-soft); color: var(--good); }
.badge.ok { background: var(--good-soft); color: var(--good); }
.badge.offer { background: var(--accent-soft); color: var(--accent); font-weight: 700; gap: 0.25rem; }

/* ---------- Aktive Marktplatz-Gebote ---------- */
tr.has-offer { background: var(--accent-soft); }
tr.has-offer:hover { background: var(--accent-soft); }
tr.has-offer td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.bid-cell-wrap { position: relative; display: inline-block; }
.bid-cell {
  width: 130px; padding: 0.4rem 0.6rem; font-size: 0.85rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.bid-cell::placeholder { color: var(--text-muted); }
.bid-cell.has-bid {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent); font-weight: 700;
  padding-right: 1.6rem;
}
.bid-cell:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.bid-clear-x {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  color: var(--accent); font-size: 1.05rem; line-height: 1;
  cursor: pointer; user-select: none;
}
.bid-clear-x:hover { color: var(--danger); }

.bid-diff-hint { font-size: 0.72rem; margin-top: 0.2rem; font-weight: 600; }
.bid-diff-hint.hint { font-weight: 400; }

/* ---------- Popup fuer Gebote (touch-/PWA-freundlich) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(19, 20, 23, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.4rem; width: 100%; max-width: 340px; box-shadow: var(--shadow);
}
.modal-title { font-weight: 700; margin-bottom: 0.9rem; font-size: 0.95rem; }
.modal-input {
  width: 100%; padding: 0.75rem 0.8rem; font-size: 1.1rem;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1.1rem;
}
.modal-actions { display: flex; gap: 0.6rem; }
.modal-actions button {
  flex: 1; padding: 0.8rem; border-radius: 8px; font-weight: 600;
  font-size: 0.9rem; border: none; cursor: pointer; min-height: 44px;
}
#bid-modal-no { background: var(--bg); color: var(--text); }
#bid-modal-yes { background: var(--accent); color: #fff; }
#bid-modal-yes:focus { outline: 3px solid #131417; outline-offset: 2px; }

.star { color: #f5a623; font-size: 1rem; line-height: 1; flex-shrink: 0; }

.star-toggle {
  background: none; border: none; margin: 0;
  font-size: 1.05rem; line-height: 1; cursor: pointer;
  color: var(--light-star, #c7cbd1); flex-shrink: 0;
  width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
}
.star-toggle.active { color: #f5a623; }
.star-toggle:hover { color: #f5a623; opacity: 0.8; }

.icon-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.55rem 0.8rem; font-size: 0.82rem; font-weight: 600; color: var(--text);
  cursor: pointer; min-height: 40px;
}
.icon-btn:hover { background: var(--bg); }
.view-toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

@media (max-width: 640px) {
  .app-shell { flex-direction: column; }
  main { padding: 1.2rem; padding-bottom: 5.5rem; }
  .kpi-tile { min-width: 140px; }

  /* Mobile: Sidebar wird zu einer unten fixierten, horizontal scrollbaren
     Navigationsleiste (Icon + kleines Label je Eintrag) statt der
     hochkant-Liste am oberen Bildschirmrand. */
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: auto;
    padding: 0;
    z-index: 20;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
  }
  .sidebar .brand { display: none; }
  .sidebar nav {
    flex-direction: row;
    gap: 0;
    width: 100%;
    padding: 0.4rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom));
  }
  .sidebar .nav-section { display: none; }
  /* Nur die 4 wichtigsten Bereiche stehen unten - alles andere ist ueber
     die Dashboard-Kacheln erreichbar (Nutzer-Entscheidung, um die Leiste
     nicht mit zu vielen Icons zu ueberladen). */
  .sidebar a { display: none; }
  .sidebar a.mobile-primary {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0.3rem;
    font-size: 0.68rem;
    text-align: center;
    border-radius: 8px;
  }
  .sidebar a span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .sidebar a .icon { opacity: 0.85; }
  .sidebar a .badge-beta { display: none; }
}

table.sortable-table th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
table.sortable-table th[data-sort]:hover { color: var(--text); }
table.sortable-table th[data-sort].sorted-asc::after { content: " \25B2"; font-size: 0.65em; }
table.sortable-table th[data-sort].sorted-desc::after { content: " \25BC"; font-size: 0.65em; }

/* ---------- Mobile Kartenansicht (PWA/Smartphone) ---------- *
 * Verwandelt Zeilen von table.mobile-cards in Karten: Foto+Name oben,
 * Punkte/Ablaufzeit rechts, Marktwert + Gebotsfeld darunter - angelehnt an
 * die offizielle Kickbase-App-Ansicht auf dem Handy. Sekundaere Spalten
 * (Team, Position, Rabatt, Saisonpunkte, Verkaeufer, Hinzugefuegt am)
 * werden ausgeblendet, um die Karte schlank zu halten. */
@media (max-width: 700px) {
  table.mobile-cards thead, table.mobile-cards tfoot { display: none; }
  table.mobile-cards, table.mobile-cards tbody, table.mobile-cards tr, table.mobile-cards td {
    display: block; width: 100%;
  }
  table.mobile-cards { min-width: 0; }
  table.mobile-cards tr {
    display: flex; flex-wrap: wrap; align-items: baseline;
    padding: 0.8rem 0.9rem; gap: 0.15rem 0.6rem;
  }
  table.mobile-cards td { border: none !important; padding: 0 !important; width: auto; }

  table.mobile-cards td[data-col="name"] {
    order: 1; flex: 1 1 100%; margin-bottom: 0.35rem;
  }
  table.mobile-cards td[data-col="name"] a { font-weight: 700; font-size: 0.95rem; }
  table.mobile-cards td[data-col="name"] .timeline-photo { width: 44px; height: 44px; }

  table.mobile-cards td[data-col="avg_points"] {
    order: 2; margin-left: auto; text-align: right; font-size: 0.85rem; color: var(--text-muted);
  }
  table.mobile-cards td[data-col="avg_points"]::before { content: "\00D8 "; }
  table.mobile-cards td[data-col="expires_in_seconds"] {
    order: 3; text-align: right; font-size: 0.8rem;
  }

  table.mobile-cards td[data-col="market_value"] {
    order: 4; flex: 1 1 100%; font-weight: 600; padding-top: 0.3rem !important;
    border-top: 1px solid var(--border) !important; margin-top: 0.3rem;
  }
  table.mobile-cards td[data-col="offer"],
  table.mobile-cards td[data-col="offers"] { order: 5; flex: 1 1 100%; margin-top: 0.5rem; }
  table.mobile-cards td[data-col="offer"] .bid-cell-wrap,
  table.mobile-cards td[data-col="offer"] .bid-cell { width: 100%; }

  table.mobile-cards td[data-col="team"],
  table.mobile-cards td[data-col="pos"],
  table.mobile-cards td[data-col="discount_pct"],
  table.mobile-cards td[data-col="total_points"],
  table.mobile-cards td[data-col="change_24h"],
  table.mobile-cards td[data-col="seller"],
  table.mobile-cards td[data-col="listed_at"],
  table.mobile-cards td[data-col="price"] { display: none; }

  /* Nutzer-konfigurierbare Zusatzfelder (siehe "Mobile-Ansicht"-Button) -
     ueberschreibt die Standard-Sichtbarkeit oben. */
  table.mobile-cards td.mf-show {
    display: block !important; order: 3; flex: 1 1 100%;
    font-size: 0.78rem; color: var(--text-muted); padding: 0.1rem 0 !important;
  }
  table.mobile-cards td.mf-show::before { content: attr(data-mobile-label) ": "; font-weight: 600; }
  table.mobile-cards td.mf-hide { display: none !important; }

  /* Transfers-Tabelle: eigene Kartenreihenfolge (Spieler, Preis, Datum,
     Marktwert damals, Differenz immer sichtbar; Art/Team/Von/Zu ueber
     "Mobile-Ansicht" zuschaltbar). */
  #transfers-table.mobile-cards td[data-col="amount"] {
    order: 2; margin-left: auto; text-align: right; font-weight: 700;
  }
  #transfers-table.mobile-cards td[data-col="date"] {
    order: 3; flex: 1 1 100%; text-align: right; font-size: 0.8rem; color: var(--text-muted);
  }
  #transfers-table.mobile-cards td[data-col="market_value"] {
    order: 4; flex: 1 1 100%; padding-top: 0.3rem !important;
    border-top: 1px solid var(--border) !important; margin-top: 0.3rem;
  }
  #transfers-table.mobile-cards td[data-col="overpaid"] { order: 5; flex: 1 1 100%; font-size: 0.85rem; }
  #transfers-table.mobile-cards td[data-col="kind"],
  #transfers-table.mobile-cards td[data-col="team"],
  #transfers-table.mobile-cards td[data-col="seller"],
  #transfers-table.mobile-cards td[data-col="buyer"] { display: none; }

  /* Kader-Tabelle: Spieler + Marktwert immer sichtbar, Rest ueber
     "Mobile-Ansicht" zuschaltbar. */
  #squad-table.mobile-cards td[data-col="market_value"] {
    order: 2; flex: 1 1 100%; font-weight: 700; padding-top: 0.3rem !important;
    border-top: 1px solid var(--border) !important; margin-top: 0.3rem;
  }
  #squad-table.mobile-cards td[data-col="team"],
  #squad-table.mobile-cards td[data-col="pos"],
  #squad-table.mobile-cards td[data-col="change_24h"],
  #squad-table.mobile-cards td[data-col="total_points"],
  #squad-table.mobile-cards td[data-col="avg_points"],
  #squad-table.mobile-cards td[data-col="status"] { display: none; }

  /* Scouting-Tabelle: Spieler + Marktwert immer sichtbar, Rest ueber
     "Mobile-Ansicht" zuschaltbar. */
  #scouting-table.mobile-cards td[data-col="market_value"] {
    order: 2; flex: 1 1 100%; font-weight: 700; padding-top: 0.3rem !important;
    border-top: 1px solid var(--border) !important; margin-top: 0.3rem;
  }
  #scouting-table.mobile-cards td[data-col="team"],
  #scouting-table.mobile-cards td[data-col="pos"],
  #scouting-table.mobile-cards td[data-col="change_24h"],
  #scouting-table.mobile-cards td[data-col="avg_points"],
  #scouting-table.mobile-cards td[data-col="total_points"],
  #scouting-table.mobile-cards td[data-col="status"] { display: none; }

  /* Spielersuche-Tabelle: Spieler + Marktwert immer sichtbar, Rest ueber
     "Mobile-Ansicht" zuschaltbar. */
  #search-table.mobile-cards td[data-col="market_value"] {
    order: 2; flex: 1 1 100%; font-weight: 700; padding-top: 0.3rem !important;
    border-top: 1px solid var(--border) !important; margin-top: 0.3rem;
  }
  #search-table.mobile-cards td[data-col="team"],
  #search-table.mobile-cards td[data-col="pos"],
  #search-table.mobile-cards td[data-col="avg_points"],
  #search-table.mobile-cards td[data-col="total_points"] { display: none; }
}

/* ---------- Dashboard Feature-Kacheln ---------- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.8rem;
}
.feature-tile {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.3rem 1rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.feature-tile:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(16,24,40,0.12); }
.feature-tile .icon { color: var(--accent); }

/* ---------- Player card grid (Kader) ---------- */
.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}
.player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
}
.player-photo {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #eef1f6 center/cover no-repeat;
  border: 2px solid var(--border);
  position: relative;
}
.risk-badge {
  position: absolute; top: -4px; right: -4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--danger); color: #fff;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}

/* ---------- S11-Wahrscheinlichkeits-Badge (Aufstellung) ---------- */
.s11-badge {
  position: absolute; top: -5px; left: -5px;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  z-index: 2;
}
.s11-badge svg { width: 13px; height: 13px; flex-shrink: 0; }
.s11-badge.s11-sicher { background: #1d6fe0; }
.s11-badge.s11-erwartet { background: #16a34a; }
.s11-badge.s11-unsicher { background: #e08a1d; }
.s11-badge.s11-unwahrscheinlich { background: #e04b1d; }
.s11-badge.s11-ausgeschlossen { background: #1f2430; }

/* ---------- Status-Badge (Verletzung/Aufbautraining, Aufstellung) ---------- */
.status-badge {
  position: absolute; top: -5px; right: -5px;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  z-index: 2;
}
.status-badge svg { width: 13px; height: 13px; flex-shrink: 0; }
.status-badge.status-injured { background: var(--danger); }
.status-badge.status-stricken { background: #e08a1d; }
.status-badge.status-rehab { background: #6b7280; }
.status-badge.status-suspended { background: #1f2430; }
.status-badge.status-unknown { background: var(--danger); }

/* ---------- Naechster-Gegner-Badge (Aufstellung, optional per Settings) --- */
.opponent-badge {
  position: absolute; bottom: -11px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  background: #1f2430; border: 2px solid #fff; border-radius: 999px;
  padding: 3px 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  z-index: 3; white-space: nowrap;
}
.opponent-badge-vs {
  color: #fff; font-size: 0.58rem; font-weight: 800; letter-spacing: 0.02em;
}
.opponent-badge img { width: 22px; height: 22px; object-fit: contain; flex-shrink: 0; border-radius: 50%; }
.opponent-badge img.opponent-badge-own { box-shadow: 0 0 0 2px #ffd23f; }

.lineup-alert {
  display: flex; align-items: center; gap: 0.8rem;
  background: var(--danger-soft, #ffe2d1); border: 2px solid var(--danger);
  color: #8a2200; border-radius: var(--radius);
  padding: 1rem 1.2rem; margin: -0.4rem 0 1.4rem; font-size: 1.05rem;
}
.lineup-alert svg { flex-shrink: 0; color: var(--danger); }

.s11-legend {
  display: flex; flex-wrap: wrap; gap: 1rem;
  margin-bottom: 1.2rem; padding: 0.8rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.s11-legend-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; }
.s11-badge-static { position: static; }
.player-name { font-weight: 700; font-size: 0.95rem; }
.player-team { font-size: 0.78rem; color: var(--text-muted); }
.player-meta { display: flex; gap: 0.6rem; font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.player-meta b { color: var(--text); }

/* ---------- Transfers timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.8rem 0.2rem;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.timeline-icon.buy { background: var(--danger-soft); color: var(--danger); }
.timeline-icon.sell { background: var(--good-soft); color: var(--good); }
.timeline-photo {
  width: 34px; height: 34px; border-radius: 50%; background: #eef1f6 center/cover no-repeat;
  flex-shrink: 0;
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-title { font-size: 0.9rem; font-weight: 600; }
.timeline-sub { font-size: 0.78rem; color: var(--text-muted); }
.timeline-amount { font-weight: 700; font-size: 0.95rem; white-space: nowrap; }

/* ---------- Pitch / Aufstellung ---------- */
.pitch-wrap { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.pitch {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 3 / 4;
  background:
    repeating-linear-gradient(0deg, #1f9d4a 0, #1f9d4a 11.11%, #22ab52 11.11%, #22ab52 22.22%);
  border: 3px solid rgba(255,255,255,0.85);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pitch::before {
  content: "";
  position: absolute; inset: 10px;
  border: 2px solid rgba(255,255,255,0.55);
  border-radius: 6px;
}
.pitch::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 90px; height: 90px; margin: -45px 0 0 -45px;
  border: 2px solid rgba(255,255,255,0.55);
  border-radius: 50%;
}
.pitch-row {
  position: absolute;
  left: 0; right: 0;
  display: flex;
  justify-content: space-evenly;
  padding: 0 0.5rem;
}
.pitch-player {
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  width: 78px;
}
.pitch-photo {
  width: 46px; height: 46px; border-radius: 50%;
  background: #fff center/cover no-repeat;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  position: relative;
}
.pitch-photo.risk { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255, 70, 0, 0.45); }
.pitch-name {
  font-size: 0.72rem; font-weight: 700; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 78px;
}
.pitch-points {
  font-size: 0.66rem; color: #eafff0;
  background: rgba(0,0,0,0.35); border-radius: 999px; padding: 0 0.4rem;
}

/* ---------- Spieltags-Balkenchart (Spielerseite) ---------- */
.bar-chart-scroll { overflow-x: auto; overflow-y: hidden; margin-bottom: 0.6rem; }
.bar-chart-plot { position: relative; }
.gridlines { position: absolute; left: 0; right: 0; bottom: 0; top: 0; pointer-events: none; }
.gridline {
  position: absolute; left: 34px; right: 0; height: 1px;
  background: var(--border);
}
.gridline span {
  position: absolute; left: -34px; top: -7px; width: 30px;
  font-size: 0.62rem; color: var(--text-muted); text-align: right;
}
.bar-chart {
  display: flex; align-items: flex-end; gap: 8px;
  min-width: max-content; padding: 0.4rem 0.2rem 0;
  margin-left: 34px; position: relative;
}
.bar-col {
  display: flex; flex-direction: column; align-items: center;
  width: 34px; flex-shrink: 0;
}
.bar-badges {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 36px; justify-content: flex-end; margin-bottom: 3px;
}
.bar-badge {
  font-size: 0.6rem; font-weight: 700; border-radius: 4px;
  padding: 0 4px; color: #fff; white-space: nowrap;
}
.bar-badge.goal { background: var(--accent); }
.bar-badge.assist { background: #2563eb; }
.bar-points {
  font-size: 0.68rem; font-weight: 700; color: var(--text);
  height: 14px; margin-bottom: 2px;
}
.bar-track {
  height: 150px; width: 100%;
  display: flex; align-items: flex-end; justify-content: center;
}
.bar {
  width: 100%; background: var(--accent);
  border-radius: 4px 4px 0 0; min-height: 2px;
}
.bar.sub { background: #b8c2cf; }
.bar-footer { height: 32px; display: flex; flex-direction: column; align-items: center; padding-top: 3px; }
.bar-minutes { font-size: 0.62rem; color: var(--text-muted); }
.bar-label { font-size: 0.68rem; color: var(--text-muted); font-weight: 600; }

/* ---------- Drag & Drop Aufstellung ---------- */
.dnd-columns {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  margin-bottom: 1.2rem;
}
.dnd-zone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  min-height: 120px;
  padding: 0.6rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.dnd-zone.drag-over { background: var(--accent-soft); border-color: var(--accent); }
.dnd-chip {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  cursor: grab;
  font-size: 0.85rem;
}
.dnd-chip:active { cursor: grabbing; opacity: 0.7; }
.dnd-chip.drag-over-chip { outline: 2px solid var(--accent); background: var(--accent-soft); }

/* ---------- Vereins-Wappen-Chips (Spielersuche) ---------- */
.team-crest-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 0.3rem 0.7rem 0.3rem 0.3rem; font-size: 0.78rem; font-weight: 600;
  color: var(--text); cursor: pointer;
}
.team-crest-chip img { width: 20px; height: 20px; object-fit: contain; }
.team-crest-chip:hover { background: var(--bg); }
.team-crest-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

@media (max-width: 640px) {
  .dnd-columns { grid-template-columns: 1fr; }
}

/* ---------- Suggestions ---------- */
.suggestion-card {
  border: 1px solid var(--warning);
  background: var(--warning-soft);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}
.suggestion-header { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; margin-bottom: 0.3rem; }
.suggestion-reasons { font-size: 0.85rem; color: #3a3d40; margin: 0 0 0.7rem; padding-left: 1.1rem; }
.candidate-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.candidate-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  font-size: 0.82rem;
  display: flex; flex-direction: column; gap: 0.15rem;
}
.candidate-chip b { font-size: 0.86rem; }

/* ---------- Misc ---------- */
pre {
  background: #131417; color: #dee4ec; padding: 1rem;
  border-radius: var(--radius); overflow-x: auto; max-height: 500px;
  font-size: 0.82rem;
}
.error {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--danger-soft); color: #8a2200;
  padding: 0.75rem 1rem; border-radius: 10px; margin-bottom: 1.2rem;
  font-size: 0.9rem;
}
.warning-box {
  display: flex; align-items: flex-start; gap: 0.6rem;
  background: var(--warning-soft); color: #33363a;
  padding: 0.8rem 1rem; border-radius: 10px; margin-bottom: 1.2rem;
  font-size: 0.85rem;
}
.hint { color: var(--text-muted); font-size: 0.85rem; }
form input { padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; }
form button {
  padding: 0.5rem 1rem; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
form button:hover { background: #cc3800; }
form button:disabled { background: #a8adb4; cursor: not-allowed; }
form input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Filter form ---------- */
.filter-form {
  display: flex; align-items: flex-end; gap: 1.2rem; flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.filter-form label {
  display: block; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 0.3rem;
}
.filter-form select, .filter-form input[type="number"] {
  padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.88rem; min-width: 140px;
}
.filter-form input[type="number"] { min-width: 100px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1.3rem; border-bottom: 1px solid var(--border); }
.tab-btn {
  border: none; background: none; cursor: pointer;
  padding: 0.6rem 1rem; font-size: 0.92rem; font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Nur fuer Tablet-Breiten (Sidebar bleibt seitlich, klappt aber auf reine
   Icons zusammen) - ab 640px und darunter uebernimmt die untere
   Navigationsleiste (siehe @media max-width: 640px), diese Regeln duerfen
   die dort NICHT wieder ueberschreiben. */
@media (max-width: 780px) and (min-width: 641px) {
  .sidebar { width: 68px; }
  .sidebar a span, .brand span, .nav-section { display: none; }
  .brand { justify-content: center; }
  .sidebar a { justify-content: center; }
  main { padding: 1.2rem; }
}
