:root {
  --azul: #0099ff;
  --azul-oscuro: #0077cc;
  --azul-claro: #e6f5ff;
  --gris-fondo: #f4f6f9;
  --gris-borde: #dde3ea;
  --texto: #1c2733;
  --texto-suave: #64748b;
  --verde: #16a34a;
  --rojo: #dc2626;
  --amarillo: #d97706;
  --blanco: #ffffff;
  --radio: 10px;
  --sombra: 0 2px 10px rgba(15, 30, 60, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--gris-fondo);
  color: var(--texto);
  font-size: 14px;
}
a { color: var(--azul); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ===== Pantalla de login ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--azul) 0%, #005fa3 100%);
  padding: 20px;
}
.login-card {
  background: var(--blanco);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-logo-img {
  display: block;
  max-width: 230px;
  width: 100%;
  height: auto;
  margin: 0 auto 18px;
}
.login-card h1 { text-align: center; font-size: 18px; margin: 0 0 4px; }
.login-card .empresa { text-align: center; color: var(--texto-suave); font-size: 12px; margin-bottom: 24px; }
.login-aviso-camara {
  text-align: center; color: var(--amarillo); background: #fef3c7; border: 1px solid #fde68a;
  border-radius: 8px; padding: 9px 12px; font-size: 12.5px; font-weight: 700; margin-bottom: 16px; line-height: 1.4;
}
.login-condicion-camara {
  text-align: center; margin-top: 16px; font-size: 12px; color: var(--amarillo); text-decoration: underline;
  cursor: pointer; font-weight: 600;
}
.campo { margin-bottom: 16px; }
.campo label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--texto-suave); }
.campo input, .campo select, .campo textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--gris-borde); border-radius: 8px; font-size: 14px;
  outline: none; transition: border-color .15s;
}
.campo input:focus, .campo select:focus, .campo textarea:focus { border-color: var(--azul); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px; border: none; font-weight: 600; font-size: 14px;
  transition: opacity .15s, transform .05s, box-shadow .15s;
  box-shadow: 4px 4px 10px rgba(0,0,0,0.18);
}
.btn:hover:not(:disabled) { box-shadow: 6px 6px 14px rgba(0,0,0,0.24); }
.btn:active { transform: scale(0.98); box-shadow: 2px 2px 6px rgba(0,0,0,0.16); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-primario { background: var(--azul); color: white; width: 100%; }
.btn-primario:hover { background: var(--azul-oscuro); }
.btn-secundario { background: var(--azul-claro); color: var(--azul-oscuro); }
.btn-outline { background: transparent; border: 1.5px solid var(--gris-borde); color: var(--texto); }
.btn-peligro { background: #fee2e2; color: var(--rojo); }
.btn-exito { background: #dcfce7; color: var(--verde); }
.btn-chico { padding: 6px 12px; font-size: 12.5px; }
.error-msg { background: #fee2e2; color: var(--rojo); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.ok-msg { background: #dcfce7; color: #15803d; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.demo-usuarios { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--gris-borde); font-size: 11.5px; color: var(--texto-suave); }
.demo-usuarios code { background: var(--gris-fondo); padding: 1px 5px; border-radius: 4px; }

/* ===== Verificación facial (login y "Registrar rostro" en el perfil) ===== */
.facial-video-wrap {
  position: relative; width: 100%; max-width: 300px; aspect-ratio: 4/3; margin: 0 auto 16px;
  border-radius: 12px; overflow: hidden; background: #111; box-shadow: var(--sombra);
}
.facial-video-wrap video {
  width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); /* efecto espejo, más natural */
  display: block;
}
.facial-ovalo {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 64%; height: 82%; border-radius: 50%;
  border: 4px solid var(--azul); background: rgba(0,153,255,0.06);
  transition: border-color .25s, background .25s; pointer-events: none;
}
.facial-ovalo.listo { border-color: var(--verde); background: rgba(22,163,74,0.10); }
.facial-ovalo.error { border-color: var(--rojo); background: rgba(220,38,38,0.08); }
.facial-estado-msg {
  text-align: center; font-size: 13px; font-weight: 600; color: var(--texto-suave);
  margin-bottom: 14px; min-height: 18px; transition: color .2s;
}
.facial-estado-msg.listo { color: var(--verde); }
.facial-estado-msg.error { color: var(--rojo); }
.facial-cargando {
  text-align: center; color: var(--texto-suave); font-size: 13px; padding: 30px 0;
}

/* ===== Selector de método de verificación (modal "🔒 Seguridad") ===== */
.seguridad-opcion {
  border: 1.5px solid var(--gris-borde); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px;
}
.seguridad-opcion.activa { border-color: var(--azul); background: var(--azul-claro); }
.seguridad-opcion-titulo { font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.seguridad-opcion-desc { font-size: 12.5px; color: var(--texto-suave); }

/* ===== Layout principal ===== */
.app { display: block; min-height: 100vh; }

/* El menú ahora es una pantalla completa que se despliega encima de todo
   (con el botón ☰ de la barra superior) y se retrae solo al elegir una
   pestaña — ya no es una columna fija al lado del contenido. Por eso
   ".main" ya no necesita dejarle espacio a un costado. */
.main { min-width: 0; }
.topbar {
  height: 60px; background: white; border-bottom: 1px solid var(--gris-borde);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 30;
}
.topbar h2 { font-size: 17px; margin: 0; }
.menu-toggle {
  display: flex; align-items: center; justify-content: center; background: none; border: none;
  font-size: 21px; cursor: pointer; color: var(--texto); padding: 4px 9px; border-radius: 8px; line-height: 1;
}
.menu-toggle:hover { background: var(--gris-fondo); }

/* ===== Menú principal (pantalla completa, botones grandes por categoría) ===== */
.sidebar {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: var(--gris-fondo);
  flex-direction: column;
}
.sidebar.abierto { display: flex; }
.sidebar-header {
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-oscuro) 100%);
  padding: 16px 20px; display: flex; align-items: center; gap: 12px; color: white; flex-shrink: 0;
}
.sidebar-header .logo { width: 38px; height: 38px; background: white; border-radius: 10px; display:flex; align-items:center; justify-content:center; flex-shrink:0; padding: 5px; }
.sidebar-header .logo img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-header .titulo { font-weight: 800; font-size: 15.5px; color: white; line-height:1.2; }
.sidebar-header .subtitulo { font-size: 11px; color: rgba(255,255,255,0.82); }
.btn-cerrar-menu {
  margin-left: auto; background: rgba(255,255,255,0.16); border: none; color: white;
  width: 32px; height: 32px; border-radius: 50%; font-size: 16px; cursor: pointer; flex-shrink: 0;
}
.btn-cerrar-menu:hover { background: rgba(255,255,255,0.3); }

.nav-menu { flex: 1; overflow-y: auto; padding: 20px; }
.menu-boton-inicio { max-width: 320px; margin-bottom: 22px; }
.menu-columnas { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 26px; }
.menu-columna-titulo {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .04em; color: var(--azul-oscuro); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--azul-claro);
}
.menu-botones { display: flex; flex-direction: column; gap: 10px; }
.menu-boton {
  display: flex; align-items: center; gap: 12px; background: var(--azul); color: white; text-decoration: none;
  padding: 13px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 700; box-shadow: 0 2px 8px rgba(0,153,255,0.25);
  transition: transform .08s, background .15s; cursor: pointer; border: none; width: 100%; text-align: left; font-family: inherit;
}
.menu-boton:hover { background: var(--azul-oscuro); }
.menu-boton:active { transform: scale(0.97); }
.menu-boton.activo { background: var(--azul-oscuro); box-shadow: 0 0 0 3px rgba(0,119,204,0.35) inset; }
.menu-boton .nav-icon { font-size: 19px; width: 24px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: 14px 20px; background: white; border-top: 1px solid var(--gris-borde); flex-shrink: 0; }
.usuario-chip { display: flex; align-items: center; gap: 10px; }
.usuario-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--azul); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink:0; }
.usuario-info .nombre { font-size: 12.5px; font-weight: 600; color: var(--texto); }
.usuario-info .rol { font-size: 10.5px; color: var(--texto-suave); }
.btn-salir { margin-top: 10px; width: 100%; background: var(--gris-fondo); color: var(--texto); border:none; padding: 8px; border-radius: 7px; font-size: 12px; }
.btn-campana { position: relative; background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px 8px; line-height: 1; border-radius: 8px; }
.btn-campana:hover { background: var(--gris-fondo); }
.campana-badge {
  position: absolute; top: -2px; right: 0; background: var(--rojo); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
/* Aviso de solicitud nueva sin ver: la campana parpadea (color + tamaño)
   hasta que alguien la abre, aunque el sonido ya haya terminado de sonar. */
@keyframes campana-parpadea {
  0%, 100% { color: inherit; transform: scale(1); }
  50% { color: var(--rojo); transform: scale(1.22); }
}
.btn-campana.parpadea { animation: campana-parpadea 0.85s ease-in-out infinite; }
.btn-campana.parpadea .campana-badge { animation: campana-parpadea 0.85s ease-in-out infinite; }
.contenido { padding: 24px; max-width: 1300px; }

.card {
  background: white; border-radius: var(--radio); padding: 20px; box-shadow: var(--sombra); margin-bottom: 20px;
  border: 1px solid var(--gris-borde);
}
.card h3 { margin: 0 0 16px; font-size: 15px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: white; border-radius: var(--radio); padding: 18px; box-shadow: var(--sombra); border-left: 4px solid var(--azul); }
.kpi .label { font-size: 12px; color: var(--texto-suave); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .valor { font-size: 24px; font-weight: 800; margin-top: 6px; }
.kpi.alerta { border-left-color: var(--amarillo); }
.kpi.rojo { border-left-color: var(--rojo); }
.kpi.verde { border-left-color: var(--verde); }

/* Gráfico de movimientos en la pantalla de Inicio: una fila por tipo de
   documento, con una barra horizontal que crece según la cantidad. */
.grafico-movimientos { display: flex; flex-direction: column; gap: 14px; }
.fila-grafico { display: grid; grid-template-columns: minmax(110px, 170px) 1fr 36px; align-items: center; gap: 12px; }
.fila-grafico-etiqueta { font-size: 13px; font-weight: 600; line-height: 1.25; }
.fila-grafico-nota { display: block; font-size: 10.5px; font-weight: 500; color: var(--texto-suave); text-transform: uppercase; letter-spacing: .02em; }
.fila-grafico-barra-fondo { background: var(--gris-fondo); border-radius: 999px; height: 14px; overflow: hidden; }
.fila-grafico-barra { background: linear-gradient(90deg, var(--azul), var(--azul-oscuro)); height: 100%; border-radius: 999px; min-width: 3px; transition: width .5s ease; }
.fila-grafico-valor { font-size: 15px; font-weight: 800; text-align: right; }
@media (max-width: 560px) {
  .fila-grafico { grid-template-columns: minmax(90px, 120px) 1fr 30px; gap: 8px; }
  .fila-grafico-etiqueta { font-size: 12px; }
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; background: var(--gris-fondo); color: var(--texto-suave); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
td { padding: 10px 12px; border-bottom: 1px solid var(--gris-borde); }
tr:hover td { background: #fafcff; }
.tabla-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-gris { background: #eef1f5; color: #55606b; }
.badge-azul { background: var(--azul-claro); color: var(--azul-oscuro); }
.badge-verde { background: #dcfce7; color: #15803d; }
.badge-rojo { background: #fee2e2; color: var(--rojo); }
.badge-amarillo { background: #fef3c7; color: #b45309; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-derecha { display: flex; gap: 8px; flex-wrap: wrap; }
.buscador { padding: 9px 12px; border: 1.5px solid var(--gris-borde); border-radius: 8px; min-width: 220px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 20, 35, 0.5); display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal {
  background: white; border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  padding: 24px;
}
.modal.ancho { max-width: 780px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header h3 { margin: 0; }
.cerrar-x { background: none; border: none; font-size: 20px; color: var(--texto-suave); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.items-factura { border: 1px solid var(--gris-borde); border-radius: 8px; overflow: hidden; margin: 12px 0; }
.items-factura table { font-size: 12.5px; }
.totales-factura { margin-left: auto; width: 260px; }
.totales-factura .fila { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.totales-factura .fila.total { font-weight: 800; font-size: 16px; border-top: 1px solid var(--gris-borde); margin-top: 4px; padding-top: 10px; }

.vacio { text-align: center; padding: 40px 20px; color: var(--texto-suave); }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--gris-borde); flex-wrap: wrap; }
.tab { padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--texto-suave); border-bottom: 2px solid transparent; cursor: pointer; }
.tab.activo { color: var(--azul); border-bottom-color: var(--azul); }

.aviso {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 12px 14px; border-radius: 8px; font-size: 12.5px; margin-bottom: 16px;
}
.aviso.info { background: var(--azul-claro); border-color: #bfe4ff; color: var(--azul-oscuro); }
.aviso.exito { background: #dcfce7; border-color: #bbf7d0; color: var(--verde); }

.clave-acceso { font-family: monospace; font-size: 11px; word-break: break-all; color: var(--texto-suave); }

/* ===== Bloqueo automático por inactividad ===== */
.bloqueo-overlay {
  position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-oscuro) 100%);
}
.bloqueo-card {
  background: white; border-radius: 16px; width: 100%; max-width: 380px; padding: 30px 28px; text-align: center;
  box-shadow: 0 20px 50px rgba(0, 30, 60, 0.35);
}
.bloqueo-logo { width: 56px; height: 56px; margin: 0 auto 14px; background: var(--azul-claro); border-radius: 14px; display: flex; align-items: center; justify-content: center; padding: 8px; }
.bloqueo-logo img { width: 100%; height: 100%; object-fit: contain; }
.bloqueo-card h2 { font-size: 17px; margin: 0 0 8px; color: var(--azul-oscuro); }
.bloqueo-card p { font-size: 13px; color: var(--texto-suave); margin: 0 0 18px; line-height: 1.5; }
.bloqueo-card form { text-align: left; }

/* ===== Semáforo de riesgo del cliente / desempeño del trabajador ===== */
.riesgo-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; vertical-align: middle; cursor: pointer; }
.riesgo-dot.VERDE { background: var(--verde); }
.riesgo-dot.AMARILLO { background: #eab308; }
.riesgo-dot.NARANJA { background: #f97316; }
.riesgo-dot.ROJO { background: var(--rojo); }
.riesgo-dot.AZUL { background: var(--azul); }
.riesgo-dot.NEGRO { background: #111827; }
.riesgo-dot.GRIS { background: var(--texto-suave); }

.popover-riesgo {
  position: fixed;
  z-index: 200;
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 30, 60, 0.22);
  padding: 12px 14px;
  width: 240px;
  font-size: 12.5px;
}
.popover-riesgo-titulo { font-weight: 700; margin-bottom: 6px; }
.popover-riesgo-linea { margin-bottom: 4px; line-height: 1.4; word-break: break-word; }

