/* =========================================================
   Tenant Select + Portal institucional (UI moderna)
   ========================================================= */

:root {
  --tp-edu: #2563eb;
  --tp-salud: #10b981;
  --tp-tech: #06b6d4;
  --tp-empresa: #6366f1;
  --tp-fundacion: #f59e0b;
  --tp-gobierno: #0f172a;
  --tp-asistencial: #ec4899;
  --tp-otro: #64748b;
  --tp-ink: #0f172a;
  --tp-muted: #64748b;
  --tp-line: rgba(15, 23, 42, 0.08);
  --tp-card: #ffffff;
  --tp-radius: 22px;
  --tp-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --tp-shadow-lg: 0 28px 60px rgba(15, 23, 42, 0.14);
  --tp-primary: #0d6efd;
}

body.app-public-body:has(.tenant-shell),
body.app-public-body:has(.portal-shell) {
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(13, 110, 253, 0.12), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(16, 185, 129, 0.08), transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  margin-bottom: 0;
}

.tenant-shell,
.portal-shell {
  min-height: calc(100vh - 72px);
  padding-bottom: 3.5rem;
}

/* ---------- Hero ---------- */
.tp-hero {
  padding: 2.25rem 0 1.25rem;
}

.tp-hero-panel {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid var(--tp-line);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
  box-shadow: var(--tp-shadow);
  padding: 1.75rem 1.5rem;
}

.tp-hero-panel::before {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13, 110, 253, 0.16), transparent 70%);
  pointer-events: none;
}

.tp-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--tp-primary);
  background: rgba(13, 110, 253, 0.1);
  border: 1px solid rgba(13, 110, 253, 0.14);
}

.tp-title {
  color: var(--tp-ink);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0.85rem 0 0.5rem;
  line-height: 1.15;
}

.tp-subtitle {
  color: var(--tp-muted);
  font-size: 1.05rem;
  margin: 0;
  max-width: 52rem;
}

.tp-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.tp-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--tp-line);
  color: var(--tp-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.tp-chip strong {
  color: var(--tp-ink);
}

.tp-search-wrap {
  position: relative;
  margin-top: 1.15rem;
  max-width: 420px;
}

.tp-search-wrap i {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.tp-search {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--tp-line);
  background: #fff;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  font-weight: 500;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.tp-search:focus {
  outline: none;
  border-color: rgba(13, 110, 253, 0.45);
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.12);
}

/* ---------- Tabs ---------- */
.tp-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1.5rem 0 1.25rem;
  padding: 0;
  list-style: none;
  border: 0;
}

.tp-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--tp-line);
  background: #fff;
  color: #475569;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  font-weight: 700;
  font-size: 0.9rem;
  transition: 0.2s ease;
}

.tp-tab:hover {
  transform: translateY(-1px);
  color: var(--tp-ink);
  border-color: rgba(13, 110, 253, 0.22);
}

.tp-tab.active {
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
}

.tp-tab .tp-count {
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  background: rgba(15, 23, 42, 0.08);
}

.tp-tab.active .tp-count {
  background: rgba(255, 255, 255, 0.24);
}

.tp-tab.acento-edu.active { background: var(--tp-edu); }
.tp-tab.acento-salud.active { background: var(--tp-salud); }
.tp-tab.acento-tech.active { background: var(--tp-tech); }
.tp-tab.acento-empresa.active { background: var(--tp-empresa); }
.tp-tab.acento-fundacion.active { background: var(--tp-fundacion); }
.tp-tab.acento-gobierno.active { background: var(--tp-gobierno); }
.tp-tab.acento-asistencial.active { background: var(--tp-asistencial); }
.tp-tab.acento-otro.active { background: var(--tp-otro); }

/* ---------- Institution cards ---------- */
.tp-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 250px;
  text-align: left;
  border: 1px solid var(--tp-line);
  border-radius: var(--tp-radius);
  background: var(--tp-card);
  box-shadow: var(--tp-shadow);
  padding: 1.25rem;
  transition: 0.25s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

button.tp-card {
  cursor: pointer;
}

.tp-card::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--tp-primary);
  opacity: 0.85;
}

.tp-card.acento-edu::after { background: var(--tp-edu); }
.tp-card.acento-salud::after { background: var(--tp-salud); }
.tp-card.acento-tech::after { background: var(--tp-tech); }
.tp-card.acento-empresa::after { background: var(--tp-empresa); }
.tp-card.acento-fundacion::after { background: var(--tp-fundacion); }
.tp-card.acento-gobierno::after { background: var(--tp-gobierno); }
.tp-card.acento-asistencial::after { background: var(--tp-asistencial); }
.tp-card.acento-otro::after { background: var(--tp-otro); }

.tp-card:hover {
  transform: translateY(-7px);
  box-shadow: var(--tp-shadow-lg);
  border-color: rgba(13, 110, 253, 0.16);
}

.tp-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tp-logo,
.tp-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(13, 110, 253, 0.1);
  color: var(--tp-primary);
  font-size: 1.55rem;
}

.tp-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tp-card.acento-edu .tp-icon { background: rgba(37, 99, 235, 0.12); color: var(--tp-edu); }
.tp-card.acento-salud .tp-icon { background: rgba(16, 185, 129, 0.12); color: var(--tp-salud); }
.tp-card.acento-tech .tp-icon { background: rgba(6, 182, 212, 0.12); color: var(--tp-tech); }
.tp-card.acento-empresa .tp-icon { background: rgba(99, 102, 241, 0.12); color: var(--tp-empresa); }
.tp-card.acento-fundacion .tp-icon { background: rgba(245, 158, 11, 0.14); color: var(--tp-fundacion); }
.tp-card.acento-gobierno .tp-icon { background: rgba(15, 23, 42, 0.08); color: var(--tp-gobierno); }
.tp-card.acento-asistencial .tp-icon { background: rgba(236, 72, 153, 0.12); color: var(--tp-asistencial); }

.tp-arrow {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #f1f5f9;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s ease;
}

.tp-card:hover .tp-arrow {
  background: var(--tp-primary);
  color: #fff;
}

.tp-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.tp-card-body h3 {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--tp-ink);
  margin: 0 0 0.35rem;
  line-height: 1.25;
}

.tp-meta {
  color: var(--tp-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.tp-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.tp-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #f8fafc;
  border: 1px solid var(--tp-line);
  color: #475569;
}

.tp-pill.is-ok { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.tp-pill.is-warn { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.tp-pill.is-off { background: #f1f5f9; border-color: #e2e8f0; color: #64748b; }

.tp-role-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #52627a;
  margin-bottom: 0.25rem;
}

.tp-role-select {
  border-radius: 12px !important;
  margin-bottom: 0.65rem;
}

.tp-cta {
  margin-top: auto;
  padding-top: 0.65rem;
  border: 0;
  background: transparent;
  color: var(--tp-primary);
  font-weight: 800;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-align: left;
}

/* ---------- Empty / alerts ---------- */
.tp-empty {
  background: #fff;
  border: 1px solid var(--tp-line);
  border-radius: 24px;
  box-shadow: var(--tp-shadow);
  padding: 2.75rem 1.5rem;
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
}

.tp-empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: #f1f5f9;
  color: #64748b;
}

.tp-alert {
  border: 0;
  border-radius: 18px;
  box-shadow: var(--tp-shadow);
}

/* ---------- Portal ---------- */
.portal-brand-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.portal-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--tp-line);
  box-shadow: var(--tp-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 1.8rem;
  color: var(--tp-primary);
  flex-shrink: 0;
}

.portal-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portal-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}

.portal-stat {
  background: #fff;
  border: 1px solid var(--tp-line);
  border-radius: 14px;
  padding: 0.65rem 0.9rem;
  min-width: 110px;
}

.portal-stat small {
  display: block;
  color: var(--tp-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.portal-stat strong {
  color: var(--tp-ink);
  font-size: 1.15rem;
}

.portal-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1.75rem 0 0.9rem;
}

.portal-section-title h2 {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0;
  color: var(--tp-ink);
}

.portal-section-title span {
  color: var(--tp-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.module-card {
  position: relative;
  min-height: 250px;
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  color: #1f2937;
  text-decoration: none;
  border-radius: var(--tp-radius);
  border: 1px solid var(--tp-line);
  background: #fff;
  box-shadow: var(--tp-shadow);
  transition: 0.25s ease;
  overflow: hidden;
}

.module-card:hover {
  transform: translateY(-7px);
  box-shadow: var(--tp-shadow-lg);
  color: #1f2937;
  border-color: rgba(13, 110, 253, 0.18);
}

.module-card.is-private::before {
  content: "Privado";
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid var(--tp-line);
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
}

.module-card.is-public::before {
  content: "Público";
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
}

.module-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.module-card h5 {
  font-weight: 800;
  margin: 0;
  padding-right: 4.2rem;
  font-size: 1.05rem;
}

.module-card p {
  color: #6b7280;
  margin: 0;
  flex: 1;
  font-size: 0.93rem;
  line-height: 1.45;
}

.module-card .module-go {
  color: var(--tp-primary);
  font-weight: 800;
  margin-top: 0.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.module-card.tone-blue .module-icon { color: #1d4ed8; background: #dbeafe; }
.module-card.tone-green .module-icon { color: #047857; background: #d1fae5; }
.module-card.tone-amber .module-icon { color: #b45309; background: #fef3c7; }
.module-card.tone-violet .module-icon { color: #6d28d9; background: #ede9fe; }
.module-card.tone-slate .module-icon { color: #0f172a; background: #e2e8f0; }
.module-card.tone-cyan .module-icon { color: #0e7490; background: #cffafe; }
.module-card.tone-orange .module-icon { color: #9a3412; background: #ffedd5; }
.module-card.tone-rose .module-icon { color: #be123c; background: #ffe4e6; }
.module-card.tone-teal .module-icon { color: #0f766e; background: #ccfbf1; }
.module-card.tone-indigo .module-icon { color: #3730a3; background: #e0e7ff; }

.module-card.tone-blue .module-go { color: #1d4ed8; }
.module-card.tone-green .module-go { color: #047857; }
.module-card.tone-amber .module-go { color: #b45309; }
.module-card.tone-violet .module-go { color: #6d28d9; }
.module-card.tone-slate .module-go { color: #0f172a; }
.module-card.tone-cyan .module-go { color: #0e7490; }
.module-card.tone-orange .module-go { color: #9a3412; }
.module-card.tone-rose .module-go { color: #be123c; }
.module-card.tone-teal .module-go { color: #0f766e; }
.module-card.tone-indigo .module-go { color: #3730a3; }

.portal-side-card {
  background: #fff;
  border: 1px solid var(--tp-line);
  border-radius: 22px;
  box-shadow: var(--tp-shadow);
  padding: 1.25rem;
  height: 100%;
}

.portal-side-card h3 {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0 0 0.75rem;
}

.portal-side-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.portal-side-list li {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  color: #475569;
  font-size: 0.9rem;
}

.portal-side-list i {
  color: var(--tp-primary);
  margin-top: 0.15rem;
}

.portal-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin-top: 2rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 767.98px) {
  .tp-hero-panel {
    border-radius: 20px;
    padding: 1.25rem 1rem;
  }

  .tp-title {
    font-size: 1.55rem;
  }

  .tp-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    -webkit-overflow-scrolling: touch;
  }

  .tp-tab {
    flex: 0 0 auto;
  }

  .module-card h5 {
    padding-right: 0;
    margin-top: 0.35rem;
  }

  .module-card.is-private::before,
  .module-card.is-public::before {
    position: static;
    align-self: flex-start;
    margin-bottom: 0.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tp-card,
  .module-card,
  .tp-tab {
    transition: none;
  }

  .tp-card:hover,
  .module-card:hover {
    transform: none;
  }
}
