/* ==========================================================================
   VecinGo — sistema de diseño
   Sobrio: la jerarquía la dan el espacio y el peso, no el color. Una sola
   familia de acento. Sin framework: tokens + componentes.
   ========================================================================== */

:root {
  /* Acento: verde profundo, no neón. Comunidad, no app de gimnasio. */
  --a-50:  #edfaf3;
  --a-100: #d3f2e1;
  --a-200: #a9e4c6;
  --a-300: #6fcfa3;
  --a-400: #3bb582;
  --a-500: #1d9a68;
  --a-600: #137d55;
  --a-700: #106345;

  --n-0:   #ffffff;
  --n-50:  #f7f9fb;
  --n-100: #eef2f6;
  --n-150: #e4eaf0;
  --n-200: #d7dee7;
  --n-300: #b6c1cf;
  --n-400: #8593a6;
  --n-600: #4a5769;
  --n-900: #141a21;
  --n-950: #0b0f14;

  --ok:    #15803d;
  --warn:  #b45309;
  --bad:   #be123c;
  --info:  #1d4ed8;
  --grape: #6d28d9;

  --bg:        var(--n-50);
  --bg-alt:    var(--n-100);
  --surface:   var(--n-0);
  --surface-2: var(--n-50);
  --border:    var(--n-150);
  --border-fuerte: var(--n-200);
  --text:      var(--n-900);
  --text-soft: var(--n-600);
  --text-mute: var(--n-400);
  --accent:    var(--a-600);
  --accent-soft: var(--a-50);

  --r-sm: 9px;
  --r:    13px;
  --r-lg: 18px;
  --r-xl: 26px;

  /* Sombras contenidas: la profundidad la da el borde, no el humo. */
  --s-1: 0 1px 2px rgba(20,26,33,.04);
  --s-2: 0 1px 3px rgba(20,26,33,.06), 0 1px 2px rgba(20,26,33,.04);
  --s-3: 0 4px 12px -2px rgba(20,26,33,.08), 0 2px 6px -2px rgba(20,26,33,.05);
  --s-4: 0 18px 40px -12px rgba(20,26,33,.18), 0 4px 12px -4px rgba(20,26,33,.08);

  --sans: "Segoe UI Variable Display", "Segoe UI", Inter, system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --paso: 180ms cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0a0e13;
    --bg-alt:    #0f141b;
    --surface:   #121820;
    --surface-2: #171f29;
    --border:    #212b38;
    --border-fuerte: #2c3846;
    --text:      #e9eef5;
    --text-soft: #a3b0c0;
    --text-mute: #6f7e91;
    --accent:    var(--a-300);
    --accent-soft: rgba(59,181,130,.12);
    --ok: #4ade80; --warn: #fbbf24; --bad: #fb7185; --info: #60a5fa; --grape: #a78bfa;
    --s-1: 0 1px 2px rgba(0,0,0,.5);
    --s-2: 0 1px 3px rgba(0,0,0,.55);
    --s-3: 0 6px 16px -4px rgba(0,0,0,.6);
    --s-4: 0 24px 50px -16px rgba(0,0,0,.75);
  }
}

* { box-sizing: border-box; }
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  letter-spacing: -0.006em; -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 640; letter-spacing: -0.022em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: .95rem; }
p  { margin: 0; }

/* iconos de trazo, heredan el color del texto */
.i { width: 18px; height: 18px; flex: none; stroke-width: 1.75; }

/* ---------------------------------------------------------------- layout */

.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.app > * { min-width: 0; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: thin;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(145deg, var(--a-400), var(--a-700));
  display: grid; place-items: center; color: #fff;
  font-weight: 750; font-size: .95rem; letter-spacing: -.04em;
  box-shadow: 0 2px 8px -2px rgba(16,99,69,.5), inset 0 1px 0 rgba(255,255,255,.22);
}
.brand-name { font-weight: 680; font-size: 1.04rem; letter-spacing: -.025em; }
.brand-sub  { font-size: .7rem; color: var(--text-mute); margin-top: -2px; letter-spacing: 0; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .085em;
  color: var(--text-mute); font-weight: 680; padding: 14px 10px 5px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--text-soft); font-weight: 500; font-size: .875rem;
  text-decoration: none; transition: background var(--paso), color var(--paso);
}
.nav a .i { color: var(--text-mute); transition: color var(--paso); }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a:hover .i { color: var(--text-soft); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 620; }
.nav a.active .i { color: var(--accent); }

.who {
  margin-top: auto; padding: 11px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem;
}
.who-name { font-weight: 620; overflow: hidden; text-overflow: ellipsis; }
.who-role { color: var(--text-mute); font-size: .72rem; }
.who .btn { margin-top: 9px; }

.main { padding: 24px 30px 72px; max-width: 1280px; width: 100%; min-width: 0; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 20px; max-width: 100%;
}
.page-head .sub { color: var(--text-soft); font-size: .875rem; margin-top: 2px; }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--s-1); min-width: 0;
  transition: box-shadow var(--paso), border-color var(--paso);
}
a.card:hover { box-shadow: var(--s-3); border-color: var(--border-fuerte); text-decoration: none; }
.card-pad { padding: 17px 19px; }
.card-head {
  padding: 14px 19px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(min(174px, 100%), 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 15px 16px; box-shadow: var(--s-1);
  position: relative; overflow: hidden; min-width: 0;
}
.stat::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 2px;
  background: var(--acento, var(--accent)); opacity: .85;
}
.stat-label {
  font-size: .71rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-mute); font-weight: 660;
}
.stat-value {
  font-size: 1.7rem; font-weight: 660; letter-spacing: -.035em; margin-top: 3px;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.stat-foot { font-size: .755rem; color: var(--text-soft); margin-top: 2px; }

/* --------------------------------------------------------------- píldoras */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 620; white-space: nowrap;
  background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border);
}
.pill-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.ok    { background: color-mix(in srgb, var(--ok) 10%, transparent);    color: var(--ok);    border-color: color-mix(in srgb, var(--ok) 26%, transparent); }
.pill.warn  { background: color-mix(in srgb, var(--warn) 12%, transparent);  color: var(--warn);  border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.pill.bad   { background: color-mix(in srgb, var(--bad) 10%, transparent);   color: var(--bad);   border-color: color-mix(in srgb, var(--bad) 26%, transparent); }
.pill.info  { background: color-mix(in srgb, var(--info) 10%, transparent);  color: var(--info);  border-color: color-mix(in srgb, var(--info) 26%, transparent); }
.pill.grape { background: color-mix(in srgb, var(--grape) 10%, transparent); color: var(--grape); border-color: color-mix(in srgb, var(--grape) 26%, transparent); }

/* --------------------------------------------------------------- tablas */

.table-wrap { overflow-x: auto; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
thead th {
  text-align: left; font-size: .69rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-mute); font-weight: 680; background: var(--surface-2);
  padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--paso); }
tbody tr:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .83em; }

/* ------------------------------------------------------------- controles */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: var(--accent); color: #fff;
  font: inherit; font-size: .865rem; font-weight: 590; cursor: pointer;
  transition: background var(--paso), transform 80ms, box-shadow var(--paso), opacity var(--paso);
  white-space: nowrap; box-shadow: var(--s-1);
}
.btn:hover  { background: var(--a-700); box-shadow: var(--s-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--text-soft); border-color: var(--border-fuerte); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 85%, black); }
.btn.sm { padding: 5px 10px; font-size: .79rem; gap: 5px; }
.btn.sm .i { width: 15px; height: 15px; }
.btn.block { width: 100%; }
.btn.grande { padding: 12px 24px; font-size: .94rem; border-radius: 11px; }

@media (prefers-color-scheme: dark) {
  .btn { color: var(--n-950); }
  .btn:hover { background: var(--a-200); }
  .btn.ghost { color: var(--text-soft); }
  .btn.danger { color: #fff; }
}

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field label { font-size: .79rem; font-weight: 600; color: var(--text-soft); }
.field .hint { font-size: .73rem; color: var(--text-mute); }
input, select, textarea {
  font: inherit; font-size: .875rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-fuerte);
  border-radius: var(--r-sm); padding: 8px 11px; width: 100%;
  transition: border-color var(--paso), box-shadow var(--paso);
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.field input[type="checkbox"] { width: auto; margin-right: 7px; vertical-align: middle; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .row-2 { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- avisos */

.alert {
  padding: 10px 13px; border-radius: var(--r-sm);
  font-size: .855rem; margin-bottom: 13px; border: 1px solid;
  display: flex; gap: 9px; align-items: flex-start; line-height: 1.5;
}
.alert.err  { background: color-mix(in srgb, var(--bad) 7%, var(--surface));  color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 24%, transparent); }
.alert.ok   { background: color-mix(in srgb, var(--ok) 8%, var(--surface));   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 24%, transparent); }
.alert.info { background: color-mix(in srgb, var(--info) 7%, var(--surface)); color: var(--info); border-color: color-mix(in srgb, var(--info) 24%, transparent); }

.empty { padding: 44px 20px; text-align: center; color: var(--text-mute); }
.empty .i { width: 34px; height: 34px; opacity: .4; margin-bottom: 8px; stroke-width: 1.4; }

/* --------------------------------------------------------------- medidor */

.meter { height: 7px; border-radius: 999px; background: var(--bg-alt); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .55s cubic-bezier(.4,0,.2,1); }
.meter.is-ok  > span { background: var(--ok); }
.meter.is-bad > span { background: var(--bad); }
.quorum-num { font-size: 2.2rem; font-weight: 660; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------- puerta / ingreso */

.puerta {
  min-height: 100vh; display: flex; flex-direction: column;
  background:
    radial-gradient(1100px 560px at 6% -14%, color-mix(in srgb, var(--a-400) 16%, transparent), transparent 60%),
    radial-gradient(820px 480px at 98% 4%, color-mix(in srgb, var(--info) 10%, transparent), transparent 58%),
    var(--bg);
}
.puerta > * { width: 100%; min-width: 0; max-width: 100%; }
.puerta-nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 26px; max-width: 1120px; margin: 0 auto; }
.puerta-nav .brand { padding: 0; }

.hero { max-width: 780px; margin: 0 auto; padding: 56px 24px 30px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 5.6vw, 3.25rem); line-height: 1.06; letter-spacing: -.04em; font-weight: 690; overflow-wrap: anywhere; }
.hero-sub { margin: 18px auto 0; max-width: 600px; font-size: 1.02rem; color: var(--text-soft); line-height: 1.62; }
.hero-cta { display: flex; gap: 11px; justify-content: center; flex-wrap: wrap; margin: 28px 0 10px; }

.tarjetas {
  max-width: 1120px; margin: 0 auto; padding: 14px 24px 56px;
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(272px, 100%), 1fr));
}
.tarjeta {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 19px; box-shadow: var(--s-1);
  transition: transform var(--paso), box-shadow var(--paso), border-color var(--paso);
}
.tarjeta:hover { transform: translateY(-2px); box-shadow: var(--s-3); border-color: var(--border-fuerte); }
.tarjeta-ico {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 11px;
}
.tarjeta-ico .i { width: 20px; height: 20px; }
.tarjeta h3 { margin-bottom: 5px; }
.tarjeta p { font-size: .865rem; color: var(--text-soft); line-height: 1.55; }
.puerta-pie { margin-top: auto; padding: 20px 24px; text-align: center; font-size: .78rem; color: var(--text-mute); border-top: 1px solid var(--border); }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 22px;
  background: radial-gradient(900px 460px at 14% -12%, color-mix(in srgb, var(--a-400) 14%, transparent), transparent 60%), var(--bg);
}
.login-card {
  width: 100%; max-width: 396px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 30px 28px; box-shadow: var(--s-4);
}
.login-card .brand { justify-content: center; margin-bottom: 6px; padding: 0; }
.login-title { text-align: center; margin-bottom: 2px; font-size: 1.4rem; }
.login-sub { text-align: center; color: var(--text-soft); font-size: .855rem; margin-bottom: 20px; }
.login-foot { text-align: center; margin-top: 16px; font-size: .78rem; color: var(--text-mute); }

.pestanas { display: flex; gap: 3px; padding: 3px; margin-bottom: 17px; background: var(--bg-alt); border-radius: 10px; }
.pestana {
  flex: 1; padding: 7px 10px; border: 0; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: .84rem; font-weight: 580; background: transparent; color: var(--text-soft);
  transition: background var(--paso), color var(--paso);
}
.pestana.activa { background: var(--surface); color: var(--text); box-shadow: var(--s-1); }

/* --------------------------------------------------------- barra de demo */

.demo-bar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 8px 18px; font-size: .82rem;
  background: color-mix(in srgb, var(--grape) 10%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--grape) 26%, transparent);
  position: sticky; top: 0; z-index: 30;
}
.demo-bar strong { color: var(--grape); }
.demo-bar span { color: var(--text-soft); }
.demo-bar a { margin-left: auto; font-weight: 620; }

/* ============================ PLANO DEL CONJUNTO ======================== */

.plano-wrap {
  position: relative; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--s-1);
}
.plano {
  display: block; width: 100%; height: min(60vh, 560px);
  touch-action: none; cursor: grab; background: var(--bg-alt);
}
@media (max-width: 900px) { .plano { height: min(52vh, 420px); } }
.plano.arrastrando { cursor: grabbing; }
.plano-suelo { fill: var(--bg-alt); }
.plano-verde { fill: color-mix(in srgb, var(--a-400) 13%, transparent); }
.plano-via   { fill: none; stroke: var(--border-fuerte); stroke-width: 7; stroke-linecap: round; opacity: .85; }
.plano-rejilla { stroke: var(--border); stroke-width: .5; opacity: .5; }

.pin { cursor: pointer; transition: opacity var(--paso); }
.pin-cuerpo { stroke: var(--surface); stroke-width: 1.5; }
.pin-eco { transform-origin: center; transform-box: fill-box; }
.pin.urgente .pin-eco { animation: latir 2.1s ease-out infinite; }
@keyframes latir {
  0%   { r: 6;  opacity: .55; }
  70%  { r: 20; opacity: 0; }
  100% { r: 20; opacity: 0; }
}
.pin-etiqueta {
  font-family: var(--sans); font-size: 7px; font-weight: 640;
  fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 2.5;
}
.pin:hover .pin-cuerpo { stroke-width: 2.5; }
.pin-unidad   { fill: var(--info); }
.pin-mora     { fill: var(--bad); }
.pin-zona     { fill: var(--grape); }
.pin-dano     { fill: var(--warn); }
.pin-ayuda    { fill: var(--ok); }
.pin-fantasma { fill: var(--text-mute); opacity: .45; }

.plano-barra {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.plano-leyenda { display: flex; gap: 12px; flex-wrap: wrap; font-size: .74rem; color: var(--text-soft); }
.plano-leyenda span { display: inline-flex; align-items: center; gap: 5px; }
.plano-leyenda i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.plano-detalle {
  position: absolute; right: 10px; bottom: 10px; width: min(280px, calc(100% - 20px));
  background: var(--surface); border: 1px solid var(--border-fuerte);
  border-radius: var(--r); box-shadow: var(--s-4); padding: 13px 15px;
  animation: subir .2s cubic-bezier(.4,0,.2,1);
}
.chip {
  border: 1px solid var(--border-fuerte); background: var(--surface);
  color: var(--text-soft); border-radius: 999px; padding: 4px 10px;
  font-size: .76rem; font-weight: 570; cursor: pointer; transition: all var(--paso);
}
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ------------------------------------------------------ subida de archivos */

.soltar {
  border: 1.5px dashed var(--border-fuerte); border-radius: var(--r);
  padding: 18px; text-align: center; cursor: pointer;
  background: var(--surface-2); transition: all var(--paso); color: var(--text-soft);
}
.soltar:hover, .soltar.encima { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.soltar .i { width: 26px; height: 26px; opacity: .7; margin-bottom: 5px; }
.soltar-nombre { font-size: .8rem; font-weight: 580; }
.previa {
  margin-top: 10px; border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--border); position: relative; background: var(--bg-alt);
}
.previa img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.previa-pie {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  font-size: .76rem; color: var(--text-soft); background: var(--surface);
}
.barra-subida { height: 3px; background: var(--bg-alt); border-radius: 999px; overflow: hidden; margin-top: 7px; }
.barra-subida > span { display: block; height: 100%; background: var(--accent); transition: width .2s linear; }

/* --------------------------------------------------------------- voz */

.voz-btn { position: relative; }
.voz-btn.escuchando { background: var(--bad); }
.voz-btn.escuchando::after {
  content: ""; position: absolute; inset: -4px; border-radius: inherit;
  border: 2px solid var(--bad); animation: latir-voz 1.3s ease-out infinite;
}
@keyframes latir-voz { 0% { opacity: .8; transform: scale(1) } 100% { opacity: 0; transform: scale(1.35) } }
.voz-panel {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border-fuerte);
  border-radius: var(--r-lg); box-shadow: var(--s-4); padding: 14px 18px;
  z-index: 80; max-width: min(460px, calc(100vw - 28px)); text-align: center;
}
.voz-onda { display: flex; gap: 3px; justify-content: center; align-items: flex-end; height: 22px; margin-bottom: 8px; }
.voz-onda i { width: 3px; background: var(--accent); border-radius: 2px; animation: onda 1s ease-in-out infinite; }
.voz-onda i:nth-child(2){animation-delay:.1s} .voz-onda i:nth-child(3){animation-delay:.2s}
.voz-onda i:nth-child(4){animation-delay:.3s} .voz-onda i:nth-child(5){animation-delay:.4s}
@keyframes onda { 0%,100% { height: 5px } 50% { height: 20px } }

/* ---------------------------------------------------------------- varios */

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.stack { display: flex; flex-direction: column; gap: 13px; }
.stack > * { min-width: 0; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-mute); }
.soft  { color: var(--text-soft); }
.tiny  { font-size: .765rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.modal-back {
  position: fixed; inset: 0; background: rgba(8,12,17,.5);
  display: grid; place-items: center; padding: 20px; z-index: 60;
  backdrop-filter: blur(4px); animation: aparecer .16s ease;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--s-4);
  width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto;
  animation: subir .2s cubic-bezier(.4,0,.2,1);
}
.modal .card-head { position: sticky; top: 0; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; z-index: 1; }
@keyframes aparecer { from { opacity: 0 } to { opacity: 1 } }
@keyframes subir { from { opacity: 0; transform: translateY(12px) scale(.99) } to { opacity: 1; transform: none } }

.spinner {
  width: 16px; height: 16px; border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: currentColor; border-radius: 50%;
  animation: girar .7s linear infinite; display: inline-block;
}
@keyframes girar { to { transform: rotate(360deg) } }
.loading { padding: 44px; text-align: center; color: var(--text-mute); }

.toast-box {
  position: fixed; right: 16px; bottom: 16px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(400px, calc(100vw - 32px));
}
.toast { margin: 0; box-shadow: var(--s-4); background: var(--surface); animation: entrar .22s cubic-bezier(.4,0,.2,1); }
.toast.ok  { background: color-mix(in srgb, var(--ok) 9%, var(--surface)); }
.toast.err { background: color-mix(in srgb, var(--bad) 9%, var(--surface)); }
@keyframes entrar { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }

.gate-input { font-size: 1.4rem; font-family: var(--mono); text-align: center; letter-spacing: .12em; padding: 14px; }

.vote-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.vote-btn {
  padding: 15px 8px; border-radius: var(--r); border: 1.5px solid var(--border-fuerte);
  background: var(--surface); cursor: pointer; font: inherit; font-weight: 640;
  font-size: .92rem; transition: all var(--paso); color: var(--text);
}
.vote-btn:hover { transform: translateY(-2px); box-shadow: var(--s-3); }
.vote-btn.si  { border-color: color-mix(in srgb, var(--ok) 42%, transparent);  color: var(--ok); }
.vote-btn.no  { border-color: color-mix(in srgb, var(--bad) 42%, transparent); color: var(--bad); }
.vote-btn.si:hover  { background: color-mix(in srgb, var(--ok) 9%, transparent); }
.vote-btn.no:hover  { background: color-mix(in srgb, var(--bad) 9%, transparent); }
.vote-btn.abs:hover { background: var(--surface-2); }

.topbar-mobile { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; width: 252px;
    transform: translateX(-100%); transition: transform .24s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--s-4);
  }
  .sidebar.open { transform: none; }
  .topbar-mobile {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-bottom: 1px solid var(--border);
    background: var(--surface); position: sticky; top: 0; z-index: 45;
  }
  .demo-bar { top: 45px; z-index: 44; }
  .main { padding: 16px 14px 72px; }
  .grid-stats { grid-template-columns: repeat(auto-fit, minmax(min(146px, 100%), 1fr)); }
  :where(.btn, .card, .page-head, .stat, h1, h2, .table-wrap) { scroll-margin-top: 92px; }
  .page-head { position: relative; z-index: 1; }
  .hero { padding: 34px 20px 22px; }
  .puerta-nav { padding: 14px 18px; }
  .plano-detalle { right: 8px; left: 8px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===================== MAPA REAL (Leaflet + OpenStreetMap) ================ */

.mapa { width: 100%; height: min(62vh, 580px); background: var(--bg-alt); }
.mapa.ubicando { cursor: crosshair; }
@media (max-width: 900px) { .mapa { height: min(54vh, 440px); } }

/* Marcadores propios: un punto con anillo, y un eco que late si está abierto. */
.mk {
  display: block; width: 14px; height: 14px; border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35);
  position: relative;
}
.mk-casa  { background: var(--info); }
.mk-mora  { background: var(--bad); }
.mk-zona  { background: var(--grape); }
.mk-dano  { background: var(--warn); }
.mk-ayuda { background: var(--ok); }
.mk.urgente::after {
  content: ""; position: absolute; inset: -2.5px; border-radius: 50%;
  background: inherit; opacity: .5; animation: eco 2.1s ease-out infinite;
}
@keyframes eco {
  0%   { transform: scale(1);   opacity: .5; }
  70%  { transform: scale(3.4); opacity: 0; }
  100% { transform: scale(3.4); opacity: 0; }
}
.mk-txt {
  position: absolute; left: 50%; top: -18px; transform: translateX(-50%);
  font-size: 10px; font-weight: 660; white-space: nowrap; color: var(--n-900);
  paint-order: stroke; text-shadow:
    0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
  pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  .mk-txt { color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 4px #000; }
}

/* Leaflet trae su propio look; se alinea con el sistema de diseño. */
.leaflet-container { font: inherit; background: var(--bg-alt); }
.leaflet-popup-content-wrapper {
  border-radius: var(--r); box-shadow: var(--s-4);
  background: var(--surface); color: var(--text);
}
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 11px 13px; font-size: .84rem; }
.pop-pills { margin: 5px 0 3px; }
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 88%, transparent) !important;
  color: var(--text-mute); font-size: .66rem;
}
.leaflet-control-attribution a { color: var(--text-soft); }
.leaflet-bar a {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.leaflet-bar a:hover { background: var(--surface-2); }
@media (prefers-color-scheme: dark) {
  /* Las teselas claras se atenúan para que no deslumbren en modo oscuro. */
  .leaflet-tile-pane { filter: brightness(.72) contrast(1.08) saturate(.9); }
}

/* Las etiquetas de casa solo se muestran con zoom suficiente: si no, se
   solapan entre sí y estorban más de lo que informan. */
.mk-txt { display: none; }
.mapa.con-textos .mk-txt { display: block; }

/* En pantalla estrecha las etiquetas se solapan aunque el zoom sea alto: ahí
   el nombre se consulta tocando el punto, que además es el gesto natural. */
@media (max-width: 900px) { .mapa.con-textos .mk-txt { display: none; } }
