/* AsuReporta · sistema visual
   Idea: app cívica cercana, pensada primero para el celular. Azul río (confianza, institucional)
   + rosa lapacho (calidez, acciones del vecino). Tarjetas aireadas, botones grandes, estados con color. */
:root {
  --rio: #0f5c8c;          /* primario: azul del río Paraguay */
  --rio-hover: #0b4a72;
  --rio-suave: #e3eef6;
  --sobre-color: #ffffff;   /* texto sobre botones de color */
  --lapacho: #c83e7a;      /* acento: rosa lapacho */
  --lapacho-suave: #fbe7f0;
  --fondo: #f3f6f9;
  --superficie: #ffffff;
  --superficie-2: #f7f9fb;
  --texto: #15212d;
  --texto-2: #566575;
  --borde: #dde4ec;
  --ok: #1d7a46; --ok-suave: #e3f3e9;
  --aviso: #a35a00; --aviso-suave: #fdf0dc;
  --alerta: #b42318; --alerta-suave: #fde8e6;
  --info: #1f6fd1; --info-suave: #e5effc;
  --sombra: 0 1px 2px rgba(16, 40, 64, .06), 0 4px 16px rgba(16, 40, 64, .06);
  --sombra-alta: 0 10px 30px rgba(16, 40, 64, .14);
  --radio: 16px; --radio-chico: 10px;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-texto: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --rio: #5fb0e4; --rio-hover: #84c4ee; --rio-suave: #15344a; --sobre-color: #0e141a;
    --lapacho: #f07fb0; --lapacho-suave: #3d1d2c;
    --fondo: #0e141a; --superficie: #161e26; --superficie-2: #1b252f;
    --texto: #e7edf3; --texto-2: #9aabbb; --borde: #2a3743;
    --ok: #5cc98a; --ok-suave: #173526; --aviso: #f0b45a; --aviso-suave: #3a2a12;
    --alerta: #f08a80; --alerta-suave: #3d1a17; --info: #7fb2f5; --info-suave: #172b45;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25); --sombra-alta: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --rio: #5fb0e4; --rio-hover: #84c4ee; --rio-suave: #15344a; --sobre-color: #0e141a;
  --lapacho: #f07fb0; --lapacho-suave: #3d1d2c;
  --fondo: #0e141a; --superficie: #161e26; --superficie-2: #1b252f;
  --texto: #e7edf3; --texto-2: #9aabbb; --borde: #2a3743;
  --ok: #5cc98a; --ok-suave: #173526; --aviso: #f0b45a; --aviso-suave: #3a2a12;
  --alerta: #f08a80; --alerta-suave: #3d1a17; --info: #7fb2f5; --info-suave: #172b45;
  --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25); --sombra-alta: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--f-texto); font-size: 16px; line-height: 1.5; background: var(--fondo); color: var(--texto); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.2; margin: 0 0 .5em; text-wrap: balance; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; } h4 { font-size: 1rem; }
p { margin: 0 0 .75em; }
a { color: var(--rio); text-underline-offset: 3px; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--lapacho); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* Barra superior */
header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left)); background: var(--superficie); border-bottom: 1px solid var(--borde); }
header strong { font-family: var(--f-display); font-size: 1.1rem; display: flex; align-items: center; gap: 8px; color: var(--texto); }
header strong::before { content: ""; width: 26px; height: 26px; flex: none; border-radius: 8px;
  background: var(--rio) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3a6 6 0 0 0-6 6c0 4.5 6 11 6 11s6-6.5 6-11a6 6 0 0 0-6-6z' fill='white'/%3E%3Ccircle cx='12' cy='9' r='2.3' fill='%230f5c8c'/%3E%3C/svg%3E") center/18px no-repeat; }
header a, header span { font-size: .9rem; color: var(--texto-2); }
header a { color: var(--rio); font-weight: 600; text-decoration: none; }
header a:hover { text-decoration: underline; }
#sesion { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 10px; align-items: center; text-align: right; }

main { max-width: 1180px; margin: 0 auto; padding: 16px 16px 48px; display: grid; gap: 16px; }
main > * { min-width: 0; }

/* Tarjetas */
.card { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 20px; box-shadow: var(--sombra); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.muted { color: var(--texto-2); }
.oculto { display: none !important; }

/* Formularios */
label { display: block; font-weight: 600; font-size: .92rem; margin: 4px 0; }
input, select, textarea { font: inherit; color: var(--texto); background: var(--superficie-2); width: 100%; padding: 12px 14px; margin: 4px 0 12px;
  border: 1.5px solid var(--borde); border-radius: var(--radio-chico); min-height: 48px; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; min-height: 88px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--rio); box-shadow: 0 0 0 4px var(--rio-suave); }
input[type=file] { padding: 10px; background: var(--superficie); }
input[type=radio], input[type=checkbox] { width: auto; min-height: 0; margin: 0 6px 0 0; accent-color: var(--rio); }
details summary { cursor: pointer; font-weight: 600; color: var(--rio); padding: 8px 0; }

/* Botones */
button, .btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 10px 20px; border-radius: 999px; border: 0; cursor: pointer; background: var(--rio); color: var(--sobre-color); text-decoration: none;
  transition: background .15s, transform .1s, box-shadow .15s; }
button:hover { background: var(--rio-hover); }
button:active { transform: scale(.98); }
button:disabled { opacity: .6; cursor: progress; }
button.btn-sec, .btn-sec { background: var(--superficie); color: var(--rio) !important; border: 1.5px solid var(--borde); }
button.btn-sec:hover, .btn-sec:hover { border-color: var(--rio); background: var(--rio-suave); }
button.btn-ok { background: var(--ok); } button.btn-no { background: var(--alerta); }
button.btn-lapacho { background: var(--lapacho); }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 520px) { form > button, .acciones > button, .acciones > a, .btn-bloque { width: 100%; } }

/* Grillas */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.grid > select, .grid > input { margin: 0; }

/* Indicadores */
#kpis { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
#kpis .card { padding: 14px 16px; position: relative; overflow: hidden; }
#kpis .card .muted { font-size: .85rem; font-weight: 600; }
.kpi { font-family: var(--f-display); font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* Estados */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--rio-suave); color: var(--rio); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.est-recibida { background: var(--alerta-suave); color: var(--alerta); }
.est-en_revision, .est-asignada { background: var(--aviso-suave); color: var(--aviso); }
.est-en_proceso { background: var(--info-suave); color: var(--info); }
.est-resuelta { background: var(--ok-suave); color: var(--ok); }
.est-rechazada { background: var(--superficie-2); color: var(--texto-2); }
.badge.rojo { background: var(--alerta-suave); color: var(--alerta); } .badge.naranja { background: var(--aviso-suave); color: var(--aviso); }
.badge.verde { background: var(--ok-suave); color: var(--ok); }
.badge.sin-punto::before { display: none; }

/* Barras de gráfico */
.bar { height: 8px; background: linear-gradient(90deg, var(--rio), color-mix(in srgb, var(--rio) 70%, var(--lapacho))); border-radius: 99px; margin: 4px 0 10px; }

/* Tablas */
.tabla-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-2); font-weight: 700; padding: 10px 8px; border-bottom: 1.5px solid var(--borde); white-space: nowrap; }
td { padding: 12px 8px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
tr:hover td { background: var(--superficie-2); }

/* Avisos */
.aviso { background: var(--aviso-suave); border: 1px solid color-mix(in srgb, var(--aviso) 30%, transparent); border-radius: var(--radio); padding: 16px; margin: 8px 0; }
.aviso.ok { background: var(--ok-suave); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.offline { background: var(--aviso); color: var(--sobre-color); padding: 10px 16px; text-align: center; font-weight: 600; }

/* Reportes cercanos (duplicados) */
.similar { display: flex; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid color-mix(in srgb, var(--aviso) 25%, transparent); }
.similar img { width: 76px; height: 76px; object-fit: cover; border-radius: var(--radio-chico); flex: none; }
.similar button { margin-top: 8px; min-height: 40px; padding: 8px 14px; background: var(--lapacho); }

/* Fotos */
img.foto { width: 100%; max-height: 340px; object-fit: cover; border-radius: var(--radio-chico); display: block; margin: 8px 0; }
.antes-despues { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 12px; }
.antes-despues b { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--texto-2); }
.antes-despues img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radio-chico); display: block; margin-top: 4px; }

/* Estrellas */
.estrellas { font-size: 2.2rem; color: #f2a600; cursor: pointer; user-select: none; display: flex; gap: 4px; margin: 4px 0 8px; }
.estrellas span { padding: 0 2px; }

/* Línea de tiempo del seguimiento */
.linea { list-style: none; padding: 0; margin: 8px 0 16px; position: relative; }
.linea li { position: relative; padding: 0 0 14px 26px; }
.linea li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--rio); box-shadow: 0 0 0 4px var(--rio-suave); }
.linea li::after { content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 2px; background: var(--borde); }
.linea li:last-child::after { display: none; }
.linea small { color: var(--texto-2); display: block; }

/* Tareas de cuadrilla */
.tarea { border-left: 6px solid var(--rio); }
.tarea.urgente { border-left-color: var(--alerta); } .tarea.alta { border-left-color: var(--aviso); } .tarea.baja { border-left-color: var(--borde); }

/* Cajón del panel */
.cajon { position: fixed; right: 16px; top: 64px; width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 90px); overflow: auto;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra-alta); padding: 16px; z-index: 20; }
.leaflet-container { font-family: var(--f-texto); border-radius: var(--radio-chico); }
@media (max-width: 520px) {
  .card { padding: 16px; }
  #kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  #kpis .card { padding: 10px 12px; }
  .kpi { font-size: 1.5rem; }
  header strong { font-size: 1rem; }
}

/* ===== Capa premium ===== */
:root { --radio: 20px; --vidrio: rgba(255,255,255,.78); --sombra-suave: 0 1px 1px rgba(16,40,64,.04), 0 2px 6px rgba(16,40,64,.04), 0 12px 32px -8px rgba(16,40,64,.10);
  --degradado: linear-gradient(135deg, #0c4a72 0%, #0f5c8c 45%, #7a3f86 100%); --ease: cubic-bezier(.2,.8,.2,1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --vidrio: rgba(22,30,38,.78); --sombra-suave: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -8px rgba(0,0,0,.5);
  --degradado: linear-gradient(135deg, #0b2a40 0%, #123f5e 50%, #4a2552 100%); } }
:root[data-theme="dark"] { --vidrio: rgba(22,30,38,.78); --sombra-suave: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -8px rgba(0,0,0,.5);
  --degradado: linear-gradient(135deg, #0b2a40 0%, #123f5e 50%, #4a2552 100%); }
.card { box-shadow: var(--sombra-suave); border-color: color-mix(in srgb, var(--borde) 70%, transparent); }
header { background: var(--vidrio); -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px); border-bottom-color: color-mix(in srgb, var(--borde) 60%, transparent); }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--texto-2); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .9rem; flex: none;
  background: var(--lapacho-suave); color: var(--lapacho); border: 0; padding: 0; min-height: 0; cursor: pointer; }
.avatar:hover { background: var(--lapacho-suave); filter: brightness(.96); }

/* Entrada suave de contenido */
@keyframes subir { from { opacity: .001; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.entra { animation: subir .45s var(--ease) both; }
.entra:nth-child(2) { animation-delay: .04s; } .entra:nth-child(3) { animation-delay: .08s; } .entra:nth-child(4) { animation-delay: .12s; }

/* Pasos de avance del reporte */
.pasos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 10px; }
.pasos div { display: grid; gap: 6px; font-size: .7rem; font-weight: 600; color: var(--texto-2); }
.pasos div::before { content: ""; height: 5px; border-radius: 99px; background: var(--borde); }
.pasos div.hecho::before { background: var(--rio); } .pasos div.hecho { color: var(--texto); }
.pasos.fin div::before { background: var(--ok); }

/* Hoja inferior (celular) / panel lateral (computadora) */
.velo { position: fixed; inset: 0; background: rgba(8,18,28,.45); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .25s; }
.velo.ver { opacity: 1; pointer-events: auto; }
.hoja { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; background: var(--superficie);
  border-radius: 24px 24px 0 0; box-shadow: var(--sombra-alta); padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .35s var(--ease); visibility: hidden; }
.hoja.ver { transform: none; visibility: visible; }
.hoja::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--borde); margin: 4px auto 12px; }
.hoja .cerrar { position: sticky; top: 0; float: right; width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%;
  background: var(--superficie-2); color: var(--texto); font-size: 1.3rem; z-index: 1; }
@media (min-width: 900px) {
  .hoja { left: auto; top: 0; width: min(560px, 46vw); max-height: none; border-radius: 0; padding: 20px 28px 32px; transform: translateX(105%); }
  .hoja::before { display: none; }
}

/* Barra de navegación inferior (app del vecino) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--vidrio); -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid color-mix(in srgb, var(--borde) 60%, transparent); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a, .tabbar button { display: grid; justify-items: center; gap: 2px; min-height: 52px; padding: 6px 4px; border-radius: 14px; background: transparent;
  color: var(--texto-2); font-size: .74rem; font-weight: 600; text-decoration: none; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar [aria-current="page"] { color: var(--rio); background: var(--rio-suave); }
.tabbar button:hover, .tabbar a:hover { background: var(--superficie-2); }
@media (min-width: 900px) { .tabbar { left: 50%; right: auto; bottom: 16px; transform: translateX(-50%); width: 420px; border-radius: 22px; border: 1px solid var(--borde); box-shadow: var(--sombra-alta); } }

/* Indicadores con ícono */
.kpi-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 8px; background: var(--rio-suave); color: var(--rio); }
.kpi-ico svg { width: 18px; height: 18px; }
.kpi-ico.alerta { background: var(--alerta-suave); color: var(--alerta); } .kpi-ico.aviso { background: var(--aviso-suave); color: var(--aviso); }
.kpi-ico.ok { background: var(--ok-suave); color: var(--ok); } .kpi-ico.lapacho { background: var(--lapacho-suave); color: var(--lapacho); }
.kpi-sub { font-size: .78rem; color: var(--texto-2); margin-top: 2px; }
.franja-alerta { box-shadow: inset 4px 0 0 var(--alerta), var(--sombra-suave) !important; }
.franja-aviso { box-shadow: inset 4px 0 0 var(--aviso), var(--sombra-suave) !important; }

/* Éxito al enviar */
@keyframes trazo { to { stroke-dashoffset: 0; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
.exito { text-align: center; padding: 12px 4px 4px; }
.exito .circulo { width: 84px; height: 84px; border-radius: 50%; background: var(--ok-suave); display: grid; place-items: center; margin: 0 auto 14px; animation: pop .5s var(--ease) both; }
.exito path { stroke: var(--ok); stroke-width: 3.5; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: trazo .5s .25s var(--ease) forwards; }

/* Esqueletos de carga */
@keyframes brillo { to { background-position: -200% 0; } }
.esqueleto { border-radius: 12px; min-height: 64px; background: linear-gradient(90deg, var(--superficie-2) 0%, var(--borde) 50%, var(--superficie-2) 100%); background-size: 200% 100%; animation: brillo 1.4s linear infinite; }
.instalar { min-height: 40px; padding: 8px 14px; font-size: .9rem; }
.ayuda-ios { position: fixed; inset: 0; z-index: 60; background: rgba(8,18,28,.5); display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.ayuda-caja { background: var(--superficie); color: var(--texto); border-radius: 24px; padding: 22px; max-width: 420px; width: 100%; box-shadow: var(--sombra-alta); animation: subir .3s var(--ease) both; margin-bottom: env(safe-area-inset-bottom); }
.ayuda-caja ol { padding-left: 20px; display: grid; gap: 8px; margin: 8px 0 12px; }
