:root {
  --fondo: #f6f7f9; --panel: #fff; --texto: #1a1d23; --suave: #5b6472; --borde: #dde1e7;
  --acento: #1d4ed8; --acento-texto: #fff; --ok: #15803d; --alerta: #b45309; --error: #b91c1c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #111317; --panel: #1b1e24; --texto: #e7e9ee; --suave: #9aa3b2; --borde: #2c313a;
    --acento: #5b8cff; --acento-texto: #0b1020; --ok: #4ade80; --alerta: #fbbf24; --error: #f87171;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, sans-serif; background: var(--fondo); color: var(--texto); }
header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--borde); }
.marca { font-weight: 700; color: var(--texto); text-decoration: none; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 80px; }
h1 { font-size: 1.3rem; margin: 4px 0 12px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.panel { background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.suave { color: var(--suave); font-size: .9rem; }
.fila { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.boton { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--borde); background: var(--panel); color: var(--texto);
  font: inherit; text-decoration: none; cursor: pointer; }
.boton.primario { background: var(--acento); border-color: var(--acento); color: var(--acento-texto); font-weight: 600; }
.boton.peligro { color: var(--error); }
.boton:disabled { opacity: .5; cursor: default; }
.boton.grande { width: 100%; min-height: 52px; font-size: 1.05rem; }
label { display: block; font-size: .85rem; color: var(--suave); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--texto); background: var(--fondo);
  border: 1px solid var(--borde); border-radius: 8px; padding: 9px 10px; }
textarea { min-height: 120px; resize: vertical; }
textarea.crece { min-height: 0; resize: none; overflow: hidden; }
/* iOS Safari da a los campos de fecha un ancho mínimo propio que desborda la rejilla */
input[type="date"], input[type="datetime-local"] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; display: block; min-height: 42px; }
.grid2 > * { min-width: 0; }
.estado-guardado { font-size: .8rem; color: var(--suave); }
.enlace { background: none; border: 0; padding: 0; color: var(--acento); font: inherit; text-decoration: underline; cursor: pointer; }
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.fotos figure { margin: 0; position: relative; }
.fotos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.fotos figcaption { position: absolute; top: 4px; left: 4px; background: #000a; color: #fff; font-size: .75rem; padding: 1px 6px; border-radius: 6px; }
.fotos .quitar { position: absolute; top: 4px; right: 4px; background: #000a; color: #fff; border: 0; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; }
.lista a.item { display: flex; gap: 12px; align-items: center; padding: 10px; color: inherit; text-decoration: none;
  border-bottom: 1px solid var(--borde); }
.lista a.item:last-child { border-bottom: 0; }
.lista img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; }
.chip { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--borde); white-space: nowrap; }
.chip.borrador { color: var(--suave); }
.chip.presentada, .chip.en_tramite { color: var(--acento); border-color: var(--acento); }
.chip.publicada_teu, .chip.sancionada { color: var(--ok); border-color: var(--ok); }
.chip.archivada, .chip.sin_noticias { color: var(--alerta); border-color: var(--alerta); }
.matricula { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: .05em; }
.vehiculo { border: 1px solid var(--borde); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.checks label { display: flex; gap: 8px; align-items: center; color: var(--texto); font-size: .95rem; margin: 4px 0; }
.checks input { width: auto; }
.nota { border-left: 3px solid var(--alerta); padding: 6px 10px; background: color-mix(in srgb, var(--alerta) 10%, transparent); border-radius: 0 8px 8px 0; }
.pasos { padding-left: 20px; margin: 0; }
.pasos li { margin-bottom: 10px; }
.cronologia { list-style: none; padding: 0; margin: 0; }
.cronologia li { padding: 6px 0; border-bottom: 1px dashed var(--borde); font-size: .9rem; }
#aviso { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 560px; margin: 0 auto; padding: 12px 14px;
  border-radius: 10px; background: var(--texto); color: var(--fondo); z-index: 9; }
.cargando { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: giro .8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
