* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #f4f4f4;
}

/* ===============================
   APP CONTAINER
   =============================== */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===============================
   CONTROLS – EINE ZEILE
   =============================== */

.controls {
  display: flex;
  gap: .5rem;
  padding: .75rem;
  background: #ffffff;
  border-bottom: 1px solid #ccc;
  position: sticky;
  top: 0;
  z-index: 30;
}

.controls input,
.controls select {
  flex: 1;
  min-width: 0;
  padding: .6rem;
  font-size: 1rem;
}

#overview .k-font-control {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex: 0 0 auto;
  white-space: nowrap;
}

#overview .k-font-control label {
  font-size: .8rem;
  font-weight: 600;
  color: #444;
}

#overview .k-font-control input[type="range"] {
  width: 88px;
}

#overview .k-font-control span {
  font-size: .75rem;
  color: #555;
  min-width: 40px;
  text-align: right;
}

/* ===============================
   PAGE NAVIGATION
   =============================== */

.page-nav {
  display: block;
  padding: .5rem .75rem;
  background: #f4f4f4;
  border-bottom: 1px solid #ddd;
}

.page-nav a {
  display: inline-block;
  margin-right: 1rem;
  text-decoration: none;
  color: #555;
  font-weight: 500;
  padding: .25rem .5rem;
  border-radius: 4px;
}

.page-nav a.active {
  background: #ffffff;
  border: 1px solid #ccc;
  color: #000;
}

.page-nav a:hover {
  background: #eaeaea;
}

/* ===============================
   MAIN CONTENT
   =============================== */

main {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

/* ===============================
   INDEX.PHP – DETAILS VIEW
   =============================== */

.detail-row {
  margin-bottom: .35rem;
}

/* ===============================
   OVERVIEW.PHP – RANKING VIEW
   =============================== */

#overview .ranking-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem .7rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

#overview .ranking-row:hover {
  background: #dedede;
}

#overview .ranking-row:nth-of-type(odd) {
  background: #ffffff;
}

#overview .ranking-row:nth-of-type(even) {
  background: #eaeaea;
}

/* Ranking Nummer */
#overview .rank-number {
  font-weight: 600;
  min-width: 2rem;
  flex-shrink: 0;
}

/* Inhalt (Name + Werte + Bewertung) */
#overview .rank-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

/* Kopfzeile (Name links, Gesamtpunkte rechts) */
#overview .rank-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
}

/* Name */
#overview .rank-name {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  word-break: break-word;
}

#overview .rank-total-points {
  font-size: .85rem;
  font-weight: 600;
  opacity: .85;
  white-space: nowrap;
  flex-shrink: 0;
}

#overview .rank-metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: .45rem;
  margin-top: 6px;
}

#overview .rank-metric {
  border: 1px solid #d6d6d6;
  border-radius: 6px;
  padding: .25rem .35rem;
  background: rgba(255, 255, 255, 0.55);
  min-width: 0;
}

#overview .rank-metric-label {
  display: block;
  font-size: .66rem;
  line-height: 1.2;
  opacity: .7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#overview .rank-metric-value {
  display: block;
  font-size: .82rem;
  line-height: 1.25;
  font-weight: 600;
  word-break: break-word;
}

/* 🔥 Bewertungstext (Spalte K) */
#overview .rank-text {
  font-size: var(--overview-k-font-size, .75rem);
  opacity: 0.6;
  margin-top: 8px;
  line-height: 1.35;
  word-break: break-word;
}

/* ===============================
   CENTER LOGO
   =============================== */

#logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 60vh;
}

#logo-container img {
  max-width: 250px;
  width: 100%;
  height: auto;
  opacity: 0.9;
}

/* ===============================
   MOBILE OPTIMIERUNG
   =============================== */

@media (max-width: 600px) {

  .controls {
    padding: .5rem;
    gap: .4rem;
  }

  .controls input,
  .controls select {
    padding: .5rem;
    font-size: .9rem;
  }

  #overview .k-font-control {
    gap: .25rem;
  }

  #overview .k-font-control label {
    font-size: .72rem;
  }

  #overview .k-font-control input[type="range"] {
    width: 72px;
  }

  #overview .k-font-control span {
    font-size: .68rem;
    min-width: 34px;
  }

  main {
    padding: .6rem;
  }

  #overview .ranking-row {
    padding: .6rem .5rem;
    gap: .6rem;
  }

  #overview .rank-name {
    font-size: .95rem;
  }

  #overview .rank-total-points {
    font-size: .75rem;
  }

  #overview .rank-metrics-row {
    grid-template-columns: repeat(auto-fit, minmax(75px, 1fr));
    gap: .35rem;
    margin-top: 5px;
  }

  #overview .rank-metric {
    padding: .2rem .3rem;
  }

  #overview .rank-metric-label {
    font-size: .6rem;
  }

  #overview .rank-metric-value {
    font-size: .72rem;
  }

  #overview .rank-number {
    min-width: 1.6rem;
    font-size: .9rem;
  }

  #logo-container {
    height: 40vh;
  }

  #logo-container img {
    max-width: 180px;
  }
}

/* ===============================
   LOADING OVERLAY
   =============================== */

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(244, 244, 244, 0.85);
  display: none; /* 🔥 standardmäßig aus */
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#loading-overlay.active {
  display: flex; /* 🔥 nur wenn aktiv sichtbar */
}

.loader {
  width: 42px;
  height: 42px;
  border: 4px solid #ddd;
  border-top: 4px solid #444;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
