/* Garaje · estilos */
:root {
  --fondo: #f3f4f7;
  --tarjeta: #ffffff;
  --texto: #1b1f2a;
  --suave: #667085;
  --linea: #e4e7ec;
  --marca: #1d3557;
  --marca-2: #2b5b94;
  --acento: #f08a24;
  --rojo: #d92d20;
  --rojo-f: #fef3f2;
  --ambar: #b54708;
  --ambar-f: #fffaeb;
  --verde: #067647;
  --verde-f: #ecfdf3;
  --gris-f: #f2f4f7;
  --sombra: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radio: 14px;
  --t-mant: #2b5b94; --t-rep: #c4320a; --t-comb: #f08a24; --t-doc: #7a5af8; --t-otr: #667085;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0f1218; --tarjeta: #181c25; --texto: #eef0f4; --suave: #98a2b3; --linea: #2a303c;
    --marca: #9ec5fe; --marca-2: #7fb0f5; --rojo: #f97066; --rojo-f: #3a1a18; --ambar: #fdb022; --ambar-f: #33260d;
    --verde: #47cd89; --verde-f: #10291d; --gris-f: #222733; --sombra: none;
    --t-mant: #7fb0f5; --t-rep: #f97066; --t-doc: #a48afb; --t-otr: #98a2b3;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo); color: var(--texto);
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
.oculto { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--texto); }
a { color: var(--marca-2); }

/* ---------- acceso ---------- */
.acceso { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; max-width: 420px; margin: 0 auto; }
.acceso-marca { text-align: center; margin-bottom: 24px; }
.acceso-marca .logo { font-size: 56px; }
.acceso-marca h1 { font-size: 32px; margin: 4px 0; }
.acceso-marca p { color: var(--suave); margin: 0; }

/* ---------- cabecera y barra ---------- */
.cabecera {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: var(--fondo);
}
.cabecera h1 { font-size: 24px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hueco { width: 40px; }
.icono-boton { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--tarjeta); box-shadow: var(--sombra); font-size: 26px; line-height: 1; }

main { max-width: 720px; margin: 0 auto; padding: 0 16px 16px; }

.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around; align-items: center;
  background: var(--tarjeta); border-top: 1px solid var(--linea); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav { flex: 1; background: none; border: 0; font-size: 11px; color: var(--suave); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.nav span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.nav.activa { color: var(--marca); font-weight: 600; }
.nav.activa span { filter: none; opacity: 1; }
.mas { width: 56px; height: 56px; margin-top: -26px; border: 0; border-radius: 50%; background: var(--acento); color: #fff; font-size: 30px; box-shadow: 0 4px 12px rgba(240,138,36,.4); }

/* ---------- bloques ---------- */
.tarjeta { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; }
.seccion { margin: 22px 0 8px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.seccion h2 { font-size: 17px; }
.seccion .enlace { background: none; border: 0; color: var(--marca-2); font-size: 14px; padding: 0; }
.lista { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; }
.fila { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--linea); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.fila:last-child { border-bottom: 0; }
.fila .ico { font-size: 22px; width: 36px; height: 36px; border-radius: 10px; background: var(--gris-f); display: grid; place-items: center; flex: none; }
.fila .cuerpo { flex: 1; min-width: 0; }
.fila .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.fila .s { font-size: 13px; color: var(--suave); }
.fila .der { text-align: right; flex: none; font-size: 14px; }
.vacio { text-align: center; color: var(--suave); padding: 28px 16px; }
.vacio .grande { font-size: 44px; }
.pista { font-size: 13px; color: var(--suave); margin: 6px 2px 0; }

/* ---------- estados ---------- */
.est { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.est.vencido { background: var(--rojo-f); color: var(--rojo); }
.est.pronto { background: var(--ambar-f); color: var(--ambar); }
.est.ok { background: var(--verde-f); color: var(--verde); }
.est.sin_dato { background: var(--gris-f); color: var(--suave); }
.fila.vencido .ico { background: var(--rojo-f); }
.fila.pronto .ico { background: var(--ambar-f); }
.progreso { height: 5px; background: var(--gris-f); border-radius: 9px; margin-top: 6px; overflow: hidden; }
.progreso i { display: block; height: 100%; background: var(--verde); border-radius: 9px; }
.progreso.pronto i { background: var(--ambar); }
.progreso.vencido i { background: var(--rojo); }

.boton-hecho { border: 1px solid var(--linea); background: var(--tarjeta); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--verde); }

/* ---------- vehículos ---------- */
.coches { display: grid; gap: 12px; }
.coche { display: flex; gap: 14px; align-items: center; text-align: left; border: 0; width: 100%; }
.coche .foto { width: 64px; height: 64px; border-radius: 12px; background: var(--gris-f) center/cover; display: grid; place-items: center; font-size: 32px; flex: none; }
.coche .nom { font-weight: 700; font-size: 17px; }
.matricula { display: inline-block; font: 600 12px/1 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .5px; border: 1.5px solid var(--texto); border-left: 7px solid #2649a6; border-radius: 4px; padding: 3px 6px; }
.coche .km { font-size: 14px; color: var(--suave); margin-top: 4px; }
.coche .badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.archivado { opacity: .55; }

.cabeza-coche { display: flex; gap: 14px; align-items: center; }
.cabeza-coche .foto { width: 88px; height: 88px; border-radius: 16px; background: var(--gris-f) center/cover; display: grid; place-items: center; font-size: 44px; flex: none; border: 0; position: relative; }
.cabeza-coche .foto::after { content: "📷"; position: absolute; right: -4px; bottom: -4px; font-size: 14px; background: var(--tarjeta); border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; box-shadow: var(--sombra); }
.kms { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--linea); }
.kms b { font-size: 22px; }
.cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.cifra { background: var(--gris-f); border-radius: 10px; padding: 10px; text-align: center; }
.cifra b { display: block; font-size: 17px; }
.cifra span { font-size: 12px; color: var(--suave); }

.pestanas { display: flex; gap: 4px; background: var(--gris-f); border-radius: 12px; padding: 4px; margin: 16px 0 12px; }
.pestanas button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 4px; font-size: 14px; color: var(--suave); }
.pestanas button.activa { background: var(--tarjeta); color: var(--texto); font-weight: 600; box-shadow: var(--sombra); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--linea); background: var(--tarjeta); border-radius: 99px; padding: 6px 12px; font-size: 14px; }
.chip.activa { background: var(--marca); border-color: var(--marca); color: var(--tarjeta); }
.desliza { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; scrollbar-width: none; }
.desliza::-webkit-scrollbar { display: none; }

.ficha { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 15px; }
.ficha dt { color: var(--suave); }
.ficha dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

/* ---------- gastos ---------- */
.gran-cifra { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.barras { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 140px; margin-top: 14px; }
.barras .col { display: flex; flex-direction: column-reverse; height: 100%; justify-content: flex-start; position: relative; }
.barras .col i { display: block; border-radius: 2px; }
.barras .col i + i { margin-bottom: 1px; }
.meses { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; font-size: 10px; color: var(--suave); text-align: center; margin-top: 4px; }
.leyenda { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--suave); margin-top: 10px; }
.leyenda span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--c); margin-right: 5px; }
.barra-h { height: 8px; background: var(--gris-f); border-radius: 9px; margin-top: 6px; overflow: hidden; }
.barra-h i { display: block; height: 100%; border-radius: 9px; }

/* ---------- formularios ---------- */
.form { display: grid; gap: 14px; }
.form h2 { font-size: 20px; }
label { display: grid; gap: 5px; font-size: 14px; font-weight: 600; color: var(--suave); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--linea); border-radius: 10px; background: var(--tarjeta); font-size: 16px; font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--marca-2); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }
.dos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.dos > *, input, select { min-width: 0; }
.hoja, .hoja-contenido { overflow-x: hidden; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; color: var(--texto); font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--marca-2); flex: none; }
.checks { display: grid; gap: 2px; max-height: 300px; overflow: auto; border: 1px solid var(--linea); border-radius: 10px; padding: 6px 10px; }
.checks .check { padding: 7px 0; border-bottom: 1px solid var(--linea); }
.checks .check:last-child { border-bottom: 0; }
.checks .check small { color: var(--suave); display: block; font-size: 12px; }
.error { color: var(--rojo); font-size: 14px; margin: 0; min-height: 1em; }
.boton { border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 700; font-size: 16px; background: var(--gris-f); width: 100%; }
.boton.principal { background: var(--marca); color: var(--tarjeta); }
.boton.peligro { background: none; color: var(--rojo); border: 1px solid var(--linea); }
.boton.pequeno { width: auto; padding: 8px 14px; font-size: 14px; border-radius: 99px; }
.boton:disabled { opacity: .6; }
.acciones { display: grid; gap: 10px; margin-top: 4px; }
.foto-previa { max-width: 100%; max-height: 220px; border-radius: 10px; display: block; }

/* ---------- hoja ---------- */
.hoja-fondo { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
.hoja {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 92vh; overflow: auto; max-width: 640px; margin: 0 auto;
  background: var(--fondo); border-radius: 20px 20px 0 0; padding: 10px 16px calc(24px + env(safe-area-inset-bottom));
  animation: sube .22s ease-out;
}
@keyframes sube { from { transform: translateY(40px); opacity: .4; } }
.hoja-asa { width: 40px; height: 5px; border-radius: 9px; background: var(--linea); margin: 0 auto 10px; }
.hoja-cerrar { position: absolute; right: 12px; top: 10px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--gris-f); }

.aviso {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--texto); color: var(--fondo); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.cargando { text-align: center; color: var(--suave); padding: 40px 0; }
