/* =============================================================================
   JR SNAP CREW · app de empleados (Juniper Ridge Construction)
   -----------------------------------------------------------------------------
   Para el teléfono, con botones grandes (guantes, sol, prisa). Colores de la
   marca con contraste AA. Sin nada de afuera: la política de seguridad solo
   permite lo propio, y los anchos que cambian (barras) se ponen desde el JS.
   ============================================================================= */
@font-face {
    font-family: "Montserrat";
    src: url("fonts/montserrat-latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "Playfair Display";
    src: url("fonts/playfair-display-latin-700-normal.woff2") format("woff2");
    font-weight: 700; font-style: normal; font-display: swap;
}

:root {
    --tinta: #141414;
    --tinta-2: #26231f;
    --crema: #f6f3ec;
    --tarjeta: #ffffff;
    --linea: #e8e1d2;
    --oro: #c9a95c;
    --oro-texto: #7a6027;
    --oro-suave: #f5eddb;
    --texto: #1f1f1f;
    --tenue: #5f5b53;
    --ok: #155d3b;
    --ok-suave: #e3f3ea;
    --aviso: #8a4b00;
    --aviso-suave: #fff1dc;
    --error: #b42318;
    --error-suave: #fdecea;
    --radio: 18px;
    --sombra: 0 1px 2px rgba(20, 20, 20, .05), 0 10px 28px rgba(20, 20, 20, .08);
    --serif: "Playfair Display", Georgia, "Times New Roman", serif;
    --arriba: env(safe-area-inset-top, 0px);
    --abajo: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
    margin: 0; min-height: 100%; background: var(--crema); color: var(--texto);
    font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
img { max-width: 100%; display: block; }
a { color: var(--oro-texto); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--oro); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; color: var(--tinta); }
h1 { font-family: var(--serif); font-size: 1.75rem; }
h2 { font-size: 1.15rem; font-weight: 750; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .8rem; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.cw-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.cw-tenue { color: var(--tenue); }
.cw-chico { font-size: .86rem; }

/* --- Marco ------------------------------------------------------------------ */
.cw-app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.cw-barra {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
    background: var(--tinta); color: #fff; padding: calc(10px + var(--arriba)) 14px 10px;
}
.cw-marca { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .2px; flex: 1; min-width: 0; }
.cw-marca b { color: var(--oro); font-weight: 800; }
.cw-ico-btn { background: transparent; border: 0; color: inherit; padding: 8px; margin: -8px 0 -8px -6px; border-radius: 12px; cursor: pointer; }
.cw-red { font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); white-space: nowrap; }
.cw-red.sin { background: #5a2a00; color: #ffd9a6; }
.cw-main { flex: 1; padding: 16px 16px calc(96px + var(--abajo)); width: 100%; max-width: 680px; margin: 0 auto; outline: none; }
.cw-main.lleno { padding: 0; max-width: none; }

.cw-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
    background: rgba(255, 255, 255, .97); border-top: 1px solid var(--linea); padding: 6px 8px calc(6px + var(--abajo));
    backdrop-filter: blur(10px);
}
.cw-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--tenue); text-decoration: none; font-size: .74rem; font-weight: 600; border-radius: 12px; }
.cw-nav a.activo { color: var(--tinta); }
.cw-nav a.activo svg { color: var(--oro-texto); }

/* --- Barra de subida (pendientes) -------------------------------------------- */
.cw-subida { position: sticky; top: calc(54px + var(--arriba)); z-index: 19; background: var(--tinta-2); color: #fff; padding: 8px 16px 10px; }
.cw-subida-fila { display: flex; align-items: center; gap: 10px; font-size: .86rem; font-weight: 600; }
.cw-subida-txt { flex: 1; }
.cw-subida .cw-link { color: var(--oro); }
.cw-barrita { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .15); overflow: hidden; margin-top: 7px; }
.cw-barrita span {
    display: block; height: 100%; width: 0; border-radius: inherit; transition: width .4s ease;
    background: linear-gradient(90deg, #b8964a, #e3c77f, #b8964a); background-size: 200% 100%;
}
.cw-subida.activa .cw-barrita span { animation: cw-brillo 1.4s linear infinite; }
@keyframes cw-brillo { from { background-position: 200% 0; } to { background-position: 0 0; } }

/* --- Piezas --------------------------------------------------------------------- */
.cw-tarjeta { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 18px; margin-bottom: 14px; }
.cw-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 52px; padding: 12px 20px;
    border: 0; border-radius: 14px; background: var(--tinta); color: #fff; font: inherit; font-weight: 700; font-size: 1rem;
    text-decoration: none; cursor: pointer; width: 100%; touch-action: manipulation;
}
.cw-btn:disabled { opacity: .5; cursor: default; }
.cw-btn-oro { background: linear-gradient(180deg, #d6b86c, #b8964a); color: var(--tinta); }
.cw-btn-suave { background: #ece6d8; color: var(--tinta); }
.cw-btn-peligro { background: var(--error-suave); color: var(--error); }
.cw-btn-grande { min-height: 64px; font-size: 1.08rem; border-radius: 18px; }
.cw-botones { display: grid; gap: 10px; margin-top: 14px; }
.cw-botones.dos { grid-template-columns: 1fr 1fr; }
.cw-link { background: none; border: 0; padding: 6px 2px; font: inherit; font-weight: 700; color: var(--oro-texto); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.cw-campo { display: block; margin-bottom: 12px; }
.cw-campo > span { display: block; font-size: .86rem; font-weight: 700; margin-bottom: 5px; }
.cw-input, .cw-textarea, .cw-select {
    width: 100%; min-height: 52px; border: 1.5px solid var(--linea); border-radius: 14px; background: #fff;
    padding: 12px 14px; font: inherit; font-size: 1.05rem; color: var(--texto);
}
.cw-textarea { min-height: 90px; resize: vertical; }
.cw-input:focus, .cw-textarea:focus, .cw-select:focus { border-color: var(--oro); outline: none; box-shadow: 0 0 0 3px rgba(201, 169, 92, .25); }
.cw-codigo { letter-spacing: 10px; text-align: center; font-size: 1.6rem; font-weight: 700; }
.cw-chip { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #efe9dc; color: var(--tinta-2); white-space: nowrap; }
.cw-chip.ok { background: var(--ok-suave); color: var(--ok); }
.cw-chip.aviso { background: var(--aviso-suave); color: var(--aviso); }
.cw-chip.error { background: var(--error-suave); color: var(--error); }
.cw-chip.oro { background: var(--oro-suave); color: var(--oro-texto); }
.cw-nota { border-radius: 14px; padding: 12px 14px; font-size: .92rem; margin-bottom: 12px; background: var(--oro-suave); color: var(--tinta-2); }
.cw-nota.ok { background: var(--ok-suave); color: var(--ok); }
.cw-nota.aviso { background: var(--aviso-suave); color: var(--aviso); }
.cw-nota.error { background: var(--error-suave); color: var(--error); }
.cw-nota strong { display: block; }

/* --- Entrar ------------------------------------------------------------------------ */
.cw-solo .cw-centro, .cw-entrar { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
.cw-centro { padding: 24px 16px; max-width: 460px; margin: 0 auto; }
.cw-entrar .cw-logo { width: 74px; height: auto; margin: 0 auto 10px; }
.cw-entrar h1 { text-align: center; margin-bottom: 2px; }
.cw-entrar .cw-sub { text-align: center; color: var(--tenue); margin-bottom: 20px; }
.cw-idiomas { display: flex; justify-content: center; gap: 8px; margin-bottom: 18px; }
.cw-idiomas button { border: 1.5px solid var(--linea); background: #fff; border-radius: 999px; padding: 6px 14px; font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; }
.cw-idiomas button[aria-pressed="true"] { background: var(--tinta); color: #fff; border-color: var(--tinta); }

/* --- Inicio ------------------------------------------------------------------------- */
.cw-hola { margin: 4px 0 14px; }
.cw-hola h1 { font-size: 1.6rem; margin: 0; }
.cw-checkin-btn { position: relative; overflow: hidden; }
.cw-checkin-btn svg { width: 26px; height: 26px; }
.cw-buscar { position: relative; margin: 6px 0 10px; }
.cw-buscar svg { position: absolute; left: 14px; top: 15px; color: var(--tenue); }
.cw-buscar .cw-input { padding-left: 44px; }
.cw-tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.cw-tabs button { flex: none; border: 0; background: #ebe4d5; color: var(--tinta-2); border-radius: 999px; padding: 9px 15px; font: inherit; font-weight: 700; font-size: .88rem; cursor: pointer; }
.cw-tabs button[aria-selected="true"] { background: var(--tinta); color: #fff; }
.cw-tabs .n { opacity: .7; margin-left: 3px; }
.cw-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cw-proy {
    display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: #fff; border: 0; border-radius: 16px;
    box-shadow: var(--sombra); padding: 14px; font: inherit; color: inherit; cursor: pointer;
}
.cw-proy .cw-proy-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--oro-suave); color: var(--oro-texto); display: grid; place-items: center; flex: none; }
.cw-proy.terminado .cw-proy-ico { background: #ececec; color: #555; }
.cw-proy-txt { flex: 1; min-width: 0; }
.cw-proy-txt strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-proy-txt small { display: block; color: var(--tenue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-proy-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.cw-grupo { font-size: .75rem; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 800; color: var(--tenue); margin: 16px 2px 8px; }
.cw-vacio { text-align: center; padding: 28px 12px; color: var(--tenue); }
.cw-vacio svg { width: 40px; height: 40px; margin: 0 auto 8px; color: var(--oro-texto); }
.cw-borrador { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.cw-borrador > div { flex: 1; min-width: 0; }
.cw-borrador > .cw-btn { flex-basis: 100%; }

/* --- Radar del check-in ------------------------------------------------------------- */
.cw-cargando { display: grid; place-items: center; min-height: 50vh; }
.cw-radar { position: relative; width: 170px; height: 170px; margin: 18px auto 14px; display: grid; place-items: center; }
.cw-radar span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--oro); opacity: 0; animation: cw-onda 2.4s ease-out infinite; }
.cw-radar span:nth-child(2) { animation-delay: .8s; }
.cw-radar span:nth-child(3) { animation-delay: 1.6s; }
.cw-radar .cw-pin { position: relative; width: 64px; height: 64px; border-radius: 50%; background: var(--tinta); color: var(--oro); display: grid; place-items: center; box-shadow: 0 8px 22px rgba(0, 0, 0, .25); animation: cw-late 1.2s ease-in-out infinite; }
.cw-radar .cw-pin svg { width: 30px; height: 30px; }
@keyframes cw-onda { 0% { transform: scale(.35); opacity: .9; } 100% { transform: scale(1); opacity: 0; } }
@keyframes cw-late { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.cw-paso { text-align: center; font-weight: 700; min-height: 1.6em; }
.cw-pasos { display: flex; justify-content: center; gap: 6px; margin: 10px 0 4px; }
.cw-pasos i { width: 8px; height: 8px; border-radius: 50%; background: #d9d1bf; }
.cw-pasos i.hecho { background: var(--oro); }
.cw-resultado { text-align: center; }
.cw-resultado .cw-lista, .cw-resultado .cw-nota { text-align: left; }
.cw-resultado .cw-gran-ico { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; margin: 6px auto 12px; background: var(--ok-suave); color: var(--ok); animation: cw-aparece .35s ease-out; }
.cw-resultado .cw-gran-ico.aviso { background: var(--aviso-suave); color: var(--aviso); }
.cw-resultado .cw-gran-ico.error { background: var(--error-suave); color: var(--error); }
.cw-resultado .cw-gran-ico svg { width: 36px; height: 36px; }
@keyframes cw-aparece { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cw-dir { color: var(--tenue); font-size: .92rem; }

/* --- Fotos ------------------------------------------------------------------------------ */
.cw-fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.cw-foto { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #ddd; }
.cw-foto img { width: 100%; height: 100%; object-fit: cover; }
.cw-foto button { position: absolute; top: 4px; right: 4px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .62); color: #fff; display: grid; place-items: center; cursor: pointer; }
.cw-foto button svg { width: 18px; height: 18px; }
.cw-foto .cw-foto-n { position: absolute; left: 6px; bottom: 6px; font-size: .7rem; font-weight: 800; color: #fff; background: rgba(0, 0, 0, .55); border-radius: 999px; padding: 1px 7px; }
.cw-oculto-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* --- Recorrido (cámara a pantalla completa) ---------------------------------------------- */
.cw-camara { position: fixed; inset: 0; z-index: 40; background: #000; color: #fff; display: flex; flex-direction: column; }
.cw-camara video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cw-cam-arriba { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; padding: calc(12px + var(--arriba)) 14px 12px; background: linear-gradient(180deg, rgba(0, 0, 0, .7), rgba(0, 0, 0, 0)); }
.cw-rec { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cw-rec i { width: 12px; height: 12px; border-radius: 50%; background: #ff3b30; animation: cw-parpadeo 1s steps(2, start) infinite; }
.cw-rec.pausa i { background: #aaa; animation: none; }
@keyframes cw-parpadeo { to { visibility: hidden; } }
.cw-cam-proy { flex: 1; min-width: 0; font-size: .82rem; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.cw-nivel { position: relative; z-index: 2; margin: 0 14px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.cw-nivel span { display: block; height: 100%; width: 0; background: #34c759; border-radius: inherit; }
.cw-cam-aviso { position: relative; z-index: 2; margin: 10px 14px 0; padding: 10px 12px; border-radius: 12px; background: rgba(255, 159, 10, .92); color: #1a1a1a; font-weight: 700; font-size: .9rem; }
.cw-cam-aviso.error { background: rgba(255, 69, 58, .95); color: #fff; }
.cw-cam-abajo { position: relative; z-index: 2; margin-top: auto; padding: 12px 14px calc(16px + var(--abajo)); background: linear-gradient(0deg, rgba(0, 0, 0, .75), rgba(0, 0, 0, 0)); }
.cw-tira { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; min-height: 56px; }
.cw-tira img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .8); flex: none; }
.cw-cam-botones { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.cw-disparo { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: rgba(255, 255, 255, .25); cursor: pointer; transition: transform .1s; }
.cw-disparo:active { transform: scale(.92); background: #fff; }
.cw-cam-lado { background: rgba(0, 0, 0, .45); color: #fff; border: 1.5px solid rgba(255, 255, 255, .55); border-radius: 14px; min-height: 50px; padding: 8px 10px; font: inherit; font-weight: 700; font-size: .88rem; cursor: pointer; }
.cw-flash { position: absolute; inset: 0; z-index: 3; background: #fff; opacity: 0; pointer-events: none; }
.cw-flash.on { animation: cw-flash .25s ease-out; }
@keyframes cw-flash { from { opacity: .8; } to { opacity: 0; } }

/* --- Historial ------------------------------------------------------------------------------ */
.cw-env { display: flex; gap: 12px; align-items: flex-start; }
.cw-env .cw-proy-ico { width: 40px; height: 40px; border-radius: 12px; background: var(--oro-suave); color: var(--oro-texto); display: grid; place-items: center; flex: none; }
.cw-env > div { flex: 1; min-width: 0; }

/* --- Avisos y diálogo -------------------------------------------------------------------------- */
.cw-toast { position: fixed; left: 16px; right: 16px; bottom: calc(86px + var(--abajo)); z-index: 60; max-width: 520px; margin: 0 auto; background: var(--tinta); color: #fff; padding: 13px 16px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); font-weight: 600; font-size: .94rem; }
.cw-toast.error { background: var(--error); }
.cw-dialogo { border: 0; border-radius: 20px; padding: 22px; width: min(92vw, 420px); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.cw-dialogo::backdrop { background: rgba(0, 0, 0, .5); }
.cw-dialogo h2 { margin-bottom: 8px; }
.cw-dialogo-botones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.cw-dialogo-botones .cw-btn { min-height: 48px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
@media (min-width: 720px) {
    .cw-fotos { grid-template-columns: repeat(4, 1fr); }
}
