/* Fichar — estilos principales. Sin recursos externos. */
:root {
  --azul: #1a4a8a;
  --azul-cl: #2d6fcc;
  --verde: #1a8a4a;
  --rojo: #c0392b;
  --naranja: #d35400;
  --gris: #6c757d;
  --fondo: #f4f7fb;
  --blanco: #ffffff;
  --borde: #d0d8e8;
  --texto: #1a2030;
  --radio: 10px;
  --sombra: 0 2px 8px rgba(0,0,0,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  min-height: 100vh;
}

/* -------- Layout -------- */
.app-header {
  background: var(--azul);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.app-header h1 { font-size: 1.1rem; font-weight: 700; }
.app-header .nav-link { color: rgba(255,255,255,.85); font-size: .85rem; text-decoration: none; }
.app-header .nav-link:hover { color: white; }

.container { max-width: 480px; margin: 0 auto; padding: 16px; }
.container-wide { max-width: 900px; margin: 0 auto; padding: 16px; }

/* -------- Tarjetas -------- */
.card {
  background: var(--blanco);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 20px;
  margin-bottom: 16px;
}

/* -------- Estado del trabajador -------- */
.estado-grande {
  text-align: center;
  padding: 32px 16px;
}
.estado-icono { font-size: 4rem; margin-bottom: 8px; }
.estado-texto { font-size: 1.5rem; font-weight: 700; color: var(--azul); }
.estado-subtexto { font-size: .95rem; color: var(--gris); margin-top: 4px; }

/* -------- Botón principal de fichar -------- */
.btn-fichar {
  display: block;
  width: 100%;
  padding: 18px;
  font-size: 1.2rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radio);
  cursor: pointer;
  letter-spacing: .02em;
  transition: transform .1s, box-shadow .1s;
}
.btn-fichar:active { transform: scale(.97); }
.btn-fichar.entrada { background: var(--verde); color: white; }
.btn-fichar.pausa { background: var(--naranja); color: white; }
.btn-fichar.fin-pausa { background: var(--azul-cl); color: white; }
.btn-fichar.salida { background: var(--rojo); color: white; }

/* -------- Horas -------- */
.horas-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.hora-box {
  background: white;
  border-radius: 8px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--sombra);
}
.hora-box .label { font-size: .75rem; color: var(--gris); text-transform: uppercase; letter-spacing: .04em; }
.hora-box .valor { font-size: 1.2rem; font-weight: 700; color: var(--azul); }

/* -------- Formularios -------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; color: #444; }
input[type=text], input[type=password], input[type=number],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--borde);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--texto);
  background: white;
  appearance: auto;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--azul-cl);
  box-shadow: 0 0 0 3px rgba(45,111,204,.15);
}
textarea { min-height: 80px; resize: vertical; }

/* PIN */
.pin-input {
  letter-spacing: .3em;
  font-size: 1.5rem;
  text-align: center;
  -webkit-text-security: disc;
}

/* -------- Botones -------- */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--azul); color: white; }
.btn-secondary { background: var(--gris); color: white; }
.btn-danger { background: var(--rojo); color: white; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* -------- Alertas -------- */
.alerta { padding: 12px 16px; border-radius: 8px; margin-bottom: 12px; font-size: .9rem; }
.alerta-error { background: #fde8e8; border-left: 4px solid var(--rojo); color: var(--rojo); }
.alerta-info { background: #e8f0ff; border-left: 4px solid var(--azul-cl); color: var(--azul); }
.alerta-ok { background: #e6f9ed; border-left: 4px solid var(--verde); color: var(--verde); }
.alerta-aviso { background: #fff3e0; border-left: 4px solid var(--naranja); color: var(--naranja); }

/* -------- Tabla -------- */
.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th { background: var(--azul); color: white; padding: 8px 12px; text-align: left; font-weight: 600; }
.tabla td { padding: 7px 12px; border-bottom: 1px solid var(--borde); }
.tabla tr:hover td { background: #f0f4ff; }
.tabla .corregido { text-decoration: line-through; color: var(--gris); }

/* -------- Badge estado -------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 700;
}
.badge-trabajando { background: #d4edda; color: #155724; }
.badge-pausa { background: #fff3cd; color: #856404; }
.badge-fuera { background: #f8d7da; color: #721c24; }
.badge-pendiente { background: #fff3cd; color: #856404; }
.badge-aceptada { background: #d4edda; color: #155724; }
.badge-rechazada { background: #f8d7da; color: #721c24; }

/* -------- Historial -------- */
.historial-dia {
  border: 1px solid var(--borde);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}
.historial-dia-header {
  background: #f0f4ff;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  cursor: pointer;
}
.historial-dia-body { padding: 8px 12px; display: none; }
.historial-dia-body.abierto { display: block; }

/* -------- Admin -------- */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px;
  background: var(--azul);
  color: white;
  padding: 20px 0;
  flex-shrink: 0;
}
.admin-sidebar .logo { padding: 0 16px 16px; font-weight: 700; font-size: 1.1rem; border-bottom: 1px solid rgba(255,255,255,.2); }
.admin-sidebar a {
  display: block;
  padding: 10px 16px;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .9rem;
}
.admin-sidebar a:hover, .admin-sidebar a.activo { background: rgba(255,255,255,.1); color: white; }
.admin-main { flex: 1; overflow-x: auto; }
.admin-topbar {
  background: white;
  padding: 12px 24px;
  border-bottom: 1px solid var(--borde);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-content { padding: 24px; }
.admin-title { font-size: 1.3rem; font-weight: 700; color: var(--azul); margin-bottom: 20px; }
.empresa-bloque { margin-bottom: 32px; }
.empresa-bloque h2 { font-size: 1.1rem; color: var(--azul); border-bottom: 2px solid var(--azul); padding-bottom: 6px; margin-bottom: 12px; }

/* -------- Responsive -------- */
@media (max-width: 600px) {
  .admin-sidebar { display: none; }
  .container-wide { padding: 12px; }
  .admin-content { padding: 12px; }
  .horas-grid { grid-template-columns: repeat(3, 1fr); }
  .tabla { font-size: .8rem; }
  .tabla th, .tabla td { padding: 5px 8px; }
}

/* -------- Login -------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--azul);
}
.login-box {
  background: white;
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.login-box h1 { text-align: center; color: var(--azul); margin-bottom: 24px; }
.login-logo { text-align: center; font-size: 2.5rem; margin-bottom: 8px; }

/* -------- Offline banner -------- */
#offline-banner {
  display: none;
  background: var(--naranja);
  color: white;
  text-align: center;
  padding: 8px;
  font-size: .85rem;
  font-weight: 600;
}
