/* ============ Tokens: claro (por defecto) y oscuro ============ */
:root {
  --fondo: #f4f3ef;
  --superficie: #ffffff;
  --superficie-2: #f8f7f4;
  --tinta: #1d2126;
  --tinta-2: #5b6168;
  --linea: #dcdad3;
  --linea-suave: #efede8;
  --hover: #eef2f7;
  --chip: #eef0f2;
  --pista: #e8e6e0;
  --input: #ffffff;
  --acento: #1f4e79;
  --acento-txt: #1f4e79;
  --barra: #1f4e79;
  --rojo: #c0392b;
  --amarillo: #d69e00;
  --verde: #2e8b57;
  --gris: #8a9099;
  --aviso: #fdf3e1;
  --aviso-txt: #6b4f00;
  --aviso-rojo: #fbe9e7;
  --pend: #fffaf0;
  --pend-borde: #f0d9a8;
  --sombra: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --radio: 8px;
  color-scheme: light;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--tinta);
}
:root[data-theme="dark"] {
  --fondo: #11151a;
  --superficie: #1a2028;
  --superficie-2: #151a21;
  --tinta: #e4e7eb;
  --tinta-2: #9aa4af;
  --linea: #2d3642;
  --linea-suave: #252d37;
  --hover: #233042;
  --chip: #2a3340;
  --pista: #2d3642;
  --input: #11151a;
  --acento: #3a78b5;
  --acento-txt: #8cbbea;
  --barra: #13314e;
  --rojo: #e0604f;
  --amarillo: #e5b22e;
  --verde: #45b07a;
  --gris: #8a94a0;
  --aviso: #3a3018;
  --aviso-txt: #f1d48a;
  --aviso-rojo: #3d2220;
  --pend: #2a2618;
  --pend-borde: #5a4a1f;
  --sombra: 0 1px 3px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fondo); color: var(--tinta); }
body { transition: background .2s; }
h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: var(--acento-txt); }
.num { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.btn {
  font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; text-decoration: none;
  border: 1px solid transparent; border-radius: 6px; padding: 7px 14px;
  background: #fff; color: #1f4e79; white-space: nowrap;
}
.btn-sec { background: transparent; color: inherit; border-color: currentColor; }
.btn-tema {
  font-size: 17px; line-height: 1; width: 36px; height: 34px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--linea); background: var(--superficie); color: var(--tinta);
}
.barra .btn-tema { border-color: rgba(255,255,255,.5); background: transparent; color: #fff; }

/* ============ Pantalla de inicio ============ */
.inicio {
  min-height: 100%; display: grid; grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(1200px 500px at 15% -10%, color-mix(in srgb, var(--acento) 16%, transparent), transparent 70%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--verde) 14%, transparent), transparent 70%),
    var(--fondo);
}
.inicio-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; }
.muni { font-size: 13px; color: var(--tinta-2); letter-spacing: .02em; }
.inicio-centro { align-self: center; justify-self: center; width: min(860px, 100%); padding: 24px 20px; text-align: center; }
.logo-app { display: inline-block; width: 64px; height: 64px; color: var(--acento); }
.logo-app svg, .marca .logo svg { width: 100%; height: 100%; display: block; }
:root[data-theme="dark"] .logo-app { color: #2f6fae; }
.inicio h1 { font-size: clamp(28px, 5vw, 42px); margin-top: 8px; letter-spacing: -.01em; }
.lema { color: var(--tinta-2); font-size: 16px; margin: 10px auto 28px; max-width: 520px; }
.opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; text-align: left; }
.opcion {
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  display: grid; gap: 6px; align-content: start;
  background: var(--superficie); border: 1px solid var(--linea); border-radius: 12px; padding: 22px;
  box-shadow: var(--sombra); transition: transform .12s, border-color .12s;
}
.opcion:hover, .opcion:focus-visible { transform: translateY(-2px); border-color: var(--acento); outline: none; }
.op-ico { font-size: 28px; color: var(--acento-txt); }
.op-tit { font-size: 18px; font-weight: 600; }
.op-txt { font-size: 14px; color: var(--tinta-2); line-height: 1.45; }
.op-ir { font-size: 14px; font-weight: 500; color: var(--acento-txt); margin-top: 6px; }
.link-insp { display: inline-block; margin-top: 22px; font-size: 14px; }

.credito {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px;
  padding: 16px 20px 22px; border-top: 1px solid var(--linea); font-size: 13px; color: var(--tinta-2);
}
.cred-logo { display: inline-flex; }
.cred-logo img { height: 34px; display: block; }
.cred-datos { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; }

/* ============ Aplicación ============ */
.app { height: 100%; display: flex; flex-direction: column; }
.barra {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--barra); color: #fff;
}
.marca { display: flex; align-items: center; gap: 10px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; padding: 0; }
.marca .logo { width: 30px; height: 30px; color: #fff; flex: none; }
.marca .h1 { display: block; font-size: 17px; font-weight: 600; }
.marca .sub { display: block; font-size: 12.5px; opacity: .85; }
.sesion { display: flex; align-items: center; gap: 8px; }
.usuario { font-size: 12.5px; text-align: right; line-height: 1.25; }

.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--linea); background: var(--superficie);
}
.kpi { font: inherit; color: inherit; text-align: left; background: none; border: 0; border-radius: 6px; padding: 4px 6px; cursor: pointer; }
.kpi:hover, .kpi:focus-visible { background: var(--hover); outline: none; }
.kpi .e::after { content: ' ›'; opacity: .5; }
.kpi .v { font-family: 'IBM Plex Mono', monospace; font-size: 20px; font-weight: 500; }
.kpi .e { font-size: 12px; color: var(--tinta-2); }
.kpi.alerta .v { color: var(--rojo); }

.cuerpo { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 0; position: relative; }
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--superficie); border-right: 1px solid var(--linea); }
.filtros { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--linea); }
.fila { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
input, select, textarea {
  font: inherit; font-size: 13.5px; width: 100%; padding: 7px 9px;
  border: 1px solid var(--linea); border-radius: 6px; background: var(--input); color: var(--tinta);
}
textarea { resize: vertical; min-height: 54px; }
.btn-nueva {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 9px; border-radius: 6px;
  border: 1px dashed var(--acento); background: color-mix(in srgb, var(--acento) 10%, transparent); color: var(--acento-txt);
}
.contador { margin: 0; padding: 8px 12px; font-size: 12px; color: var(--tinta-2); }
.lista { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; }
.lista li {
  display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 8px; border-radius: 6px; cursor: pointer;
}
.lista li:hover, .lista li.activa { background: var(--hover); }
.lista .t { font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.lista .s { font-size: 12px; color: var(--tinta-2); }
.lista .p { font-family: 'IBM Plex Mono', monospace; font-size: 13px; }
.punto { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }

.mapa-wrap { position: relative; min-height: 0; }
#mapa { position: absolute; inset: 0; background: var(--superficie-2); }
.mapa-wrap.eligiendo #mapa { cursor: crosshair; }
.leyenda {
  position: absolute; left: 12px; bottom: 22px; z-index: 500;
  background: var(--superficie); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 8px 10px; font-size: 12px; display: grid; gap: 4px;
}
.leyenda div { display: flex; align-items: center; gap: 6px; }
.banner-ubic {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1200;
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 14px; border-radius: var(--radio);
  background: var(--barra); color: #fff; box-shadow: var(--sombra); font-size: 14px; font-weight: 500;
}

/* Logo HydroGIS: versión para fondo claro y oscuro */
.logo-o { display: none !important; }
:root[data-theme="dark"] .logo-c { display: none !important; }
:root[data-theme="dark"] .logo-o { display: block !important; }

/* Mapa base oscuro sin proveedor externo: se oscurecen las teselas de OpenStreetMap */
.mapa-wrap.calles-oscuro .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.85) saturate(.55); }

/* Filtro por estado sobre el mapa */
.chips-estado {
  position: absolute; top: 10px; left: 56px; z-index: 900; max-width: calc(100% - 68px);
  display: flex; gap: 6px; overflow-x: auto; padding: 2px; scrollbar-width: none;
}
.chips-estado::-webkit-scrollbar { display: none; }
.chip-est {
  font: inherit; font-size: 12.5px; font-weight: 500; white-space: nowrap; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px;
  background: var(--superficie); color: var(--tinta); border: 1px solid var(--linea); box-shadow: var(--sombra);
}
.chip-est .n { font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; color: var(--tinta-2); }
.chip-est .d { width: 9px; height: 9px; border-radius: 50%; }
.chip-est.on { background: var(--acento); color: #fff; border-color: var(--acento); }
.chip-est.on .n { color: #fff; opacity: .85; }
.btn-mapa {
  position: absolute; right: 12px; bottom: 26px; z-index: 900; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--linea); background: var(--superficie); color: var(--tinta); box-shadow: var(--sombra);
}
.btn-mapa:hover { border-color: var(--acento); }
.banner-recorrido {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 1200;
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-radius: 999px;
  background: var(--barra); color: #fff; box-shadow: var(--sombra); font-size: 13.5px; font-weight: 500; max-width: 92%;
}
.banner-recorrido #rec-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-recorrido .btn { padding: 5px 10px; }

/* Detalle de indicadores */
.dlg-kpi { width: min(560px, 94vw); max-height: 86vh; padding: 0; overflow: hidden; }
.dlg-kpi[open] { display: flex; flex-direction: column; }
.kpi-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 18px 8px; }
.kpi-cab h2 { font-size: 17px; }
.kpi-cab .cerrar { border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--tinta-2); }
#kpi-cuerpo { padding: 4px 18px 8px; overflow-y: auto; }
#kpi-acciones { padding: 10px 18px 16px; border-top: 1px solid var(--linea); }
#kpi-acciones:empty { display: none; }
.kpi-nota { font-size: 13px; color: var(--tinta-2); margin: 0 0 10px; }
.barras-h { display: grid; gap: 7px; margin: 6px 0 12px; }
.bh { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; }
.bh .trk { height: 10px; background: var(--pista); border-radius: 3px; overflow: hidden; }
.bh .fill { height: 100%; background: var(--acento); border-radius: 3px; }
.bh .val { font-family: 'IBM Plex Mono', monospace; font-size: 12px; text-align: right; white-space: nowrap; }
.filas-kpi { list-style: none; margin: 0; padding: 0; }
.filas-kpi li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--linea-suave); cursor: pointer; border-radius: 4px; }
.filas-kpi li:hover { background: var(--hover); }
.filas-kpi .t { font-size: 13.5px; font-weight: 500; }
.filas-kpi .s { font-size: 12px; color: var(--tinta-2); }
.filas-kpi .v { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; text-align: right; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 3000;
  background: #1d2126; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; max-width: 92vw; box-shadow: var(--sombra);
}

/* Leaflet en modo oscuro */
:root[data-theme="dark"] .leaflet-bar a, :root[data-theme="dark"] .leaflet-control-layers {
  background: var(--superficie); color: var(--tinta); border-color: var(--linea);
}
:root[data-theme="dark"] .leaflet-control-attribution { background: rgba(26,32,40,.8); color: var(--tinta-2); }
:root[data-theme="dark"] .leaflet-control-attribution a { color: var(--acento-txt); }
:root[data-theme="dark"] .leaflet-tooltip { background: var(--superficie); color: var(--tinta); border-color: var(--linea); }
:root[data-theme="dark"] .leaflet-tooltip-top:before { border-top-color: var(--superficie); }
:root[data-theme="dark"] .leaflet-control-layers-toggle { filter: invert(1) hue-rotate(180deg); }

/* ============ Ficha ============ */
.ficha {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: 410px; z-index: 1100;
  background: var(--superficie); border-radius: var(--radio); box-shadow: var(--sombra);
  overflow-y: auto; padding: 16px 18px;
}
.ficha.oculta { visibility: hidden; }
.ficha .cerrar { position: absolute; top: 10px; right: 10px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--tinta-2); }
.ficha h2 { font-size: 18px; padding-right: 26px; line-height: 1.3; }
.ficha .cod { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--tinta-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--chip); }
.chip.sem { color: #fff; font-weight: 500; }
.ficha p.desc { font-size: 13.5px; color: var(--tinta-2); margin: 6px 0 12px; }
.acciones-ficha { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.btn-f {
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; padding: 6px 12px; border-radius: 6px;
  border: 1px solid var(--acento); background: transparent; color: var(--acento-txt);
}
.btn-f.lleno { background: var(--acento); color: #fff; }
.btn-f.peligro { border-color: var(--rojo); color: var(--rojo); }
.btn-f:disabled { opacity: .5; cursor: default; }
.barras { display: grid; gap: 8px; margin: 12px 0; }
.barra-av .lbl { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 3px; }
.barra-av .trk { height: 8px; background: var(--pista); border-radius: 4px; overflow: hidden; }
.barra-av .fill { height: 100%; border-radius: 4px; }
dl.datos { display: grid; grid-template-columns: max-content 1fr; gap: 5px 12px; font-size: 13px; margin: 12px 0; }
dl.datos dt { color: var(--tinta-2); }
dl.datos dd { margin: 0; }
.ficha h3 { font-size: 14px; margin: 18px 0 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.t th { text-align: left; font-weight: 500; color: var(--tinta-2); border-bottom: 1px solid var(--linea); padding: 4px; }
table.t td { border-bottom: 1px solid var(--linea-suave); padding: 5px 4px; vertical-align: top; }
table.t td.n, table.t th.n { text-align: right; font-family: 'IBM Plex Mono', monospace; }
table.t td.acc { white-space: nowrap; text-align: right; }
.mini-btn { border: 0; background: none; cursor: pointer; color: var(--tinta-2); font-size: 14px; padding: 2px 4px; border-radius: 4px; }
.mini-btn:hover { background: var(--hover); color: var(--tinta); }
.aviso { font-size: 12.5px; padding: 8px 10px; border-radius: 6px; background: var(--aviso); color: var(--aviso-txt); margin: 8px 0; }
.aviso.rojo { background: var(--aviso-rojo); color: var(--tinta); }

/* Formularios de edición */
.form-ed { display: grid; gap: 10px; margin-top: 8px; }
.form-ed label { display: grid; gap: 4px; font-size: 12.5px; color: var(--tinta-2); }
.form-ed label.chk { display: flex; align-items: center; gap: 8px; color: var(--tinta); font-size: 13.5px; }
.form-ed label.chk input { width: auto; }
.form-ed .fila { grid-template-columns: 1fr 1fr; }
.form-ed .fila3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.form-ed fieldset { border: 1px solid var(--linea); border-radius: 6px; padding: 8px 10px 10px; margin: 0; display: grid; gap: 8px; }
.form-ed legend { font-size: 12.5px; color: var(--tinta-2); padding: 0 4px; }
.ubic-txt { font-size: 12.5px; font-family: 'IBM Plex Mono', monospace; }
.form-ed .error { color: var(--rojo); font-size: 12.5px; margin: 0; min-height: 1em; }
.form-ed .botones { display: flex; gap: 8px; justify-content: flex-end; }
.item-form { background: var(--superficie-2); border: 1px solid var(--linea); border-radius: 6px; padding: 10px; margin: 8px 0; }

/* Validación y fotos */
.pend { border: 1px solid var(--pend-borde); background: var(--pend); border-radius: 6px; padding: 9px 10px; margin-bottom: 8px; font-size: 13px; }
.pend-cab { display: flex; justify-content: space-between; gap: 8px; }
.pend-sub { font-size: 12px; color: var(--tinta-2); margin-top: 3px; }
.pend-acc { display: flex; gap: 8px; margin-top: 8px; }
.btn-v { flex: 1; font: inherit; font-size: 13px; font-weight: 500; border-radius: 6px; padding: 7px; cursor: pointer; border: 1px solid; background: var(--superficie); }
.btn-v.ok { color: var(--verde); border-color: var(--verde); }
.btn-v.ok:hover { background: var(--verde); color: #fff; }
.btn-v.obs { color: var(--rojo); border-color: var(--rojo); }
.btn-v.obs:hover { background: var(--rojo); color: #fff; }
.btn-v:disabled { opacity: .5; cursor: default; }
.minis { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.mini { position: relative; display: block; width: 64px; height: 64px; border-radius: 6px; overflow: hidden; border: 2px solid transparent; }
.minis.grande .mini { width: 84px; height: 84px; }
.mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini.revisar { border-color: var(--amarillo); }
.mini span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; text-align: center; background: var(--amarillo); color: #fff; }

/* Pie con créditos */
.pie {
  display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; justify-content: center;
  padding: 5px 16px; font-size: 12px; color: var(--tinta-2);
  background: var(--superficie); border-top: 1px solid var(--linea);
}
.pie-logo img { height: 18px; display: block; }

/* Login */
dialog { border: 0; border-radius: var(--radio); box-shadow: var(--sombra); padding: 20px; width: min(360px, 92vw); background: var(--superficie); color: var(--tinta); }
dialog::backdrop { background: rgba(10,14,18,.55); }
dialog form { display: grid; gap: 10px; }
dialog label { display: grid; gap: 4px; font-size: 13px; }
dialog .nota { margin: 0; font-size: 12.5px; color: var(--tinta-2); }
dialog .error { margin: 0; color: var(--rojo); font-size: 12.5px; min-height: 1em; }
dialog .btn { background: var(--acento); color: #fff; }
dialog .btn.btn-sec { background: transparent; color: var(--tinta-2); border-color: var(--linea); }
.acciones { display: flex; justify-content: flex-end; gap: 8px; }

.estado-carga { padding: 16px; font-size: 13px; color: var(--tinta-2); }

/* ============ Celular ============ */

/* ===================================================================
   v1.3 — movimiento, notificaciones, decisiones, fotos y diseño móvil
   =================================================================== */
html { -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
.app { height: 100dvh; }
:root { --linea-mapa: color-mix(in srgb, var(--acento) 22%, transparent); }
:root[data-theme="dark"] { --linea-mapa: color-mix(in srgb, #8cbbea 18%, transparent); }

/* ---------- Inicio animado ---------- */
.inicio { position: relative; overflow: hidden; min-height: 100dvh; isolation: isolate; }
.inicio > :not(.fondo-mapa) { position: relative; z-index: 1; }
.fondo-mapa { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at 50% 45%, transparent 18%, #000 70%); mask-image: radial-gradient(ellipse at 50% 45%, transparent 18%, #000 70%); }
.fondo-mapa .calles path { fill: none; stroke: var(--linea-mapa); stroke-width: 2; stroke-dasharray: 1700; stroke-dashoffset: 1700;
  animation: dibuja 2.6s cubic-bezier(.4,.1,.2,1) forwards; animation-delay: var(--d, 0s); }
.fondo-mapa .calles path.av { stroke-width: 7; stroke: color-mix(in srgb, var(--acento) 30%, transparent); stroke-dasharray: 2200; stroke-dashoffset: 2200; }
@keyframes dibuja { to { stroke-dashoffset: 0; } }
.fondo-mapa .pin { opacity: 0; animation: cae-pin .7s cubic-bezier(.3,1.5,.5,1) forwards; animation-delay: var(--d); }
.fondo-mapa .pin > path, .fondo-mapa .pin > circle:last-child { transform-box: fill-box; }
@keyframes cae-pin { from { opacity: 0; translate: 0 -60px; } to { opacity: .9; translate: 0 0; } }
.fondo-mapa .onda { transform-box: fill-box; transform-origin: center; opacity: 0; animation: onda 2.8s ease-out infinite; animation-delay: calc(var(--d) + .7s); }
@keyframes onda { 0% { opacity: .45; transform: scale(.4); } 100% { opacity: 0; transform: scale(3.4); } }

.inicio-top, .inicio-centro > *, .credito { animation: sube .6s cubic-bezier(.2,.7,.2,1) both; }
.inicio-centro > :nth-child(1) { animation: cae-logo .9s cubic-bezier(.3,1.6,.5,1) both .1s; }
.inicio-centro > :nth-child(2) { animation-delay: .2s; }
.inicio-centro > :nth-child(3) { animation-delay: .3s; }
.inicio-centro > :nth-child(4) { animation-delay: .4s; }
.inicio-centro > :nth-child(5) { animation-delay: .5s; }
.inicio-centro > :nth-child(6) { animation-delay: .65s; }
.credito { animation-delay: .8s; }
@keyframes sube { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes cae-logo { from { opacity: 0; transform: translateY(-40px) scale(.7); } to { opacity: 1; transform: none; } }
.logo-app { filter: drop-shadow(0 8px 14px rgba(31,78,121,.28)); }
.logo-app svg { animation: flota 4s ease-in-out infinite 1.2s; }
@keyframes flota { 50% { transform: translateY(-5px); } }
.inicio h1 { background: linear-gradient(100deg, var(--tinta) 30%, var(--acento-txt) 50%, var(--tinta) 70%); background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: brillo-txt 6s ease-in-out infinite 1.5s; }
@keyframes brillo-txt { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }
.inicio.sale { animation: inicio-sale .32s ease-in forwards; }
@keyframes inicio-sale { to { opacity: 0; transform: scale(1.04); filter: blur(2px); } }
.inicio.vuelve { animation: aparece .35s ease-out; }
.app.entra { animation: aparece .45s ease-out; }
@keyframes aparece { from { opacity: 0; } to { opacity: 1; } }

.cifras { display: flex; justify-content: center; gap: 10px 34px; flex-wrap: wrap; margin: -10px auto 26px; }
.cifras div { display: grid; }
.cifras b { font-family: 'IBM Plex Mono', monospace; font-size: clamp(20px, 3.2vw, 26px); font-weight: 500; color: var(--acento-txt); }
.cifras span { font-size: 12.5px; color: var(--tinta-2); }
.opcion { position: relative; overflow: hidden; }
.opcion::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 40%, color-mix(in srgb, var(--acento) 10%, transparent) 50%, transparent 60%);
  transform: translateX(-100%); transition: transform .6s; }
.opcion:hover::after { transform: translateX(100%); }
.op-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--acento) 12%, transparent); transition: transform .25s; }
.op-ico svg { width: 24px; height: 24px; }
.opcion:hover .op-ico { transform: rotate(-6deg) scale(1.08); }
.op-ir { transition: letter-spacing .2s; }
.opcion:hover .op-ir { letter-spacing: .02em; }

/* ---------- Tablero: entradas ---------- */
.kpi { animation: sube .45s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 50ms); }
.lista li { animation: sube .35s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 25ms); transition: background .15s; }
.lista li.activa { box-shadow: inset 3px 0 0 var(--acento); }
.chip-est { transition: background .2s, color .2s, transform .12s; }
.chip-est:active { transform: scale(.95); }
.leaflet-interactive.marcador { transform-box: fill-box; transform-origin: center; animation: pop-m .45s cubic-bezier(.3,1.6,.5,1) both; transition: transform .15s; }
.leaflet-interactive.marcador:hover { transform: scale(1.25); }
@keyframes pop-m { from { transform: scale(0); } to { transform: scale(1); } }
.leaflet-interactive.anillo { transform-box: fill-box; transform-origin: center; animation: anillo 1.8s ease-out infinite; pointer-events: none; }
@keyframes anillo { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(2.6); opacity: 0; } }
.ficha.abre { animation: ficha-in .35s cubic-bezier(.2,.8,.2,1); }
@keyframes ficha-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.barra-av .fill { animation: crece 1s cubic-bezier(.2,.7,.2,1) both .1s; }
@keyframes crece { from { width: 0; } }
.manija { display: none; }
.toast.entra { animation: toast-in .3s cubic-bezier(.2,.8,.2,1); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
.estado-carga { animation: aparece .3s; }

#dec-cuerpo { padding: 4px 18px 8px; overflow-y: auto; }
#dec-acciones { padding: 10px 18px 16px; border-top: 1px solid var(--linea); }
.kpi .v { white-space: nowrap; font-size: clamp(16px, 1.3vw, 20px); }
.kpi .e { white-space: nowrap; }
.btn-filtros svg { width: 18px; height: 18px; }

/* ---------- Validación ---------- */
.pend { animation: sube .35s both; animation-delay: calc(var(--i, 0) * 50ms); transition: transform .4s, opacity .4s; }
.pend.sale-ok { transform: translateX(40px); opacity: 0; border-color: var(--verde); }
.pend.sale-obs { transform: translateX(-40px); opacity: 0; border-color: var(--rojo); }
.ficha h3 small.ayuda { font-weight: 400; }
.ayuda { font-size: 12px; color: var(--tinta-2); margin: 6px 0; }
.decisiones { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.decisiones li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: start; padding: 8px 9px; border: 1px solid var(--linea); border-radius: 6px; font-size: 13px; }
.dec-punto { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; }
.btn-f.chico { padding: 4px 10px; font-size: 12.5px; }
.candado { font-size: 11.5px; color: var(--tinta-2); white-space: nowrap; }
.mini { padding: 0; cursor: zoom-in; background: none; transition: transform .15s; }
.mini:hover { transform: scale(1.06); }
.mini-trk { height: 4px; background: var(--pista); border-radius: 2px; overflow: hidden; margin-top: 4px; max-width: 160px; }
.mini-trk div { height: 100%; width: var(--w); background: var(--acento); animation: crece .9s both .2s; }

.dec-opciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 10px 0; }
.dec-op input { position: absolute; opacity: 0; }
.dec-op span { display: block; text-align: center; padding: 10px; border-radius: 8px; border: 1.5px solid var(--linea); cursor: pointer; font-weight: 500; font-size: 13.5px; transition: all .15s; }
.dec-op input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.dec-op input:focus-visible + span { outline: 2px solid var(--acento); }
.dec-motivo { display: grid; gap: 4px; font-size: 13px; }
.dec-motivo small { color: var(--tinta-2); }
.historial h4 { font-size: 13px; margin: 14px 0 6px; }
.linea-tiempo { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--linea); display: grid; gap: 8px; }
.linea-tiempo li { position: relative; font-size: 12.5px; }
.linea-tiempo li::before { content: ''; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px var(--superficie); }
.linea-tiempo span { color: var(--tinta-2); margin-left: 4px; }
.linea-tiempo em { display: block; color: var(--tinta-2); }

/* ---------- Visor de foto ---------- */
.dlg-foto { width: min(1040px, 96vw); max-height: 94dvh; padding: 0; overflow: hidden; }
.dlg-foto[open] { display: flex; flex-direction: column; animation: zoom-in .25s cubic-bezier(.2,.8,.2,1); }
@keyframes zoom-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
dialog[open].dlg-kpi { animation: zoom-in .22s cubic-bezier(.2,.8,.2,1); }
.foto-cuerpo { display: grid; grid-template-columns: 1.5fr 1fr; gap: 0; min-height: 0; overflow: auto; }
.foto-img { background: #0d1117; display: grid; align-content: center; justify-items: center; gap: 8px; padding: 10px; }
.foto-img img { max-width: 100%; max-height: 72dvh; object-fit: contain; border-radius: 4px; }
.foto-img a { color: #8cbbea; font-size: 12.5px; }
.foto-info { padding: 12px 16px 16px; overflow: auto; }
#foto-mapa { height: 170px; border-radius: 8px; margin-bottom: 10px; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 5px 12px; font-size: 12.5px; margin: 0; }
dl.meta dt { color: var(--tinta-2); }
dl.meta dd { margin: 0; word-break: break-word; }
dl.meta code { font-size: 11.5px; }

/* ---------- Campana y panel de notificaciones ---------- */
.notif-wrap { position: relative; }
.btn-notif { position: relative; border: 0; background: transparent; color: #fff; width: 38px; height: 36px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.btn-notif:hover { background: rgba(255,255,255,.12); }
.btn-notif svg { width: 21px; height: 21px; }
.btn-notif.timbre svg { animation: timbre .9s; transform-origin: 50% 10%; }
@keyframes timbre { 15% { transform: rotate(16deg); } 30% { transform: rotate(-14deg); } 45% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } 75% { transform: rotate(3deg); } }
.notif-badge { position: absolute; top: 1px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #e5483a; color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; animation: pop-m .3s both; }
.panel-notif { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, 92vw); max-height: 70dvh; overflow: auto; z-index: 2500;
  background: var(--superficie); color: var(--tinta); border: 1px solid var(--linea); border-radius: 10px; box-shadow: var(--sombra); padding: 10px; animation: baja .2s ease-out; }
@keyframes baja { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.pn-cab { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 8px; }
.link-btn { border: 0; background: none; color: var(--acento-txt); font: inherit; font-size: 12.5px; cursor: pointer; padding: 4px; }
.notif-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.notif { display: grid; grid-template-columns: 30px 1fr; gap: 9px; padding: 9px; border-radius: 8px; cursor: pointer; border: 1px solid var(--linea-suave); animation: sube .25s both; animation-delay: calc(var(--i, 0) * 30ms); }
.notif:hover { background: var(--hover); }
.notif.nueva { border-left: 3px solid var(--acento); background: color-mix(in srgb, var(--acento) 7%, var(--superficie)); }
.notif-ico { width: 30px; height: 30px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.notif-tit { font-weight: 600; font-size: 13px; }
.notif-msg { font-size: 12.5px; color: var(--tinta-2); margin-top: 2px; line-height: 1.4; }
.notif-meta { font-size: 11px; color: var(--tinta-2); margin-top: 3px; }
.notif-vacio { text-align: center; color: var(--tinta-2); font-size: 13px; padding: 18px 6px; }

/* ---------- Filtros y navegación móvil (ocultos en escritorio) ---------- */
.buscar-fila { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.btn-filtros { display: none; }
.filtros-mas { display: grid; gap: 8px; }
.nav-movil { display: none; }

/* ===================== Celular ===================== */
@media (max-width: 760px) {
  body { overscroll-behavior-y: none; }
  .opciones { grid-template-columns: 1fr; }
  .opcion { padding: 16px; grid-template-columns: 44px 1fr; column-gap: 14px; }
  .opcion .op-ico { grid-row: span 3; }
  .opcion .op-txt { font-size: 13px; }
  .inicio-centro { padding: 10px 18px 18px; }
  .lema { margin-bottom: 18px; font-size: 15px; }
  .cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: -4px auto 18px; }
  .cifras b { font-size: 16px; }
  .cifras span { font-size: 11px; }
  .fondo-mapa .pin { scale: .8; }
  .logo-app { width: 54px; height: 54px; }

  .app { height: 100dvh; }
  .barra { padding: calc(6px + env(safe-area-inset-top)) 10px 6px; gap: 6px; }
  .marca .sub, .usuario, #link-inspector { display: none; }
  .marca .h1 { font-size: 16px; }
  .sesion { gap: 4px; }
  .sesion .btn { padding: 6px 10px; font-size: 13px; }
  .kpis { display: flex; overflow-x: auto; gap: 2px; padding: 6px 8px; scrollbar-width: none; scroll-snap-type: x proximity; }
  .kpis::-webkit-scrollbar { display: none; }
  .kpi { flex: none; scroll-snap-align: start; padding: 4px 8px; }
  .kpi .v { font-size: 16px; white-space: nowrap; }
  .kpi .e { white-space: nowrap; font-size: 11.5px; }

  .cuerpo { display: block; position: relative; flex: 1; overflow: hidden; }
  .mapa-wrap { position: absolute; inset: 0; }
  .panel { position: absolute; inset: 0; z-index: 1300; border: 0; transform: translateY(102%); transition: transform .32s cubic-bezier(.2,.8,.2,1); }
  body.ver-lista .panel { transform: none; }
  .lista { padding-bottom: 16px; }
  .lista li { padding: 12px 8px; }
  .btn-filtros { display: inline-flex; align-items: center; gap: 4px; font: inherit; font-size: 15px; padding: 0 12px; border-radius: 6px;
    border: 1px solid var(--linea); background: var(--input); color: var(--tinta); cursor: pointer; }
  .btn-filtros.activos { border-color: var(--acento); color: var(--acento-txt); }
  .btn-filtros span:empty { display: none; }
  .filtros-mas { display: none; }
  .filtros-mas.abierto { display: grid; animation: baja .2s; }
  input, select { font-size: 16px; padding: 9px 10px; }   /* evita el zoom automático de iOS */

  .chips-estado { left: 8px; right: 8px; top: 8px; max-width: none; }
  .leaflet-top.leaflet-left { top: 50px; }
  .leyenda { left: 8px; bottom: 10px; padding: 6px 9px; cursor: pointer; }
  .leyenda > div { display: none; }
  .leyenda.abierta > div { display: flex; }
  .leyenda strong::after { content: ' ▾'; font-weight: 400; opacity: .6; }
  .btn-mapa { display: none; }
  .banner-recorrido { bottom: 12px; font-size: 12.5px; }
  .banner-ubic { top: 56px; font-size: 13px; }

  .ficha { position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); top: auto; width: auto; max-height: calc(78dvh - 60px);
    border-radius: 16px 16px 0 0; padding-top: 22px; z-index: 1400; transition: transform .25s; box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
  .ficha.abre { animation: hoja-in .35s cubic-bezier(.2,.8,.2,1); }
  @keyframes hoja-in { from { transform: translateY(100%); } to { transform: none; } }
  .manija { display: block; position: absolute; top: 8px; left: 50%; width: 42px; height: 5px; margin-left: -21px; border-radius: 3px; background: var(--linea); }
  .ficha .cerrar { top: 12px; }
  .acciones-ficha .btn-f { padding: 8px 12px; }

  .nav-movil { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: relative; z-index: 1500;
    height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--superficie); border-top: 1px solid var(--linea); box-shadow: 0 -2px 12px rgba(0,0,0,.06); }
  .nav-movil button { border: 0; background: none; color: var(--tinta-2); font: inherit; font-size: 11px; display: grid; justify-items: center; align-content: center; gap: 3px; cursor: pointer; }
  .nav-movil button svg { width: 22px; height: 22px; transition: transform .2s; }
  .nav-movil button.on { color: var(--acento-txt); font-weight: 600; }
  .nav-movil button.on svg { transform: translateY(-2px) scale(1.08); }
  .nav-movil b { font-weight: 500; font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; }
  .pie { display: none; }

  .panel-notif { position: fixed; left: 8px; right: 8px; width: auto; top: calc(52px + env(safe-area-inset-top)); }
  dialog { max-width: 100vw; }
  .dlg-kpi, .dlg-foto { width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  dialog[open].dlg-kpi, .dlg-foto[open] { animation: hoja-in .3s cubic-bezier(.2,.8,.2,1); }
  .foto-cuerpo { grid-template-columns: 1fr; }
  .foto-img img { max-height: 46dvh; }
  .bh { grid-template-columns: 100px 1fr auto; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (max-width: 760px) and (orientation: landscape) { .ficha { max-height: calc(92dvh - 60px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .fondo-mapa .calles path { stroke-dashoffset: 0; }
  .fondo-mapa .pin { opacity: .9; }
}
