/* =====================================================================
   Catálogo de despiece · hoja de estilos única
   Idea: esto no es una tienda, es un expediente técnico. Las referencias
   OEM son la identidad de cada pieza, así que la tipografía monoespaciada
   es el elemento protagonista, no un detalle.
   ===================================================================== */

:root {
  --tinta:      #15181b;
  --tinta-70:   #3d4448;
  --apagado:    #69726f;
  --papel:      #eff1ef;
  --panel:      #ffffff;
  --linea:      #d6dad8;
  --linea-sutil:#e6e9e7;
  --petroleo:   #12474f;
  --petroleo-cl:#e3edee;
  --ambar:      #b8690a;
  --ambar-cl:   #fbf0df;
  --rojo:       #9d2b1f;
  --rojo-cl:    #f8e6e3;

  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --r: 3px;
  --sombra: 0 1px 2px rgba(21, 24, 27, .06), 0 6px 18px -12px rgba(21, 24, 27, .28);
  --ancho: 1180px;
}

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

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--tinta);
  background: var(--papel);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--petroleo); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--tinta); }

img { max-width: 100%; display: block; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: clamp(1.65rem, 1.2rem + 1.8vw, 2.4rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 1em; }

:focus-visible { outline: 2px solid var(--petroleo); outline-offset: 2px; }

/* --- Piezas tipográficas reutilizables ------------------------------- */

.mono { font-family: var(--mono); font-variant-ligatures: none; }

.eyebrow {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--apagado);
  margin: 0 0 .6rem;
}

/* La referencia es el dato que el comprador va a comparar con su pieza:
   se trata como una etiqueta física, no como texto corrido. */
.ref {
  font-family: var(--mono);
  font-size: .86rem;
  font-weight: 600;
  letter-spacing: .04em;
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  padding: .18em .5em;
  display: inline-block;
  white-space: nowrap;
}
.ref--sm { font-size: .76rem; }

.silencio { color: var(--apagado); }
.pequeno  { font-size: .85rem; }
.centro   { text-align: center; }

/* --- Estructura ------------------------------------------------------- */

.envoltorio { width: 100%; max-width: var(--ancho); margin: 0 auto; padding: 0 20px; }

.cabecera {
  background: var(--panel);
  border-bottom: 1px solid var(--linea);
  position: sticky;
  top: 0;
  z-index: 30;
}
.cabecera__fila {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 60px;
  flex-wrap: wrap;
}
.marca {
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
  color: var(--tinta);
  display: flex;
  align-items: baseline;
  gap: .55rem;
}
.marca span { font-family: var(--mono); font-size: .7rem; letter-spacing: .12em; color: var(--petroleo); text-transform: uppercase; }
.navegacion { display: flex; gap: 1.1rem; margin-left: auto; align-items: center; flex-wrap: wrap; }
.navegacion a { font-size: .92rem; text-decoration: none; color: var(--tinta-70); }
.navegacion a:hover, .navegacion a[aria-current] { color: var(--petroleo); }

.principal { padding: 2.5rem 0 4rem; }
.seccion + .seccion { margin-top: 3rem; }

.pie {
  border-top: 1px solid var(--linea);
  background: var(--panel);
  padding: 2rem 0;
  font-size: .87rem;
  color: var(--apagado);
}
.pie a { color: var(--tinta-70); }

/* --- Portada ---------------------------------------------------------- */

.portada {
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  padding: 2.2rem;
  box-shadow: var(--sombra);
}
.portada__lema { font-size: 1.05rem; max-width: 62ch; color: var(--tinta-70); }

/* Ficha técnica del coche: rejilla de datos, no párrafos. */
.datos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0;
  border-top: 1px solid var(--linea);
  margin-top: 1.6rem;
}
.datos div {
  border-bottom: 1px solid var(--linea-sutil);
  border-right: 1px solid var(--linea-sutil);
  padding: .7rem .9rem .7rem 0;
}
.datos dt { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--apagado); margin-bottom: .15rem; }
.datos dd { margin: 0; font-weight: 550; }

/* --- Rejilla de piezas ------------------------------------------------ */

.rejilla {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.tarjeta {
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .15s ease, transform .15s ease;
}
.tarjeta:hover { border-color: var(--petroleo); transform: translateY(-2px); }
.tarjeta__foto {
  aspect-ratio: 4 / 3;
  background: var(--papel);
  object-fit: cover;
  width: 100%;
  border-bottom: 1px solid var(--linea-sutil);
}
.tarjeta__vacio {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(135deg, var(--papel), var(--papel) 10px, #e8ebe9 10px, #e8ebe9 20px);
  border-bottom: 1px solid var(--linea-sutil);
  color: var(--apagado);
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.tarjeta__cuerpo { padding: .85rem .95rem 1rem; display: flex; flex-direction: column; gap: .45rem; flex: 1; }
.tarjeta__titulo { font-weight: 620; font-size: .98rem; line-height: 1.3; }
.tarjeta__titulo a { color: var(--tinta); text-decoration: none; }
.tarjeta__titulo a:hover { color: var(--petroleo); text-decoration: underline; }
.tarjeta__pie { margin-top: auto; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* --- Estado: cada uno con su propio tono, nunca sólo con color -------- */

.estado {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .74rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .22em .6em;
  border-radius: 100px;
  border: 1px solid;
}
.estado::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.estado--ok      { color: var(--petroleo); background: var(--petroleo-cl); border-color: #bcd6d9; }
.estado--aviso   { color: var(--ambar);    background: var(--ambar-cl);    border-color: #ecd6ab; }
.estado--espera  { color: var(--tinta-70); background: var(--papel);       border-color: var(--linea); }
.estado--reserva { color: var(--rojo);     background: var(--rojo-cl);     border-color: #e8c4bd; }
.estado--fin     { color: var(--apagado);  background: var(--papel);       border-color: var(--linea); }

.logistica { font-size: .78rem; color: var(--apagado); display: flex; gap: .35rem; align-items: center; }

/* --- Filtros ---------------------------------------------------------- */

.filtros {
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: grid;
  gap: .75rem;
  grid-template-columns: minmax(200px, 2fr) repeat(auto-fit, minmax(140px, 1fr)) auto;
  align-items: end;
}
.campo { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.campo > label { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--apagado); font-weight: 650; }

input[type=text], input[type=search], input[type=email], input[type=tel],
input[type=number], input[type=password], input[type=date], input[type=url],
select, textarea {
  font: inherit;
  font-size: .95rem;
  color: var(--tinta);
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  padding: .5rem .6rem;
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; min-height: 5.5rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--petroleo); outline: none; box-shadow: 0 0 0 3px rgba(18, 71, 79, .12); }
input.mono, textarea.mono { font-family: var(--mono); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem; }
.chip {
  font-size: .82rem;
  text-decoration: none;
  color: var(--tinta-70);
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: 100px;
  padding: .28rem .7rem;
}
.chip:hover { border-color: var(--petroleo); }
.chip[aria-current] { background: var(--tinta); border-color: var(--tinta); color: #fff; }
.chip small { color: inherit; opacity: .6; margin-left: .3rem; }

/* --- Botones ---------------------------------------------------------- */

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  font: inherit;
  font-size: .93rem;
  font-weight: 600;
  line-height: 1.2;
  padding: .6rem 1rem;
  border-radius: var(--r);
  border: 1px solid var(--tinta);
  background: var(--tinta);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}
.boton:hover { background: #000; color: #fff; }
.boton--primario { background: var(--petroleo); border-color: var(--petroleo); }
.boton--primario:hover { background: #0d363c; color: #fff; }
.boton--suave { background: var(--panel); color: var(--tinta); border-color: var(--linea); }
.boton--suave:hover { background: var(--papel); color: var(--tinta); border-color: var(--petroleo); }
.boton--peligro { background: var(--panel); color: var(--rojo); border-color: #e8c4bd; }
.boton--peligro:hover { background: var(--rojo-cl); color: var(--rojo); }
.boton--sm { font-size: .82rem; padding: .35rem .65rem; }
.boton--bloque { width: 100%; }
.boton[disabled] { opacity: .45; cursor: not-allowed; }

.acciones { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* --- Ficha de pieza --------------------------------------------------- */

.ficha { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .85fr); gap: 2rem; align-items: start; }

/* Firma visual del sitio: la cabecera de la ficha imita la etiqueta que
   acompaña físicamente a la pieza en la estantería. */
.etiqueta {
  background: var(--panel);
  border: 1px solid var(--linea);
  border-left: 4px solid var(--petroleo);
  border-radius: var(--r);
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.4rem;
}
.etiqueta__codigo {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--petroleo);
}
.etiqueta h1 { margin: .3rem 0 .6rem; }
.etiqueta__meta { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

.galeria { display: grid; gap: .6rem; }
.galeria__principal {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  aspect-ratio: 4 / 3;
  object-fit: contain;
}
.galeria__tiras { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .5rem; }
.galeria__tiras button {
  padding: 0;
  border: 1px solid var(--linea);
  border-radius: var(--r);
  background: var(--panel);
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 1;
}
.galeria__tiras button[aria-current] { border-color: var(--petroleo); box-shadow: 0 0 0 2px rgba(18,71,79,.18); }
.galeria__tiras img { width: 100%; height: 100%; object-fit: cover; }
.galeria__rol {
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--apagado);
  min-height: 1.2em;
}

.video { position: relative; aspect-ratio: 16/9; border: 1px solid var(--linea); border-radius: var(--r); overflow: hidden; background: var(--tinta); }
.video iframe { width: 100%; height: 100%; border: 0; display: block; }
.video__portada { width: 100%; height: 100%; object-fit: cover; opacity: .75; }
.video__boton {
  position: absolute; inset: 0; width: 100%; border: 0; cursor: pointer;
  background: transparent; color: #fff; font: inherit; font-weight: 650;
  display: grid; place-items: center; gap: .4rem;
}
.video__boton span { background: rgba(0,0,0,.62); padding: .5rem 1rem; border-radius: 100px; font-size: .9rem; }

.bloque {
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.bloque > h2 { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--apagado); margin-bottom: .9rem; }

.lista-datos { margin: 0; display: grid; gap: .6rem; }
.lista-datos > div { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: .8rem; align-items: baseline; }
.lista-datos dt { font-size: .8rem; color: var(--apagado); }
.lista-datos dd { margin: 0; }

.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th {
  text-align: left;
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--apagado);
  font-weight: 700;
  padding: .45rem .6rem .45rem 0;
  border-bottom: 1px solid var(--linea);
  white-space: nowrap;
}
.tabla td { padding: .6rem .6rem .6rem 0; border-bottom: 1px solid var(--linea-sutil); vertical-align: top; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla--compacta td, .tabla--compacta th { font-size: .85rem; }

/* Medidor de certeza: cuatro cuadrados que se llenan según el nivel.
   Codifica la evidencia real, no decora. */
.certeza { display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; }
.certeza__barras { display: inline-flex; gap: 2px; }
.certeza__barras i { width: 7px; height: 13px; background: var(--linea); border-radius: 1px; display: block; }
.certeza__barras i.on { background: var(--petroleo); }
.certeza--D .certeza__barras i.on { background: var(--apagado); }
.certeza__letra { font-family: var(--mono); font-weight: 700; font-size: .8rem; }

.aviso {
  border-left: 3px solid var(--ambar);
  background: var(--ambar-cl);
  padding: .8rem 1rem;
  border-radius: 0 var(--r) var(--r) 0;
  font-size: .89rem;
  color: #6b3d05;
}
.aviso strong { color: #5a3304; }

.nota { border-left: 3px solid var(--linea); padding-left: .9rem; color: var(--tinta-70); font-size: .92rem; }

.defecto { border-left: 3px solid var(--rojo); background: var(--rojo-cl); padding: .8rem 1rem; border-radius: 0 var(--r) var(--r) 0; font-size: .9rem; }

/* --- Barra de solicitud ----------------------------------------------- */

.solicitud-barra {
  position: sticky;
  bottom: 0;
  z-index: 25;
  background: var(--tinta);
  color: #fff;
  padding: .7rem 0;
  box-shadow: 0 -6px 20px -14px rgba(0,0,0,.7);
}
.solicitud-barra .envoltorio { display: flex; align-items: center; gap: 1rem; justify-content: space-between; flex-wrap: wrap; }
.solicitud-barra a { color: #fff; }
.solicitud-barra .boton { background: #fff; color: var(--tinta); border-color: #fff; }
.solicitud-barra .boton:hover { background: var(--papel); color: var(--tinta); }
.contador { font-family: var(--mono); font-weight: 700; }

.mensaje { padding: .8rem 1rem; border-radius: var(--r); margin-bottom: 1rem; font-size: .92rem; border: 1px solid; }
.mensaje--ok    { background: var(--petroleo-cl); border-color: #bcd6d9; color: #0d363c; }
.mensaje--error { background: var(--rojo-cl); border-color: #e8c4bd; color: var(--rojo); }

.error-campo { color: var(--rojo); font-size: .84rem; }

.vacio {
  background: var(--panel);
  border: 1px dashed var(--linea);
  border-radius: var(--r);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--apagado);
}

.paginacion { display: flex; gap: .4rem; justify-content: center; margin-top: 2rem; flex-wrap: wrap; }
.paginacion a, .paginacion span {
  min-width: 2.2rem; text-align: center; padding: .35rem .6rem;
  border: 1px solid var(--linea); border-radius: var(--r);
  background: var(--panel); text-decoration: none; font-size: .9rem;
}
.paginacion [aria-current] { background: var(--tinta); color: #fff; border-color: var(--tinta); }

/* --- Panel privado ---------------------------------------------------- */

.admin { background: #f6f7f6; }
.admin .cabecera { background: var(--tinta); border-bottom-color: #000; }
.admin .marca, .admin .navegacion a { color: #fff; }
.admin .marca span { color: #8fb3b8; }
.admin .navegacion a:hover, .admin .navegacion a[aria-current] { color: #8fb3b8; }

.tablero { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.5rem; }
.metrica { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--r); padding: .9rem 1rem; }
.metrica b { display: block; font-size: 1.7rem; font-family: var(--mono); letter-spacing: -.02em; line-height: 1.1; }
.metrica span { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--apagado); }
.metrica--alerta b { color: var(--ambar); }

.fila-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: .8rem; }
.fila-form--ancha { grid-template-columns: 1fr; }

.repetible { border: 1px solid var(--linea); border-radius: var(--r); padding: .8rem; margin-bottom: .6rem; background: #fbfcfb; }
.repetible__cabecera { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.repetible__n { font-family: var(--mono); font-size: .78rem; color: var(--apagado); }

.casilla { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.casilla input { width: auto; }

.miniatura-admin { display: flex; gap: .8rem; align-items: flex-start; border: 1px solid var(--linea); border-radius: var(--r); padding: .6rem; background: var(--panel); margin-bottom: .5rem; }
.miniatura-admin img { width: 86px; height: 86px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--linea-sutil); }
.miniatura-admin__datos { flex: 1; min-width: 0; font-size: .85rem; }

.privado {
  border: 1px solid #d8ccb4;
  background: #fdfaf2;
  border-radius: var(--r);
  padding: 1rem;
}
.privado > h3 { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: #8a6d2f; }

.entrar { max-width: 380px; margin: 4rem auto; }

details.pliegue { border: 1px solid var(--linea); border-radius: var(--r); background: var(--panel); margin-bottom: 1rem; }
details.pliegue > summary { cursor: pointer; padding: .8rem 1rem; font-weight: 600; font-size: .92rem; list-style: none; }
details.pliegue > summary::-webkit-details-marker { display: none; }
details.pliegue > summary::before { content: "▸ "; color: var(--apagado); }
details.pliegue[open] > summary::before { content: "▾ "; }
details.pliegue > div { padding: 0 1rem 1rem; }

.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Responsive ------------------------------------------------------- */

@media (max-width: 900px) {
  .ficha { grid-template-columns: 1fr; }
  .filtros { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .principal { padding: 1.5rem 0 3rem; }
  .portada { padding: 1.4rem; }
  .filtros { grid-template-columns: 1fr; }
  .rejilla { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
  .lista-datos > div { grid-template-columns: 1fr; gap: .1rem; }
  .cabecera__fila { min-height: 54px; }
  .navegacion { gap: .8rem; font-size: .88rem; }
}

@media print {
  .cabecera, .pie, .solicitud-barra, .acciones { display: none; }
  body { background: #fff; }
  .bloque, .etiqueta { break-inside: avoid; }
}

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