/* Pica Pica · OpenBlue — "tarjeta de fichar"
   Tinta de reloj para las cifras, papel blanco plano sobre gris azulado,
   un color fijo por negocio (naranja Pica Pica, azul OpenBlue). */

@font-face {
  font-family: "Red Hat Text";
  src: url("/fonts/red-hat-text-latin.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Red Hat Mono";
  src: url("/fonts/red-hat-mono-latin.woff2") format("woff2");
  font-weight: 500 700; font-style: normal; font-display: swap;
}

:root {
  --fondo: #eef1f4;
  --papel: #ffffff;
  --filete: #dce1e7;
  --filete-campo: #7d8a98;
  --tinta: #16202a;
  --suave: #526070;
  --reloj: #044e8b;
  --pica: #e85125;
  --ob: #044e8b;
  --accion: #b8401b;
  --accion-osc: #9c3415;
  --accion-claro: #fdede7;
  --ob-claro: #e4edf6;
  --ok: #17663b;      --ok-claro: #e3f2ea;
  --aviso: #7a4a00;   --aviso-claro: #fdf0d5;
  --error: #a8201a;   --error-claro: #fbe5e3;
  --radio: 14px;
  --radio-peq: 10px;
  --sombra: 0 1px 2px rgba(22, 32, 42, .06), 0 4px 14px rgba(22, 32, 42, .05);
  --tab-h: 64px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-hoja: cubic-bezier(.32, .72, 0, 1);
  --texto: "Red Hat Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Red Hat Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-family: var(--texto);
  color: var(--tinta);
  background: var(--fondo);
  -webkit-text-size-adjust: 100%;
  accent-color: var(--accion);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--fondo); line-height: 1.4; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
::selection { background: #cfe0f1; color: var(--tinta); }
:focus-visible { outline: 3px solid var(--reloj); outline-offset: 2px; border-radius: 6px; }
img { max-width: 100%; }
.mono, .cifra, .num, .tabla td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.cargando { padding: 40vh 0 0; text-align: center; color: var(--suave); }
.oculto-visual { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- marcas ---------- */
.marcas { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.marcas img { display: block; height: 28px; width: auto; }
.marcas .ob { border-radius: 3px; }

/* ---------- estructura ---------- */
.cabecera {
  position: sticky; top: 0; z-index: 10; background: var(--papel);
  padding: calc(env(safe-area-inset-top) + 10px) max(16px, calc((100% - 788px) / 2)) 10px;
  box-shadow: 0 1px 0 var(--filete);
}
.cabecera::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; background: linear-gradient(90deg, var(--pica) 0 50%, var(--ob) 50% 100%); }

main {
  padding: 20px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px);
  max-width: 820px; margin: 0 auto;
}
main.entra { animation: entra .22s var(--ease) both; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--papel); box-shadow: 0 -1px 0 var(--filete);
  display: flex; padding: 0 max(0px, calc((100% - 820px) / 2)) env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; height: var(--tab-h); border: 0; background: none; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: .75rem; font-weight: 500; color: var(--suave); cursor: pointer;
}
.tabs button svg { width: 24px; height: 24px; transition: transform .18s var(--ease); }
.tabs button[aria-current="page"] { color: var(--accion); font-weight: 700; }
.tabs button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accion); }
.tabs button:active svg { transform: scale(.88); }

h1, h2, h3 { text-wrap: balance; }
h2 { font-size: 1.4rem; line-height: 1.2; margin: 0 0 14px; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 26px 0 10px; }
.sub { color: var(--suave); font-size: .95rem; margin: -8px 0 16px; }

/* ---------- superficies ---------- */
.tarjeta { background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; margin-bottom: 12px; }
.fila { display: flex; align-items: center; gap: 12px; }
.fila .crece { flex: 1; min-width: 0; }
main > .fila:first-child { margin-bottom: 14px; }
main > .fila:first-child h2 { margin: 0; }
.lista { list-style: none; margin: 0; padding: 0; background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; }
.lista > li { padding: 13px 14px; border-bottom: 1px solid var(--filete); }
.lista > li:last-child { border-bottom: 0; }
.lista > li.click, tr.click, .frow.click { cursor: pointer; transition: background-color .15s; }
.lista > li.click:active, tr.click:active, .frow.click:active { background: #f4f6f8; }
.titulo { font-weight: 600; }
.detalle { color: var(--suave); font-size: .88rem; margin-top: 2px; }
.cifra { font-weight: 700; }
.vacio { text-align: center; color: var(--suave); padding: 28px 12px; }
.lista > li.vacio { padding: 28px 12px; }

.foto {
  width: 52px; height: 52px; border-radius: var(--radio-peq); object-fit: cover; flex: none;
  background: var(--fondo); display: flex; align-items: center; justify-content: center; color: #8a96a3;
}
.foto svg { width: 26px; height: 26px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600; line-height: 1.5;
  padding: 1px 9px; border-radius: 99px; background: var(--fondo); color: var(--suave); margin-right: 4px; white-space: nowrap;
}
.chip.ok { background: var(--ok-claro); color: var(--ok); }
.chip.aviso { background: var(--aviso-claro); color: var(--aviso); }
.chip.error { background: var(--error-claro); color: var(--error); }
.chip.pica_pica { background: var(--accion-claro); color: var(--accion); }
.chip.openblue { background: var(--ob-claro); color: var(--ob); }
.punto { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--suave); }
.punto.pica_pica { background: var(--pica); }
.punto.openblue { background: var(--ob); }

.resumen { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.resumen.tres { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.resumen .tarjeta { margin: 0; padding: 12px 14px; }
.resumen .num { font-size: 1.5rem; font-weight: 700; color: var(--reloj); line-height: 1.15; }
.resumen .etq { font-size: .8rem; color: var(--suave); margin-top: 2px; overflow-wrap: anywhere; }

/* ---------- fichar ---------- */
.hola { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.hola h2 { margin: 0; }
.hoy-txt { color: var(--suave); font-size: .95rem; }
.hoy-txt::first-letter { text-transform: uppercase; }
.selector { position: relative; margin-bottom: 12px; }
.selector .punto { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.selector select { padding-left: 34px; font-weight: 600; }
.estampa { animation: estampa .25s var(--ease) both; }

/* tarjeta de horas: una fila por registro */
.ficha { margin-top: 18px; background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; }
.ficha .cab { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 14px 14px 10px; border-top: 4px solid; border-image: linear-gradient(90deg, var(--pica) 0 50%, var(--ob) 50% 100%) 1; }
.ficha .cab b { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.ficha .cab span { font-size: .85rem; color: var(--suave); }
.ficha .fhead, .ficha .frow { display: grid; grid-template-columns: 3.4rem 1fr auto; align-items: center; gap: 6px; padding: 0 14px; }
.ficha .fhead { height: 30px; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--suave); border-bottom: 1px solid var(--filete); }
.ficha .frow { min-height: 50px; align-items: baseline; padding-block: 13px; border-bottom: 1px solid var(--fondo); font-family: var(--mono); font-size: 1rem; font-weight: 500; color: var(--reloj); font-variant-numeric: tabular-nums; }
.ficha .frow:last-child { border-bottom: 0; }
.ficha .frow .dia { font-family: var(--texto); font-weight: 700; color: var(--tinta); line-height: 1.1; }
.ficha .frow .dia small { display: block; font-weight: 500; font-size: .72rem; color: var(--suave); }
.ficha .frow .tot { text-align: right; font-weight: 700; color: var(--tinta); }
.ficha .frow.hoy { background: #fff1eb; }
.ficha .frow.hoy .dia { color: var(--accion); }
.ficha .frow.cerrado { color: var(--suave); }
.ficha .frow .tienda { font-family: var(--texto); font-size: .95rem; color: var(--tinta); display: flex; align-items: center; gap: 7px; min-width: 0; }
.ficha .frow .tienda .punto { width: 8px; height: 8px; border-radius: 2px; }
.ficha .frow.cerrado .tienda { color: var(--suave); }
.obs { grid-column: 2 / -1; display: flex; gap: 6px; align-items: flex-start; margin-top: 4px; font-family: var(--texto); font-size: .85rem; font-weight: 400; color: var(--suave); white-space: pre-wrap; overflow-wrap: anywhere; }
.obs svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.obs span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ficha .vacio { font-family: var(--texto); }
.ficha .pie { padding: 10px 14px 14px; font-size: .85rem; color: var(--suave); }

/* ---------- formularios ---------- */
.campo { display: block; margin-bottom: 14px; }
.campo > span { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 6px; }
.campo small { display: block; color: var(--suave); font-size: .82rem; margin-top: 5px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=month], input[type=search], select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--filete-campo); border-radius: var(--radio-peq); background: var(--papel);
  font-size: 16px; /* evita zoom en iOS */ min-height: 48px;
  transition: border-color .15s, box-shadow .15s;
}
input[type=time], input[type=number] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input::placeholder, textarea::placeholder { color: #6b7785; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--reloj); box-shadow: 0 0 0 3px rgba(4, 78, 139, .22); }
textarea { min-height: 72px; resize: vertical; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.campo .selector { margin-bottom: 0; }
.clave { position: relative; }
.clave input { padding-right: 52px; }
.ojo {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; border-radius: 8px; background: none; color: var(--suave);
  display: grid; place-items: center; cursor: pointer;
}
.ojo svg { width: 22px; height: 22px; }
.ojo[aria-pressed="true"] { color: var(--reloj); }
.horas-min label { display: block; }
.horas-min input, .horas-min select { font-family: var(--mono); font-size: 1.25rem; font-weight: 700; color: var(--reloj); }
.horas-min small { display: block; font-size: .8rem; color: var(--suave); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-height: 44px; }
.check input { width: 22px; height: 22px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--accion); color: #fff; font-weight: 700; text-decoration: none;
  transition: transform .14s var(--ease), background-color .15s;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active:not([disabled]) { transform: scale(.97); background: var(--accion-osc); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.bloque { width: 100%; }
.btn.grande { min-height: 54px; font-size: 1.05rem; }
.btn.sec { background: var(--papel); color: var(--tinta); box-shadow: inset 0 0 0 1px var(--filete-campo); }
.btn.sec:active:not([disabled]) { background: #f4f6f8; }
.btn.peligro { background: var(--papel); color: var(--error); box-shadow: inset 0 0 0 1px #e3a9a4; }
.btn.peligro:active:not([disabled]) { background: var(--error-claro); }
.btn.oscuro { background: var(--tinta); }
.btn.peq { min-height: 40px; padding: 0 12px; font-size: .9rem; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.zona-peligro { margin-top: 32px; padding-top: 18px; border-top: 1px dashed var(--filete-campo); }
.barra { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.barra.una { grid-template-columns: 1fr auto; }
.barra.solo { grid-template-columns: 1fr; }
.barra .btn { white-space: nowrap; padding-inline: 12px; }
.barra.acc { grid-template-columns: auto 1fr; }

.total-vivo {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  background: var(--ob-claro); border-radius: var(--radio-peq); padding: 11px 14px; margin-bottom: 14px; font-size: .95rem; color: var(--ob); font-weight: 600;
}
.total-vivo b { font-family: var(--mono); font-size: 1.15rem; }
.total-vivo.mal { background: var(--aviso-claro); color: var(--aviso); }
.error-form { color: var(--error); font-size: .92rem; font-weight: 500; margin: -4px 0 12px; }
.error-form:empty { display: none; }

.foto-prev { width: 100%; max-height: 220px; object-fit: contain; border-radius: var(--radio-peq); background: var(--fondo); margin-top: 8px; }

/* ---------- login ---------- */
.login { max-width: 400px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 8vh) 20px 40px; }
.login .marca { margin-bottom: 26px; text-align: center; }
.login .marca .marcas {
  justify-content: center; flex-wrap: wrap; gap: 12px 18px; margin-bottom: 22px;
  background: var(--papel); border-radius: var(--radio); padding: 16px 18px; box-shadow: var(--sombra);
}
.login .marca .marcas img { height: 34px; }
.login .marca h1 { margin: 0 0 4px; font-size: 1.5rem; }
.login .marca p { margin: 0; color: var(--suave); }

/* ---------- hoja modal ---------- */
.velo {
  position: fixed; inset: 0; background: rgba(16, 24, 32, .5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  animation: velo .22s ease-out both;
}
.hoja {
  background: var(--fondo); width: 100%; max-width: 620px; max-height: 92vh; max-height: 92dvh; overflow: auto; overscroll-behavior: contain;
  border-radius: 20px 20px 0 0; padding: 10px 16px calc(env(safe-area-inset-bottom) + 20px);
  animation: sube .26s var(--ease-hoja) both;
  box-shadow: 0 -8px 30px rgba(16, 24, 32, .18);
}
.hoja::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: #c3cbd4; margin: 0 auto 10px; }
.hoja .cab { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.hoja .cab h2 { flex: 1; margin: 0; font-size: 1.25rem; }
.hoja .cerrar { border: 0; background: var(--papel); width: 44px; height: 44px; border-radius: 50%; cursor: pointer; box-shadow: var(--sombra); display: grid; place-items: center; color: var(--tinta); }
.hoja .cerrar svg { width: 20px; height: 20px; }
.velo.sale { animation: velo-sale .2s ease-in both; }
.velo.sale .hoja { animation: baja .2s ease-in both; }
@media (min-width: 700px) {
  .velo { align-items: center; }
  .hoja { border-radius: 20px; }
  .hoja::before { display: none; }
}

/* ---------- tabla horas ---------- */
.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--papel); }
.tabla th, .tabla td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--filete); vertical-align: top; }
.tabla th:first-child, .tabla td:first-child { padding-left: 14px; }
.tabla th:last-child, .tabla td:last-child { padding-right: 14px; }
.tabla th { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--suave); }
.tabla td.num, .tabla th.num { text-align: right; white-space: nowrap; }
.tabla td.num { font-weight: 700; color: var(--tinta); }
.tabla td.hor { font-family: var(--mono); color: var(--reloj); white-space: nowrap; }
.tabla td .detalle { display: flex; align-items: center; gap: 6px; }
.tabla td .detalle .punto { width: 8px; height: 8px; border-radius: 2px; }
.tabla tr:last-child td { border-bottom: 0; }
.desplaza { overflow-x: auto; margin-bottom: 14px; background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--tinta); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 100;
  transition: opacity .2s var(--ease), transform .24s var(--ease); max-width: 90vw; font-size: .95rem; font-weight: 500;
  box-shadow: 0 6px 20px rgba(16, 24, 32, .25);
}
#toast.ver { opacity: 1; transform: translate(-50%, 0); }
#toast.arriba { bottom: auto; top: calc(env(safe-area-inset-top) + 16px); }
#toast.error { background: var(--error); }

/* ---------- movimiento ---------- */
.lista > li, .ficha .frow, .tabla tbody tr, .resumen > * { animation: aparece .26s var(--ease) both; }
.lista > li:nth-child(2), .ficha .frow:nth-child(3), .tabla tbody tr:nth-child(2), .resumen > :nth-child(2) { animation-delay: .03s; }
.lista > li:nth-child(3), .ficha .frow:nth-child(4), .tabla tbody tr:nth-child(3), .resumen > :nth-child(3) { animation-delay: .06s; }
.lista > li:nth-child(4), .ficha .frow:nth-child(5), .tabla tbody tr:nth-child(4) { animation-delay: .09s; }
.lista > li:nth-child(5), .ficha .frow:nth-child(6), .tabla tbody tr:nth-child(5) { animation-delay: .12s; }
.lista > li:nth-child(n+6), .ficha .frow:nth-child(n+7), .tabla tbody tr:nth-child(n+6) { animation-delay: .15s; }

@keyframes entra { from { opacity: 0; transform: translateY(6px); } }
@keyframes aparece { from { opacity: 0; transform: translateY(8px); } }
@keyframes sube { from { transform: translateY(100%); } }
@keyframes baja { to { transform: translateY(100%); } }
@keyframes velo { from { background-color: rgba(16, 24, 32, 0); } }
@keyframes velo-sale { to { background-color: rgba(16, 24, 32, 0); } }
@keyframes estampa { 0% { opacity: 0; transform: scale(1.5) rotate(-6deg); } 60% { opacity: 1; transform: scale(.94) rotate(-1deg); } 100% { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .velo, .hoja, main.entra { animation: fundido .15s linear both !important; animation-duration: .15s !important; }
}
@keyframes fundido { from { opacity: 0; } }
