:root {
  --primary: #0b6e4f;
  --primary-dark: #08523b;
  --bg: #f2f5f4;
  --card: #ffffff;
  --text: #1c2b26;
  --muted: #5f6f69;
  --error: #c0392b;
  --border: #cfd8d4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

.contenedor {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.contenedor.ancho { max-width: 1400px; }

h1 { font-size: 1.5rem; margin: 8px 0 4px; color: var(--primary-dark); }
.sub { color: var(--muted); margin: 0 0 18px; }

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
}

label { display: block; font-weight: 600; margin: 14px 0 6px; }

input, select {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

button, .btn {
  display: inline-block;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}

button:hover { background: var(--primary-dark); }
button:disabled { opacity: .6; cursor: wait; }
button.secundario { background: #fff; color: var(--primary-dark); border: 1px solid var(--primary); }
button.secundario:hover { background: #e8f1ee; }
button.peligro { background: var(--error); padding: 6px 10px; font-size: .85rem; }

form button[type="submit"] { width: 100%; margin-top: 20px; }

.oculto { display: none !important; }

.mensaje { margin-top: 14px; padding: 12px; border-radius: 8px; font-weight: 600; }
.mensaje.error { background: #fdecea; color: var(--error); }
.mensaje.ok { background: #e6f4ee; color: var(--primary-dark); }

.exito { text-align: center; padding: 20px 0; }
.exito .check { font-size: 3rem; }

.barra { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.barra input { flex: 1; min-width: 180px; }
.barra button { width: auto; }

.resumen { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { background: #e8f1ee; border-radius: 999px; padding: 6px 12px; font-size: .9rem; }
.chip b { color: var(--primary-dark); }

.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); overflow-wrap: break-word; }
td.nw, th.nw { white-space: nowrap; }
th { background: #e8f1ee; position: sticky; top: 0; }

/* Consulta de puesto */
.puesto-resultado { text-align: center; font-size: 1.1rem; }
.puesto-num { font-size: 4.5rem; font-weight: 800; line-height: 1.1; color: var(--primary-dark); margin-top: 6px; }
#resultado { margin-top: 18px; }

/* Grupos en admin */
.grupos { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 16px; background: #fafcfb; }
.grupos h2 { margin: 0 0 10px; font-size: 1.1rem; color: var(--primary-dark); }
.grupos-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.grupos-form label { margin: 0 0 4px; font-size: .9rem; }
.grupos-form .campo { min-width: 140px; }
.grupos-form input, .grupos-form select { width: 100%; }
.grupos-form button { width: auto; }
.grupos-estado { margin: 10px 0 0; color: var(--muted); font-size: .92rem; }
.chip.puesto { background: #dbeee6; }
select.filtro { width: auto; min-width: 150px; }

/* Total de registrados */
.total-box { display: flex; align-items: baseline; gap: 12px; background: var(--primary); color: #fff; border-radius: 12px; padding: 14px 20px; margin-bottom: 16px; }
.total-num { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.total-label { font-size: 1.05rem; }

/* Edición en admin */
td.acciones { white-space: nowrap; }
td.acciones button { padding: 6px 10px; font-size: .85rem; margin-right: 6px; }
td.aviso { color: var(--error); font-weight: 600; }
tr.editando td { background: #fffbe6; }
input.ed, select.ed { padding: 6px 8px; font-size: .9rem; min-width: 70px; width: 100%; }

/* Asignación manual */
.ayuda { margin: 0 0 10px; color: var(--muted); font-size: .92rem; }
.chip.puesto.excede { background: #fdecea; color: var(--error); font-weight: 600; }
select.sel-puesto { width: auto; min-width: 64px; padding: 6px 8px; font-size: .95rem; }
select.sel-puesto:disabled { opacity: .5; }
details.auto { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
details.auto summary { cursor: pointer; font-weight: 600; color: var(--primary-dark); margin-bottom: 8px; }

/* Pestañas del admin */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; margin-bottom: -1px; position: relative; z-index: 1; }
.tab { background: #dfe8e4; color: var(--primary-dark); border: 1px solid var(--border); border-bottom: none; border-radius: 10px 10px 0 0; padding: 10px 16px; font-weight: 600; }
.tab:hover { background: #cfe0d9; }
.tab.activa { background: var(--card); color: var(--primary-dark); box-shadow: 0 -2px 0 var(--primary) inset; }
.tabs-der { margin-left: auto; display: flex; gap: 8px; padding-bottom: 4px; }
.tabs-der button { padding: 6px 12px; font-size: .9rem; }

/* Tablet: tabla más compacta para evitar el scroll horizontal */
@media (max-width: 900px) {
  .contenedor.ancho { padding-left: 10px; padding-right: 10px; }
  table { font-size: .88rem; }
  th, td { padding: 6px 5px; }
  td.acciones button { padding: 5px 8px; margin-right: 4px; }
}

/* Celular: cada fila de participantes se muestra como una tarjeta */
@media (max-width: 640px) {
  .card { padding: 12px; }
  #tab-participantes table, #tab-participantes tbody, #tab-participantes tr, #tab-participantes td { display: block; width: 100%; }
  #tab-participantes thead { display: none; }
  #tab-participantes tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; padding: 6px 10px; background: #fff; }
  #tab-participantes tr.editando { background: #fffbe6; }
  #tab-participantes td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px dashed var(--border); padding: 6px 0; text-align: right; }
  #tab-participantes td:last-child { border-bottom: none; }
  #tab-participantes td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; flex: 0 0 auto; }
  #tab-participantes td.acciones { justify-content: flex-end; white-space: normal; }
  #tab-participantes td.acciones::before { content: none; }
  #tab-participantes td.acciones button { margin: 0 0 0 6px; }
  #tab-participantes input.ed, #tab-participantes select.ed { width: 62%; }
}

/* Verificación de inscripción */
.nombre-verificado { font-size: 1.6rem; font-weight: 800; color: var(--primary-dark); margin: 8px 0; overflow-wrap: break-word; }
