:root {
  --fondo: #f5f5f2;
  --papel: #ffffff;
  --tinta: #1f2328;
  --tenue: #6b7075;
  --linea: #d9dad6;
  --acento: #1d4e89;
  --acento-claro: #e6eef8;
  --peligro: #b3261e;
  --ok: #1e6b3a;
  --aviso: #8a5a00;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, "Segoe UI", Roboto, Arial, sans-serif; background: var(--fondo); color: var(--tinta); }
a { color: var(--acento); }
main { max-width: 1200px; margin: 0 auto; padding: 18px 20px 60px; }
h1 { font-size: 1.5rem; margin: .3em 0 .6em; }
h2 { font-size: 1.15rem; margin: 1.6em 0 .6em; }
.tenue { color: var(--tenue); font-weight: normal; }
code { background: #ecece8; padding: 1px 4px; border-radius: 3px; }

.barra { background: var(--acento); color: #fff; padding: 10px 20px; display: flex; gap: 16px; align-items: baseline; }
.barra .marca { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.torneo-actual { opacity: .85; }
.tabs { background: var(--papel); border-bottom: 1px solid var(--linea); padding: 0 20px; display: flex; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--tinta); border-bottom: 3px solid transparent; }
.tabs a.activo { border-color: var(--acento); color: var(--acento); font-weight: 600; }
.tabs a:hover { background: var(--acento-claro); }

.msg { padding: 10px 14px; border-radius: 6px; margin: 0 0 12px; border: 1px solid; }
.msg.ok { background: #e8f4ec; border-color: #b6dcc3; color: var(--ok); }
.msg.error { background: #fbeaea; border-color: #efc2bf; color: var(--peligro); }
.msg.aviso { background: #fff5dd; border-color: #ecd59a; color: var(--aviso); }

.tabla { border-collapse: collapse; background: var(--papel); width: 100%; margin-bottom: 12px; }
.tabla th, .tabla td { border: 1px solid var(--linea); padding: 5px 8px; text-align: left; vertical-align: middle; }
.tabla th { background: #eceeea; font-weight: 600; white-space: nowrap; }
.tabla tbody tr:nth-child(even) { background: #fafaf8; }
.tabla .num { text-align: right; white-space: nowrap; }
.tabla .centro { text-align: center; }
.tabla tr.retirado td { color: var(--tenue); }
.tabla tr.pendiente { background: #fff8e6 !important; }
.tabla tr.podio td:first-child { font-weight: 700; }
.eq { font-size: .75em; background: var(--acento-claro); color: var(--acento); padding: 1px 5px; border-radius: 3px; }
.ronda-celda small { display: block; font-size: .72em; color: var(--tenue); line-height: 1.1; }
.miembros { font-size: .9em; }
.acciones { white-space: nowrap; }
.acciones form { display: inline; }

input, select, textarea, button { font: inherit; }
input, select, textarea { padding: 5px 7px; border: 1px solid #c4c6c1; border-radius: 4px; background: #fff; }
input.ancho { width: 100%; min-width: 220px; }
input.corto { width: 80px; }
textarea { width: 100%; }
textarea.codigo { font-family: Consolas, monospace; font-size: 13px; white-space: pre; }

.formulario { background: var(--papel); border: 1px solid var(--linea); border-radius: 8px; padding: 14px 16px; display: grid; gap: 10px; max-width: 520px; }
.formulario h2 { margin: 0; }
.formulario label { display: grid; gap: 4px; }
.formulario label.check { display: flex; gap: 8px; align-items: center; }
.formulario small { color: var(--tenue); }
.formulario fieldset { border: 1px solid var(--linea); border-radius: 6px; display: grid; gap: 8px; }
.ancho-form { max-width: 620px; }
.columnas { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.columnas .formulario { max-width: none; align-content: start; }

.btn { display: inline-block; padding: 7px 14px; border: 1px solid #b9bcb6; border-radius: 6px; background: #fff; color: var(--tinta); cursor: pointer; text-decoration: none; }
.btn:hover { background: #f0f0ec; }
.btn.primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn.primario:hover { background: #163d6c; }
.btn.peligro { color: var(--peligro); border-color: #e2b4b0; }
.btn.chico { padding: 3px 9px; font-size: .88em; }
.botones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.botones form { margin: 0; }
.separado { border-top: 1px solid var(--linea); padding-top: 12px; margin-top: 18px; }

.rondas { margin-bottom: 8px; }
.rondas a { display: inline-block; min-width: 30px; text-align: center; padding: 4px 8px; margin-right: 4px; border: 1px solid var(--linea); border-radius: 4px; background: #fff; text-decoration: none; }
.rondas a.activo { background: var(--acento); color: #fff; border-color: var(--acento); }
.nota { font-size: .88em; color: var(--tenue); }

/* ---------- Encabezado ---------- */
.barra .enlaces { margin-left: auto; display: flex; gap: 14px; }
.barra .enlaces a { color: #fff; text-decoration: none; opacity: .9; }
.barra .enlaces a:hover { opacity: 1; text-decoration: underline; }
.formulario .dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tabla.angosta { width: auto; min-width: 420px; }
.cab-print .inst { font-size: 10pt; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- Faltas ---------- */
select.motivo { max-width: 180px; }
.f-hay { color: var(--aviso); font-weight: 700; }
.f-max { color: var(--peligro); font-weight: 700; }
.faltas-celda .btn { min-width: 64px; }
.lado h2 { font-size: 1.05rem; }
.contador { font-size: 2rem; font-weight: 700; line-height: 1; }
.contador small { font-size: .9rem; color: var(--tenue); font-weight: 400; }
.lista-faltas { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.en-linea { display: inline; }
.nota-corr { display: grid; gap: 4px; max-width: 640px; margin: 8px 0; }
.nueva-falta { display: grid; gap: 8px; border-top: 1px solid var(--linea); padding-top: 10px; }
.nueva-falta label { display: grid; gap: 4px; }

/* ---------- Ayuda ---------- */
.ayuda { max-width: 860px; background: var(--papel); border: 1px solid var(--linea); border-radius: 8px; padding: 8px 28px 24px; }
.ayuda h2 { border-bottom: 1px solid var(--linea); padding-bottom: 4px; scroll-margin-top: 12px; }
.ayuda li { margin-bottom: 6px; }
.indice { font-size: .92em; background: var(--acento-claro); padding: 8px 12px; border-radius: 6px; }

/* ---------- Diplomas ---------- */
.diplomas { display: grid; gap: 24px; justify-items: center; }
.diploma {
  --c: #b8932f;                      /* oro */
  width: 279.4mm; height: 215.9mm; background: #fff; position: relative;
  zoom: .55; box-shadow: 0 2px 14px rgba(0,0,0,.18);
  font-family: Georgia, "Times New Roman", serif; color: #1f2a3a;
}
.diploma.lugar-2 { --c: #8e98a4; }   /* plata */
.diploma.lugar-3 { --c: #a8693a; }   /* bronce */
.diploma .marco {
  position: absolute; inset: 12mm; border: 1.6mm solid #1d3d66; outline: .4mm solid var(--c); outline-offset: -4mm;
  display: flex; flex-direction: column; align-items: center; text-align: center; padding: 9mm 22mm 8mm; overflow: hidden;
}
.diploma .marco:focus { outline-style: dashed; }
.caballo { position: absolute; right: 10mm; bottom: -14mm; font-size: 120mm; line-height: 1; color: #1d3d66; opacity: .045; pointer-events: none; }
.d-inst { font-size: 15pt; letter-spacing: .14em; text-transform: uppercase; color: #1d3d66; }
.d-org { font-size: 12pt; color: #5b6573; margin-top: 1mm; }
.medalla { width: 15mm; height: 19.5mm; margin: 3mm 0 1mm; }
.medalla .cinta1 { fill: #1d3d66; } .medalla .cinta2 { fill: #2f5d94; }
.medalla .disco { fill: var(--c); } .medalla .aro { fill: none; stroke: #fff; stroke-width: 2.5; opacity: .7; }
.medalla .num-medalla { font: 700 40px Georgia, serif; fill: #fff; }
.d-otorga, .d-a { font-size: 13pt; font-style: italic; color: #5b6573; }
.d-titulo { font-size: 40pt; line-height: 1.1; letter-spacing: .22em; text-transform: uppercase; color: #1d3d66; margin: 0 0 1mm; padding-left: .22em; }
.d-nombre { font-size: 28pt; line-height: 1.2; font-weight: 700; margin: 1mm 0 0; padding: 0 8mm 2mm; border-bottom: .3mm solid var(--c); }
.d-plantel { font-size: 12.5pt; color: #5b6573; margin-top: 1.5mm; }
.d-texto { font-size: 14.5pt; margin-top: 4mm; line-height: 1.45; }
.d-lugar { color: var(--c); font-size: 19pt; text-transform: uppercase; letter-spacing: .06em; }
.d-detalle { font-size: 11pt; color: #5b6573; margin-top: 2mm; }
.d-fecha { font-size: 12pt; margin-top: 3mm; }
.d-firmas { margin-top: auto; padding-top: 14mm; width: 100%; display: flex; justify-content: space-around; gap: 20mm; }
.firma { width: 75mm; font-size: 11.5pt; }
.firma .linea { border-top: .35mm solid #1f2a3a; margin-bottom: 2mm; }
.firma .f-cargo { font-size: 10pt; color: #5b6573; font-style: italic; }

@page diploma { size: letter landscape; margin: 0; }
@media print {
  .diplomas { display: block; }
  .diploma { zoom: 1; box-shadow: none; page: diploma; break-after: page; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .diploma:last-child { break-after: auto; }
  .diploma .marco { outline-style: solid !important; }
}

.solo-print { display: none; }

@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 11pt; }
  main { padding: 0; max-width: none; }
  .no-print, .no-print * { display: none !important; }
  .solo-print { display: inline; }
  .cab-print { display: block; text-align: center; margin-bottom: 8px; }
  .cab-print h1 { font-size: 15pt; margin: 0; }
  .cab-print h2 { font-size: 12pt; margin: 4px 0 10px; }
  .cab-print p { margin: 2px 0; }
  .tabla th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tabla tbody tr { background: #fff !important; }
  .tabla td, .tabla th { padding: 3px 6px; }
  .eq { background: none; padding: 0; color: #000; }
  .mesas td { height: 2.2em; }
}
