/* Autopartes HGR · app de patio. Pensada para usarse con una mano, al sol y con guantes:
   botones grandes, alto contraste, una columna. */
:root {
  --bg: #EEF1F4; --surface: #FFFFFF; --surface-2: #F6F8FA; --fg: #1A2129; --muted: #5D6874; --line: #D3D9E0;
  --accent: #1D5BA8; --accent-fg: #FFFFFF; --accent-soft: #E2ECF8;
  --tag: #EED8A2; --tag-fg: #4F3B0C; --tag-line: #D2B56E;
  --ok: #1E6B3D; --ok-bg: #DCF0E3; --warn: #8A5A00; --warn-bg: #FCEBC7; --bad: #B3261E; --bad-bg: #FBE4E2;
  --gris: #6B7480; --gris-bg: #E8EBEF;
  --shadow: 0 10px 30px rgba(16, 24, 34, .16);
  --f-display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151A; --surface: #191F26; --surface-2: #1F262E; --fg: #E5E9ED; --muted: #98A3AF; --line: #2E363F;
    --accent: #6FA3E6; --accent-fg: #0E1620; --accent-soft: #1E2E44;
    --tag: #463A1E; --tag-fg: #F2DCA0; --tag-line: #6A5628;
    --ok: #7FD3A0; --ok-bg: #173326; --warn: #F2C266; --warn-bg: #3A2E14; --bad: #F28B82; --bad-bg: #3A1C1A;
    --gris: #AAB3BD; --gris-bg: #262D35;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 16px; line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.oculto { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
label.btn { position: relative; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* barra superior */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--accent); color: var(--accent-fg);
}
.brand { font-family: var(--f-display); font-weight: 700; font-size: 22px; letter-spacing: .02em; color: inherit; text-decoration: none; }
.brand span { opacity: .75; }
.who { font-size: 13px; opacity: .9; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* contenido */
.view { max-width: 720px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; margin: 0; text-wrap: balance; line-height: 1.1; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: var(--f-body); font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.cargando { color: var(--muted); padding: 40px 0; text-align: center; }
.fila { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fila.entre { justify-content: space-between; }
.pila { display: flex; flex-direction: column; gap: 10px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }

/* botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-decoration: none;
  color: var(--fg); cursor: pointer; text-align: center;
}
.btn.primario { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.peligro { color: var(--bad); border-color: var(--bad); }
.btn.peligro.armado { background: var(--bad); color: var(--surface); }
.btn.chico { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.btn.ancho { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.acciones { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* formularios */
.campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.campos .completo { grid-column: 1 / -1; }
@media (max-width: 460px) { .campos { grid-template-columns: minmax(0, 1fr); } }
label.campo { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; color: var(--muted); min-width: 0; }
label.campo input, label.campo select, label.campo textarea, .buscar {
  width: 100%; min-width: 0; min-height: 48px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 400; font-size: 16px; color: var(--fg);
}
label.campo textarea { min-height: 84px; resize: vertical; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; min-height: 44px; }
label.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.ayuda { font-size: 13px; color: var(--muted); font-weight: 400; }
.mayus { text-transform: uppercase; font-family: var(--f-mono); letter-spacing: .04em; }

/* resumen */
.resumen { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dato { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 2px; }
.dato .n { font-family: var(--f-display); font-weight: 700; font-size: 30px; font-variant-numeric: tabular-nums; line-height: 1.05; }
.dato .l { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }

/* chips de filtro */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips a { flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); text-decoration: none; font-size: 14px; font-weight: 600; }
.chips a.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* listas */
.lista { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.item { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.item:first-child { border-top: 0; }
.item.sin-foto { grid-template-columns: minmax(0, 1fr) auto; }
.thumb { width: 64px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .s { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.item .der { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.precio { font-family: var(--f-display); font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vacio { padding: 28px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* etiqueta tipo SKU */
.sku { font-family: var(--f-mono); font-size: 12px; background: var(--tag); color: var(--tag-fg); border: 1px solid var(--tag-line); border-radius: 3px 10px 10px 3px; padding: 1px 8px 1px 6px; white-space: nowrap; }
.sku.grande { font-size: 15px; padding: 3px 12px 3px 8px; }

/* estados */
.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.chip.borrador, .chip.baja { background: var(--gris-bg); color: var(--gris); }
.chip.en_revision, .chip.lista { background: var(--warn-bg); color: var(--warn); }
.chip.publicada { background: var(--accent-soft); color: var(--accent); }
.chip.vendida { background: var(--ok-bg); color: var(--ok); }
.chip.montada { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line); }

/* fotos */
.fotos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.foto { position: relative; aspect-ratio: 4 / 3; max-width: 100%; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.foto img { width: 100%; height: 100%; object-fit: cover; }
.foto .tipo { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.foto .quitar { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: 16px; line-height: 30px; padding: 0; cursor: pointer; }
.foto.subiendo::after { content: "Subiendo…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; font-size: 13px; font-weight: 600; }

.texto-ficha { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 14px; max-height: 280px; overflow: auto; }
.historial div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding-block: 6px; font-variant-numeric: tabular-nums; font-size: 14px; }

.aviso { border-radius: 10px; padding: 12px 14px; font-weight: 500; }
.aviso.error { background: var(--bad-bg); color: var(--bad); }
.aviso.info { background: var(--accent-soft); color: var(--accent); }
.aviso.warn { background: var(--warn-bg); color: var(--warn); }

/* login */
.login { max-width: 420px; margin: 8vh auto 0; width: 100%; }

/* barra inferior */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar a { display: grid; place-items: center; min-height: 60px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; }
.tabbar a.on { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 30;
  background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow);
  max-width: calc(100% - 32px); text-align: center;
}
.toast.error { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: var(--surface); }

/* --- avisos y fotos por grupo --- */
.aviso.ok { background: var(--ok-bg); color: var(--ok); }
.ancho-total { grid-column: 1 / -1; }
.contador { font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.contador.lleno { color: var(--warn); }
.zona { transition: border-color .15s, background-color .15s; }
.zona.encima { border: 2px dashed var(--accent); background: var(--accent-soft); }
.zona.bloqueada .fotos { opacity: .55; }
.soltar { border: 1.5px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); font-size: 14px; font-weight: 600; background: var(--surface-2); }
.vacio-fotos { grid-column: 1 / -1; }
.lista.sin-borde { border: 0; border-radius: 0; }
.usuario select { min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); padding: 4px 8px; }
.dos-columnas { display: flex; flex-direction: column; gap: 16px; }
.col-fotos, .col-datos { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* celular o PC: según el tipo de puntero */
@media (pointer: fine) { .solo-movil { display: none !important; } }
@media (pointer: coarse) { .solo-escritorio { display: none !important; } }

/* --- escritorio: menú lateral y ficha a dos columnas --- */
@media (min-width: 960px) {
  body.con-menu { padding-bottom: 24px; padding-left: 220px; }
  body.con-menu .topbar { margin-left: -220px; padding-left: 236px; }
  .tabbar { top: 0; bottom: 0; right: auto; width: 220px; display: flex; flex-direction: column; gap: 4px; padding: 76px 12px 16px; border-top: 0; border-right: 1px solid var(--line); z-index: 9; }
  .tabbar a { min-height: 46px; justify-items: start; padding: 0 14px; border-radius: 8px; place-items: center start; }
  .tabbar a.on { box-shadow: none; background: var(--accent-soft); }
  .view { max-width: 1180px; padding: 24px 28px; }
  .dos-columnas { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; gap: 20px; }
  .dos-columnas > .col-fotos { position: sticky; top: 76px; }
  .resumen { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .acciones { grid-template-columns: repeat(2, minmax(0, max-content)); }
  .fotos { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .campos.cuatro { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .toast { bottom: 24px; left: calc(50% + 110px); }
  .item { padding: 10px 16px; }
}
@media (max-width: 959px) { .solo-escritorio.mayus { display: none; } }

/* ejemplos dentro de campos vacíos: claramente distintos de un dato */
::placeholder { color: var(--muted); opacity: .6; font-style: italic; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--fg); opacity: 1; -webkit-text-fill-color: var(--fg); cursor: default; }
.aviso.guardado { font-weight: 600; border: 1px solid currentColor; }
.item.editando { display: block; background: var(--surface-2); }
.completo-item { width: 100%; }
.mayus::placeholder { text-transform: none; font-family: var(--f-body); letter-spacing: 0; }

/* descripción del vehículo: ejemplo muy tenue */
textarea.tenue::placeholder { opacity: .35; }
.chip.siniestro { background: var(--bad-bg); color: var(--bad); }
.una-columna { max-width: 760px; display: flex; flex-direction: column; gap: 16px; }
.datos-veh { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.5; }

/* NIU del Folio de Retiro: siempre visible */
.encabezado-veh { align-items: center; }
.niu { display: inline-flex; align-items: baseline; gap: 6px; background: var(--fg); color: var(--bg); border: 0; border-radius: 8px; padding: 6px 12px; font-family: var(--f-mono); font-size: 13px; letter-spacing: .04em; cursor: pointer; }
.niu b { font-size: 17px; }
.niu.vacio-niu { background: var(--warn-bg); color: var(--warn); cursor: default; font-family: var(--f-body); font-weight: 600; }
.niu.chico-niu { padding: 1px 8px; font-size: 11px; cursor: default; }
.niu.chico-niu b { font-size: 12px; }
.con-boton { flex-wrap: nowrap; }
.con-boton input { flex: 1; }

/* v1.7 · expediente legal */
.expediente { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 4px; }
.exp { border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; border: 2px solid transparent; }
.exp .exp-nombre { font-weight: 600; font-size: 14px; line-height: 1.2; }
.exp .exp-estado { font-weight: 700; font-size: 16px; }
.exp .exp-det { opacity: .85; }
.exp .btn { margin-top: auto; }
.exp.subido { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.exp.falta { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.exp.pendiente { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.texto-ok { color: var(--ok); font-weight: 700; } .texto-bad { color: var(--bad); font-weight: 700; }
.chip.exp-ok { background: var(--ok-bg); color: var(--ok); }
.chip.exp-falta { background: var(--bad-bg); color: var(--bad); }
@media (max-width: 420px) { .expediente { grid-template-columns: 1fr; } .exp { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; } .exp .btn { margin: 0 0 0 auto; } }

/* v1.8 · IA */
.aviso-sonnet .fila { margin-top: 10px; gap: 8px; flex-wrap: wrap; }
#iaAviso:not(:empty) { margin-top: 10px; }
.tabla-ia { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla-ia th, .tabla-ia td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line, rgba(127,127,127,.25)); }
.tabla-ia th { font-weight: 600; color: var(--muted, inherit); font-size: 12px; }

/* v1.8.1 · gasto de IA en Inicio */
.fila-inicio { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.gasto-ia { display: flex; border: 1px solid var(--line, rgba(127,127,127,.3)); border-radius: 12px; background: var(--surface, #fff); color: inherit; text-decoration: none; overflow: hidden; }
.gasto-ia:empty { display: none; }
.gasto-ia .gia { display: flex; flex-direction: column; padding: 8px 16px; min-width: 130px; }
.gasto-ia .gia + .gia { border-left: 1px solid var(--line, rgba(127,127,127,.3)); }
.gasto-ia .l { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .7; font-weight: 600; }
.gasto-ia b { font-size: 18px; font-family: var(--f-mono, monospace); }
.gasto-ia .s { font-size: 12px; opacity: .7; }
@media (max-width: 600px) { .gasto-ia { width: 100%; } .gasto-ia .gia { flex: 1; min-width: 0; } }

/* v1.9 · precios de Mercado Libre */
.precios-ml { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 6px; }
.precios-ml > div { background: var(--accent-soft, rgba(29,90,168,.08)); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.precios-ml .tipico { background: var(--ok-bg); color: var(--ok); }
.precios-ml .l { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .75; font-weight: 600; }
.precios-ml b { font-size: 16px; }
.ejemplos-ml { display: grid; gap: 6px; margin-top: 10px; }
.ejemplos-ml a { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; color: inherit; text-decoration: none; padding: 6px; border-radius: 8px; border: 1px solid var(--line, rgba(127,127,127,.25)); font-size: 13px; }
.ejemplos-ml img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.ejemplos-ml span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (max-width: 600px) { .precios-ml { grid-template-columns: 1fr 1fr; } }

.aviso { overflow-wrap: anywhere; }
.ml-filtros { align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 8px 0; } .ml-filtros .campo { flex: 1; min-width: 160px; margin: 0; }
textarea.texto-ficha, input.texto-ficha { width: 100%; font: inherit; line-height: 1.5; resize: vertical; box-sizing: border-box; }
#fbEstado a { color: inherit; text-decoration: underline; }
textarea.texto-ficha { max-height: none; min-height: 280px; }

/* v1.11.1 · bloques dentro de la ficha de la pieza */
fieldset.bloque { border: 1px solid var(--line, rgba(127,127,127,.3)); border-radius: 12px; padding: 12px 14px 14px; margin: 14px 0; min-width: 0; }
fieldset.bloque legend { padding: 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent, #1d5aa8); }

/* Sección de Mercado Libre: borde amarillo para distinguirla */
.card-ml { border: 2px solid #ffce00; border-left: 6px solid #ffce00; background: rgba(255, 206, 0, .05); }
.card-ml h3 { color: #a67c00; }
fieldset.bloque-ml { border-color: #ffce00; background: rgba(255, 206, 0, .06); }
fieldset.bloque-ml legend { color: #a67c00; }
