/* ==========================================================
   Control de Maquinaria - estilos base
   Pensado para uso en campo: alto contraste, objetivos táctiles
   grandes y lectura bajo luz solar.
   ========================================================== */

:root {
    --asfalto: #22262A;
    --asfalto-2: #2E343A;
    --concreto: #E9EBE7;
    --papel: #FFFFFF;
    --ambar: #F5B301;
    --ambar-claro: #FFC81F;
    --tinta: #1B1E21;
    --tinta-suave: #5B646B;
    --linea: #D4D8D2;
    --linea-fuerte: #9AA29A;
    --ok: #1F7A4D;
    --ok-fondo: #E3F2E9;
    --aviso: #8A5A00;
    --aviso-fondo: #FFF1CC;
    --error: #B3261E;
    --error-fondo: #FBE4E1;
    --info: #1F5F8B;

    --radio: 6px;
    --radio-grande: 10px;
    --fuente-titulo: 'Barlow Semi Condensed', 'Arial Narrow', system-ui, sans-serif;
    --fuente: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--fuente);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--tinta);
    background: var(--concreto);
}

h1, h2, h3 {
    font-family: var(--fuente-titulo);
    font-weight: 700;
    line-height: 1.15;
    margin: 0 0 .5em;
}
h1 { font-size: clamp(1.6rem, 4vw, 2rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--info); }
img { max-width: 100%; }

:focus-visible {
    outline: 3px solid var(--tinta);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px var(--ambar);
}

.texto-suave { color: var(--tinta-suave); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: 48px; padding: .6rem 1.25rem;
    border: 2px solid transparent; border-radius: var(--radio);
    font: 600 1rem/1.1 var(--fuente);
    text-decoration: none; cursor: pointer;
    transition: background-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primario { background: var(--ambar); color: var(--tinta); border-color: var(--tinta); }
.btn-primario:hover { background: var(--ambar-claro); }
.btn-oscuro { background: var(--asfalto); color: #fff; }
.btn-oscuro:hover { background: var(--asfalto-2); }
.btn-borde { background: transparent; color: var(--tinta); border-color: var(--linea-fuerte); }
.btn-borde:hover { background: rgba(0,0,0,.05); }
.btn-borde-claro { background: transparent; color: #E8EBE6; border-color: #5B646B; }
.btn-borde-claro:hover { background: rgba(255,255,255,.08); }
.btn-bloque { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.cargando { opacity: .7; cursor: progress; }

/* ---------- Formularios ---------- */
.campo { margin-bottom: 1.1rem; }
.campo label { display: block; font-weight: 600; margin-bottom: .35rem; }
.campo input, .campo select, .campo textarea {
    width: 100%; min-height: 48px; padding: .65rem .8rem;
    border: 2px solid var(--linea-fuerte); border-radius: var(--radio);
    background: var(--papel); color: inherit; font: inherit;
}
.campo textarea { min-height: 96px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { border-color: var(--tinta); }
.campo-ayuda { font-size: .875rem; color: var(--tinta-suave); margin: .3rem 0 0; }
.campo-error { font-size: .875rem; color: var(--error); font-weight: 500; margin: .3rem 0 0; }

.entrada-clave { position: relative; }
.entrada-clave input { padding-right: 5.5rem; }
.entrada-clave-btn {
    position: absolute; top: 6px; right: 6px; bottom: 6px;
    padding: 0 .8rem; border: 0; border-radius: 4px;
    background: var(--concreto); color: var(--tinta);
    font: 600 .875rem var(--fuente); cursor: pointer;
}

.rejilla-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
@media (max-width: 640px) { .rejilla-2 { grid-template-columns: 1fr; } }

/* ---------- Alertas ---------- */
.alerta {
    display: flex; gap: .6rem; align-items: flex-start;
    padding: .8rem 1rem; margin-bottom: 1.1rem;
    border-left: 5px solid; border-radius: var(--radio);
    font-weight: 500;
}
.alerta-error { background: var(--error-fondo); border-color: var(--error); color: #6E1510; }
.alerta-ok    { background: var(--ok-fondo);    border-color: var(--ok);    color: #114B2F; }
.alerta-aviso { background: var(--aviso-fondo); border-color: var(--ambar); color: #4D3200; }
.alerta-info  { background: #E1EEF6;            border-color: var(--info);  color: #123B56; }

/* ---------- Tarjetas ---------- */
.tarjeta {
    background: var(--papel); border: 1px solid var(--linea);
    border-radius: var(--radio-grande); overflow: hidden; margin-bottom: 1.5rem;
}
.tarjeta-cuerpo { padding: 1.5rem; }
.tarjeta-centrada { width: 100%; max-width: 440px; }
.tarjeta-ancha { width: 100%; max-width: 760px; }

.franja-peligro {
    height: 12px;
    background: repeating-linear-gradient(-45deg, var(--ambar) 0 12px, var(--asfalto) 12px 24px);
}

.auth-centro {
    min-height: 100vh; display: grid; place-items: center; align-content: center;
    padding: 1.5rem 1rem;
}

/* ---------- Tablas e insignias (se usan desde la Fase 1) ---------- */
.tabla-contenedor { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; background: var(--papel); }
.tabla th, .tabla td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--linea); }
.tabla th { font-family: var(--fuente-titulo); font-size: 1rem; background: var(--concreto); }
.insignia {
    display: inline-block; padding: .15rem .6rem; border-radius: 999px;
    font-size: .8125rem; font-weight: 600; background: var(--concreto);
}
.insignia-ok { background: var(--ok-fondo); color: var(--ok); }
.insignia-aviso { background: var(--aviso-fondo); color: var(--aviso); }
.insignia-error { background: var(--error-fondo); color: var(--error); }

/* ---------- Odómetro de tambores (elemento distintivo) ---------- */
.odo {
    display: inline-flex; gap: 3px; font-size: 1.75rem;
    font-family: var(--fuente-titulo); font-variant-numeric: tabular-nums;
}
.odo-d {
    display: inline-block; min-width: .95em; padding: .1em .12em;
    text-align: center; font-weight: 700; line-height: 1.15;
    color: #F2F4F0; border-radius: 3px;
    background: linear-gradient(180deg, #353B41 0%, #1A1D20 50%, #353B41 100%);
    box-shadow: inset 0 0 0 1px #0E1012;
}
.odo-dec {
    color: var(--tinta);
    background: linear-gradient(180deg, #FFD04D 0%, #F5B301 50%, #E3A400 100%);
}

/* ---------- Pantalla de ingreso ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 5fr) minmax(360px, 6fr); }
.login-marca {
    display: flex; flex-direction: column; justify-content: space-between;
    background: var(--asfalto); color: #E8EBE6;
}
.login-marca-interior { margin-block: auto; padding: 3rem clamp(1.5rem, 4vw, 3.5rem); }
.marca-nombre { font: 700 1.35rem var(--fuente-titulo); color: var(--ambar); margin-bottom: 1.5rem; }
.login-odo .odo { font-size: clamp(1.8rem, 4.2vw, 3.2rem); }
.login-lema { max-width: 26ch; margin: 1.75rem 0 0; font: 600 1.4rem/1.25 var(--fuente-titulo); color: #C9CFC8; }
.login-panel { display: grid; place-items: center; padding: 2rem 1.25rem; }
.login-form { width: 100%; max-width: 400px; }
.login-form h1 { margin-bottom: 1.25rem; }
.login-ayuda { margin-top: 1rem; text-align: center; }
.error-codigo { margin-bottom: 1rem; }

@media (max-width: 820px) {
    .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .login-marca-interior { padding: 1.25rem; }
    .marca-nombre { margin-bottom: .75rem; }
    .login-odo .odo { font-size: 1.6rem; }
    .login-lema { display: none; }
    .franja-peligro { height: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ==========================================================
   Componentes de las Fases 1 a 6
   ========================================================== */
[hidden] { display: none !important; }

.btn-chico { min-height: 38px; padding: .35rem .8rem; font-size: .9375rem; }
.btn-grande { min-height: 56px; font-size: 1.125rem; }
.btn-peligro { background: var(--error); color: #fff; }
.btn-peligro:hover { background: #8F1D17; }

.barra-acciones { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.barra-acciones-inicio { justify-content: flex-start; align-items: center; }

.tarjeta-form { max-width: 820px; }
fieldset { margin: 0 0 1.25rem; padding: 1rem 1.25rem; border: 2px solid var(--linea); border-radius: var(--radio); }
legend { padding: 0 .5rem; font: 700 1.1rem var(--fuente-titulo); }
.etiqueta-grupo { margin: 1rem 0 .5rem; font-weight: 600; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; margin-bottom: .5rem; }
.check { display: flex; align-items: center; gap: .6rem; min-height: 44px; padding: .4rem .7rem;
    border: 2px solid var(--linea-fuerte); border-radius: var(--radio); background: var(--papel); cursor: pointer; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--tinta); flex: none; }

/* Filtros */
.filtros {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; align-items: end;
    margin-bottom: 1.25rem; padding: 1rem 1rem .25rem;
    background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio-grande);
}
.filtros .campo-ancho { grid-column: span 2; }
.filtros-acciones { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
@media (max-width: 640px) { .filtros .campo-ancho { grid-column: auto; } }

/* Tablas */
.acciones-fila { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.acciones-fila form { margin: 0; }
.tabla td strong { font-weight: 600; }
.paginacion { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1rem; margin: 1rem 0 2rem; }

/* Totales de reportes */
.resumen-chips { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem; }
.chip-total {
    display: flex; flex-direction: column; min-width: 170px; padding: .7rem 1rem;
    background: var(--papel); border: 1px solid var(--linea); border-left: 5px solid var(--ambar); border-radius: var(--radio);
}
.chip-total strong { font: 700 1.25rem var(--fuente-titulo); }

.rejilla-reportes { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.enlace-tarjeta { display: block; margin: 0; text-decoration: none; color: inherit; border-left: 5px solid var(--ambar); }
.enlace-tarjeta:hover { background: #FBFBF9; }
.enlace-tarjeta h2 { margin-bottom: .35rem; }
.enlace-tarjeta p { margin: 0; }

.rejilla-resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 0 1.25rem; }
@media (max-width: 520px) { .rejilla-resumen { grid-template-columns: 1fr; } }
.cifra-grande { margin: 0; font: 700 2rem var(--fuente-titulo); }

/* Detalle de jornada */
.datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem 1.5rem; margin: 0 0 1rem; }
.datos dt { font-size: .875rem; color: var(--tinta-suave); }
.datos dd { margin: 0; font-weight: 600; }
.fotos { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.fotos figure { margin: 0; }
.fotos img { display: block; width: 100%; max-height: 380px; object-fit: contain; background: var(--asfalto); border-radius: var(--radio); }
.fotos figcaption { margin-top: .4rem; font-weight: 500; }
.auditoria-json { margin: .4rem 0 0; font-size: .8125rem; word-break: break-word; }

.vista-previa { display: block; width: 100%; max-height: 260px; margin-top: .6rem; object-fit: contain; background: var(--asfalto); border-radius: var(--radio); }
.campo-error-bloque { color: var(--error); }

/* Impresión de pantallas (reglas completas en print.css) */
.solo-imprimir { display: none; }
