/* ==========================================
   KILOMETRAJE / COMBUSTIBLE (flota.css)
   Patentes animadas, ficha del vehículo, registro diario, gráficos y tabla
   ========================================== */
.flota { max-width: 1000px; margin: 0 auto; --km: #00d2ff; --diesel: #ffb300; --ok: #2ecc71; --aviso: #ffb300; --malo: #ff4d4d; }
.flota-panel { background: #050505; border: 1px solid #1c1c1c; border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.flota-titulo { margin: 0 0 10px; font-size: 13px; font-weight: 500; color: var(--accent-cyan); letter-spacing: .5px; }
.flota-label { text-align: left; margin-bottom: 6px; }
.flota-ayuda { margin: 4px 0 0; font-size: 11px; color: #777; min-height: 14px; }

/* ---------- PATENTES ---------- */
.flota-patentes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; perspective: 900px; }
.patente-card { position: relative; padding: 10px 10px 12px; background: #070707; border: 1px solid #1d1d1d; border-radius: 10px; cursor: pointer; text-align: center;
    opacity: 0; transform: rotateX(-80deg) translateY(-20px); transform-origin: top center;
    transition: border-color .25s, box-shadow .25s, background .25s; }
.patente-card.entrar { animation: patente-entrar .7s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes patente-entrar { to { opacity: 1; transform: rotateX(0) translateY(0); } }
.patente-card img, .patente-card .patente-texto { display: block; width: 100%; aspect-ratio: 23 / 10; object-fit: cover; border-radius: 5px; background: #fff; }
.patente-card .patente-texto { display: flex; align-items: center; justify-content: center; color: #111; font: 700 22px/1 'Arial Black', Arial, sans-serif; letter-spacing: 2px; border: 2px solid #111; box-sizing: border-box; }
.patente-card .patente-info { margin-top: 8px; font-size: 11px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.patente-card .patente-info b { color: #ddd; font-weight: 500; }
.patente-card .patente-estado { position: absolute; top: -8px; right: 8px; font-size: 10px; padding: 2px 8px; border-radius: 10px; background: #111; border: 1px solid; }
.patente-estado.activo { color: var(--ok); border-color: var(--ok); }
.patente-estado.detenido { color: var(--malo); border-color: var(--malo); }
/* Revisión técnica o permiso con problemas: etiqueta "Problema" parpadeando en la esquina izquierda */
.patente-card .patente-problema { position: absolute; top: -8px; left: 8px; font-size: 10px; padding: 2px 8px; border-radius: 10px; background: #111;
    border: 1px solid var(--malo); color: var(--malo); animation: alerta-blink 1s steps(1) infinite; z-index: 2; }
.patente-card.detenido img, .patente-card.detenido .patente-texto { filter: grayscale(.6) brightness(.8); }
@media (hover: hover) {
    .patente-card:hover { border-color: rgba(0, 210, 255, .5); box-shadow: 0 6px 18px rgba(0, 210, 255, .15); }
}
.patente-card.activa { border-color: var(--accent-cyan); background: #031014; box-shadow: 0 0 18px rgba(0, 210, 255, .35); }
.patente-card.activa.entrar { animation: patente-entrar .7s cubic-bezier(.2, 1.4, .4, 1) forwards, patente-flotar 2.6s ease-in-out .7s infinite; }
@keyframes patente-flotar { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.patente-card .brillo { position: absolute; inset: 10px 10px auto; aspect-ratio: 23 / 10; border-radius: 5px; overflow: hidden; pointer-events: none; }
.patente-card.activa .brillo::after { content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .65), transparent); animation: patente-brillo 2.6s ease-in-out infinite; }
@keyframes patente-brillo { 0% { left: -60%; } 55%, 100% { left: 130%; } }

/* ---------- FICHA ---------- */
.flota-ficha { min-height: 120px; }
.ficha-cabecera { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.ficha-cabecera h3 { margin: 0; font-size: 16px; font-weight: 500; color: #fff; }
.ficha-cabecera .ficha-sub { font-size: 12px; color: #888; }
.ficha-alertas { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.ficha-alerta { font-size: 11px; padding: 4px 10px; border-radius: 12px; border: 1px solid; white-space: nowrap; }
.ficha-alerta.ok { color: var(--ok); border-color: rgba(46, 204, 113, .5); }
.ficha-alerta.aviso { color: var(--aviso); border-color: rgba(255, 179, 0, .6); }
.ficha-alerta.malo { color: var(--malo); border-color: rgba(255, 77, 77, .6); }
.ficha-alerta.nulo { color: #888; border-color: #333; }
/* Falta menos de un mes (o ya venció): la alerta parpadea */
.ficha-alerta.parpadea { animation: alerta-blink 1s steps(1) infinite; }
.ficha-alerta.aviso.parpadea { background: rgba(255, 179, 0, .12); }
.ficha-alerta.malo.parpadea { background: rgba(255, 77, 77, .14); }
@keyframes alerta-blink { 50% { opacity: .15; } }
@media (prefers-reduced-motion: reduce) { .ficha-alerta.parpadea { animation-duration: 2s; } }
.ficha-datos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.ficha-dato { display: grid; grid-template-columns: 120px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid #141414; font-size: 12px; min-height: 16px; }
.ficha-dato span { color: #777; }
.ficha-dato b { color: #eee; font-weight: 500; word-break: break-word; }
.ficha-docs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 18px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #1c1c1c; align-items: end; }
.ficha-doc span { display: block; margin-bottom: 4px; font-size: 12px; color: #777; }
/* Campos editables: borde cian para que se note que se pueden modificar */
.ficha-docs .calendario-wrap { margin-bottom: 0; }
.ficha-docs .ficha-input { margin-bottom: 0; height: 34px; padding: 6px 30px 6px 10px; font-size: 13px; color: #eee; background-color: #050505; border: 1px solid rgba(0, 210, 255, .55); border-radius: 6px; }
.ficha-docs .ficha-input:focus { border-color: var(--accent-cyan); box-shadow: 0 0 8px rgba(0, 210, 255, .3); }
.ficha-sino { display: flex; height: 34px; border: 1px solid rgba(0, 210, 255, .55); border-radius: 6px; overflow: hidden; }
.ficha-sino button { flex: 1; margin: 0; padding: 0; border: none; border-radius: 0; background: #050505; box-shadow: none; font-size: 13px; }
.ficha-sino button + button { border-left: 1px solid rgba(0, 210, 255, .35); }
.ficha-sino button.activo { background: var(--accent-cyan); color: #000; font-weight: 600; }
#btnGuardarDocs { margin: 0; height: 34px; padding: 0 12px; background: transparent; color: var(--accent-cyan); border: 1px solid var(--accent-cyan); font-weight: 600; }
.flota .escribiendo::after { content: '▌'; color: var(--accent-cyan); animation: parpadeo-cursor .6s steps(1) infinite; }

/* ---------- REGISTRO DIARIO ---------- */
.flota-form { display: grid; grid-template-columns: 1.1fr 1.2fr 1fr 130px; gap: 10px; align-items: end; }
.flota-form input { margin-bottom: 0; text-transform: none; }
.flota-form .calendario-wrap { margin-bottom: 0; }
#btnGuardarKm { margin: 0; background: var(--accent-cyan); color: #000; font-weight: 600; border-color: var(--accent-cyan); }

/* Odómetro digital: números verdes de 7 segmentos; cada número sube al tocarlo */
.odometro { display: flex; align-items: center; gap: 2px; height: 42px; padding: 0 6px; background: #050505; border: 1px solid #2a2a2a; border-radius: 8px; box-sizing: border-box; outline: none; }
.odometro.cambiado { border-color: rgba(0, 230, 60, .6); }
.odometro .odo-digito { width: 22px; height: 34px; margin: 0; padding: 1px; background: none; border: 1px solid transparent; border-radius: 4px; box-shadow: none; cursor: pointer; }
.odo-digito svg { display: block; width: 100%; height: 100%; }
.odo-digito polygon { fill: #0d230f; transition: fill .15s; }
.odo-digito polygon.on { fill: #19ff3c; filter: drop-shadow(0 0 2px rgba(25, 255, 60, .7)); }
.odo-digito.pulso { animation: odo-pulso .25s ease-out; }
@keyframes odo-pulso { 50% { transform: scale(1.15); } }
@media (hover: hover) {
    .odometro .odo-digito:hover { background: none; box-shadow: none; border-color: rgba(25, 255, 60, .5); }
    .odometro .odo-reset:hover { background: none; box-shadow: none; color: #19ff3c; }
}
.odo-km { margin: 0 2px 0 5px; font: 700 13px Arial, sans-serif; color: #19ff3c; }
.odometro .odo-reset { width: auto; box-shadow: none; margin: 0 0 0 auto; padding: 2px 6px; background: none; border: none; color: #777; font-size: 16px; cursor: pointer; }

/* Litros consumidos: etiqueta calculada con la aguja (no se escribe) */
.flota-litros { display: flex; align-items: center; height: 42px; padding: 0 12px; background: #050505; border: 1px solid #2a2a2a; border-radius: 8px;
    box-sizing: border-box; color: var(--diesel); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Medidor de combustible (E a F) */
.flota-registro { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: center; }
.flota-medidor { text-align: center; }
.medidor-combustible { background: #000; border: 1px solid #1d1d1d; border-radius: 10px; padding: 8px 10px 0; cursor: pointer; touch-action: none; outline: none; }
.medidor-combustible:focus-visible { border-color: var(--accent-cyan); }
.medidor-combustible.nuevo { border-color: rgba(0, 210, 255, .6); box-shadow: 0 0 12px rgba(0, 210, 255, .2); }
.medidor-combustible svg { display: block; width: 100%; height: auto; }
.medidor-arco { fill: none; stroke: #fff; stroke-width: 4; }
.medidor-marcas line { stroke: #fff; }
.medidor-letra { fill: #fff; font: 400 20px Arial, sans-serif; }
.medidor-bomba path, .medidor-bomba rect { fill: #f5b300; }
.medidor-bomba .hueco { fill: #000; }
.medidor-bomba .manguera { fill: none; stroke: #f5b300; stroke-width: 2; }
.medidor-aguja { transform-origin: 100px 122px; transition: transform .9s cubic-bezier(.25, .8, .3, 1); }   /* movimiento lento y suave */
.medidor-aguja path { fill: #e01b1b; }
.medidor-combustible.sin-dato .medidor-aguja { opacity: .25; }
.medidor-texto { margin: 6px 0 0; font-size: 12px; color: #ccc; line-height: 1.4; }
.medidor-texto b { color: #fff; font-weight: 600; }
.medidor-texto small { color: #777; font-size: 11px; }

/* ---------- RESUMEN ---------- */
.flota-cabecera { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.flota-cabecera .flota-titulo { margin: 0; }
.flota-periodos { display: flex; gap: 6px; }
.flota-periodos button { width: auto; margin: 0; padding: 5px 12px; font-size: 11px; border-radius: 14px; }
.flota-periodos button.activo { background: var(--accent-cyan); color: #000; border-color: var(--accent-cyan); }
.flota-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.flota-kpi { background: #080808; border: 1px solid #1a1a1a; border-radius: 8px; padding: 10px 12px; }
.flota-kpi span { display: block; font-size: 11px; color: #888; margin-bottom: 4px; }
.flota-kpi b { font-size: 20px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.flota-kpi small { font-size: 11px; color: #888; margin-left: 3px; }
.flota-kpi.km { border-left: 3px solid var(--km); }
.flota-kpi.diesel { border-left: 3px solid var(--diesel); }

/* ---------- GRÁFICOS ---------- */
.flota-graficos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.flota-grafico { margin: 0; background: #080808; border: 1px solid #1a1a1a; border-radius: 8px; padding: 10px 10px 4px; position: relative; }
.flota-grafico figcaption { font-size: 12px; color: #bbb; margin-bottom: 4px; }
.flota-grafico svg { display: block; width: 100%; height: 190px; overflow: visible; }
.flota-grafico .eje text { fill: #777; font-size: 10px; font-family: inherit; }
.flota-grafico .grilla line { stroke: #1d1d1d; stroke-width: 1; }
.flota-grafico .base { stroke: #333; stroke-width: 1; }
.flota-grafico .barra { transition: opacity .15s; pointer-events: none; }
.flota-grafico .zona:hover + .barra, .flota-grafico .barra.hover { opacity: .75; }
.flota-grafico .vacio { fill: #555; font-size: 12px; }
.grafico-tooltip { position: absolute; pointer-events: none; background: #111; border: 1px solid #333; border-radius: 6px; padding: 6px 9px; font-size: 11px; color: #ddd;
    white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .12s; z-index: 5; }
.grafico-tooltip b { color: #fff; }
.grafico-tooltip.visible { opacity: 1; }

/* ---------- TABLA ---------- */
.flota-tabla-wrap { max-height: 320px; overflow-y: auto; margin-bottom: 0; }
.flota-tabla thead th { position: sticky; top: 0; z-index: 1; }
.flota-tabla th:nth-child(n+2), .flota-tabla td:nth-child(n+2) { text-align: right; }
.flota-tabla td:nth-child(n+3) { color: #ddd; font-weight: normal; }
.flota-tabla td:nth-child(2) { color: #ddd; font-weight: normal; }
.flota-tabla td:nth-child(3) { color: var(--km); font-weight: 600; }
.flota-tabla td:nth-child(4) { color: var(--diesel); font-weight: 600; }
.flota-tabla td { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- CELULAR ---------- */
/* Tablet: el registro no cabe en 4 columnas al lado del medidor → los campos uno bajo otro */
@media (min-width: 761px) and (max-width: 1000px) {
    .flota-form { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .flota-patentes { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .ficha-datos { grid-template-columns: 1fr; }
    .ficha-docs { grid-template-columns: 1fr 1fr; }
    #btnGuardarDocs { grid-column: 1 / -1; }
    .ficha-alertas { margin-left: 0; }
    .flota-form { grid-template-columns: 1fr; }
    .flota-registro { grid-template-columns: 1fr; }
    .flota-medidor { max-width: 240px; margin: 0 auto; width: 100%; }
    #btnGuardarKm, .flota-form > div:nth-child(3) { grid-column: 1 / -1; }
    .flota-kpis { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .flota-kpi { padding: 8px 9px; }
    .flota-graficos { grid-template-columns: 1fr; }
    .flota-kpi b { font-size: 17px; }
}
.ficha-docs .ficha-texto { padding-right: 10px; caret-color: var(--cursor-color); }
