:root {
  --sg-primary: #0f5bd7;
  --sg-secondary: #10b7b2;
  --sg-surface: rgba(255, 255, 255, 0.92);
  --sg-border: rgba(15, 91, 215, 0.08);
  --sg-bg: #f4f8ff;
  --sg-text: #17324d;
  --sg-muted: #6c7a89;
  --sg-shadow: 0 10px 30px rgba(19, 31, 56, 0.06);
}

html, body {
  min-height: 100%;
  background: radial-gradient(circle at top left, rgba(16, 183, 178, 0.11), transparent 26%),
              radial-gradient(circle at top right, rgba(15, 91, 215, 0.12), transparent 28%),
              var(--sg-bg);
  color: var(--sg-text);
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

.app-shell, .portal-shell, .public-shell {
  position: relative;
  overflow-x: hidden;
}

.app-gradient, .auth-backdrop, .portal-backdrop, .public-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.68), rgba(255,255,255,0.18));
  z-index: -1;
}

.sidebar {
  width: 292px;
  min-height: 100vh;
  padding: 1.5rem;
  background: linear-gradient(180deg, #0d2d63 0%, #0f5bd7 65%, #10b7b2 100%);
  color: white;
  position: sticky;
  top: 0;
}

.sidebar-link {
  display: block;
  padding: .9rem 1rem;
  border-radius: 1rem;
  color: rgba(255,255,255,.88);
  text-decoration: none;
  transition: transform .15s ease, background-color .15s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
  color: white;
  background: rgba(255,255,255,.15);
  transform: translateX(2px);
}

.topbar, .portal-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  backdrop-filter: blur(16px);
  background: rgba(244, 248, 255, 0.82);
  border-bottom: 1px solid var(--sg-border);
}

.mobile-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .6rem .9rem;
  box-shadow: 0 12px 25px rgba(15, 91, 215, 0.18);
}

.mobile-menu-toggle .menu-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.brand-logo, .auth-logo, .landing-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.landing-logo {
  width: 58px;
  height: 58px;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  width: min(100%, 460px);
  background: var(--sg-surface);
  border: 1px solid var(--sg-border);
  border-radius: 1.5rem;
  box-shadow: 0 22px 60px rgba(8, 15, 33, 0.12);
  padding: 2rem;
}

.public-main {
  min-height: 100vh;
  display: block;
  width: 100%;
}

.landing-hero,
.portal-access {
  width: 100%;
}

.landing-nav {
  background: rgba(255,255,255,.7);
  border: 1px solid var(--sg-border);
  border-radius: 1.4rem;
  padding: 1rem 1.1rem;
  box-shadow: var(--sg-shadow);
  backdrop-filter: blur(16px);
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .85rem;
  border-radius: 999px;
  background: rgba(15, 91, 215, 0.1);
  color: var(--sg-primary);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.landing-panel,
.metric-card,
.card {
  border-radius: 1.4rem;
  border: 1px solid var(--sg-border);
  background: var(--sg-surface);
  box-shadow: var(--sg-shadow);
}

.landing-panel {
  overflow: hidden;
}

.landing-kpi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 72px;
  border-radius: 1.2rem;
  background: linear-gradient(135deg, var(--sg-primary), var(--sg-secondary));
  color: white;
  font-weight: 800;
  letter-spacing: .04em;
  box-shadow: 0 18px 35px rgba(15, 91, 215, 0.22);
}

.landing-stats {
  display: grid;
  gap: .85rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.landing-stat,
.landing-feature,
.info-tile {
  border-radius: 1rem;
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(15, 91, 215, 0.08);
}

.landing-stat {
  padding: 1rem;
  display: grid;
  gap: .3rem;
}

.landing-stat strong,
.info-tile strong {
  font-size: 1rem;
}

.landing-stat span,
.info-tile span {
  color: var(--sg-muted);
  font-size: .9rem;
}

.landing-features {
  display: grid;
  gap: .75rem;
}

.landing-feature {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  padding: .9rem 1rem;
}

.landing-feature span {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: rgba(16, 183, 178, 0.13);
  color: var(--sg-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-weight: 800;
}

.portal-org-card {
  transition: transform .15s ease, box-shadow .15s ease;
}

.portal-org-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 35px rgba(19, 31, 56, 0.09);
}

.org-icon {
  width: 52px;
  height: 52px;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--sg-primary), var(--sg-secondary));
  color: white;
  font-weight: 800;
}

.portal-profile-photo {
  width: 170px;
  height: 170px;
  border-radius: 1.5rem;
  overflow: hidden;
  box-shadow: 0 14px 35px rgba(19, 31, 56, 0.12);
}

.portal-profile-image,
.portal-profile-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portal-profile-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--sg-primary), var(--sg-secondary));
  color: white;
  font-size: 2rem;
  font-weight: 800;
}

.info-tile {
  padding: 1rem 1.05rem;
  display: grid;
  gap: .35rem;
}

.metric-card {
  padding: 1.1rem 1.15rem;
}

.metric-label {
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--sg-muted);
  margin-bottom: .4rem;
}

.metric-value {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.1;
}

.avatar-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--sg-primary), var(--sg-secondary));
  color: white;
  font-weight: 700;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 1.05rem;
}

.avatar-xl {
  width: 92px;
  height: 92px;
  font-size: 1.15rem;
}

.member-photo {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 1.2rem;
  border: 4px solid rgba(15, 91, 215, 0.1);
}

.member-list-photo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 50%;
  flex: 0 0 auto;
  border: 2px solid rgba(15, 91, 215, 0.12);
}

.member-list-photo-lg {
  width: 64px;
  height: 64px;
}

.org-choice {
  cursor: pointer;
  border-radius: 1.2rem;
  border: 1px solid var(--sg-border);
  background: var(--sg-surface);
}

.quota-check {
  cursor: pointer;
  border-radius: 1rem;
}

.offcanvas {
  border-top-right-radius: 1.5rem;
  border-bottom-right-radius: 1.5rem;
}

.mobile-menu {
  background: rgba(255, 255, 255, 0.98);
}

.mobile-menu .offcanvas-header {
  background: white;
}

.mobile-menu .offcanvas-body {
  background: transparent;
  overflow-y: auto;
}

.mobile-menu .nav-link,
.mobile-menu .sidebar-link {
  color: var(--sg-text) !important;
  background: rgba(15, 91, 215, 0.05);
  border: 1px solid rgba(15, 91, 215, 0.08);
  border-radius: 1rem;
  padding: .85rem 1rem;
  font-weight: 600;
  display: block;
}

.mobile-menu .nav-link:hover,
.mobile-menu .sidebar-link:hover,
.mobile-menu .nav-link.active,
.mobile-menu .sidebar-link.active {
  color: white !important;
  background: linear-gradient(135deg, var(--sg-primary), var(--sg-secondary));
  transform: none;
}

.mobile-menu .btn-outline-primary {
  border-width: 2px;
}

.btn {
  border-radius: .95rem;
}

.btn-lg {
  padding-top: .9rem;
  padding-bottom: .9rem;
}

.table {
  margin-bottom: 0;
}

.table > :not(caption) > * > * {
  padding: .95rem .9rem;
}

.table thead th {
  color: var(--sg-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.portal-shell-content {
  display: grid;
  gap: 1rem;
}

@media (max-width: 991.98px) {
  .auth-card {
    padding: 1.25rem;
  }

  .sidebar {
    display: none;
  }

  .landing-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 575.98px) {
  .mobile-menu-toggle .menu-label {
    display: none;
  }

  .topbar .container-fluid {
    gap: .75rem;
  }

  .topbar .fs-5 {
    font-size: 1rem !important;
  }

  .landing-nav {
    flex-direction: column;
    align-items: flex-start !important;
  }
}
