/* ---------- Match History: KPIs, filtros y tarjetas de partida (acordeón) ----------
   Victoria = lima, derrota = coral, y siempre con la palabra escrita: el color nunca va solo. */
#tab-history {
  --mh-win: var(--pz-jg);
  --mh-loss: var(--pz-top);
  --mh-win-bg: rgba(155, 229, 100, 0.045);
  --mh-loss-bg: rgba(255, 122, 89, 0.05);
  --mh-border: var(--pz-line-strong);
  --mh-gold: var(--pz-chalk);
  --mh-card-bg: var(--pz-glass-2);
}

/* KPIs: una sola franja con celdas separadas por filetes (no cinco tarjetas sueltas) */
.mh-kpis {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 14px;
  background: var(--pz-glass-2);
  border: 1px solid var(--pz-line-strong);
  border-radius: var(--pz-radius-lg);
  overflow: hidden;
}
@media (max-width: 900px) { .mh-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mh-kpi { display: flex; flex-direction: column; gap: 6px; padding: 18px 22px; border-left: 1px solid var(--pz-line-strong); }
.mh-kpi:first-child { border-left: 0; }
.mh-kpi-label { font-size: 13px; font-weight: 600; color: var(--pz-chalk-dim); display: inline-flex; align-items: center; gap: 8px; }
.mh-kpi-blue .mh-kpi-label::before, .mh-kpi-red .mh-kpi-label::before { content: ""; width: 10px; height: 10px; border-radius: 2px; }
.mh-kpi-blue .mh-kpi-label::before { background: var(--pz-mid); }
.mh-kpi-red .mh-kpi-label::before { background: var(--pz-top); }
.mh-kpi-value { font-size: 34px; font-weight: 700; font-stretch: 75%; line-height: 1.05; color: var(--pz-chalk); background: none; -webkit-text-fill-color: currentColor; }
.mh-kpi-value small { font-size: 14px; font-weight: 500; font-stretch: 100%; color: var(--pz-chalk-dim); -webkit-text-fill-color: var(--pz-chalk-dim); margin-left: 4px; }

/* Gráficos plegados */
details.mh-charts { margin-bottom: 14px; }
details.mh-charts > summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px;
  color: var(--pz-chalk); font-size: 14px; font-weight: 600; padding: 4px 0 12px;
}
details.mh-charts > summary::-webkit-details-marker { display: none; }
details.mh-charts > summary::before {
  content: ""; width: 8px; height: 8px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .2s var(--pz-ease);
}
details.mh-charts[open] > summary::before { transform: rotate(45deg); }

/* Filtros en una sola línea */
.mh-filters {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  padding: 16px 20px; margin-bottom: 16px;
  background: var(--pz-glass-2);
  border: 1px solid var(--pz-line-strong); border-radius: var(--pz-radius-lg);
}
.mh-filter { display: flex; flex-direction: column; gap: 6px; min-width: 160px; flex: 1 1 160px; }
.mh-filter label { font-size: 13px; font-weight: 600; color: var(--pz-chalk-dim); }
.mh-filter select, .mh-filter input {
  background-color: var(--pz-glass); color: var(--pz-chalk);
  border: 1px solid var(--pz-line-strong); border-radius: var(--pz-radius);
  padding: 10px 12px; font: 400 14px/1.3 var(--pz-font); width: 100%;
  transition: border-color .15s ease;
}
.mh-filter select { padding-right: 34px; }
.mh-filter input::placeholder { color: var(--pz-chalk-faint); }
.mh-filter select:hover, .mh-filter input:hover { border-color: var(--pz-chalk-faint); }
.mh-filter select:focus, .mh-filter input:focus { outline: none; border-color: var(--pz-focus); box-shadow: 0 0 0 1px var(--pz-focus); }
.mh-count { margin-left: auto; align-self: center; font-size: 14px; color: var(--pz-chalk-dim); white-space: nowrap; }

/* Tarjeta de partida */
.mh-list { display: flex; flex-direction: column; gap: 10px; }
.match-card {
  background: var(--mh-card-bg);
  border: 1px solid var(--pz-line-strong);
  border-radius: var(--pz-radius-lg);
  overflow: hidden;
  transition: border-color .15s ease, background-color .15s ease;
}
.match-card.win { background: linear-gradient(var(--mh-win-bg), var(--mh-win-bg)), var(--mh-card-bg); }
.match-card.loss { background: linear-gradient(var(--mh-loss-bg), var(--mh-loss-bg)), var(--mh-card-bg); }
.match-card:hover { border-color: var(--pz-chalk-faint); }
.match-card.open { border-color: var(--pz-chalk-dim); }

.mc-head {
  display: grid;
  grid-template-columns: 150px minmax(170px, 230px) minmax(0, 1fr) 250px 96px;
  align-items: center; gap: 20px;
  padding: 16px 20px; cursor: pointer;
}
.mc-head:focus-visible { outline: 2px solid var(--pz-focus); outline-offset: -3px; }

/* Col 1: estado = marca + palabra */
.mc-status { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mc-result { font-size: 18px; font-weight: 700; font-stretch: 75%; display: inline-flex; align-items: center; gap: 9px; text-transform: none; }
.mc-result::before { content: ""; width: 11px; height: 11px; border-radius: 3px; background: var(--pz-chalk-faint); flex: none; }
.match-card.win .mc-result { color: var(--mh-win); }
.match-card.win .mc-result::before { background: var(--mh-win); }
.match-card.loss .mc-result { color: var(--mh-loss); }
.match-card.loss .mc-result::before { background: var(--mh-loss); }
.match-card.unknown .mc-result { color: var(--pz-chalk-dim); }
.mc-tag {
  align-self: flex-start; font-size: 12px; font-weight: 700;
  padding: 2px 8px; border: 1px solid var(--pz-line-strong); border-radius: 6px; color: var(--pz-chalk-dim);
}
.mc-tag.stage { background: var(--pz-chalk); border-color: var(--pz-chalk); color: var(--pz-glass); }
.mc-meta { font-size: 13px; color: var(--pz-chalk-dim); line-height: 1.5; }

/* Col 2: equipos */
.mc-teams { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mc-team {
  font-size: 17px; font-weight: 700; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: none; -webkit-text-fill-color: currentColor; color: var(--pz-chalk);
}
.mc-team.rival { font-weight: 600; background: none; -webkit-text-fill-color: var(--pz-chalk-dim); color: var(--pz-chalk-dim); }
.mc-vs-word { font-size: 12px; color: var(--pz-chalk-faint); font-weight: 600; }
.mc-side { align-self: flex-start; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; margin-top: 2px; }
.mc-side.blue { background: rgba(76, 201, 240, 0.14); color: var(--pz-mid); }
.mc-side.red { background: rgba(255, 122, 89, 0.14); color: var(--pz-top); }

/* Col 3: composiciones frente a frente */
.mc-comps { display: flex; align-items: center; justify-content: center; gap: 14px; min-width: 0; }
.mc-comp { display: flex; gap: 5px; }
.mc-comp img, .mc-comp .mc-empty {
  width: 42px; height: 42px; border: 1px solid var(--pz-line-strong); border-radius: 8px;
  background: var(--pz-glass); object-fit: cover;
}
.mc-comp.ours img { border-color: var(--pz-chalk-faint); }
.mc-comp img.broken { visibility: hidden; }
.mc-comps .mc-vs { font-size: 12px; font-weight: 700; color: var(--pz-chalk-faint); }

/* Col 4: métricas */
.mc-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.mc-metric .v { font-size: 17px; font-weight: 700; white-space: nowrap; }
.mc-metric .l { font-size: 12px; color: var(--pz-chalk-dim); margin-top: 3px; white-space: nowrap; }

/* Col 5: acciones */
.mc-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.mc-chevron { width: 24px; height: 24px; color: var(--pz-chalk-dim); transition: transform .2s var(--pz-ease), color .15s ease; }
.match-card:hover .mc-chevron, .match-card.open .mc-chevron { color: var(--pz-chalk); }
.match-card.open .mc-chevron { transform: rotate(180deg); }
.mc-note { display: inline-flex; color: var(--pz-chalk-dim); cursor: help; }
.mc-note svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.delete-match-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--pz-radius); color: var(--pz-chalk-dim);
  cursor: pointer; line-height: 1; padding: 8px;
  transition: color .15s, background-color .15s, border-color .15s;
}
.delete-match-btn:hover { color: var(--pz-danger); background: rgba(255, 122, 89, 0.1); border-color: var(--pz-danger); }
/* rol "player": solo lectura, sin acciones destructivas */
body.role-readonly .delete-match-btn { display: none; }

/* Acordeón */
.match-details { border-top: 1px solid var(--pz-line-strong); background: var(--pz-glass); }
.match-details[hidden] { display: none; }
.mc-objectives { padding: 12px 24px 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 16px; }
.mc-obj-title { font-size: 15px; font-weight: 700; color: var(--pz-chalk); margin: 0; white-space: nowrap; }
.mc-obj-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.mc-obj { padding: 6px 6px; background: var(--pz-glass-2); border: 1px solid var(--pz-line-strong); border-radius: 8px; text-align: center; }
.mc-obj .l { font-size: 12px; color: var(--pz-chalk-dim); margin-bottom: 1px; }
.mc-obj .v { font-size: 15px; font-weight: 700; white-space: nowrap; }
.mc-obj .v .blue { color: var(--pz-mid); }
.mc-obj .v .red { color: var(--pz-top); }
.mc-obj .v .sep { color: var(--pz-chalk-faint); font-weight: 400; margin: 0 4px; }

@media (max-width: 1250px) {
  .mc-head { grid-template-columns: 140px minmax(0, 1fr) 230px 90px; }
  .mc-comps { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
}
@media (max-width: 700px) {
  .mc-head { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 14px; }
  .mc-teams, .mc-metrics { grid-column: 1 / -1; }
  .mc-comps { grid-row: auto; flex-wrap: wrap; }
  .mc-actions { grid-column: 2; grid-row: 1; }
  .mc-comp img, .mc-comp .mc-empty { width: 32px; height: 32px; }
  .mc-objectives { grid-template-columns: minmax(0, 1fr); }
}
