:root {
  --azul: #0f3d5e;
  --azul-claro: #e7f0f7;
  --texto: #1b2430;
  --sub: #5d6b7a;
  --borde: #d9e1e8;
  --fondo: #f3f6f9;
  --tarjeta: #ffffff;
  --verde: #1d7a46;
  --verde-claro: #e3f4ea;
  --rojo: #b3261e;
  --rojo-claro: #fbe7e5;
  --ambar: #a35c00;
  --ambar-claro: #fff1dc;
  --radio: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h2 { font-size: 1.15rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h3 { font-size: 1rem; margin-top: 1rem; }
code { background: var(--azul-claro); padding: 0 .3em; border-radius: 4px; }
.sub { color: var(--sub); font-size: .9rem; }
.vacio { color: var(--sub); font-style: italic; }
.cargando { text-align: center; color: var(--sub); padding: 2rem; }
[hidden] { display: none !important; }

/* Marco */
.cabecera {
  background: var(--azul); color: #fff; display: flex; justify-content: space-between; align-items: center;
  padding: calc(.7rem + env(safe-area-inset-top)) 1rem .7rem; gap: 1rem;
}
.marca { display: flex; align-items: center; gap: .6rem; }
.marca small { display: block; font-size: .75rem; opacity: .8; }
.logo {
  width: 38px; height: 38px; border-radius: 10px; background: #fff; color: var(--azul);
  display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; flex: none;
}
.login .logo { background: var(--azul); color: #fff; }
.usuario { font-size: .9rem; opacity: .9; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pestanas {
  display: flex; gap: .25rem; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--borde);
  padding: .4rem .6rem; position: sticky; top: 0; z-index: 5; scrollbar-width: none;
}
.pestanas::-webkit-scrollbar { display: none; }
.pestanas button {
  border: 0; background: none; padding: .55rem .8rem; border-radius: 999px; font: inherit; font-size: .95rem;
  color: var(--sub); white-space: nowrap; cursor: pointer;
}
.pestanas button[aria-current="page"] { background: var(--azul); color: #fff; }
main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
main.centrado { min-height: 100vh; display: grid; place-items: center; }

.tarjeta {
  background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 1.1rem; margin-bottom: 1rem;
}
.tarjeta.destacada { border-color: var(--ambar); background: var(--ambar-claro); }
.tarjeta.error { border-color: var(--rojo); background: var(--rojo-claro); }

/* Botones y formularios */
.btn {
  font: inherit; border: 1px solid var(--borde); background: #fff; color: var(--texto); border-radius: 10px;
  padding: .6rem 1rem; cursor: pointer; min-height: 44px;
}
.btn:hover { border-color: var(--azul); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primario { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn-peligro { background: #fff; border-color: var(--rojo); color: var(--rojo); }
.btn-peq { min-height: 34px; padding: .3rem .7rem; font-size: .9rem; }
.btn-grande { width: 100%; padding: .9rem; font-size: 1.05rem; }
.btn-enlace { border: 0; background: none; color: var(--azul); text-decoration: underline; font: inherit; cursor: pointer; padding: .5rem; }
.fila-botones { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--sub); }
input, select, textarea {
  font: inherit; color: var(--texto); border: 1px solid var(--borde); border-radius: 10px; padding: .6rem .7rem;
  background: #fff; min-height: 44px; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid #8cc2ec; outline-offset: 1px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; margin: 0; flex: none; }
.formulario { display: flex; flex-direction: column; gap: .8rem; }
.formulario > .btn { align-self: flex-start; }
.fila-campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; }
.casillas label, label.casilla, .opciones label { flex-direction: row; align-items: center; gap: .5rem; color: var(--texto); }
.opciones { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.opciones legend { font-size: .9rem; color: var(--sub); margin-bottom: .3rem; }
.controles { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.controles label { min-width: 180px; }
.login { width: min(400px, 100%); display: flex; flex-direction: column; gap: 1rem; }

/* Fichar */
.fichar { text-align: center; }
.fecha-hoy { color: var(--sub); }
.reloj { font-size: clamp(2.8rem, 14vw, 4.5rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--azul); }
.estado { display: inline-block; padding: .35rem .9rem; border-radius: 999px; font-weight: 600; margin: .3rem 0 1rem; }
.estado-fuera { background: #eef1f4; color: var(--sub); }
.estado-trabajando { background: var(--verde-claro); color: var(--verde); }
.estado-pausa { background: var(--ambar-claro); color: var(--ambar); }
.estado-alerta { background: var(--rojo-claro); color: var(--rojo); }
.botones { display: grid; gap: .7rem; max-width: 420px; margin: 0 auto; }
.btn-fichar { font-size: 1.25rem; font-weight: 700; padding: 1.1rem; border: 0; border-radius: 16px; color: #fff; min-height: 64px; }
.btn-entrada { background: var(--verde); }
.btn-salida { background: var(--rojo); }
.btn-pausa { background: var(--ambar); }
.nota { color: var(--sub); font-size: .8rem; max-width: 460px; margin: 1rem auto 0; }
.pildora { background: var(--azul-claro); color: var(--azul); font-size: .85rem; padding: .15rem .6rem; border-radius: 999px; font-weight: 600; }
.lista-fichajes { list-style: none; padding: 0; margin: 0; }
.lista-fichajes li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .5rem 0; border-bottom: 1px solid var(--borde); }
.lista-fichajes li:last-child { border-bottom: 0; }
.lista-fichajes li.anulado strong { text-decoration: line-through; color: var(--sub); }
.ico { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: .8rem; flex: none; }
.ico-entrada { background: var(--verde); } .ico-salida { background: var(--rojo); }
.ico-inicio_pausa, .ico-fin_pausa { background: var(--ambar); }
.marca-ok, .marca-inc { font-size: .78rem; padding: .05rem .5rem; border-radius: 999px; font-weight: 600; }
.marca-ok { background: var(--verde-claro); color: var(--verde); }
.marca-inc { background: var(--ambar-claro); color: var(--ambar); }

/* Informe */
.cab-informe { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.cab-informe p { margin: .1rem 0; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; }
.resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin: 1rem 0; }
.resumen div { background: var(--fondo); border-radius: 10px; padding: .6rem .8rem; }
.resumen span { display: block; font-size: .8rem; color: var(--sub); }
.resumen strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabla { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 720px; }
.tabla th, .tabla td { border-bottom: 1px solid var(--borde); padding: .4rem .45rem; text-align: left; vertical-align: top; }
.tabla th { background: var(--fondo); font-weight: 600; position: sticky; top: 0; }
.tabla tfoot td { font-weight: 700; border-top: 2px solid var(--texto); }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla .inc { color: var(--ambar); font-size: .8rem; }
.tabla tr.finde td { background: #fafbfc; }
.tabla tr.fila-vacia td { color: #9aa6b2; }
.neg { color: var(--rojo); } .pos { color: var(--verde); }
.chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.chip { font-size: .78rem; padding: .05rem .4rem; border-radius: 6px; background: var(--fondo); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip-entrada { background: var(--verde-claro); color: var(--verde); }
.chip-salida { background: var(--rojo-claro); color: var(--rojo); }
.chip-inicio_pausa, .chip-fin_pausa { background: var(--ambar-claro); color: var(--ambar); }
.chip-anulado { text-decoration: line-through; color: var(--sub); }
.chip-curso { background: var(--azul-claro); color: var(--azul); }
.leyenda, .pie { font-size: .78rem; color: var(--sub); }
.firma { border-top: 1px solid var(--borde); margin-top: 1rem; padding-top: .8rem; }
.firmas { padding-left: 1.1rem; }
.firmar textarea { margin-top: .4rem; }
.huella { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .72rem; color: var(--sub); word-break: break-all; }
.solo-imprimir { display: none; }

/* Equipo y correcciones */
.equipo, .correcciones { list-style: none; padding: 0; margin: 0; }
.equipo li { display: flex; gap: .8rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--borde); }
.punto { width: 14px; height: 14px; border-radius: 50%; flex: none; background: #b7c2cc; }
.punto-trabajando { background: var(--verde); } .punto-pausa { background: var(--ambar); } .punto-alerta { background: var(--rojo); }
.correcciones li { padding: .8rem 0; border-bottom: 1px solid var(--borde); display: flex; flex-direction: column; gap: .2rem; }
.correcciones li:last-child, .equipo li:last-child { border-bottom: 0; }
.cab-corr { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.etiqueta { font-size: .75rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; }
.etiqueta-pendiente { background: var(--ambar-claro); color: var(--ambar); }
.etiqueta-aprobada { background: var(--verde-claro); color: var(--verde); }
.etiqueta-rechazada { background: var(--rojo-claro); color: var(--rojo); }
.horario { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.ayuda ol { padding-left: 1.2rem; margin: .3rem 0; }

/* Avisos */
#avisos {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom));
  width: min(520px, calc(100% - 2rem)); display: flex; flex-direction: column; gap: .5rem; z-index: 50;
}
.aviso { padding: .85rem 1rem; border-radius: 12px; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.18); font-weight: 600; }
.aviso-ok { background: var(--verde); }
.aviso-atencion { background: var(--ambar); }
.aviso-error { background: var(--rojo); }

@media (min-width: 700px) {
  .botones { grid-template-columns: repeat(2, 1fr); max-width: 520px; }
  .botones .btn-fichar:only-child { grid-column: 1 / -1; }
}

/* Impresión / PDF del informe */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .no-imprimir, #avisos, .controles { display: none !important; }
  .solo-imprimir { display: flex !important; }
  main { padding: 0; max-width: none; }
  .tarjeta { border: 0; padding: 0; margin: 0; }
  .tabla { min-width: 0; font-size: 10px; }
  .tabla th { position: static; }
  .tabla tr { break-inside: avoid; }
  .resumen div { border: 1px solid #ccc; }
  .cajas-firma { gap: 2rem; margin-top: 1.2rem; }
  .cajas-firma div { flex: 1; border-top: 1px solid #000; padding-top: .3rem; margin-top: 3rem; text-align: center; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
