/* ===== Resultados Reto LABSAG ===== */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f0;
  --text: #0f172a;
  --muted: #64748b;
  --subtle: #94a3b8;
  --brand: #0b5cad;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --gold: #d99a00;
  --silver: #8a97a6;
  --bronze: #b0703c;
  --sidebar-w: 264px;
  --accent: var(--brand);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.material-symbols-rounded {
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  font-variation-settings: "FILL" 0, "wght" 400;
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand { display: block; padding: 4px 10px 20px; }
.brand img { display: block; width: 100%; max-width: 180px; height: auto; }

.sidebar-label {
  margin: 8px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--subtle);
}

.sim-nav { display: flex; flex-direction: column; gap: 2px; }

.sim-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 14px;
  color: #334155;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.sim-link:hover { background: var(--surface-2); color: var(--text); }

.sim-link.active {
  background: color-mix(in srgb, var(--accent) 10%, white);
  color: var(--accent);
  font-weight: 600;
}

.sim-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, white);
}

.sim-link.active .sim-icon { background: var(--accent); color: #fff; }

.sim-icon.lg { width: 48px; height: 48px; border-radius: 12px; background: var(--accent); color: #fff; }
.sim-icon.lg .material-symbols-rounded { font-size: 26px; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-footer a {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}

.sidebar-footer a:hover { color: var(--text); background: var(--surface-2); }

.main {
  padding: 40px clamp(16px, 4vw, 48px) 32px;
  max-width: 1440px;
  width: 100%;
}

/* ---------- Hero ---------- */

.hero { margin-bottom: 28px; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  background: #fff7e0;
  color: #9a6b00;
  font-size: 13px;
  font-weight: 600;
}

.eyebrow .material-symbols-rounded { font-size: 18px; font-variation-settings: "FILL" 1; }

.hero h1 {
  margin: 14px 0 6px;
  font-size: clamp(28px, 3.4vw, 38px);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -.02em;
}

.hero p { margin: 0; max-width: 680px; color: var(--muted); }

/* Encabezado principal dentro de la pastilla (h1 con la edición) */
.eyebrow:has(h1) { gap: 10px; padding: 8px 20px 8px 12px; }
.eyebrow:has(h1) .material-symbols-rounded { font-size: clamp(24px, 2.6vw, 30px); }
.hero .eyebrow h1 {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -.01em;
  color: inherit;
}

.hero h2 {
  margin: 16px 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ---------- Simulator section ---------- */

.sim {
  margin-bottom: 32px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scroll-margin-top: 24px;
}

.js .sim:not(.active) { display: none; }

.sim-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.sim-title { display: flex; align-items: center; gap: 14px; }

.sim-kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sim-title h2 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.01em; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: #eef1f6;
  border-radius: 11px;
}

.seg {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}

.seg:hover { color: var(--text); }

.seg.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}

.seg .count {
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, white);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.seg .count:empty { display: none; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  min-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--subtle);
  transition: border-color .15s, box-shadow .15s;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--text);
}

.panel-title { margin: 0 0 12px; font-size: 16px; font-weight: 600; }

.panel + .panel { margin-top: 28px; }

.js .panel-title { display: none; }
.js .panel:not(.active) { display: none; }
.js .panel + .panel { margin-top: 0; }

/* ---------- Podium ---------- */

.podium {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.podium:empty { display: none; }

.prize {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}

.prize::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--medal);
}

.prize.gold   { --medal: var(--gold);   background: #fffaeb; }
.prize.silver { --medal: var(--silver); background: #f5f7fa; }
.prize.bronze { --medal: var(--bronze); background: #fbf4ee; }

.medal {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--medal);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}

.prize-body { min-width: 0; }

.prize-place {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.prize-name { margin: 2px 0 0; font-weight: 700; font-size: 15px; line-height: 1.3; }

.prize-meta { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- Tables ---------- */

.table-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table-scroll {
  max-height: 70vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.table-scroll th,
.table-scroll td {
  width: auto;
  height: auto;
  padding: 10px 14px;
  white-space: nowrap;
  text-align: right !important;
  border-bottom: 1px solid #eef1f5;
  vertical-align: middle;
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--accent);
}

/* #, Industria, Firma y Ganadores alineados a la izquierda */
.table-scroll th:nth-child(-n+3),
.table-scroll td:nth-child(-n+3),
.table-scroll th:last-child,
.table-scroll td:last-child { text-align: left !important; }

.table-scroll td:first-child,
.table-scroll th:first-child { width: 48px; color: var(--subtle); font-weight: 500; }

.table-scroll td:nth-child(2) { font-weight: 600; }

.table-scroll td:nth-child(3) { color: #334155; }

.table-scroll tbody tr { transition: background .12s; }
.table-scroll tbody tr:nth-child(even) td { background: #fbfcfe; }
.table-scroll tbody tr:hover td { background: color-mix(in srgb, var(--accent) 6%, white); }
.table-scroll tbody tr:last-child td { border-bottom: 0; }

/* Fila del período con mejor resultado final */
.table-scroll td.last-period { font-weight: 700; color: var(--text); }

.table-scroll tr.is-gold td   { background: #fffaeb !important; }
.table-scroll tr.is-silver td { background: #f5f7fa !important; }
.table-scroll tr.is-bronze td { background: #fbf4ee !important; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.badge.gold   { background: #fdefc4; color: #8a6100; }
.badge.silver { background: #e6eaf0; color: #4b5866; }
.badge.bronze { background: #f4e1d2; color: #84501f; }
.badge.honor  { background: #e7f0fb; color: #1d5a99; }
.badge.none   { background: #f1f5f9; color: var(--muted); }
.badge.none::before { display: none; }

.empty { margin: 0; padding: 28px; text-align: center; color: var(--muted); }

/* ---------- Teams ---------- */

.teams { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.teams-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-weight: 600;
  font-size: 14px;
}

.teams-title .material-symbols-rounded { color: var(--accent); }

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}

.chip .material-symbols-rounded { font-size: 15px; color: var(--subtle); }

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, white);
}

.chip:hover .material-symbols-rounded { color: var(--accent); }

/* Participantes por industria (desde la base de datos) */
.industrias {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  align-items: start;
}

.industria {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}

.industria[open] {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 2px 10px rgba(15, 23, 42, .06);
}

.industria summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.industria summary::-webkit-details-marker { display: none; }
.industria summary:hover { background: var(--surface-2); }

.industria-nombre { font-weight: 600; font-size: 14px; }

.industria-count {
  padding: 1px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, white);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.industria .chevron { margin-left: auto; color: var(--subtle); transition: transform .15s; }
.industria[open] .chevron { transform: rotate(180deg); color: var(--accent); }

.participantes {
  margin: 0;
  padding: 4px 0 6px;
  list-style: none;
  border-top: 1px solid var(--border);
}

.participantes li {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 14px;
  font-size: 13.5px;
}

.participantes li:nth-child(even) { background: #fbfcfe; }

.p-firma { color: var(--muted); font-weight: 500; white-space: nowrap; }
/* En la base los nombres están en minúsculas */
.p-nombre { color: var(--text); overflow-wrap: anywhere; text-transform: capitalize; }

.participantes-vacio {
  margin: 0;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.footer { padding: 8px 0 0; font-size: 13px; color: var(--subtle); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(15, 23, 42, .05);
  }

  .brand { padding: 0; flex: none; }
  .brand img { width: 96px; }

  .sidebar-label, .sidebar-footer { display: none; }

  .sim-nav {
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sim-nav::-webkit-scrollbar { display: none; }

  .sim-link { flex: none; padding: 7px 10px; gap: 8px; font-size: 13px; }
  .sim-link .sim-icon { width: 26px; height: 26px; }
  .sim-link .sim-icon .material-symbols-rounded { font-size: 17px; }

  .main { padding-top: 24px; }
  .sim { scroll-margin-top: 80px; }
}

@media (max-width: 640px) {
  .sim { padding: 16px; border-radius: 12px; }
  .toolbar, .segmented, .search { width: 100%; }
  .seg { flex: 1; padding: 8px 6px; }
  .search { min-width: 0; }
  .table-scroll th, .table-scroll td { padding: 9px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
