/* ============================================================
   MiMuni · Tema por tokens con modo claro (default) y oscuro.
   El branding de la DB sobreescribe los tokens del tema oscuro
   (y opcionalmente los del claro) vía branding.js.
   Mobile-first, max 420px.
   ============================================================ */

/* ---------- TEMA CLARO (por defecto) ---------- */
:root {
  --bg: #eef3f9;
  --bg-tint: rgba(2, 132, 199, .07);
  --grid-line: rgba(2, 132, 199, .055);
  --surface: rgba(255, 255, 255, .82);
  --surface-high: #ffffff;
  --glass-strong: rgba(255, 255, 255, .78);
  --bar-bg: rgba(255, 255, 255, .92);
  --primary: #0284c7;
  --primary-soft: #0369a1;
  --secondary: #0d9488;
  --text: #16233b;
  --muted: #5b6b83;
  --heading: #0f1c33;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b3261e;
  --outline: rgba(2, 132, 199, .30);
  --outline-dim: rgba(2, 132, 199, .14);
  --glow: 0 4px 18px rgba(15, 40, 80, .10);
  --glow-strong: 0 6px 24px rgba(2, 132, 199, .22);
  --h-shadow: none;
  --btn-a: #0ea5e9;
  --btn-b: #0d9488;
  --btn-fg: #ffffff;
  --btn-glow: 0 4px 16px rgba(2, 132, 199, .35);
  --card-inset: inset 0 1px 0 rgba(255, 255, 255, .9);
  --radius-sm: 4px;
  --radius-md: 12px;
  --radius-xl: 24px;
  --font: 'Montserrat', system-ui, sans-serif;
}

/* ---------- TEMA OSCURO (Cyber-Municipal) ---------- */
html[data-theme="dark"] {
  --bg: #000000;
  --bg-tint: rgba(56, 189, 248, .12);
  --grid-line: rgba(56, 189, 248, .09);      /* grid más visible en oscuro */
  --surface: rgba(13, 18, 31, .85);
  --surface-high: #161b29;
  --glass-strong: rgba(13, 18, 31, .72);
  --bar-bg: rgba(13, 18, 31, .95);
  --primary: #38bdf8;
  --primary-soft: #8ed5ff;
  --secondary: #44e2cd;
  --text: #dee2f5;
  --muted: #9aa5b8;
  --heading: #ffffff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #ffb4ab;
  --outline: rgba(56, 189, 248, .35);
  --outline-dim: rgba(56, 189, 248, .16);
  --glow: 0 0 15px rgba(56, 189, 248, .25);
  --glow-strong: 0 0 22px rgba(56, 189, 248, .4);
  --h-shadow: 0 0 14px rgba(56, 189, 248, .45);
  --btn-a: #8ed5ff;
  --btn-b: #38bdf8;
  --btn-fg: #001018;
  --btn-glow: 0 0 18px rgba(56, 189, 248, .45);
  --card-inset: inset 0 1px 0 rgba(255, 255, 255, .05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px; font-weight: 500; line-height: 1.55;
  min-height: 100dvh;
  background-image:
    radial-gradient(600px 300px at 50% -5%, var(--bg-tint), transparent 70%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
  transition: background-color .3s ease, color .3s ease;
}

#app {
  max-width: 420px;
  margin: 0 auto;
  padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
@media (min-width: 480px) {
  #app { border-inline: 1px solid var(--outline-dim); }
}

/* ---------- tipografía ---------- */
h1 { font-size: 24px; font-weight: 900; letter-spacing: 2px; text-transform: uppercase;
     color: var(--heading); text-shadow: var(--h-shadow); }
h2 { font-size: 17px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--heading); }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--secondary); }
.muted { color: var(--muted); font-size: 13.5px; }
a { color: var(--primary); text-decoration: underline; }

/* ---------- boot ---------- */
.boot { display: grid; place-items: center; gap: 8px; min-height: 70dvh; text-align: center; color: var(--muted); }
.boot-logo { font-size: 32px; font-weight: 900; letter-spacing: 4px; text-transform: uppercase;
             color: var(--primary); text-shadow: var(--h-shadow); }

/* ---------- iconos (Phosphor) ---------- */
.ph, .ph-fill { font-size: 20px; line-height: 1; vertical-align: -3px; }

/* ---------- cards glass ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--glow), var(--card-inset);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  margin-bottom: 14px;
}
.card h2 { margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- botones ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 12px 18px;
  font: inherit; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; font-size: 14px;
  color: var(--btn-fg);
  background: linear-gradient(180deg, var(--btn-a), var(--btn-b));
  border: none; border-radius: var(--radius-md);
  box-shadow: var(--btn-glow);
  cursor: pointer;
  transition: transform 150ms, box-shadow 150ms, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn.secondary {
  background: var(--surface-high); color: var(--primary);
  border: 1px solid var(--outline); box-shadow: none;
}
.btn.small { width: auto; min-height: 44px; font-size: 12.5px; padding: 8px 14px; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .tab:focus-visible, .widget:focus-visible {
  outline: 2px solid var(--secondary); outline-offset: 2px;
}
.btn[aria-busy="true"] { opacity: .7; pointer-events: none; }

/* ---------- formularios ---------- */
label { display: block; font-size: 12.5px; font-weight: 700; letter-spacing: 1px;
        text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  font: inherit; color: var(--text);
  background: var(--surface-high);
  border: 1px solid var(--outline); border-radius: var(--radius-md);
}
.field { margin-bottom: 14px; }
.field .error { display: none; margin-top: 6px; font-size: 13px; color: var(--danger); font-weight: 600; }
.field.invalid input { border-color: var(--danger); border-width: 2px; }
.field.invalid .error { display: block; }
.field.invalid .error::before { content: "⚠ "; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ---------- header ---------- */
.appbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.appbar img { width: 40px; height: 40px; border-radius: 10px; }
.appbar .who { flex: 1; min-width: 0; }
.appbar .who .name { font-weight: 800; }
.iconbtn {
  width: 48px; height: 48px; display: grid; place-items: center;
  background: var(--surface-high); color: var(--primary);
  border: 1px solid var(--outline); border-radius: var(--radius-md);
  font-size: 20px; cursor: pointer; position: relative; text-decoration: none;
  transition: transform .15s, border-color .15s;
}
.iconbtn:active { transform: scale(.9); }
.iconbtn .dot { position: absolute; top: 8px; right: 8px; width: 10px; height: 10px;
                border-radius: 50%; background: var(--warn); }

/* ---------- stats / nivel ---------- */
.level-ring { display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%;
              border: 3px solid var(--primary); box-shadow: var(--glow-strong); flex-shrink: 0;
              font-size: 32px; font-weight: 900; color: var(--primary); font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 9999px; background: var(--surface-high);
       border: 1px solid var(--outline); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit;
              background: linear-gradient(90deg, var(--secondary), var(--primary));
              transition: width .6s cubic-bezier(.2,.9,.3,1); }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface-high); border: 1px solid var(--outline);
        border-radius: var(--radius-md); padding: 14px 12px; text-align: center; }
.stat .n { font-size: 34px; font-weight: 900; color: var(--primary); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }

/* ---------- pills / badges ---------- */
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 5px;
        font-size: 11px; font-weight: 700; letter-spacing: 1px; line-height: 1;
        text-transform: uppercase; border-radius: 9999px; padding: 6px 12px;
        border: 1px solid var(--outline); color: var(--primary); background: var(--outline-dim); }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 9%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 9%, transparent); }
.pill.pc { color: #ffffff; background: linear-gradient(180deg, var(--secondary), color-mix(in srgb, var(--secondary) 75%, black)); border: none; font-weight: 800; }
html[data-theme="dark"] .pill.pc { color: #001018; background: linear-gradient(180deg, #44e2cd, #2bbfae); }

/* ---------- listas ---------- */
.list-item { display: flex; gap: 12px; align-items: center; padding: 14px 4px;
             border-bottom: 1px solid var(--outline-dim); transition: background .15s; }
.list-item:last-child { border-bottom: none; }
.list-item.unread { background: var(--outline-dim); border-radius: var(--radius-md); padding-inline: 10px; }

/* ---------- estados vacíos ---------- */
.empty { text-align: center; padding: 28px 12px; display: grid; gap: 10px; justify-items: center; }
.empty .art { font-size: 40px; }

/* ---------- avatar ---------- */
.avatar-stage { display: grid; place-items: center; padding: 18px; }
.avatar-fig { width: 120px; height: 160px; border-radius: var(--radius-xl);
              border: 2px dashed var(--outline); display: grid; place-items: center;
              color: var(--muted); }

/* Escenario paper-doll: capas apiladas sobre el cuerpo base (1024x1536, 2:3) */
.avatar-stage-fig { position: relative; aspect-ratio: 2 / 3; width: min(230px, 58vw); }
.avatar-stage-fig::before {   /* pedestal de luz bajo el personaje */
  content: ''; position: absolute; left: 50%; bottom: -6px;
  width: 78%; height: 12%; transform: translateX(-50%);
  background: radial-gradient(ellipse at center,
    color-mix(in srgb, var(--primary) 38%, transparent), transparent 70%);
  filter: blur(2px); pointer-events: none;
}
.avatar-layer { position: absolute; inset: 0; width: 100%; height: 100%;
                object-fit: contain; transition: opacity .15s; }
@media (prefers-reduced-motion: reduce) { .avatar-layer { transition: none; } }

/* Barra de confirmación de preview (aparece cuando lo previsualizado ≠ equipado) */
.avatar-confirm { display: flex; gap: 8px; align-items: center; justify-content: center;
                  margin-top: 10px; flex-wrap: wrap; }
.avatar-confirm .btn[disabled] { opacity: .5; cursor: not-allowed; }

.item .thumb img { width: 44px; height: 44px; object-fit: contain; display: block; }
.item.previewing { border-color: var(--primary);
                   box-shadow: 0 0 12px color-mix(in srgb, var(--primary) 40%, transparent); }
.itemgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.item { display: flex; flex-direction: column; align-items: center; gap: 6px;
        padding: 10px 6px; text-align: center;
        background: var(--surface-high); border: 1px solid var(--outline);
        border-radius: var(--radius-md); cursor: pointer; min-height: 96px;
        font: inherit; color: var(--text);
        transition: transform .15s, border-color .15s, box-shadow .15s; }
.item:active { transform: scale(.94); }
.item .thumb { font-size: 26px; color: var(--primary); }
.item .nm { font-size: 11.5px; font-weight: 600; color: var(--text); }
.item .pill { margin-top: auto; }   /* ancla el estado al borde inferior */
.item.locked { opacity: .55; }
.item.equipped { border-color: var(--ok); box-shadow: 0 0 12px color-mix(in srgb, var(--ok) 40%, transparent); }

/* ---------- widgets de sistema: Puntos Cívicos + Nivel ---------- */
.wrow { display: flex; gap: 10px; margin-bottom: 14px; }
.widget {
  flex: 1; min-width: 0; min-height: 64px;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--outline);
  border-radius: 9999px; text-decoration: none; color: var(--text);
  box-shadow: var(--glow), var(--card-inset);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  position: relative; cursor: pointer;
  transition: transform .18s cubic-bezier(.2,1.2,.3,1), box-shadow .2s, border-color .2s;
}
.w-pc { overflow: hidden; }        /* recorta el barrido de brillo */
.w-level { overflow: visible; }    /* deja respirar el glow del anillo */
.widget:hover { transform: translateY(-2px); box-shadow: var(--glow-strong), var(--card-inset); }
.widget:active { transform: scale(.96); }
.widget .w-num { font-size: 22px; font-weight: 900; color: var(--primary);
                 font-variant-numeric: tabular-nums; line-height: 1.05; display: block; }
.widget .w-label { font-size: 9.5px; font-weight: 700; letter-spacing: 1.2px;
                   text-transform: uppercase; color: var(--muted); display: block; white-space: nowrap; }
/* el nombre del rango sí envuelve: si no, se sale de la píldora */
.widget .w-rank { color: var(--secondary); white-space: normal; line-height: 1.25;
                  letter-spacing: .8px; overflow-wrap: anywhere; }
.widget .w-body { min-width: 0; }
/* PC: moneda con brillo que barre (still animation) */
.w-pc .w-ic { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
              display: grid; place-items: center; font-size: 22px; color: #fff;
              background: linear-gradient(160deg, var(--secondary), color-mix(in srgb, var(--secondary) 65%, black));
              box-shadow: 0 0 12px color-mix(in srgb, var(--secondary) 45%, transparent);
              animation: coin-tilt 5s ease-in-out infinite; }
html[data-theme="dark"] .w-pc .w-ic { color: #001018; }
.w-pc::after { content: ''; position: absolute; inset: 0;
               background: linear-gradient(115deg, transparent 42%, rgba(255,255,255,.35) 50%, transparent 58%);
               transform: translateX(-120%); animation: shine-sweep 4.5s ease-in-out infinite; pointer-events: none; }
@keyframes shine-sweep { 0%, 68% { transform: translateX(-120%); } 88%, 100% { transform: translateX(120%); } }
@keyframes coin-tilt { 0%, 86%, 100% { transform: rotate(0); } 90% { transform: rotate(-10deg); } 94% { transform: rotate(8deg); } 98% { transform: rotate(-4deg); } }
/* Nivel: anillo de progreso con pulso */
.w-level .w-ring { position: relative; width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; }
/* inset negativo + viewBox con margen: el glow del trazo cabe completo */
.w-level .w-ring svg { position: absolute; inset: -5px; overflow: visible; transform: rotate(-90deg); }
.w-level .w-ring circle { fill: none; stroke-width: 3.4; stroke-linecap: round; }
.w-level .w-ring .rg-bg { stroke: var(--outline-dim); }
.w-level .w-ring .rg-fg { stroke: var(--primary); stroke-dasharray: 0 100;
                          transition: stroke-dasharray .9s cubic-bezier(.2,.9,.3,1);
                          filter: drop-shadow(0 0 5px color-mix(in srgb, var(--primary) 75%, transparent)); }
.w-level .w-ring .w-num { font-size: 15px; }
.w-level .w-ring::after { content: ''; position: absolute; inset: -3px; border-radius: 50%;
                          border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
                          animation: ring-pulse 3s ease-out infinite; }
@keyframes ring-pulse { 0% { transform: scale(.9); opacity: .8; } 70%, 100% { transform: scale(1.18); opacity: 0; } }

/* ---------- tabbar con indicador deslizante ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 420px;
  display: grid; grid-template-columns: repeat(var(--tab-count, 5), 1fr);
  background: var(--bar-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--outline);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tab-indicator {
  position: absolute; top: 6px; left: 6px;
  width: calc((100% - 12px) / var(--tab-count, 5)); height: 56px;
  border-radius: var(--radius-md);
  background: var(--outline-dim);
  border: 1px solid var(--outline);
  box-shadow: var(--glow);
  transform: translateX(calc(var(--tab-i, 0) * 100%));
  transition: transform .38s cubic-bezier(.3, 1.25, .35, 1);
  pointer-events: none;
}
.tab {
  position: relative; z-index: 1;
  display: grid; gap: 2px; justify-items: center; padding: 8px 4px; min-height: 56px;
  color: var(--muted); text-decoration: none; border-radius: var(--radius-md);
  font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  transition: color .25s;
}
.tab .ic { transition: transform .3s cubic-bezier(.2,1.4,.3,1); }
.tab.active { color: var(--primary); }
.tab.active .ic { transform: translateY(-2px) scale(1.12); }
.tab:active .ic { transform: scale(.82); }
.tab.pop .ic { animation: tab-bounce .5s cubic-bezier(.2,1.6,.3,1); }
@keyframes tab-bounce {
  0% { transform: scale(.7); }
  45% { transform: translateY(-5px) scale(1.28); }
  100% { transform: translateY(-2px) scale(1.12); }
}

/* ---------- toasts: píldora glass iluminada ---------- */
.toasts { position: fixed; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%;
          transform: translateX(-50%); width: min(92vw, 400px);
          display: grid; gap: 8px; z-index: 50; justify-items: center; pointer-events: none; }
.toast {
  --tone: var(--primary);
  display: flex; align-items: center; gap: 10px;
  max-width: 100%; padding: 12px 20px;
  font-size: 14px; font-weight: 600; color: var(--text);
  background: color-mix(in srgb, var(--tone) 14%, var(--glass-strong));
  border: 1px solid color-mix(in srgb, var(--tone) 55%, transparent);
  border-radius: 9999px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 0 18px color-mix(in srgb, var(--tone) 40%, transparent);
  animation: toast-in .28s cubic-bezier(.2,.9,.3,1.2) both;
}
.toast .ph, .toast .ph-fill { color: var(--tone); font-size: 18px; flex-shrink: 0; }
.toast.ok    { --tone: var(--ok); }
.toast.warn  { --tone: var(--warn); }
.toast.error { --tone: var(--danger); }
.toast.pc    { --tone: var(--secondary); }
.toast.hide  { animation: toast-out .22s ease-in both; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(14px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.95); } }

/* ---------- celebraciones (oscuras en ambos temas: momento cine) ---------- */
.celebrate {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: rgba(0, 0, 6, .88);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: cel-in .25s ease-out both;
}
.celebrate.hide { animation: cel-out .35s ease-in both; }
.celebrate .cel-inner { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 0 20px; }
.celebrate .cel-num {
  font-size: clamp(72px, 26vw, 120px); font-weight: 900; line-height: 1;
  color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px #44e2cd, 0 0 90px #38bdf8;
  animation: cel-pop .5s cubic-bezier(.2,1.4,.3,1) both;
}
.celebrate .cel-label {
  font-size: 15px; font-weight: 800; letter-spacing: 3px; text-transform: uppercase;
  color: #44e2cd; text-shadow: 0 0 14px rgba(68,226,205,.6);
}
.celebrate .cel-item-ic {
  width: 130px; height: 130px; border-radius: 50%;
  display: grid; place-items: center; font-size: 64px; color: #44e2cd;
  border: 3px solid #44e2cd; background: rgba(13, 18, 31, .8);
  box-shadow: 0 0 40px rgba(68, 226, 205, .5), inset 0 0 30px rgba(68, 226, 205, .15);
  animation: item-pop .65s cubic-bezier(.2,1.5,.3,1) both;
}
.celebrate .cel-item-name {
  font-size: clamp(24px, 7vw, 34px); font-weight: 900; letter-spacing: 1px;
  text-transform: uppercase; color: #fff;
  text-shadow: 0 0 24px rgba(68,226,205,.7);
  animation: cel-pop .5s .15s cubic-bezier(.2,1.4,.3,1) both;
}
@keyframes cel-in  { from { opacity: 0; } }
@keyframes cel-out { to { opacity: 0; } }
@keyframes cel-pop { from { opacity: 0; transform: scale(.4); } }
@keyframes item-pop {
  0% { opacity: 0; transform: scale(.3) rotate(-14deg); }
  60% { transform: scale(1.12) rotate(4deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.confetti {
  position: absolute; top: -4vh; width: 9px; height: 14px; border-radius: 2px;
  opacity: .95; animation: confetti-fall linear both;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(var(--spin, 540deg)); opacity: .7; }
}

/* ---------- transición de vistas (sin glitch: opacity/transform por inline) ---------- */
#app { will-change: opacity, transform; }
#app.cascade > * { animation: rise-in .32s cubic-bezier(.2,.9,.3,1.05) both; }
#app.cascade > *:nth-child(2) { animation-delay: 50ms; }
#app.cascade > *:nth-child(3) { animation-delay: 100ms; }
#app.cascade > *:nth-child(4) { animation-delay: 150ms; }
#app.cascade > *:nth-child(n+5) { animation-delay: 190ms; }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } }

/* ---------- legal ---------- */
.legal h2 { margin: 18px 0 6px; font-size: 14px; }
.legal p, .legal li { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; }
.legal ul { padding-left: 18px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- acordeón de sistema (secciones colapsables) ---------- */
.acc {
  border: 1px solid var(--outline-dim);
  border-radius: var(--radius-md);
  background: var(--surface-high);
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color .25s, box-shadow .25s;
}
.acc.is-open { border-color: var(--outline); box-shadow: var(--glow); }
.acc-sum {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; min-height: 52px;
  font-weight: 800; font-size: 13px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--primary);
  transition: background .2s;
}
.acc-sum::-webkit-details-marker { display: none; }   /* fuera el triángulo nativo */
.acc-sum::marker { content: ''; }
.acc-sum:hover { background: var(--outline-dim); }
.acc-sum .acc-ic { color: var(--secondary); flex-shrink: 0; }
.acc-sum .acc-title { flex: 1; min-width: 0; }
/* indicador de estado: chevron que gira */
.acc-chev {
  flex-shrink: 0; color: var(--muted); font-size: 18px;
  transition: transform .38s cubic-bezier(.3, 1.2, .35, 1), color .25s;
}
.acc.is-open .acc-chev { transform: rotate(180deg); color: var(--primary); }
/* cuerpo: grid 0fr→1fr anima altura sin conocer el alto final */
.acc-body {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .36s cubic-bezier(.2, .9, .3, 1);
}
.acc.is-open .acc-body { grid-template-rows: 1fr; }
.acc-inner { min-height: 0; overflow: hidden; }
.acc-pad { padding: 2px 14px 14px; }
/* los campos entran escalonados al desplegar */
.acc.is-open .acc-pad > * { animation: acc-item-in .34s cubic-bezier(.2,.9,.3,1.05) both; }
.acc.is-open .acc-pad > *:nth-child(1) { animation-delay: 40ms; }
.acc.is-open .acc-pad > *:nth-child(2) { animation-delay: 75ms; }
.acc.is-open .acc-pad > *:nth-child(3) { animation-delay: 110ms; }
.acc.is-open .acc-pad > *:nth-child(4) { animation-delay: 145ms; }
.acc.is-open .acc-pad > *:nth-child(5) { animation-delay: 175ms; }
.acc.is-open .acc-pad > *:nth-child(6) { animation-delay: 200ms; }
.acc.is-open .acc-pad > *:nth-child(n+7) { animation-delay: 225ms; }
@keyframes acc-item-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- accesos rápidos: flotan y tienen borde neón (= son clickeables) ---------- */
@property --neon-ang { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

.stat.access {
  position: relative;
  display: grid; gap: 4px; align-content: center;
  text-decoration: none; color: var(--text);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--primary) 22%, transparent);
  animation: access-float 4.2s ease-in-out infinite, access-pulse 3.4s ease-in-out infinite;
  transition: transform .18s cubic-bezier(.2,1.2,.3,1), box-shadow .2s;
}
.stat.access:nth-child(2) { animation-delay: -2.1s, -1.7s; }   /* desfasados: no flotan al unísono */

/* trazo de neón que recorre el borde */
.stat.access::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px;
  background: conic-gradient(from var(--neon-ang),
              transparent 0deg, var(--secondary) 40deg, var(--primary) 80deg, transparent 140deg, transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask-composite: exclude;
  animation: neon-run 3.6s linear infinite;
  pointer-events: none;
}
.stat.access:nth-child(2)::before { animation-delay: -1.8s; }

.stat.access .n { color: var(--primary); }
.stat.access:hover { transform: translateY(-4px) scale(1.02);
                     box-shadow: 0 0 24px color-mix(in srgb, var(--primary) 42%, transparent); }
.stat.access:active { transform: scale(.96); }

@keyframes access-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes access-pulse {
  0%, 100% { box-shadow: 0 0 12px color-mix(in srgb, var(--primary) 18%, transparent); }
  50%      { box-shadow: 0 0 22px color-mix(in srgb, var(--primary) 40%, transparent); }
}
@keyframes neon-run { to { --neon-ang: 360deg; } }

/* ---------- fila de pills: nunca pegados, envuelven en pantallas chicas ---------- */
.pillrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }

/* ---------- pill de Puntos Cívicos: mismo brillo que el widget ---------- */
.pill.pc { position: relative; overflow: hidden; }
.pill.pc::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .45) 50%, transparent 60%);
  transform: translateX(-120%);
  animation: shine-sweep 4.5s ease-in-out infinite;
  pointer-events: none;
}
/* desfasadas por fila: si todas brillan a la vez parece un parpadeo del sistema */
.list-item:nth-child(3n+2) .pill.pc::after { animation-delay: -1.5s; }
.list-item:nth-child(3n+3) .pill.pc::after { animation-delay: -3s; }
.itemgrid .item:nth-child(3n+2) .pill.pc::after { animation-delay: -1.5s; }
.itemgrid .item:nth-child(3n+3) .pill.pc::after { animation-delay: -3s; }

/* ---------- Próximamente (módulo en flag "soon") ---------- */
.soon { text-align: center; display: grid; gap: 12px; justify-items: center; padding: 28px 16px 24px; }
.soon .art { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
             background: var(--outline-dim); border: 1px solid var(--outline); box-shadow: var(--glow); }
.soon .art i { font-size: 40px; color: var(--primary); }
.soon h2 { font-size: 19px; }
.soon p.muted { max-width: 32ch; }
.soon ul { list-style: none; display: grid; gap: 8px; text-align: left; width: 100%; margin-top: 4px; }
.soon li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text); }
.soon li i { color: var(--secondary); font-size: 18px; flex: none; margin-top: 1px; }

/* ---------- Citas (Hospitalito) ---------- */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px;
             background: var(--surface-high); border: 1px solid var(--outline); border-radius: var(--radius-md); margin-bottom: 10px; }
.segmented button { min-height: 40px; border: none; border-radius: calc(var(--radius-md) - 3px); background: transparent;
                    color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; letter-spacing: .4px; cursor: pointer;
                    transition: background .25s, color .25s; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--glow); }
.appt { display: grid; gap: 6px; padding: 14px 4px; border-bottom: 1px solid var(--outline-dim); }
.appt:last-child { border-bottom: none; }
.appt .top { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.appt .when { display: flex; gap: 12px; align-items: center; }
.appt .day { display: grid; place-items: center; min-width: 50px; padding: 6px 4px; border-radius: var(--radius-md);
             background: var(--outline-dim); border: 1px solid var(--outline); line-height: 1; }
.appt .day .d { font-size: 20px; font-weight: 900; color: var(--primary); font-variant-numeric: tabular-nums; }
.appt .day .m { font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.appt .actions { display: flex; gap: 8px; justify-content: flex-end; }
.pill.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.stale { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--warn); padding: 8px 10px;
         border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: var(--radius-md);
         background: color-mix(in srgb, var(--warn) 9%, transparent); margin-bottom: 10px; }
.btn.wa { display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.wa i { font-size: 20px; }
