/* ===== Reset básico ===== */
body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #0b132b; /* azul oscuro */
  color: #ffffff;
}

/* ===== Header y menú ===== */
header {
  background: #0d1b2a;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.4rem;
  margin: 0;
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 20px;
}

nav ul li a {
  color: #e0e0e0;
  text-decoration: none;
  font-weight: 500;
}

nav ul li a:hover {
  color: #ff7a00; /* naranja corporativo */
}

/* ===== Formularios ===== */
form#vehicleForm {
  display: grid;
  gap: 12px;
  max-width: 500px;
  background: #1b263b;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

form#vehicleForm label {
  font-weight: 600;
}

form#vehicleForm input {
  padding: 10px;
  border: 1px solid #394867;
  border-radius: 8px;
  background: #fff;
  color: #000;
}

form#vehicleForm button {
  margin-top: 10px;
  padding: 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #ff7a00;
  color: white;
  font-weight: 700;
  font-size: 1rem;
  transition: background 0.3s;
}

form#vehicleForm button:hover {
  background: #e56e00;
}

/* ===== Lista de vehículos ===== */
#vehicleList {
  margin-top: 15px;
  padding-left: 20px;
}

#vehicleList li {
  margin-bottom: 8px;
  padding: 10px;
  background: #1b263b;
  border-radius: 6px;
}

/* ===== Pre-compra v2 – layout mínimo ===== */
.wrap { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.card { background:#0d1b2a; border:1px solid #1f2d44; border-radius:12px; box-shadow:0 6px 16px rgba(0,0,0,.35); }
.card-h { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; padding:16px 20px; border-bottom:1px solid #1f2d44; }
.card-c { padding:20px; }
.title { margin:0 0 4px; font-size:1.25rem; }
.subtitle { margin:0; color:#a9b4c9; font-size:.95rem; }

.layout.row { display:flex; gap:20px; flex-wrap:wrap; }
.col.toc { flex: 1 1 280px; position:sticky; top:16px; align-self:flex-start; }
.col.main { flex: 2 1 640px; }
.kpi, .kpi-group { display:flex; gap:14px; flex-wrap:wrap; align-items:center; }
.pill { padding:6px 10px; border:1px solid #32415d; border-radius:999px; color:#cfe0ff; }

/* ===== Controles y botones ===== */
.actions { display:flex; flex-direction:column; gap:10px; margin-top:14px; }
.actions .btn,
.btn,
.btn-link {
  appearance:none; cursor:pointer; border-radius:10px; 
  border:1px solid #32415d; background:#132238; color:#fff;
  padding:10px 12px; font-weight:600;
}
.btn:hover { background:#182b49; }
.btn-link { background:transparent; border-color:#23314d; padding:8px 10px; }
.btn-link:hover { background:#14233a; }
.btn:disabled { opacity:.5; cursor:not-allowed; }

/* ===== Tabla ===== */
.table { width:100%; border-collapse:collapse; background:#0f1a2f; border:1px solid #1f2d44; border-radius:10px; overflow:hidden; }
.table th, .table td { padding:10px; border-bottom:1px solid #1f2d44; text-align:left; }
.table thead th { background:#12233e; font-weight:700; }
.field textarea, .field input[type="text"] {
  width:100%; background:#0f1a2f; border:1px solid #1f2d44; border-radius:8px; color:#fff; padding:10px;
}
.field label { display:block; margin:10px 0 6px; font-weight:700; }

/* ===== Toolbar del sistema (timer) ===== */
.system .sys-toolbar { display:flex; justify-content:space-between; align-items:center; gap:12px; margin:8px 0 14px; }

/* ===== Pills B/R/M/NA ===== */
.opts { display:flex; gap:.5rem; flex-wrap:wrap; }
.opt {
  padding:.4rem .65rem;
  border:1px solid #32415d;
  border-radius:999px;
  background:#0f1a2f;
  color:#dbe7ff;
  cursor:pointer;
  font-size:.9rem;
  transition:transform .05s ease, background .15s ease, border-color .15s ease;
}
.opt:hover { transform:translateY(-1px); background:#132238; }
.opt--active { color:#0b132b; font-weight:700; }

/* Colores por estado activo */
.opt--B.opt--active  { background:#2ecc71; border-color:#2ecc71; color:#0b132b; } /* verde (Bueno)   */
.opt--R.opt--active  { background:#f1c40f; border-color:#f1c40f; color:#0b132b; } /* amarillo (Regular) */
.opt--M.opt--active  { background:#e74c3c; border-color:#e74c3c; color:#fff;    } /* rojo (Malo)    */
.opt--NA.opt--active { background:#95a5a6; border-color:#95a5a6; color:#0b132b; } /* gris (No aplica) */

/* Opcional: estados “suaves” al pasar, antes de seleccionar */
.opt--B:hover { border-color:#2ecc71; }
.opt--R:hover { border-color:#f1c40f; }
.opt--M:hover { border-color:#e74c3c; }
.opt--NA:hover{ border-color:#95a5a6; }

/* ===== Botones del timer alineados a tu color corporativo ===== */
.btn-group .btn { padding:.45rem .7rem; }
.btn-group .btn:first-child { border-color:#28a745; } /* ▶ Iniciar: verde */
.btn-group .btn:nth-child(2) { border-color:#f1c40f; } /* ⏸ Pausar: amarillo */
.btn-group .btn:nth-child(3) { border-color:#e74c3c; } /* ⟲ Reset: rojo */

/* ===== Inputs de la cabecera ===== */
.kpi input[type="text"]{
  background:#fff; color:#000; border:1px solid #394867; border-radius:8px; padding:8px 10px;
}
/* --- Fix header del generador V2 --- */
.card-h{
  align-items: end;            /* alinea las etiquetas con los inputs */
  row-gap: 12px;               /* espacio vertical extra */
}

.kpi{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); /* responsive */
  column-gap: 16px;            /* separa inputs entre sí */
  row-gap: 10px;               /* separa filas (inputs vs pill) */
  align-items: end;
  min-width: 300px;
}

.kpi > div{ min-width: 0; }    /* permite que los inputs encojan sin romper */

.kpi label{
  display: block;
  font-size: 12px;
  color: #a9b4c9;
  margin: 0 0 4px 2px;
}

.kpi input{
  width: 100%;
  box-sizing: border-box;
  height: 38px;                /* altura uniforme */
  padding: 8px 10px;
  border: 1px solid #394867;
  border-radius: 10px;         /* esquinas suaves */
  background: #fff;
  color: #0b132b;
  outline: none;
}

.kpi input:focus{
  outline: 2px solid #ff7a00;  /* naranja corporativo */
  outline-offset: 0;
}

.pill#reportIdPill{
  grid-column: 1 / -1;         /* fuerza que el ID pase a la siguiente fila */
  justify-self: end;           /* alineado a la derecha */
  margin-top: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px dashed #32415d;
  color: #a9b4c9;
  font-size: 12px;
}

/* opcional: espaciar un poco más la línea bajo el header */
.card-h + .card-c{ padding-top: 18px; }

/* ===========================
   RESPONSIVE — Generador + Visor
   =========================== */

/* ----- Helpers generales ----- */
.table-wrap{ overflow-x:auto; }
.table-wrap::-webkit-scrollbar,
.tbl-wrap::-webkit-scrollbar{ height:8px; }
.table-wrap::-webkit-scrollbar-thumb,
.tbl-wrap::-webkit-scrollbar-thumb{ background:#1f2d44; border-radius:8px; }

/* Asegura un ancho mínimo para tablas en pantallas chicas */
.table, .tbl{ min-width: 640px; }

/* Botones y pills: mejores targets táctiles */
.btn, .opt{ min-height: 40px; }
.opt{ padding: 8px 12px; }

/* Inputs: altura mínima para táctil */
input[type="text"], textarea{ min-height: 40px; }

/* ====== Breakpoint TABLET (<= 1024px) ====== */
/* ====== TABLET (<= 1024px) ====== */
@media (max-width: 1024px){

  /* Generador: layout a una columna (TOC debajo si lo deseas) */
  .layout{ display:grid; grid-template-columns: 1fr; gap:16px; }
  .main{ order: 1; }
  .toc{ order: 2; }

  /* Header del generador: apilado y respirando */
  .card-h{ flex-direction: column; align-items: stretch; }
  .kpi{
    display:grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    column-gap: 16px;
    row-gap: 10px;
  }
  .pill#reportIdPill{
    grid-column: 1 / -1;
    justify-self: end;
  }

  /* Botones principales: ancho completo si hace falta */
  .actions .btn{ width: 100%; }

  /* Visor: header en 1 columna + KPIs debajo (alineados al ancho del contenido) */
  .hdr{ grid-template-columns: 1fr !important; }
  .hdr .logo{ max-width: 220px; }
  .hdr .summary{ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

  /* Tablas: evita cortes y habilita desplazamiento horizontal */
  .table-wrap{ overflow-x: auto; }
  .table, .tbl{ min-width: 720px; }
  /* Sticky thead puede tapar filas dentro de contenedores con overflow en iPad: lo desactivamos */
  .table thead th, .tbl thead th{ position: static !important; }
}

/* ====== MÓVIL (<= 640px) ====== */
@media (max-width: 640px){

  /* Legibilidad y respiración */
  body{ font-size: 14px; }
  .wrap{ padding: 0 10px; }

  /* KPI del generador a 1 columna */
  .kpi{
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .pill#reportIdPill{
    justify-self: stretch;
    text-align: center;
  }

  /* Botonera del sistema (generador) */
  .btn-group{ flex-wrap: wrap; gap: 8px; }
  .btn-group .btn{ flex: 1 1 48%; }

  /* Opciones B/R/M/NA en 2x2 para no apretar */
  .opts{ flex-wrap: wrap; gap: 8px; }
  .opts .opt{ flex: 1 1 calc(50% - 8px); text-align: center; min-height: 40px; }

  /* Tablas: ancho mínimo más chico + padding */
  .table, .tbl{ min-width: 520px; }
  .table th, .table td, .tbl th, .tbl td{ padding: 8px; }

  /* Visor: header compacto y KPIs fluidos */
  .hdr .logo{ max-height: 48px; }
  .hdr h1{ font-size: 20px; }
  .hdr-info{ grid-template-columns: 1fr; gap: 6px; }
  .hdr .summary{ grid-template-columns: 1fr; gap: 10px; }

  /* Barra del visor más pequeña en mobile */
  .report-toolbar{ padding: 8px; gap: 6px; }
  .report-toolbar .btn{ padding: 8px 10px; min-height: 38px; }
}

/* ====== EXTRA SMALL (<= 380px) ====== */
@media (max-width: 380px){
  .opts .opt{ flex: 1 1 100%; }   /* una por fila si es muy angosto */
  .kpi .value{ font-size: 14px; }
}
