* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #f6f8fb 0%, #e8eef7 100%);
  margin: 0;
  padding: 20px;
  color: #1a2332;
  min-height: 100vh;
}

.container { max-width: 950px; margin: 0 auto; }

header { text-align: center; padding: 24px 0 8px; }
h1 { font-size: 2.4rem; margin: 0 0 16px; color: #c0392b; }
.subtitle { color: #5a6577; margin: 0; }

.tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0 0 20px;
  flex-wrap: wrap;
}
.tab {
  background: white;
  color: #5a6577;
  border: 1px solid #d0d8e2;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover:not(.active) { background: #f0f4fa; color: #2c3e50; }
.tab.active {
  background: #c0392b;
  color: white;
  border-color: #c0392b;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

h2 { margin: 0 0 16px; font-size: 1.3rem; color: #2c3e50; }

.upload-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.upload-grid.file-row { grid-template-columns: 3fr 1fr; }

input[type="text"], input[type="number"], select {
  padding: 12px 14px;
  border: 1px solid #d0d8e2;
  border-radius: 8px;
  font-size: 1rem;
  background: white;
}

input[type="file"] {
  padding: 10px;
  border: 1px dashed #b0bccb;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fafbfd;
}

button {
  background: #c0392b;
  color: white;
  border: none;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover:not(:disabled) { background: #a83224; }
button:disabled { background: #b0bccb; cursor: not-allowed; }

.year-block {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.year-title {
  margin: 0 0 16px;
  font-size: 1.5rem;
  color: #2c3e50;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e8eef7;
}

.year-count {
  font-size: 0.85rem;
  color: #7a8595;
  font-weight: 400;
}

.details-year-header {
  margin: 30px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e8eef7;
  font-size: 1.2rem;
  color: #2c3e50;
}
.details-year-header:first-child { margin-top: 0; }

.status { margin-top: 12px; font-size: 0.9rem; color: #5a6577; min-height: 20px; }
.status.error { color: #c0392b; }
.status.success { color: #27ae60; }

.hidden { display: none; }

.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 12px;
  margin: 30px 0;
}

.podium-place {
  flex: 1;
  max-width: 200px;
  background: linear-gradient(180deg, #fff 0%, #f0f4fa 100%);
  border-radius: 12px 12px 0 0;
  text-align: center;
  padding: 20px 14px 16px;
  border: 2px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.podium-place.first {
  border-color: #f1c40f;
  min-height: 240px;
  order: 2;
  background: linear-gradient(180deg, #fff7d6 0%, #f1c40f22 100%);
}
.podium-place.second { border-color: #95a5a6; min-height: 210px; order: 1; }
.podium-place.third { border-color: #cd853f; min-height: 190px; order: 3; }

.podium-medal { font-size: 2.2rem; line-height: 1; }
.podium-name { font-weight: 600; font-size: 1.05rem; margin-top: 4px; }
.podium-score { font-size: 1.6rem; font-weight: 700; color: #c0392b; line-height: 1.1; }
.podium-bioage { margin-top: 6px; }
.podium-meta { font-size: 0.7rem; color: #7a8595; margin-top: auto; padding-top: 4px; }

.bioage {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 10px;
  background: #ecf0f5;
  color: #5a6577;
  white-space: nowrap;
  line-height: 1.4;
}
.bioage.younger { background: #d4f5e0; color: #1e7e3e; font-weight: 600; }
.bioage.older { background: #fde3d4; color: #b85c1a; font-weight: 600; }

.ranking-list { display: flex; flex-direction: column; gap: 8px; }

.ranking-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fafbfd;
  border-radius: 10px;
  border-left: 4px solid #c0392b;
  cursor: pointer;
  transition: background 0.15s;
}
.ranking-row:hover { background: #f0f4fa; }
.ranking-position { font-weight: 700; font-size: 1.2rem; color: #5a6577; width: 32px; }
.ranking-name { flex: 1; font-weight: 600; }
.ranking-meta { font-size: 0.8rem; color: #7a8595; }
.ranking-score { font-weight: 700; font-size: 1.3rem; color: #c0392b; min-width: 60px; text-align: right; }

.coverage-badge {
  display: inline-block;
  font-size: 0.7rem;
  background: #e8eef7;
  color: #5a6577;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  font-weight: 500;
}
.coverage-badge.low { background: #fff3cd; color: #856404; }

.score-bar {
  flex: 2;
  max-width: 220px;
  height: 8px;
  background: #e8eef7;
  border-radius: 4px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #e74c3c 0%, #f39c12 50%, #27ae60 100%);
  border-radius: 4px;
}

.person-detail {
  margin-bottom: 24px;
  padding: 16px;
  background: #fafbfd;
  border-radius: 10px;
}

.person-detail h3 {
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.person-detail h3 .total { font-size: 1.5rem; color: #c0392b; }
.person-detail .meta { font-size: 0.85rem; color: #5a6577; font-weight: 400; }

.alerts-banner {
  background: #fdf2f2;
  border: 1px solid #f5c2c7;
  border-left: 4px solid #c0392b;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.alerts-banner-title {
  font-weight: 700;
  color: #842029;
  margin-bottom: 6px;
  font-size: 0.95rem;
}
.alerts-banner-list { margin: 0; padding-left: 18px; color: #842029; font-size: 0.88rem; }
.alerts-banner-list li { margin: 3px 0; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid #e8eef7;
  font-size: 0.92rem;
}
th { background: #f0f4fa; font-weight: 600; color: #5a6577; }

.status-ok { color: #27ae60; font-weight: 600; }
.status-low, .status-high { color: #e67e22; font-weight: 600; }
tr.critical { background: #fff5f5; }
tr.critical .status-low, tr.critical .status-high { color: #c0392b; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #d0d8e2;
  border-top-color: #c0392b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .upload-grid { grid-template-columns: 1fr 1fr; }
  .upload-grid.file-row { grid-template-columns: 1fr; }
}

/* ============ OLIMPÍADAS ============ */

.olympics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.olympics-title h2 {
  margin: 0 0 6px;
  font-size: 1.5rem;
}

.olympics-meta {
  font-size: 0.9rem;
  color: #5a6577;
}

.prize-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.prize-chip {
  background: linear-gradient(180deg, #fff7d6 0%, #f1c40f33 100%);
  border: 1px solid #f1c40f;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #7a5c00;
}

.medal-table {
  width: 100%;
  border-collapse: collapse;
}

.medal-table th, .medal-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #e8eef7;
}

.medal-table th {
  background: #f0f4fa;
  font-weight: 600;
  font-size: 0.85rem;
  color: #5a6577;
}

.medal-table .position { font-size: 1.4rem; width: 50px; }
.medal-table .name { font-weight: 600; font-size: 1.05rem; }
.medal-table .points {
  font-weight: 700;
  color: #c0392b;
  font-size: 1.2rem;
}
.medal-table .medals { font-size: 0.85rem; color: #5a6577; }
.medal-table .completed { font-size: 0.85rem; color: #7a8595; }

.medal-table tr.medal-first {
  background: linear-gradient(90deg, #fff7d6 0%, transparent 100%);
}
.medal-table tr.medal-second {
  background: linear-gradient(90deg, #e8eef7 0%, transparent 100%);
}

.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.event-card {
  background: #fafbfd;
  border: 1px solid #e8eef7;
  border-radius: 10px;
  padding: 14px;
}

.event-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e8eef7;
}

.event-emoji { font-size: 1.8rem; line-height: 1; }
.event-name { font-weight: 600; font-size: 1rem; }
.event-unit { font-size: 0.75rem; color: #7a8595; margin-top: 2px; }

.event-table {
  width: 100%;
  border-collapse: collapse;
}

.event-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #f0f4fa;
  font-size: 0.92rem;
}

.event-table tr:last-child td { border-bottom: none; }

.event-position { width: 36px; font-size: 1.1rem; text-align: center; }
.event-participant { font-weight: 500; }
.event-points {
  text-align: right;
  font-size: 0.78rem;
  color: #7a8595;
  font-weight: 600;
  width: 50px;
}

.event-table tr.event-first { background: #fff7d6; }
.event-table tr.event-first .event-participant { font-weight: 700; }

.result-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #d0d8e2;
  border-radius: 6px;
  font-size: 0.9rem;
  background: white;
}

.result-input:focus { outline: 2px solid #c0392b; outline-offset: -1px; }
.result-input.input-error { border-color: #c0392b; background: #fff5f5; }
