/* =====================================================================
   Portal del empleado
   · Móvil (< 900px): cabecera oscura arriba y barra de botones abajo
   · PC   (≥ 900px): barra lateral a la izquierda y contenido en columnas
   ===================================================================== */
:root {
  --p-azul: #2457d6;
  --p-azul-claro: #e8efff;
  --p-tinta: #111827;
  --p-suave: #6b7280;
  --p-borde: #e5e7eb;
  --p-fondo: #f3f5f9;
  --p-tarjeta: #ffffff;
  --p-verde: #15803d;
  --p-verde-claro: #dcfce7;
  --p-ambar: #b45309;
  --p-ambar-claro: #fef3c7;
  --p-rojo: #b91c1c;
  --p-rojo-claro: #fee2e2;
  --p-radio: 16px;
  --p-sombra: 0 1px 2px rgba(17, 24, 39, .04), 0 4px 14px rgba(17, 24, 39, .05);
  --p-lateral: 248px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body.portal {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--p-fondo); color: var(--p-tinta); font-size: 15px; line-height: 1.4;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}
a { color: inherit; }
.p-wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* ---------------- Cabecera ---------------- */
.p-top { background: var(--p-tinta); color: #fff; padding: calc(14px + env(safe-area-inset-top)) 0 18px; }
.p-top .p-wrap { display: flex; align-items: center; gap: 12px; }
.p-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--p-azul); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.p-top-txt { flex: 1; min-width: 0; }
.p-top-hola { font-size: 1.02rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-top-sub { font-size: .8rem; color: #c7cbd6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-top-link { color: #c7cbd6; font-size: .8rem; text-decoration: none; border: 1px solid #374151; padding: 6px 10px; border-radius: 999px; white-space: nowrap; }

.p-titulo { font-size: 1.25rem; font-weight: 800; margin: 18px 0 12px; letter-spacing: -.01em; }
.p-sub { color: var(--p-suave); font-size: .85rem; margin: -6px 0 14px; }

/* ---------------- Tarjetas ---------------- */
.p-card { background: var(--p-tarjeta); border-radius: var(--p-radio); box-shadow: var(--p-sombra); padding: 16px; margin-bottom: 12px; }
.p-card h3 { margin: 0 0 10px; font-size: .78rem; font-weight: 700; color: var(--p-suave); text-transform: uppercase; letter-spacing: .06em; }
.p-fila { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.p-muted { color: var(--p-suave); }
.p-small { font-size: .82rem; }

/* Estado de fichaje */
.p-estado { border-radius: var(--p-radio); padding: 18px; color: #fff; box-shadow: var(--p-sombra); margin: 14px 0 12px; }
.p-estado.fuera { background: linear-gradient(135deg, #374151, #1f2937); }
.p-estado.dentro { background: linear-gradient(135deg, #15803d, #166534); }
.p-estado.pausa { background: linear-gradient(135deg, #b45309, #92400e); }
.p-estado-etq { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.p-estado-txt { font-size: 1.45rem; font-weight: 800; margin: 2px 0 2px; }
.p-estado-det { font-size: .86rem; opacity: .9; }
.p-btn-fichar { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 14px; background: #fff; color: var(--p-tinta); border: 0; border-radius: 12px; padding: 14px; font-size: 1.02rem; font-weight: 800; text-decoration: none; cursor: pointer; }

/* Cifras */
.p-cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.p-cifra { background: var(--p-tarjeta); border-radius: 14px; padding: 12px; box-shadow: var(--p-sombra); }
.p-cifra b { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.p-cifra span { font-size: .72rem; color: var(--p-suave); text-transform: uppercase; letter-spacing: .04em; }
.p-cifra small { display: block; font-size: .72rem; color: var(--p-suave); margin-top: 2px; }

/* Rejilla de accesos */
.p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.p-acceso { background: var(--p-tarjeta); border-radius: var(--p-radio); box-shadow: var(--p-sombra); padding: 14px; text-decoration: none; display: flex; flex-direction: column; gap: 6px; min-height: 108px; position: relative; transition: transform .12s, box-shadow .12s; }
.p-acceso .ico { font-size: 1.45rem; }
.p-acceso .nom { font-weight: 700; font-size: .95rem; }
.p-acceso .det { font-size: .78rem; color: var(--p-suave); }
.p-acceso.off { opacity: .55; }
.p-badge { position: absolute; top: 10px; right: 10px; background: var(--p-rojo); color: #fff; font-size: .7rem; font-weight: 700; border-radius: 999px; padding: 2px 7px; }

/* Etiquetas */
.p-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.p-tag.verde { background: var(--p-verde-claro); color: var(--p-verde); }
.p-tag.ambar { background: var(--p-ambar-claro); color: var(--p-ambar); }
.p-tag.rojo { background: var(--p-rojo-claro); color: var(--p-rojo); }
.p-tag.gris { background: #f1f5f9; color: #475569; }
.p-tag.azul { background: var(--p-azul-claro); color: var(--p-azul); }

/* Avisos */
.p-aviso { border-radius: 12px; padding: 12px 14px; font-size: .88rem; margin-bottom: 12px; display: flex; gap: 10px; align-items: flex-start; }
.p-aviso.ambar { background: var(--p-ambar-claro); color: #78350f; }
.p-aviso.rojo { background: var(--p-rojo-claro); color: #7f1d1d; }
.p-aviso.verde { background: var(--p-verde-claro); color: #14532d; }
.p-aviso.azul { background: var(--p-azul-claro); color: #1e3a8a; }

/* Listas */
.p-lista { list-style: none; margin: 0; padding: 0; }
.p-lista li { padding: 12px 0; border-top: 1px solid var(--p-borde); }
.p-lista li:first-child { border-top: 0; padding-top: 2px; }
.p-dia { font-weight: 700; }
.p-eventos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.p-ev { font-size: .8rem; padding: 3px 8px; border-radius: 8px; background: #f3f4f6; font-variant-numeric: tabular-nums; }
.p-ev.entrada { background: var(--p-verde-claro); color: var(--p-verde); }
.p-ev.salida { background: var(--p-rojo-claro); color: var(--p-rojo); }
.p-ev.pausa, .p-ev.vuelta { background: var(--p-ambar-claro); color: var(--p-ambar); }
.p-ev.anulado { text-decoration: line-through; opacity: .5; }

/* Formularios */
.p-campo { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.p-campo label { font-size: .8rem; font-weight: 600; color: #374151; }
.p-input, .p-campo input, .p-campo select, .p-campo textarea { width: 100%; padding: 12px; border: 1px solid #d1d5db; border-radius: 10px; font-size: 16px; background: #fff; color: var(--p-tinta); font-family: inherit; }
.p-campo input[type="date"], .p-campo input[type="time"] { min-width: 0; -webkit-appearance: none; appearance: none; min-height: 46px; }
.p-dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.p-dos > * { min-width: 0; }
.p-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 16px; border-radius: 12px; border: 0; font-weight: 700; font-size: .98rem; cursor: pointer; text-decoration: none; }
.p-btn.primario { background: var(--p-azul); color: #fff; }
.p-btn.oscuro { background: var(--p-tinta); color: #fff; }
.p-btn.claro { background: #fff; color: var(--p-tinta); border: 1px solid var(--p-borde); }
.p-btn.peligro { background: var(--p-rojo-claro); color: var(--p-rojo); }
.p-btn.ancho { width: 100%; }
.p-btn:disabled { opacity: .5; }

/* Botones de fichaje grandes */
.p-tipos { display: grid; gap: 10px; }
.p-tipo { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 16px; border: 0; color: #fff; font-size: 1.15rem; font-weight: 800; cursor: pointer; width: 100%; text-align: left; }
.p-tipo .ico { font-size: 1.6rem; }
.p-tipo small { display: block; font-size: .78rem; font-weight: 500; opacity: .9; }
.p-tipo.entrada { background: var(--p-verde); }
.p-tipo.salida { background: var(--p-rojo); }
.p-tipo.pausa, .p-tipo.vuelta { background: var(--p-ambar); }

/* Escáner */
.p-escaner { position: relative; border-radius: var(--p-radio); overflow: hidden; background: #000; aspect-ratio: 1 / 1; }
.p-escaner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.p-escaner .marco { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.p-escaner .msg { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: #fff; font-size: .88rem; }

/* Inicio en el móvil: una sola columna, «Próximamente» al final */
.p-inicio { display: flex; flex-direction: column; }
.p-col { display: contents; }
.p-al-final { order: 10; }
.p-inicio .p-cifras { margin-bottom: 12px; order: 5; }
.p-inicio .p-accesos { order: 6; }

/* ---------------- Menú (móvil: barra inferior) ---------------- */
.p-nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--p-borde); padding-bottom: env(safe-area-inset-bottom); z-index: 50; }
.p-nav-marca, .solo-pc { display: none !important; }
.p-nav-links { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); padding: 0 6px; }
.p-nav-links a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 9px; text-decoration: none; color: #6b7280; font-size: .68rem; font-weight: 600; }
.p-nav-links a .ico { font-size: 1.25rem; line-height: 1.2; }
.p-nav-links a.on { color: var(--p-azul); }
.p-nav-links a.fichar .ico { background: var(--p-azul); color: #fff; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; margin-top: -20px; box-shadow: 0 4px 14px rgba(36, 87, 214, .35); font-size: 1.3rem; }

.p-oculto { display: none !important; }
.p-centro { text-align: center; }
.p-sep { height: 1px; background: var(--p-borde); margin: 12px 0; }
details.p-det summary { cursor: pointer; font-weight: 600; color: var(--p-azul); list-style: none; }
details.p-det summary::-webkit-details-marker { display: none; }

/* =====================================================================
   PC y tablet horizontal
   ===================================================================== */
@media (min-width: 900px) {
  body.portal { padding-bottom: 0; padding-left: var(--p-lateral); font-size: 15px; }
  .p-wrap { max-width: 1180px; padding: 0 32px; }

  /* Barra lateral */
  .p-nav { top: 0; bottom: 0; right: auto; width: var(--p-lateral); border-top: 0; background: var(--p-tinta); color: #fff; padding: 0; display: flex; flex-direction: column; }
  .p-nav-marca { display: flex !important; align-items: center; gap: 10px; padding: 22px 20px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
  .p-nav-marca img { width: 34px; height: 34px; border-radius: 9px; }
  .p-nav-marca b { display: block; font-size: .95rem; }
  .p-nav-marca span { display: block; font-size: .75rem; color: #9ca3af; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
  .p-nav-links { display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; max-width: none; margin: 0; flex: 1; }
  .p-nav-links a, .p-nav-links a.solo-pc { display: flex !important; flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: #cbd5e1; font-size: .92rem; font-weight: 600; }
  .p-nav-links a:hover { background: rgba(255,255,255,.07); color: #fff; }
  .p-nav-links a.on { background: rgba(255,255,255,.1); color: #fff; }
  .p-nav-links a .ico { font-size: 1.05rem; width: 22px; text-align: center; }
  .p-nav-links a.fichar { background: var(--p-azul); color: #fff; margin: 4px 0; }
  .p-nav-links a.fichar .ico { width: 22px; height: auto; margin: 0; box-shadow: none; background: none; font-size: 1.05rem; display: inline; }
  .p-nav-links a.fichar:hover { background: #1e4bc0; }
  .p-nav-pie { display: flex !important; flex-direction: column; gap: 8px; padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }
  .p-nav-crm { color: #cbd5e1; text-decoration: none; font-size: .88rem; font-weight: 600; }
  .p-nav-pie button { background: none; border: 0; color: #93c5fd; padding: 0; text-align: left; cursor: pointer; font-size: .85rem; }

  /* Cabecera clara */
  .p-top { background: #fff; color: var(--p-tinta); border-bottom: 1px solid var(--p-borde); padding: 16px 0; }
  .p-top-hola { font-size: 1.25rem; font-weight: 800; }
  .p-top-sub { color: var(--p-suave); }
  .p-top-link { display: none; }
  .p-main { padding-top: 8px; padding-bottom: 40px; }
  .p-titulo { font-size: 1.5rem; margin-top: 24px; }

  /* Inicio en dos columnas */
  .p-inicio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 22px; align-items: start; padding-top: 22px; }
  .p-col { display: flex; flex-direction: column; }
  .p-col .p-estado { margin-top: 0; }
  .p-accesos { grid-template-columns: repeat(3, 1fr); margin-top: 14px; }
  .p-estado { padding: 24px; }
  .p-estado-txt { font-size: 1.8rem; }
  .p-cifras { gap: 12px; }
  .p-cifra { padding: 16px; }
  .p-cifra b { font-size: 1.5rem; }
  .p-acceso { min-height: 120px; padding: 16px; }
  .p-acceso:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(17,24,39,.05), 0 10px 24px rgba(17,24,39,.08); }

  /* Otras páginas */
  .p-grid { grid-template-columns: repeat(3, 1fr); }
  .p-tipos { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .p-tipo { padding: 26px 22px; }
  .p-escaner { max-width: 440px; }
  .p-card { padding: 20px; }
  .p-btn.ancho { width: auto; min-width: 220px; }
  .p-tipo, .p-btn-fichar { width: 100%; }
}
/* Páginas de una sola columna: que no se estiren de lado a lado en pantallas grandes */
@media (min-width: 900px) {
  .p-main.p-normal > * { max-width: 880px; }
}
