/* ===== General ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  color: #0f172a;
  min-height: 100vh;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Contenedores ===== */
.contenedor { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.contenedor-estrecho { max-width: 420px; margin: 0 auto; padding: 40px 16px; }

/* ===== Navbar ===== */
.navbar {
  background: #0f172a;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 24px;
}
.nav-superior {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.nav-menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.navbar .marca {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
}
.logo-marca {
  height: 34px;
  width: auto;
  border-radius: 6px;
}
.logo-login {
  display: block;
  margin: 0 auto 12px;
  max-height: 140px;
  max-width: 100%;
  width: auto;
  height: auto;
}
.navbar .enlace {
  color: #cbd5e1;
  font-size: 0.95rem;
  padding: 6px 12px;
  border-radius: 8px;
}
.navbar .enlace:hover {
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
}
.navbar .usuario {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.9rem; color: #e2e8f0;
}
.rol-etiqueta {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #334155;
  color: #e2e8f0;
}
.rol-etiqueta.admin { background: #f59e0b; color: #1e293b; }
.rol-etiqueta.avanzado { background: #0284c7; color: #ffffff; }

/* ===== Tarjetas / formularios ===== */
.tarjeta {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  margin-bottom: 20px;
}
h1 { font-size: 1.5rem; margin-bottom: 6px; }
h2 { font-size: 1.2rem; margin-bottom: 14px; }
p.subtitulo { color: #64748b; margin-bottom: 20px; }

label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 0.9rem; }
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 1rem;
}
input:focus { outline: 2px solid #2563eb; outline-offset: 1px; border-color: #2563eb; }
.fila-check { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.fila-check label { margin: 0; font-weight: 500; }

/* Campo de contraseña con ojo de visualización (mostrar al mantener presionado) */
.campo-password { position: relative; }
.campo-password input[type="password"] { padding-right: 46px; }
.ojo-contrasena {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 6px;
  border-radius: 6px;
  color: #64748b;
}
.ojo-contrasena:hover { background: #f1f5f9; color: #0f172a; }
.ojo-contrasena.activo { background: #dbeafe; color: #2563eb; }

select {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1;
  border-radius: 8px; font-size: 1rem; background: #fff;
}

/* Formulario de usuario (alta/edición) en PC: la tarjeta se ajusta al ancho
   de los campos (mitad del contenedor, máx. 480px) y los textos quedan
   contenidos dentro. En móvil la tarjeta sigue a ancho completo. */
@media (min-width: 769px) {
  .tarjeta-form-usuario {
    width: 50%;
    max-width: 480px;
    margin: 0 auto;
  }
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primario { background: #2563eb; color: #fff; }
.btn-primario:hover { background: #1d4ed8; text-decoration: none; }
.btn-secundario { background: #e2e8f0; color: #0f172a; }
.btn-secundario:hover { background: #cbd5e1; text-decoration: none; }
.btn-peligro { background: #dc2626; color: #fff; }
.btn-peligro:hover { background: #b91c1c; }
.grupo-botones { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Tabla ===== */
.tabla { width: 100%; border-collapse: collapse; margin-top: 16px; }
.tabla th, .tabla td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid #e2e8f0;
  font-size: 0.92rem;
}
.tabla th { background: #f8fafc; color: #475569; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.tabla tr:hover td { background: #f8fafc; }
.acciones { display: flex; gap: 8px; }
.acciones a, .acciones button {
  font-size: 0.85rem; padding: 5px 10px; border-radius: 6px;
}
.icono-estado { font-weight: 700; }
.icono-estado.ok { color: #16a34a; }
.icono-estado.no { color: #94a3b8; }

/* ===== Alertas / flash ===== */
.alerta {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px;
  font-size: 0.92rem; font-weight: 500;
}
.alerta.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alerta.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alerta.info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* ===== Buscador de funcionarios (alta de usuarios, FSClock) ===== */
.resultados-funcionarios {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  margin-top: 6px;
  max-height: 250px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}
.resultado-funcionario {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  color: #0f172a;
}
.resultado-funcionario:last-child { border-bottom: none; }
.resultado-funcionario:hover { background: #eff6ff; }
.rf-doc { font-weight: 700; color: #1e40af; }
.rf-empresa { color: #64748b; font-size: 0.8rem; }
.resultado-vacio { padding: 10px 12px; color: #64748b; font-size: 0.9rem; }
.ayuda-usuario {
  display: block;
  color: #64748b;
  font-size: 0.8rem;
  margin-top: 6px;
  line-height: 1.4;
}

/* ===== Marcas (botones de marcado) ===== */
.marcas-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 10px;
}
.marca-celda { margin: 0; }
.btn-marca {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 26px 12px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn-marca:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.15);
}
.btn-marca:active { transform: translateY(0); }
.btn-marca .marca-icono { font-size: 2rem; line-height: 1; }
.btn-marca.entrada { background: #16a34a; }
.btn-marca.entra-inter { background: #0e7490; }
.btn-marca.sale-inter { background: #b45309; }
.btn-marca.salida { background: #dc2626; }

/* PC: los 4 botones de marca con el mismo alto (como el de Entrada) */
@media (min-width: 769px) {
  .marca-celda { height: 128px; }
  .btn-marca { height: 100%; }
}

.consejo { color: #64748b; font-size: 0.9rem; margin-top: 18px; }

/* Reloj del servidor en la pantalla de marcar (moderno, protagonista) */
.reloj-servidor {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  max-width: 230px;
  margin: 0 auto 10px;
  padding: 14px 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 60%, #0c4a6e 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.10);
  overflow: hidden; /* para el brillo superior */
}
.reloj-servidor::before {
  content: '';
  position: absolute;
  inset: -60% -30%;
  background: radial-gradient(closest-side at 50% 0%, rgba(251, 191, 36, 0.16), transparent 70%);
  pointer-events: none;
}
.reloj-etiqueta {
  position: relative;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.8;
}
.reloj-hora {
  position: relative;
  font-family: 'Cascadia Mono', 'Consolas', 'SF Mono', 'Menlo', 'Courier New', monospace;
  font-size: clamp(1.4rem, 3.5vw, 1.5rem);
  font-weight: 800;
  font-stretch: expanded;
  line-height: 1.05;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 11px rgba(251, 191, 36, 0.45), 0 2px 4px rgba(0, 0, 0, 0.45);
}
.reloj-seg { color: #fbbf24; }

/* ===== Login ===== */
.pantalla-login {
  min-height: 100vh; display: flex; align-items: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}
.caja-login {
  background: #fff; border-radius: 14px; padding: 36px 32px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25); width: 100%;
}
.caja-login h1 { font-size: 1.4rem; margin-bottom: 4px; text-align: center; }
.caja-login p.subtitulo { margin-bottom: 8px; text-align: center; }
.linea-sep { border: none; border-top: 1px solid #e2e8f0; margin: 18px 0; }

/* ===== Responsive (móvil / tablet) ===== */
@media (max-width: 768px) {

  /* Contenedores: más aire al contenido */
  .contenedor, .contenedor-estrecho { padding: 20px 14px; }

  /* Navbar: los datos del usuario se apilan si el ancho no alcanza */
  .navbar .usuario { flex-wrap: wrap; row-gap: 8px; }

  /* Reloj: hora grande en móvil/tablet (en PC queda más contenida) */
  .reloj-hora { font-size: clamp(2rem, 6vw, 2.6rem); }

  /* Tablas: scroll horizontal dentro de la propia tabla */
  .tabla {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Botones: a lo ancho, apilados */
  .btn { width: 100%; text-align: center; }
  .grupo-botones { flex-direction: column; }
  .acciones { flex-wrap: wrap; }
  .acciones form, .acciones .btn { width: 100%; }
  .acciones form .btn { margin-bottom: 6px; }

  /* Marcas: grilla de 2 columnas en tablet */
  .marcas-grid { grid-template-columns: repeat(2, 1fr); }

  /* Login: la caja ocupa mejor la pantalla */
  .pantalla-login { align-items: flex-start; padding-top: 36px; }
  .caja-login { padding: 28px 20px; }

  /* Formularios: botones de acción a lo ancho */
  .fila-check { align-items: flex-start; }
  .btn-peligro { margin-top: 6px; }
}

@media (max-width: 420px) {
  .cabecera-pagina { flex-direction: column; align-items: flex-start; gap: 12px; }
  .cabecera-pagina .btn { width: 100%; }
  h1 { font-size: 1.3rem; }

  /* Marcas: 1 columna, botón en fila (ícono a la izquierda) */
  .marcas-grid { grid-template-columns: 1fr; }
  .btn-marca {
    flex-direction: row;
    justify-content: flex-start;
    padding: 18px 16px;
    gap: 14px;
  }
  .btn-marca .marca-icono { font-size: 1.6rem; }

  /* Reloj: mismo ancho que los botones y un poco separado de ellos */
  .reloj-servidor {
    width: 100%;
    max-width: none;
    margin-bottom: 30px;
  }
}