* { box-sizing: border-box; }

:root {
  --azul: #2f5fd6;
  --azul-oscuro: #1f45a8;
  --gris-fondo: #f5f6f9;
  --gris-borde: #e2e4ea;
  --gris-texto: #5a5f6d;
  --texto: #1a1c22;
  --verde: #1d8a4c;
  --verde-fondo: #dff5e6;
  --ambar: #a8710a;
  --ambar-fondo: #fbedcf;
  --rojo: #c8382c;
  --rojo-fondo: #fbe4e1;
  --rojo-borde: #f0b8b2;
  --radio: 10px;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
  font-size: 16px;
  background: var(--gris-fondo);
  color: var(--texto);
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 1rem 5.5rem;
  line-height: 1.4;
}

h1 { font-size: 1.5rem; margin: 0.25rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; color: var(--gris-texto); font-weight: 600; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }

a { color: var(--azul); }

/* --- Navegación: arriba en escritorio/tablet, fija abajo en móvil --- */
nav {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1.5rem;
  background: #fff;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio);
  padding: 0.35rem;
}
nav a {
  flex: 1;
  text-decoration: none;
  color: var(--gris-texto);
  font-weight: 600;
  text-align: center;
  padding: 0.6rem 0.25rem;
  border-radius: 7px;
  font-size: 0.9rem;
}
nav a.activo { background: var(--azul); color: #fff; }

@media (max-width: 767px) {
  body { padding-bottom: 5.5rem; }
  nav {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    margin: 0;
    z-index: 20;
    box-shadow: 0 4px 18px rgba(20, 25, 40, 0.16);
  }
  nav a { padding: 0.65rem 0.25rem; font-size: 0.82rem; }
}

/* --- Formularios y controles --- */
form { margin-bottom: 1rem; }
label { display: block; font-size: 0.85rem; color: var(--gris-texto); margin: 0.6rem 0 0.2rem; font-weight: 600; }

input, select, textarea {
  font-size: 1rem;
  padding: 0.65rem 0.7rem;
  margin: 0.25rem 0;
  width: 100%;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  background: #fff;
  color: var(--texto);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(47, 95, 214, 0.15);
}
input[type="checkbox"], input[type="radio"] { width: auto; }

button {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.7rem 1rem;
  margin: 0.25rem 0;
  width: 100%;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  background: var(--azul);
  color: #fff;
  transition: background-color 0.15s ease;
}
button:hover { background: var(--azul-oscuro); }
button.secundario { background: var(--gris-borde); color: var(--texto); }
button.secundario:hover { background: #d3d6de; }
button.peligro { background: var(--rojo-fondo); color: var(--rojo); border: 1px solid var(--rojo-borde); }
button.peligro:hover { background: var(--rojo-borde); }

.ancho-auto { width: auto; }
.fila { display: flex; gap: 0.5rem; align-items: center; margin: 0; }
.fila > input { margin: 0; }
.acciones { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.acciones form { margin: 0; width: auto; }
.acciones button { width: auto; }

/* --- Tarjetas --- */
.card, .ronda-card {
  background: #fff;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio);
  padding: 1rem 1.1rem;
  margin: 1rem 0;
}
.ronda-head { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.ronda-meta { color: var(--gris-texto); font-size: 0.88rem; margin: 0.4rem 0; }

/* --- Mensajes flash --- */
.flash { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.flash li {
  background: var(--verde-fondo);
  color: var(--verde);
  border: 1px solid #b9e6c8;
  border-radius: var(--radio);
  padding: 0.7rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.92rem;
  font-weight: 600;
}

/* --- Badges de estado --- */
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.badge.ok { background: var(--verde-fondo); color: var(--verde); }
.badge.pendiente { background: var(--ambar-fondo); color: var(--ambar); }

/* --- Tablas: contenedor con scroll horizontal en pantallas estrechas --- */
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0; border: 1px solid var(--gris-borde); border-radius: var(--radio); }
table { width: 100%; border-collapse: collapse; margin: 0; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--gris-borde); white-space: nowrap; }
th { background: #fafbfc; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; color: var(--gris-texto); }
tr:last-child td { border-bottom: none; }

@media (max-width: 767px) {
  th, td { padding: 0.5rem 0.55rem; font-size: 0.9rem; }
  .tabla-scroll td:first-child, .tabla-scroll th:first-child {
    position: sticky;
    left: 0;
    background: #fff;
    box-shadow: 1px 0 0 var(--gris-borde);
  }
  .tabla-scroll th:first-child { background: #fafbfc; }
}

/* --- Pantalla de escaneo --- */
.scan-input {
  font-size: 1.6rem;
  text-align: center;
  padding: 1rem;
  border-width: 2px;
}

/* --- Dashboard de inicio --- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 1rem 0; }
.stat-card { background: #fff; border: 1px solid var(--gris-borde); border-radius: var(--radio); padding: 0.9rem 1rem; text-align: center; }
.stat-num { display: block; font-size: 1.6rem; font-weight: 700; color: var(--azul); }
.stat-label { font-size: 0.82rem; color: var(--gris-texto); }
.cta-grande { display: block; text-align: center; background: var(--azul); color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; padding: 1rem; border-radius: var(--radio); margin: 1rem 0; }
.cta-grande:hover { background: var(--azul-oscuro); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
