/* -------------------------------------------------------------
   Stand Terpel GT Premium / Mobil Delvac
   Panel de administracion

   Mismos tokens que el admin de Terpel Gira (enterprise white +
   rojo de marca) para que los dos paneles se sientan del mismo
   sistema. Prefijo tg- igual que allá.
   ------------------------------------------------------------- */

:root {
    --white: #FFFFFF;
    --fill: #EEF1F5;
    --fill-2: #E4E9EF;
    --ink: #0B1220;
    --ink-2: #1E293B;
    --muted: #475569;
    --muted-2: #64748B;
    --line: #E2E8F0;
    --line-2: #CBD5E1;

    --brand: #E30613;
    --brand-d: #B7050F;

    --ok: #059669;
    --danger: #DC2626;
    --warn: #D97706;

    --r: 12px;
    --shadow: 0 1px 2px rgba(11, 18, 32, .04), 0 4px 12px rgba(11, 18, 32, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    color: var(--ink);
    background: var(--fill);
    -webkit-font-smoothing: antialiased;
    letter-spacing: -.005em;
    /* Terpel Sans no está en este proyecto; si se copian los woff2 se
       antepone aquí y el panel queda idéntico al de Gira. */
    font-family: 'Terpel Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Barra superior ---------------- */
.tg-top {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    padding: 0 24px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.tg-top-marca {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.tg-top-marca::before {
    content: '';
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--brand);
}
.tg-top-nav { display: flex; gap: 4px; margin-left: 12px; }
.tg-top-nav a {
    color: var(--muted);
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
}
.tg-top-nav a:hover { background: var(--fill); color: var(--ink); text-decoration: none; }
.tg-top-nav a.activo { background: var(--ink); color: var(--white); }
.tg-top-evento { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.tg-top-evento select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13.5px; max-width: 260px; background: var(--white);
}
.tg-top-evento + .tg-top-user { margin-left: 14px; }
.tg-top-user { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 14px; }
.tg-rol {
    font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 3px 8px; border-radius: 999px; background: var(--fill-2); color: var(--muted);
}
.tg-rol.super { background: #FEE2E2; color: var(--brand-d); }

/* ---------------- Contenedor ---------------- */
.tg-wrap { max-width: 1240px; margin: 0 auto; padding: 28px 24px 60px; }

.tg-h1 {
    font-size: 26px; font-weight: 700; margin: 0 0 4px;
    letter-spacing: -.02em;
}
.tg-sub { color: var(--muted); margin: 0 0 26px; }

/* ---------------- Tarjetas de metrica ---------------- */
.tg-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.tg-stat {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.tg-stat-val { font-size: 32px; font-weight: 700; line-height: 1.1; letter-spacing: -.03em; }
.tg-stat-lbl {
    font-size: 11px; font-weight: 600; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted-2); margin-top: 6px;
}
.tg-stat.acento .tg-stat-val { color: var(--brand); }
.tg-stat.ok .tg-stat-val { color: var(--ok); }
.tg-stat.warn .tg-stat-val { color: var(--warn); }

/* ---------------- Paneles ---------------- */
.tg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .tg-grid { grid-template-columns: 1fr; } }

.tg-panel {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}
.tg-panel-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 12px;
}
.tg-panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.tg-panel-head .tg-cta { margin-left: auto; }
.tg-panel-body { padding: 20px; }
.tg-empty { padding: 40px 20px; text-align: center; color: var(--muted-2); }

/* ---------------- Tabla ---------------- */

/* Envoltorio para tablas anchas.
   .tg-panel lleva overflow:hidden (lo necesita para que el borde
   redondeado recorte la primera fila). El efecto secundario es que una
   tabla mas ancha que el panel no se corta con scroll: se RECORTA, y las
   ultimas columnas -Tiempo y Puntaje- desaparecen sin aviso.
   Con este envoltorio la tabla scrollea dentro de su panel y la pagina
   nunca se mueve de lado. */
.tg-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* La barra solo aparece cuando hace falta, y discreta. */
.tg-scroll-x::-webkit-scrollbar { height: 9px; }
.tg-scroll-x::-webkit-scrollbar-thumb {
    background: var(--line-2); border-radius: 999px;
}
.tg-scroll-x::-webkit-scrollbar-track { background: var(--fill); }

.tg-tabla { width: 100%; border-collapse: collapse; font-size: 14px; }

/* Variante para la tabla de participantes, que llega a 10 columnas.
   Menos aire lateral es lo que evita el scroll en un portatil de 1366. */
.tg-tabla.compacta th,
.tg-tabla.compacta td { padding-left: 12px; padding-right: 12px; }
.tg-tabla.compacta { font-size: 13.5px; }

/* Las dos fechas en dos lineas ocupan la mitad de ancho que en una. */
.tg-fecha { white-space: nowrap; line-height: 1.35; }
.tg-fecha .hora { display: block; font-size: 12px; color: var(--muted-2); }
.tg-tabla th {
    text-align: left; padding: 11px 20px;
    font-size: 11px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted-2);
    background: var(--fill); border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.tg-tabla td { padding: 12px 20px; border-bottom: 1px solid var(--line); }
.tg-tabla tr:last-child td { border-bottom: 0; }
.tg-tabla tr:hover td { background: #FAFBFC; }
.tg-num { font-variant-numeric: tabular-nums; text-align: right; }
.tg-pos {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 8px;
    background: var(--fill-2); font-weight: 700; font-size: 13px;
}
.tg-pos.oro { background: #FEF3C7; color: #92400E; }

/* ---------------- Barra de borrado ----------------
   Va arriba Y abajo de la tabla. Con 25 filas por pagina, un boton que
   solo existe al final obliga a recorrer toda la lista para encontrarlo,
   y con prisa parece que la funcion no existe. */
.tg-barra-borrar {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: #FEFCFC;
}
.tg-barra-borrar.abajo { border-bottom: 0; border-top: 1px solid var(--line); }
.tg-barra-borrar span { color: var(--muted-2); font-size: 13px; }

/* ---------------- Ficha del participante ---------------- */
/* Encabezado de fila, para tablas de "etiqueta: valor". */
.tg-th-fila {
    width: 150px; text-align: left !important;
    background: var(--fill) !important; color: var(--muted-2);
}
.tg-fuerte { font-weight: 700; }
.tg-tenue  { color: var(--muted-2); font-size: 12.5px; }
.tg-linea-premio { margin-top: 6px; font-size: 13px; }

/* ---------------- Etiquetas ---------------- */
.tg-tag {
    display: inline-block; padding: 3px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    background: var(--fill-2); color: var(--muted);
}
.tg-tag.ok { background: #D1FAE5; color: #065F46; }
.tg-tag.no { background: #FEE2E2; color: #991B1B; }

/* ---------------- Botones ---------------- */
.tg-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: 10px;
    border: 1px solid var(--line-2); background: var(--white); color: var(--ink);
    font-weight: 600; font-size: 14px; font-family: inherit;
    cursor: pointer; text-decoration: none;
}
.tg-btn:hover { background: var(--fill); text-decoration: none; }
.tg-btn.primario { background: var(--brand); border-color: var(--brand); color: var(--white); }
.tg-btn.primario:hover { background: var(--brand-d); }
.tg-btn.peligro { color: var(--danger); border-color: #FECACA; }
.tg-btn.peligro:hover { background: #FEF2F2; }
.tg-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- Avisos ---------------- */
.tg-aviso {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px 16px; border-radius: 10px; margin-bottom: 20px;
    border: 1px solid var(--line); background: var(--white);
    border-left: 4px solid var(--muted-2);
}
.tg-aviso.ok { border-left-color: var(--ok); background: #F0FDF4; }
.tg-aviso.error { border-left-color: var(--danger); background: #FEF2F2; }
.tg-aviso.warn { border-left-color: var(--warn); background: #FFFBEB; }

/* ---------------- Login ---------------- */
.tg-login {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px; background: var(--fill);
}
.tg-login-caja {
    width: 100%; max-width: 400px;
    background: var(--white); border: 1px solid var(--line);
    border-radius: 16px; box-shadow: var(--shadow); padding: 36px 32px;
}
.tg-login-marca {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 17px; margin-bottom: 4px;
}
.tg-login-marca::before {
    content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--brand);
}
.tg-login-sub { color: var(--muted); font-size: 14px; margin-bottom: 26px; }

.tg-campo { margin-bottom: 16px; }
.tg-campo label {
    display: block; font-size: 13px; font-weight: 600;
    margin-bottom: 6px; color: var(--ink-2);
}
.tg-campo input {
    width: 100%; padding: 11px 13px;
    border: 1px solid var(--line-2); border-radius: 10px;
    font-size: 15px; font-family: inherit; color: var(--ink); background: var(--white);
}
.tg-campo input:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(227, 6, 19, .10);
}
.tg-campo input.codigo {
    letter-spacing: .5em; text-align: center;
    font-size: 22px; font-variant-numeric: tabular-nums;
}
.tg-pie { margin-top: 22px; font-size: 12px; color: var(--muted-2); text-align: center; }

/* Eventos. Van en clases y no en style="": la CSP (style-src 'self')
   bloquea los estilos en linea. */
.tg-btn.chico { padding: 6px 12px; font-size: 13px; }
.tg-acciones { white-space: nowrap; }
.tg-acciones form { display: inline-flex; gap: 6px; }
.tg-separado { margin-top: 20px; }
.tg-form-corto { max-width: 520px; }
.tg-campo label.tg-check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.tg-check input { width: auto; }
.tg-nota { margin-top: 18px; }

/* Elegir evento (pantalla tras el login) */
.tg-elegir {
    width: 100%; max-width: 560px;
    background: var(--white); border: 1px solid var(--line);
    border-radius: 16px; box-shadow: var(--shadow); padding: 36px 32px;
}
.tg-elegir-lista { display: flex; flex-direction: column; gap: 10px; }
.tg-elegir-evento {
    display: flex; flex-direction: column; gap: 6px;
    padding: 16px 18px; border: 1px solid var(--line-2); border-radius: 12px;
    color: var(--ink); background: var(--white);
}
.tg-elegir-evento:hover { border-color: var(--brand); text-decoration: none; background: #FFF7F7; }
.tg-elegir-evento.actual { border-color: var(--ink); }
.tg-elegir-evento.cerrado { background: var(--fill); }
.tg-elegir-nombre { font-weight: 700; font-size: 16px; }
.tg-elegir-datos { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
