/* ===== Colores (claro / oscuro) ===== */
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --input: #ffffff;
  --accent: #f97316;
  --accent-dark: #ea580c;
  /* Naranja oscuro para texto naranja y para fondos con texto blanco (contraste AA: 4,5:1 o más). */
  --accent-texto: #c2410c;
  --accent-fondo: #c2410c;
  --accent-fondo-hover: #9a3412;
  --ok: #16a34a;
  --warn: #b45309;
  --bad: #dc2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06);
  color-scheme: light;
}
:root[data-theme="oscuro"] {
  --bg: #0b0f14; --card: #151b23; --text: #e5e7eb; --muted: #a3acb9;
  --border: #263040; --input: #0f141b; --shadow: none;
  --ok: #22c55e; --warn: #f59e0b; --bad: #f87171; --accent-texto: #fb923c;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="claro"]) {
    --bg: #0b0f14; --card: #151b23; --text: #e5e7eb; --muted: #a3acb9;
    --border: #263040; --input: #0f141b; --shadow: none;
    --ok: #22c55e; --warn: #f59e0b; --bad: #f87171; --accent-texto: #fb923c;
    color-scheme: dark;
  }
}
/* Movimiento reducido: sin animaciones para quien lo pida en su sistema. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
/* Foco del teclado siempre visible. */
:focus-visible { outline: 3px solid var(--accent-texto); outline-offset: 2px; }
.item:focus-visible, .tab:focus-visible { outline-offset: -3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  line-height: 1.4;
}
body.modal-open { overflow: hidden; }
/* Deslizar hacia abajo para actualizar (se quita el del navegador para que no haya dos) */
html, body { overscroll-behavior-y: contain; }
.pull {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 108px); z-index: 40;
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); color: var(--muted); border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18); pointer-events: none;
  transform: translate(-50%, -80px); opacity: 0;
}
body.sin-sesion .pull { top: calc(env(safe-area-inset-top) + 8px); }
.pull.listo, .pull.girando { color: var(--accent); }
.pull.suelto { transition: transform .2s, opacity .2s; }
.pull.girando .ic { animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
button { font: inherit; }
.ic { width: 22px; height: 22px; flex: none; }
.muted { color: var(--muted); }
h2, h3 { margin: 0; }

/* ===== Barra superior ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 8px; max-width: 720px; margin: 0 auto; padding: 8px 16px; }
/* Banner con el logo, el nombre y el lema (encima de la moto y de los botones) */
.banner {
  background: linear-gradient(120deg, var(--accent-fondo), var(--accent-fondo-hover)); color: #fff;   /* contraste AA con el blanco */
  padding: calc(env(safe-area-inset-top) + 7px) 16px 7px;
}
.banner-inner { display: flex; align-items: center; gap: 10px; max-width: 720px; margin: 0 auto; }
.banner img { width: 32px; height: 32px; border-radius: 9px; flex: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, .9); }
.banner p { margin: 0; display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 10px; line-height: 1.2; }
.banner strong { font-size: 18px; letter-spacing: .2px; }
.banner span { font-size: 13px; opacity: .95; }
.moto-switcher {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  background: none; border: 0; color: var(--text); cursor: pointer; padding: 4px; text-align: left;
}
.logo { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; flex: none; }
.logo.foto { border-radius: 50%; box-shadow: 0 0 0 2px var(--accent); }

/* Indicador de sincronización */
.btn-top.activo { color: var(--accent); }
/* Importes ocultos: las casillas de importes se ven borrosas hasta que se pulsan para escribir */
body.importes-ocultos input.importe:not(:focus) { color: transparent; text-shadow: 0 0 10px var(--text); }
.sync, .btn-top {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
  display: grid; place-items: center; background: var(--card); color: var(--muted); position: relative;
}
.sync.ok { color: var(--ok); }
.sync.pendiente { color: var(--warn); }
.sync.error { color: var(--bad); }
.sync.sincronizando .ic { color: var(--accent); animation: latir 1s ease-in-out infinite; }
.sync.pendiente::after, .sync.error::after {
  content: ''; position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: currentColor;
}
@keyframes latir { 50% { opacity: .35; } }

/* Sin sesión: pantalla de acceso a pantalla completa */
body.sin-sesion .topbar, body.sin-sesion .tabbar { display: none; }
body.sin-sesion { padding-bottom: 0; }
.login { max-width: 400px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 32px) 0 32px; text-align: center; }
.login-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 10px 30px rgba(249, 115, 22, .35); }
.login h1 { margin: 16px 0 6px; font-size: 26px; }
.login p { margin: 0 0 20px; }
.login .lema { margin: -2px 0 10px; color: var(--accent-texto); font-weight: 700; letter-spacing: .02em; }
.login .bienvenida { margin: 0 0 2px; font-weight: 600; }
.login .version-login { margin: 0 0 12px; font-size: .8rem; color: var(--muted); }
.firma { text-align: center; color: var(--muted); font-size: 13px; margin: 22px 0 0 !important; }
.firma strong { color: var(--accent-texto); }
.acerca { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 28px 0 8px; font-size: 14px; line-height: 1.5; }
.acerca img { width: 40px; height: 40px; border-radius: 10px; }
.acerca strong { color: var(--text); }
.acerca .muted strong { color: var(--accent-texto); }
.login form { text-align: left; }
.login .card.pad p { margin: 0 0 14px; }
.login .login-enlace { margin: 16px 0 0; }
/* Página de privacidad */
.legal { max-width: 720px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 20px) 18px 40px; line-height: 1.6; }
.legal h1 { font-size: 26px; margin: 10px 0 4px; }
.legal h2 { font-size: 18px; margin: 26px 0 8px; }
.legal ul { padding-left: 20px; }
.legal li { margin: 4px 0; }
/* Historial compartido: logo de Motácora arriba */
.pub-marca { max-width: 720px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) 18px 0; }
.pub-marca a { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; }
.pub-marca img { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.pub-marca + .legal { padding-top: 6px; }
.pub-cabecera { display: flex; gap: 14px; align-items: center; margin: 6px 0 14px; }
.pub-cabecera h1 { margin: 0 0 2px; }
.pub-cabecera p { margin: 0; }
.pub-foto { width: 96px; height: 72px; object-fit: cover; border-radius: 12px; flex: none; }
.legal .tabla td small { font-size: 12px; }
.enlaces-legales { text-align: center; font-size: 13px; margin: 8px 0 0; }
.separador { border: 0; border-top: 1px solid var(--line, rgba(127,127,127,.25)); margin: 20px 0; }
.btn-link { background: none; border: 0; padding: 10px 8px; min-height: 44px; color: var(--accent-texto); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--border); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.btn:disabled { opacity: .6; cursor: wait; }

.barra-historial { display: flex; justify-content: space-between; align-items: center; margin: 0 4px 12px; }

/* Fotos de los registros */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.thumb {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.thumb.sin-foto::after { content: 'Sin conexión'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.thumb-x {
  position: absolute; top: 2px; right: 2px; width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; display: grid; place-items: center;
}
.thumb-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer;
  border-style: dashed; color: var(--muted); font-size: 12px;
}
.thumb-add:hover { color: var(--accent); border-color: var(--accent); }
.con-fotos { display: inline-flex; align-items: center; gap: 3px; }
.con-fotos .ic { width: 14px; height: 14px; }
.visor {
  position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .9);
  display: grid; place-items: center; padding: calc(env(safe-area-inset-top) + 16px) 16px 16px; cursor: zoom-out;
}
.visor img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.visor .icon-btn { position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 12px; background: rgba(255, 255, 255, .2); color: #fff; }

/* Fotos de la moto */
.avatar { width: 40px; height: 40px; border-radius: 11px; object-fit: cover; flex: none; }
.foto-edit { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.foto-preview {
  width: 110px; height: 82px; border-radius: 12px; flex: none; overflow: hidden;
  background: var(--bg); border: 1px dashed var(--border); display: grid; place-items: center; color: var(--muted);
}
.foto-preview img { width: 100%; height: 100%; object-fit: cover; }
.foto-btns { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.hero { position: relative; }
/* Foto de la moto en su propio recuadro, encima de la tarjeta del cuentakilómetros */
.foto-moto { position: relative; padding: 0; overflow: hidden; aspect-ratio: 16 / 9; max-height: 320px; width: 100%; margin-bottom: 12px; }
.foto-moto img { display: block; width: 100%; height: 100%; object-fit: cover; }
.foto-moto .hero-foto, .hero .hero-foto {
  position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: rgba(255, 255, 255, .2); color: #fff;
}
.foto-moto .hero-foto { background: rgba(0, 0, 0, .45); }
.foto-moto .hero-foto .ic { width: 18px; height: 18px; }
.hero .hero-foto {
  position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: rgba(255, 255, 255, .2); color: #fff;
}
.hero .hero-foto .ic { width: 18px; height: 18px; }
.hero:has(> .hero-foto) { padding-right: 56px; }
.moto-text { display: flex; flex-direction: column; min-width: 0; }
.moto-text strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.moto-text small { color: var(--muted); font-size: 13px; }
.chevron { color: var(--muted); width: 18px; height: 18px; }

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

/* ===== Barra de pestañas ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; max-width: 130px; background: none; border: 0; cursor: pointer;
  color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 500; padding: 6px 0; min-height: 52px;
}
.tab.active { color: var(--accent-texto); }
.tab-add .ic {
  width: 52px; height: 52px; padding: 13px; margin-top: -22px;
  background: var(--accent-fondo); color: #fff; border-radius: 50%;
  box-shadow: 0 6px 16px rgba(249, 115, 22, .45);
}

/* ===== Tarjetas ===== */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.pad { padding: 16px; }
.section-title {
  display: flex; justify-content: space-between; align-items: center;
  margin: 24px 4px 8px; font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
}
.link { background: none; border: 0; color: var(--accent-texto); font-weight: 600; cursor: pointer; text-transform: none; letter-spacing: 0; font-size: 14px; padding: 10px 4px; margin: -10px -4px; min-height: 44px; }

.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 18px 20px; border: 0; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}
.hero .label { display: block; font-size: 13px; opacity: .85; }
.hero strong { font-size: 40px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.hero .unit { font-size: 16px; margin-left: 4px; opacity: .85; }
.hero .desde-compra { display: block; font-size: 13px; opacity: .85; margin-top: 2px; }
.hero .btn { background: rgba(255, 255, 255, .2); color: #fff; }
.hero .btn:hover { background: rgba(255, 255, 255, .3); }

.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 14px 0 0; }
.quick-btn {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 2px; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 500;
}
.quick-btn:hover { border-color: var(--c); }
.quick-btn .ic { color: var(--c); width: 26px; height: 26px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.stat { padding: 12px 14px; }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.alerta .v { color: var(--bad); }

/* ===== Listas ===== */
.list { overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; background: none; border: 0; border-bottom: 1px solid var(--border);
  text-align: left; color: inherit; cursor: pointer;
}
.item:last-child { border-bottom: 0; }
.item:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.item-ic {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  display: grid; place-items: center; color: var(--c);
  background: color-mix(in srgb, var(--c) 15%, transparent);
}
.item-main { flex: 1; min-width: 0; display: block; }
.item-title, .item-sub, .item .bar { display: block; }
.item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 14px; flex: none; }
.item-side small { color: var(--muted); font-size: 12px; max-width: 130px; }
.empty { color: var(--muted); text-align: center; padding: 20px 16px; margin: 0; }
.group-head { display: flex; justify-content: space-between; margin: 18px 4px 6px; font-size: 13px; color: var(--muted); font-weight: 600; }

.bar { height: 6px; background: var(--border); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar { display: block; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.aviso.pronto .bar i { background: var(--warn); }
.aviso.vencido .bar i { background: var(--bad); }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--border); color: var(--muted); }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.pronto { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.vencido { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.aviso.inactivo { opacity: .5; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 10px 16px; min-height: 44px; border-radius: 999px; font-size: 14px; cursor: pointer;
}
.chip.active { background: var(--accent-fondo); border-color: var(--accent-fondo); color: #fff; }

/* ===== Gráficas ===== */
.chart { width: 100%; height: auto; display: block; }
.chart { max-height: 260px; }
.chart text { fill: var(--muted); font-size: 12px; }
.chart .grid { stroke: var(--border); }
.chart .line { stroke: var(--accent); fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.chart .area { fill: color-mix(in srgb, var(--accent) 12%, transparent); }
.chart .avg { stroke: var(--muted); stroke-dasharray: 5 5; }
.chart circle { fill: var(--card); stroke: var(--accent); stroke-width: 2.5; }
.chart .barra { fill: var(--accent); }
/* Valores de barras y puntos, y dato exacto al pulsar */
.chart text.valor { fill: var(--text); font-size: 10.5px; font-weight: 600; pointer-events: none; }
.chart .zona { fill: transparent; stroke: none; }
.chart .tocable { cursor: pointer; outline: none; }
.chart .tocable.activo .barra, .chart .tocable:focus-visible .barra { fill: var(--accent-dark); }
.chart .tocable.activo circle:not(.zona), .chart .tocable:focus-visible circle:not(.zona) { fill: var(--accent); stroke-width: 3.5; }
.chart .tocable:focus-visible .zona { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; }
.dato-grafico { font-size: 13px; color: var(--muted); margin: 6px 2px 0; min-height: 1.4em; }
.dato-grafico.con-dato { color: var(--text); font-weight: 600; }
fieldset.primeros { border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px 0; margin: 0 0 10px; }
fieldset.primeros legend { font-weight: 600; padding: 0 4px; }
.busqueda { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0 0 10px; }
.busqueda .row2 { margin: 0; }
.busqueda input { width: 100%; }
.enlace-compartido { display: flex; gap: 8px; align-items: center; }
.enlace-compartido input { flex: 1; min-width: 0; }
.hbar { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
.hbar .track { height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 5px; background: var(--c); }
.hbar strong { font-variant-numeric: tabular-nums; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tabla th, .tabla td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--border); }
.tabla th:first-child, .tabla td:first-child { text-align: left; }
.tabla th { color: var(--muted); font-weight: 600; font-size: 12px; }
.tabla tr:last-child td { border-bottom: 0; }

/* ===== Botones ===== */
.btn {
  border: 0; border-radius: 12px; padding: 12px 18px; cursor: pointer; font-weight: 600;
  background: var(--border); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn.sm { padding: 9px 14px; font-size: 14px; }
.btn.primary { background: var(--accent-fondo); color: #fff; }
.btn.primary:hover { background: var(--accent-fondo-hover); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid currentColor; }
.btn.block { width: 100%; }
.btn .ic { width: 18px; height: 18px; }
.btn-list { display: grid; gap: 8px; }
.icon-btn { background: var(--border); border: 0; color: var(--text); width: 44px; height: 44px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; font-size: 16px; }

/* ===== Modal / formularios ===== */
.modal {
  position: fixed; inset: 0; z-index: 50; display: none;
  background: rgba(0, 0, 0, .5); align-items: flex-end; justify-content: center;
}
.modal.open { display: flex; }
.sheet {
  background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 0 18px calc(18px + env(safe-area-inset-bottom));
  animation: subir .22s ease-out;
}
@keyframes subir { from { transform: translateY(40px); opacity: 0; } }
/* Al deslizar entre secciones, la nueva entra por el lado del gesto. */
#view.entra-dcha { animation: entra-dcha .2s ease-out; }
#view.entra-izq { animation: entra-izq .2s ease-out; }
@keyframes entra-dcha { from { transform: translateX(40px); opacity: 0; } }
@keyframes entra-izq { from { transform: translateX(-40px); opacity: 0; } }
@media (min-width: 700px) {
  .modal { align-items: center; }
  .sheet { border-radius: 22px; padding-bottom: 18px; }
}
.sheet-head {
  position: sticky; top: 0; z-index: 1; background: var(--card);
  display: flex; justify-content: space-between; align-items: center; padding: 16px 0 12px;
}
.sheet-head h2 { font-size: 19px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); font-weight: 600; min-width: 0; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--input);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-texto); outline-offset: -1px; }
textarea { resize: vertical; }
/* Campos de fecha: Safari (iPhone) les da un ancho mínimo propio y en dos columnas se montan uno sobre otro.
   Se quita su aspecto nativo para que se ajusten a la columna. */
input[type="date"] {
  -webkit-appearance: none; appearance: none; display: block;
  min-width: 0; max-width: 100%; min-height: 46px; text-align: left;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"]::-webkit-datetime-edit { padding: 0; }
.row2 > *, .row3 > * { min-width: 0; }
/* En pantallas estrechas, las fechas del buscador más compactas. */
@media (max-width: 480px) {
  .busqueda .row2 { gap: 8px; }
  /* (el tamaño de letra se deja en 16 px: con menos, el iPhone hace zoom al tocar el campo) */
  .busqueda input[type="date"] { padding: 10px 8px; }
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 600; padding: 0; }
.legend-small { font-weight: 500; font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chk { position: relative; }
.chk input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chk span {
  display: inline-block; padding: 11px 14px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 14px; cursor: pointer; color: var(--text); background: var(--input); user-select: none;
}
.chk input:checked + span { background: var(--accent-fondo); border-color: var(--accent-fondo); color: #fff; }
.chk input:focus-visible + span { outline: 3px solid var(--accent-texto); outline-offset: 2px; }
.switch { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; font-size: 15px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.switch small { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin: -6px 0 12px; }
.sub-form { margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-actions .primary { flex: 1; }
.form-error {
  background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad);
  padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; font-weight: 600;
}
[hidden] { display: none !important; }

.tipo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tipo-btn {
  display: flex; align-items: center; gap: 12px; padding: 14px; text-align: left;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px; color: var(--text); cursor: pointer;
}
.tipo-btn:hover { border-color: var(--c); }
.tipo-btn .item-ic { width: 42px; height: 42px; }
.tipo-btn strong { display: block; font-size: 15px; }
.tipo-btn small { color: var(--muted); font-size: 12px; }

/* ===== Bienvenida ===== */
.welcome { text-align: center; padding: 40px 16px; }
.welcome img { width: 96px; height: 96px; border-radius: 24px; box-shadow: 0 10px 30px rgba(249, 115, 22, .35); }
.welcome h1 { margin: 20px 0 8px; font-size: 26px; }
.welcome p { color: var(--muted); max-width: 420px; margin: 0 auto 24px; }
.features { display: grid; gap: 10px; text-align: left; max-width: 420px; margin: 0 auto 28px; }
.features div { display: flex; gap: 12px; align-items: center; }

/* ===== Aviso flotante ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #111827; color: #fff; padding: 11px 18px; border-radius: 18px; font-size: 14px; border: 1px solid #374151;
  display: flex; align-items: center; gap: 12px;
  transition: opacity .2s, transform .2s; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.con-accion { pointer-events: auto; }
.toast-accion { background: none; border: 0; color: #fdba74; font: inherit; font-weight: 700; cursor: pointer; padding: 10px 6px; margin: -10px -6px -10px 0; min-height: 44px; white-space: nowrap; }

/* ===== Diálogo propio (confirmar / avisar) ===== */
.dialogo { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 20px; }
.dialogo-caja { background: var(--card); color: var(--text); border-radius: 18px; padding: 20px; width: 100%; max-width: 420px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); animation: subir .18s ease-out; }
.dialogo-caja h2 { font-size: 18px; margin: 0 0 8px; }
.dialogo-caja p { margin: 0 0 16px; line-height: 1.5; }
.dialogo-caja .form-actions { justify-content: flex-end; }
.dialogo-caja .btn { min-width: 110px; }
.btn.peligro { background: #b91c1c; color: #fff; }

/* ===== Dictar por voz (js/voz.js) ===== */
.voz-menu {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 12px; padding: 14px; text-align: left;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg)); border: 1px dashed var(--accent-texto); border-radius: 14px;
  color: var(--text); cursor: pointer; font: inherit;
}
.voz-menu .ic { width: 28px; height: 28px; color: var(--accent-texto); flex: none; }
.voz-menu strong { display: block; font-size: 15px; }
.voz-menu small { color: var(--muted); font-size: 12px; }
.voz-fila { display: flex; justify-content: flex-end; margin: -4px 0 8px; }
.voz-btn .ic { width: 18px; height: 18px; }
.voz-caja { text-align: center; }
.voz-caja .form-actions { justify-content: center; flex-wrap: wrap; }
.voz-micro {
  width: 76px; height: 76px; margin: 8px auto 12px; border-radius: 50%; display: grid; place-items: center;
  background: var(--input); color: var(--muted); border: 2px solid var(--border);
}
.voz-micro .ic { width: 34px; height: 34px; }
.voz-capa[data-estado="escuchando"] .voz-micro { background: var(--accent-fondo); border-color: var(--accent-fondo); color: #fff; animation: voz-latir 1.2s ease-in-out infinite; }
.voz-capa[data-estado="procesando"] .voz-micro { color: var(--accent-texto); border-color: var(--accent-texto); }
.voz-capa[data-estado="error"] .voz-estado, .voz-capa[data-estado="denegado"] .voz-estado { color: var(--bad); font-weight: 600; }
.voz-estado { font-weight: 600; margin-bottom: 8px !important; }
.voz-texto { min-height: 1.5em; font-size: 17px; font-style: italic; overflow-wrap: anywhere; }
.voz-texto:empty { display: none; }
.voz-ejemplo { margin: 0 0 12px !important; }
@keyframes voz-latir { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 50% { box-shadow: 0 0 0 14px transparent; } }
/* Campos rellenados por voz: tono del color de la marca hasta que se tocan. */
.voz-relleno input:not([type="checkbox"]), .voz-relleno select, .voz-relleno textarea {
  border-color: var(--accent-texto); background: color-mix(in srgb, var(--accent) 12%, var(--input));
}
.voz-relleno > span:first-child::after { content: " · por voz"; color: var(--accent-texto); font-weight: 500; }
.chk.voz-relleno span, .switch.voz-relleno { box-shadow: 0 0 0 2px var(--accent-texto); }
.chk.voz-relleno span::after { content: none; }
.switch.voz-relleno { border-radius: 10px; padding: 6px 8px; }
.switch.voz-relleno > span:first-child::after { content: none; }
.voz-resumen {
  background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; overflow-wrap: anywhere;
}
.voz-resumen p { margin: 0 0 6px; }
.voz-resumen ul { margin: 0 0 6px; padding-left: 18px; }
.voz-resumen .hint { margin: 0; }
.sheet:focus { outline: none; }
.pass { position: relative; display: block; }
.pass input { padding-right: 52px; }
.ojo { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 10px; }
.ojo .ic { width: 20px; height: 20px; }

@media (max-width: 380px) {
  .quick-btn { font-size: 11px; }
  .hero strong { font-size: 34px; }
  .row3 { grid-template-columns: 1fr 1fr; }
  .tipo-grid { grid-template-columns: 1fr; }
}

/* Aviso del plan (prueba que termina o plan caducado) */
.banner-plan {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin: 0 0 14px; padding: 10px 12px; border-radius: 14px; font-size: 14px;
  background: var(--card); border: 1px solid var(--warn); color: var(--text);
}
.banner-plan.caducado { border-width: 2px; }
.banner-plan .btn { flex: none; }

/* Ajustes → Mi plan: nivel como título y la duración al lado */
.plan-cabecera { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-cabecera strong { font-size: 18px; }

/* 4.9: revisión antes de salir, modo invierno y viajes */
.hero-botones { display: flex; flex-wrap: wrap; gap: 8px; }
.section-title > span { display: inline-flex; align-items: center; gap: 6px; }
.section-title .link .ic { width: 14px; height: 14px; vertical-align: -2px; }
.invierno { margin-top: 12px; border-color: color-mix(in srgb, #38bdf8 45%, var(--border)); }
.invierno strong .ic { width: 18px; height: 18px; vertical-align: -3px; color: #0ea5e9; }
.badge.pausa { background: color-mix(in srgb, #38bdf8 15%, transparent); color: #0284c7; }
.aviso.pausa { opacity: .75; }
.resumen-viaje { margin: 4px 0 12px; display: grid; gap: 4px; font-size: 14px; }

/* ===== Defectos de una ITV (4.21) ===== */
.defecto { border: 1px solid var(--border); border-radius: 12px; padding: 10px 10px 4px; margin-bottom: 10px; background: var(--bg); }
.defecto .field { margin-bottom: 8px; }
.defecto-pie { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.defecto-pie .switch { margin-bottom: 0; }
.aviso-negativa { color: var(--bad); font-weight: 600; margin-top: 0; }
