/* Portal socio · piel visual (no cambia flujos). Cargar DESPUÉS del <style> de index.html. */
body:not(.portal-auth) {
  --p-navy: #0b1a33;
  --p-teal: #0f766e;
  --p-teal-2: #14b8a6;
  --p-mint: #99f6e4;
  --p-bg: #f3f5fb;
  --p-card: #ffffff;
  --brand: var(--p-navy);
}

body.portal-shell {
  background: var(--p-bg);
  padding: 0 !important;
  overflow-x: hidden;
}

body.portal-shell .wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px calc(112px + env(safe-area-inset-bottom, 0px));
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

body:not(.portal-auth):not(.portal-shell) .wrap {
  max-width: 840px;
  background: var(--p-card);
}

/* ----- Header sticky ----- */
.p-head {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 0 -16px 12px;
  padding: 10px 16px 10px;
  background: rgba(243, 245, 251, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}
.p-head-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 1120px;
  margin: 0 auto;
}
.p-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.p-brand .portal-brand { gap: 8px; }
body.portal-shell .portal-imagotipo {
  width: auto !important;
  max-width: min(168px, 42vw);
  max-height: 40px;
  height: auto;
}
.p-org-name {
  display: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--p-navy);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.p-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.p-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8edf8;
  color: #314769;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

/* Campana en header (deja de ser FAB) */
body.portal-shell .notif-wrap {
  position: relative !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  top: auto !important;
  z-index: 50 !important;
}
body.portal-shell .notif-btn {
  width: 40px;
  height: 40px;
  background: transparent !important;
  color: #64748b !important;
  box-shadow: none !important;
}
body.portal-shell .notif-btn:hover {
  transform: none;
  background: #eef2ff !important;
  color: var(--p-navy) !important;
  box-shadow: none !important;
}
body.portal-shell .notif-btn:active { transform: none !important; }
body.portal-shell .notif-ico svg { width: 20px; height: 20px; stroke: currentColor; }
body.portal-shell .notif-badge { top: 2px; right: 2px; }
body.portal-shell .notif-panel {
  right: 0;
  left: auto;
  bottom: auto;
  top: calc(100% + 8px);
  width: min(320px, calc(100vw - 32px));
}

.sess-wrap { position: relative; }
.sess-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  min-height: 0 !important;
  margin: 0 !important;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--p-navy);
  color: #fff;
  cursor: pointer;
  box-shadow: none !important;
  transform: none !important;
}
.sess-btn:hover { background: #163056; }
.sess-btn svg { width: 18px; height: 18px; display: block; }
.sess-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  padding: 12px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08), 0 16px 32px -16px rgba(15, 23, 42, 0.35);
  z-index: 60;
}
.sess-user {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.sess-panel #btnCerrar { width: 100%; margin: 0 !important; }

/* Tabs desktop */
.p-tabs {
  display: none;
}
.p-back-row {
  margin: 0 0 12px;
}
.p-back {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 2px;
  color: var(--p-teal);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

/* Dock móvil */
.p-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding: 0 8px env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}
.p-dock a,
.p-dock button {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  margin: 0 !important;
  padding: 4px 2px;
  border: 0;
  background: none;
  box-shadow: none !important;
  transform: none !important;
  color: #64748b;
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
}
.p-dock a span,
.p-dock button span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-dock a.is-on,
.p-dock button.is-on {
  color: var(--p-teal);
  font-weight: 800;
}
.p-dock svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Saludo */
.p-hello {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 12px;
}
.p-hello h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--p-navy);
  letter-spacing: -0.02em;
}
.p-hello-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.p-hello-sub,
.p-hello .topbar-consulta {
  margin: 4px 0 0;
  font-size: 12px;
  color: #64748b;
}
.p-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.p-pill.is-ok { background: #ccfbf1; color: #0f766e; }
.p-pill.is-deuda { background: #ffedd5; color: #c2410c; }
.p-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Billetera: agua en movimiento (olas), paleta acuática */
body.portal-shell .favor-banner {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  color: #f8fafc;
  background: #042f3c;
  box-shadow: none;
}
body.portal-shell .favor-waves {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
body.portal-shell .favor-wave {
  position: absolute;
  width: 220%;
  height: 360%;
  left: -50%;
  top: -70%;
  border-radius: 40%;
  opacity: 0.7;
  background: linear-gradient(744deg, #075985, #0284c7 55%, #7dd3fc);
  animation: favorWave 55s infinite linear;
}
body.portal-shell .favor-wave:nth-child(2),
body.portal-shell .favor-wave:nth-child(3) {
  top: 52%;
}
body.portal-shell .favor-wave:nth-child(2) {
  left: -35%;
  opacity: 0.55;
  animation-duration: 50s;
  background: linear-gradient(744deg, #0369a1, #22d3ee 58%, #e0f2fe);
}
body.portal-shell .favor-wave:nth-child(3) {
  left: -65%;
  opacity: 0.42;
  animation-duration: 45s;
  background: linear-gradient(744deg, #0ea5e9, #38bdf8 50%, #bae6fd);
}
@keyframes favorWave {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  body.portal-shell .favor-wave { animation: none; }
}
body.portal-shell .favor-banner--deuda {
  background: #3b2110;
}
body.portal-shell .favor-banner--deuda .favor-wave {
  background: linear-gradient(744deg, #9a3412, #ea580c 55%, #fdba74);
}
body.portal-shell .favor-banner--deuda .favor-wave:nth-child(2) {
  background: linear-gradient(744deg, #b45309, #f59e0b 58%, #fde68a);
}
body.portal-shell .favor-banner--deuda .favor-wave:nth-child(3) {
  background: linear-gradient(744deg, #c2410c, #fb923c 50%, #ffedd5);
}
body.portal-shell .favor-banner--deuda .favor-lbl { color: #fed7aa; }
body.portal-shell .favor-banner--deuda .favor-hint,
body.portal-shell .favor-banner--deuda .favor-pref { color: #ffedd5; }

body.portal-shell .favor-banner--mora {
  background: #3f0d12;
}
body.portal-shell .favor-banner--mora .favor-wave {
  background: linear-gradient(744deg, #9f1239, #e11d48 55%, #fda4af);
}
body.portal-shell .favor-banner--mora .favor-wave:nth-child(2) {
  background: linear-gradient(744deg, #be123c, #fb7185 58%, #fecdd3);
}
body.portal-shell .favor-banner--mora .favor-wave:nth-child(3) {
  background: linear-gradient(744deg, #e11d48, #fb7185 50%, #ffe4e6);
}
body.portal-shell .favor-banner--mora .favor-lbl { color: #fecdd3; }
body.portal-shell .favor-banner--mora .favor-hint,
body.portal-shell .favor-banner--mora .favor-pref { color: #ffe4e6; }

body.portal-shell .favor-banner--warn .favor-waves,
body.portal-shell .favor-banner--info .favor-waves {
  display: none;
}
body.portal-shell .favor-banner:hover {
  background-position: 0 0;
  box-shadow: none;
}
body.portal-shell .favor-banner .favor-content,
body.portal-shell .favor-banner .favor-actions {
  position: relative;
  z-index: 1;
}
body.portal-shell .favor-banner .favor-content {
  background: transparent;
  color: inherit;
  padding: 0;
  box-shadow: none;
}
body.portal-shell .favor-banner .favor-lbl {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #bae6fd;
}
body.portal-shell .favor-banner .favor-amt {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  margin-top: 4px;
}
body.portal-shell .favor-banner .favor-hint {
  color: rgba(224, 242, 254, 0.88);
  font-size: 12px;
}
body.portal-shell .favor-banner .favor-pref { color: #e0f2fe; font-size: 13px; }
body.portal-shell .favor-banner .favor-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
body.portal-shell .favor-banner .favor-cta,
body.portal-shell .favor-banner .favor-actions .favor-cta {
  width: auto;
  min-width: 0;
  min-height: 36px;
  margin: 0 !important;
  padding: 8px 14px;
  border-radius: 10px;
  background: #fff !important;
  color: var(--p-navy) !important;
  box-shadow: none !important;
  transform: none !important;
}
body.portal-shell .favor-banner .favor-cta:hover {
  background: #f1f5f9 !important;
}

/* Atajos */
.qa-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 2px 0 8px;
}
.qa-head h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}
.qa-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin: 0 -16px 16px;
  padding-left: 16px;
  padding-right: 16px;
  -webkit-overflow-scrolling: touch;
}
.qa-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 8px 12px;
  min-height: 48px;
  max-width: 46vw;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: var(--p-navy);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06) !important;
  transform: none !important;
  text-align: left;
  cursor: pointer;
}
.qa-btn span:last-child { min-width: 0; }
.qa-btn strong,
.qa-btn small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qa-btn:hover { background: #f8fafc; }
.qa-ico {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #ccfbf1;
  color: var(--p-teal);
}
.qa-ico svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}
.qa-btn strong { display: block; font-size: 13px; line-height: 1.1; }
.qa-btn small { display: block; font-size: 10px; color: #64748b; font-weight: 500; margin-top: 2px; }

/* Servicios como cards */
body.portal-shell .card {
  background: transparent;
  box-shadow: none;
  padding: 0;
  margin-bottom: 16px;
}
body.portal-shell #multiBody.card,
body.portal-shell #ecBody > .card {
  background: #fff;
  padding: 16px;
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
}
body.portal-shell .card > .section-head {
  border-bottom: 0;
  padding-bottom: 8px;
  margin-bottom: 8px;
}
body.portal-shell .card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
body.portal-shell .svc-list {
  gap: 8px;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  border-radius: 0;
}
body.portal-shell .svc-row {
  border: 0;
  border-left: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}
body.portal-shell .svc-row.con-deuda .svc-sum { background: #fff; }
body.portal-shell .svc-sum {
  padding: 12px 12px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
}
body.portal-shell .svc-sum-main { min-width: 0; overflow: hidden; }
body.portal-shell .svc-sum-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.portal-shell .svc-id-part { white-space: nowrap; }
body.portal-shell .svc-sum-side { flex-shrink: 0; }
body.portal-shell .svc-sum-saldo { font-size: 13px; font-weight: 700; white-space: nowrap; }
body.portal-shell .svc-ico {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #ecfdf5;
  color: var(--p-teal);
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
}
body.portal-shell .svc-row.con-deuda .svc-ico { background: #fff7ed; color: #c2410c; }
body.portal-shell .svc-row.est-suspendido .svc-ico { background: #fef2f2; color: #b91c1c; }
body.portal-shell .svc-sum-title { font-size: 14px; font-weight: 650; }
body.portal-shell .svc-sum-id { font-size: 12px; }
body.portal-shell .tk-row .svc-sum {
  grid-template-columns: minmax(0, 1fr) auto;
}
body.portal-shell .tk-row .svc-sum-badge { margin-top: 6px; }
body.portal-shell .tk-row .tk-prog { margin-top: 8px; }
body.portal-shell .svc-row:not(.tk-row) .svc-sum-badge { margin-top: 4px; line-height: 1; }
body.portal-shell .svc-row:not(.tk-row) .svc-sum-badge .badge { font-size: 11px; }
body.portal-shell .dash-layout,
body.portal-shell .dash-main,
body.portal-shell .dash-side,
body.portal-shell .fold-card {
  min-width: 0;
  max-width: 100%;
}
body.portal-shell .fold-card {
  overflow: hidden;
  box-sizing: border-box;
}
body.portal-shell .fold-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 !important;
  box-sizing: border-box;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}
body.portal-shell .fold-toggle > div {
  min-width: 0;
  overflow: hidden;
}
body.portal-shell .fold-toggle .fold-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}
body.portal-shell .fold-toggle .fold-legend {
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
body.portal-shell .fold-toggle .fold-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-width: 100%;
}
body.portal-shell .fold-toggle .svc-chev {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}
body.portal-shell .sum-bar.sticky {
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}
body.portal-shell .m-line-main .txt { min-width: 0; }
body.portal-shell .m-line-id {
  display: block;
  margin: 4px 0 6px;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
body.portal-shell .toast-wrap {
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  top: auto;
  z-index: 80;
}
body.portal-shell .svc-detail { background: #f8fafc; }
body.portal-shell .empty-box {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
}
body:not(.portal-auth):not(.portal-shell) {
  background: var(--p-bg, #f3f5fb);
}
body:not(.portal-auth):not(.portal-shell) .portal-imagotipo {
  width: auto;
  max-width: min(240px, 70vw);
  max-height: 64px;
}
body.portal-shell .fold-card {
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

.count-pill {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ccfbf1;
  color: #0f766e;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

/* Botones planos (el push 3D no pega con esta piel) */
body.portal-shell:not(.portal-auth) #app button.primary,
body.portal-shell:not(.portal-auth) #app button.ghost,
body.portal-shell:not(.portal-auth) #app button.ok {
  box-shadow: none;
  transform: none;
  margin-bottom: 0;
  border-radius: 10px;
  letter-spacing: 0.01em;
}
body.portal-shell:not(.portal-auth) #app button.primary {
  background: var(--p-navy);
}
body.portal-shell:not(.portal-auth) #app button.primary:hover {
  background: #163056;
  box-shadow: none;
}
body.portal-shell:not(.portal-auth) #app button.primary:active {
  transform: none;
  box-shadow: none;
}
body.portal-shell:not(.portal-auth) #app button.ghost {
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}
body.portal-shell:not(.portal-auth) #app button.ghost:hover {
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.18);
}
body.portal-shell:not(.portal-auth) #app button.ghost:active {
  transform: none;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

body.portal-shell .p-page-cta {
  display: none;
}

/* Navegación de escritorio (pestañas arriba, sin barra inferior): pantalla ancha, o
   ventana angosta con mouse o touchpad (zoom 125–150 %, pantalla dividida). Se pregunta
   por mouse, no por táctil: una laptop táctil con touchpad es escritorio. Sin mouse
   (celular, tablet) queda la barra inferior. El reparto en columnas sigue en 900 px. */
@media (min-width: 900px), (min-width: 601px) and (any-hover: hover) and (any-pointer: fine) {
  .p-dock { display: none; }
  body.portal-shell .wrap { padding-bottom: 40px; }
  .p-tabs {
    display: flex;
    gap: 6px;
    align-items: center;
    margin: 0 0 18px;
    padding: 4px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.05);
  }
  .p-tabs a {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    color: #64748b;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
  }
  .p-tabs a.is-on {
    background: var(--p-navy);
    color: #fff;
  }
  .p-page-cta {
    display: inline-flex;
    margin-left: auto;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--p-teal);
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
  }
  body.portal-shell .p-page-cta {
    display: inline-flex;
  }
  .p-back-row { margin-bottom: 8px; }
}

@media (min-width: 900px) {
  body.portal-shell .wrap { padding: 0 24px 40px; }
  .p-head { margin: 0 -24px 16px; padding-left: 24px; padding-right: 24px; }
  .p-org-name { display: inline; }
  .dash-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 20px;
    align-items: start;
  }
  .p-hello h1 { font-size: 1.5rem; }
  body.portal-shell .favor-banner {
    flex-direction: column;
  }
  .qa-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
    margin: 0 0 16px;
    padding: 0;
  }
  .qa-btn { width: 100%; max-width: none; }
  body.portal-shell .toast-wrap {
    top: 72px;
    bottom: auto;
    right: max(12px, env(safe-area-inset-right));
    left: auto;
    z-index: 80;
  }
}

@media (prefers-reduced-motion: reduce) {
  .p-head, .p-dock {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
