:root {
  --tpm-green-deep: #0a3d2e;
  --tpm-green-mid: #0d4f3c;
  --tpm-green-dark: #062a20;
  --tpm-sidebar-bg: linear-gradient(180deg, #0a3d2e 0%, #062a20 55%, #041a14 100%);
  --tpm-sidebar-width: 268px;
  --tpm-gold: #d4af37;
  --tpm-gold-light: #e8c547;
  --tpm-gold-dark: #a8841f;
  --tpm-sidebar-text: #c5d4ce;
  --tpm-sidebar-active: rgba(212, 175, 55, 0.12);
  --tpm-content-bg: #eef2f0;
  --tpm-card-shadow: 0 4px 18px rgba(6, 42, 32, 0.08);
  --tpm-roi: #22c55e;
  --tpm-level: #eab308;
  --tpm-performance: #3b82f6;
  --tpm-ba: #8b5cf6;
}

.tpm-body {
  background: var(--tpm-content-bg);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1e293b;
}

.text-gold {
  color: var(--tpm-gold) !important;
}

/* ——— Portal shell ——— */
.tpm-app-wrap {
  display: flex;
  min-height: 100vh;
}

.tpm-sidebar {
  width: var(--tpm-sidebar-width);
  flex-shrink: 0;
  background: #062a20;
  background: var(--tpm-sidebar-bg);
  color: var(--tpm-sidebar-text);
  border-right: 1px solid rgba(212, 175, 55, 0.15);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1030;
  overflow-y: auto;
  transition: transform 0.25s ease;
}

.tpm-sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tpm-sidebar-brand .brand-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  line-height: 1.3;
}

.tpm-sidebar-brand .brand-tagline {
  font-size: 0.65rem;
  color: var(--tpm-gold);
  margin-top: 0.25rem;
}

.tpm-nav .nav-link {
  color: var(--tpm-sidebar-text);
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.tpm-nav .nav-link i {
  width: 1.25rem;
  text-align: center;
  opacity: 0.85;
}

.tpm-nav .nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.tpm-nav .nav-link.active {
  color: #fff;
  background: var(--tpm-sidebar-active);
  border-left-color: var(--tpm-gold);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.35);
  border-radius: 0 6px 6px 0;
  margin-right: 0.5rem;
}

.tpm-nav-toggle .tpm-nav-chevron {
  margin-left: auto;
  font-size: 0.65rem;
  opacity: 0.5;
  transition: transform 0.2s ease;
}

.tpm-nav-toggle[aria-expanded="true"] .tpm-nav-chevron {
  transform: rotate(180deg);
}

.tpm-nav-sub-wrap {
  background: rgba(0, 0, 0, 0.15);
}

.tpm-nav-sub .nav-link {
  padding: 0.45rem 1rem 0.45rem 2.35rem;
  font-size: 0.8rem;
  color: #94a3b8;
  border-left: 3px solid transparent;
}

.tpm-nav-sub .nav-link:hover {
  color: #e2e8f0;
}

.tpm-nav-sub .nav-link.active {
  color: var(--tpm-gold-light);
  border-left-color: var(--tpm-gold);
  background: rgba(255, 255, 255, 0.03);
}

.tpm-sidebar-promo {
  margin: 1rem;
  padding: 1rem 0.75rem;
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(212, 175, 55, 0.18) 0%, rgba(6, 42, 32, 0.95) 100%);
  border: 1px solid rgba(212, 175, 55, 0.35);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--tpm-gold-light);
  line-height: 1.45;
  text-transform: uppercase;
}

.tpm-main {
  flex: 1;
  margin-left: var(--tpm-sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tpm-topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.tpm-impersonation-bar {
  background: #fffbeb;
  border-bottom: 1px solid #fcd34d;
  position: sticky;
  top: 0;
  z-index: 1019;
}

.tpm-search-wrap {
  max-width: 420px;
  flex: 1;
}

.tpm-search-wrap .form-control {
  border-radius: 999px;
  background: #f8fafc;
  border-color: #e2e8f0;
  font-size: 0.875rem;
  padding-left: 2.5rem;
}

.tpm-search-wrap .search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.tpm-topbar-actions .btn-link {
  color: #64748b;
  font-size: 1.1rem;
}

.tpm-badge-notify {
  position: absolute;
  top: -2px;
  right: -2px;
  font-size: 0.6rem;
  padding: 0.15rem 0.35rem;
}

.tpm-badge-notify[hidden] {
  display: none !important;
}

.tpm-content {
  padding: 1.25rem;
  flex: 1;
}

/* ——— Hero welcome ——— */
.tpm-hero {
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(105deg, #062a20 0%, #0a3d2e 40%, #0d5c45 100%);
  color: #fff;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  position: relative;
  border: 1px solid rgba(212, 175, 55, 0.2);
  box-shadow: var(--tpm-card-shadow);
}

.tpm-hero-brand::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 45%;
  max-width: 420px;
  background: url("../img/dashboard-reference.jpg") right center / cover no-repeat;
  opacity: 0.35;
  pointer-events: none;
}

.tpm-hero-brand .hero-sub {
  font-size: 0.85rem;
  opacity: 0.88;
  max-width: 28rem;
}

.tpm-hero h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.tpm-hero .hero-date {
  font-size: 0.8rem;
  opacity: 0.85;
}

.tpm-hero .btn-view-site {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 0.8rem;
}

.tpm-hero-deco {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.35;
  font-size: 4rem;
  color: var(--tpm-gold);
}

/* ——— KPI cards ——— */
.tpm-kpi-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: var(--tpm-card-shadow);
  padding: 1rem 1.1rem;
  height: 100%;
}

.tpm-kpi-card .kpi-label {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}

.tpm-kpi-card .kpi-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.tpm-kpi-card .kpi-trend {
  font-size: 0.7rem;
  margin-top: 0.35rem;
}

.tpm-kpi-card .kpi-trend.up {
  color: #16a34a;
}

.tpm-kpi-card .kpi-spark {
  height: 28px;
  margin-top: 0.5rem;
  opacity: 0.6;
}

.tpm-kpi-card .kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

/* ——— Chart panels ——— */
.tpm-panel {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: var(--tpm-card-shadow);
  height: 100%;
}

.tpm-panel-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tpm-panel-head h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.tpm-period-tabs .btn {
  font-size: 0.7rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.tpm-period-tabs .btn.active {
  background: var(--tpm-gold);
  border-color: var(--tpm-gold);
  color: #0f1419;
}

.tpm-panel-body {
  padding: 1rem 1.25rem 1.25rem;
}

/* ——— Income category cards ——— */
.tpm-income-cat {
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  height: 100%;
}

.tpm-income-cat .cat-head {
  padding: 0.65rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: #fff;
}

.tpm-income-cat.cat-roi .cat-head { background: var(--tpm-roi); }
.tpm-income-cat.cat-level .cat-head { background: var(--tpm-level); color: #422006; }
.tpm-income-cat.cat-performance .cat-head { background: var(--tpm-performance); }

.tpm-income-cat .cat-body {
  background: #fff;
  padding: 1rem;
  font-size: 0.8rem;
}

.tpm-income-cat .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.tpm-income-cat .stat-row:last-child {
  border-bottom: 0;
}

/* ——— Wallet mini cards (member) ——— */
.tpm-wallet-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  padding: 1rem;
  height: 100%;
}

.tpm-wallet-card .wallet-name {
  font-size: 0.75rem;
  color: #64748b;
}

.tpm-wallet-card .wallet-balance {
  font-size: 1.25rem;
  font-weight: 700;
}

.tpm-referral-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  border-radius: 10px;
  padding: 1rem;
  height: 100%;
}

.tpm-referral-card .btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 0;
}

.tpm-referral-card .btn-icon:hover {
  background: var(--tpm-gold);
  color: #0f1419;
}

/* ——— Tables ——— */
.tpm-table-scroll-x {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
}

.tpm-table-wrap {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: var(--tpm-card-shadow);
  max-width: 100%;
}

.tpm-table-wrap.tpm-table-scroll-x,
.tpm-table-wrap.table-responsive,
.tpm-table-wrap > .table-responsive,
.tpm-table-wrap > .tpm-table-scroll-x,
.tpm-panel-body.table-responsive,
.tpm-panel-body:has(> table) {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
}

.tpm-table-wrap:has(> .table-responsive),
.tpm-table-wrap:has(> .tpm-table-scroll-x) {
  overflow-x: visible;
}

.tpm-table-wrap:has(> table.table) {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
}

.tpm-table-wrap .table-head {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  font-weight: 600;
  font-size: 0.9rem;
}

.tpm-table-wrap .table {
  margin-bottom: 0;
  font-size: 0.8rem;
}

.tpm-table-wrap .table th {
  border-top: 0;
  background: #f8fafc;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}

.badge-status-completed {
  background: #dcfce7;
  color: #166534;
}

.badge-status-processing {
  background: #fef3c7;
  color: #92400e;
}

/* ——— Mobile ——— */
.tpm-sidebar-toggle {
  display: none;
}

@media (max-width: 991.98px) {
  .tpm-sidebar {
    transform: translateX(-100%);
  }

  .tpm-sidebar.open {
    transform: translateX(0);
  }

  .tpm-main {
    margin-left: 0;
  }

  .tpm-sidebar-toggle {
    display: inline-flex;
  }

  .tpm-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1025;
  }

  .tpm-sidebar-backdrop.show {
    display: block;
  }

  .tpm-hero-deco {
    display: none;
  }

  .tpm-hero-brand::after {
    display: none;
  }
}

/* ——— Brand logo ——— */
.tpm-brand {
  display: inline-block;
  line-height: 0;
  max-width: 100%;
}

.tpm-brand-img {
  display: block;
  height: auto;
  max-width: 100%;
  object-fit: contain;
}

.tpm-brand-tag {
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  margin-top: 0.35rem;
  text-transform: uppercase;
  font-weight: 500;
  line-height: 1.3;
}

.tpm-brand-light .tpm-brand-tag {
  color: var(--tpm-gold-light);
}

.tpm-brand-dark .tpm-brand-tag {
  color: #3d5a50;
}

.tpm-brand-sidebar .tpm-brand-img {
  width: 168px;
}

.tpm-brand-compact .tpm-brand-img {
  width: min(220px, 56vw);
}

.tpm-brand-on-light .tpm-brand-img {
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(6, 42, 32, 0.12);
}

.tpm-member-status {
  font-weight: 600;
  font-size: 0.85rem;
}

.tpm-member-status.is-active {
  color: #22c55e;
}

.tpm-member-status.is-inactive {
  color: #ef4444;
}

/* ——— Topbar user ——— */
.tpm-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tpm-green-mid), var(--tpm-green-deep));
  color: var(--tpm-gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  border: 2px solid rgba(212, 175, 55, 0.45);
}

.tpm-user-role {
  font-size: 0.65rem !important;
}

/* ——— Auth login (admin + member) ——— */
.tpm-auth-login {
  background: #e8ece9;
}

.tpm-auth-login .tpm-app-wrap,
.tpm-auth-login .tpm-main {
  display: none;
}

.tpm-login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background-color: #dce8e2;
  background-image:
    linear-gradient(165deg, rgba(6, 42, 32, 0.92) 0%, rgba(10, 61, 46, 0.88) 42%, rgba(212, 175, 55, 0.15) 100%),
    url("../img/login-suite-reference.jpg");
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
}

/* ——— Join / registration (public) ——— */
body.tpm-join-page {
  background: #06080c;
}

.tpm-join-shell {
  position: relative;
  min-height: 100vh;
  background-color: #0a1014;
  background-image:
    linear-gradient(
      165deg,
      rgba(6, 42, 32, 0.9) 0%,
      rgba(8, 14, 22, 0.82) 45%,
      rgba(4, 8, 12, 0.88) 100%
    ),
    var(--tpm-join-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.tpm-join-shell-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 60% at 50% 100%, rgba(0, 230, 118, 0.08) 0%, transparent 55%);
}

.tpm-join-container {
  position: relative;
  z-index: 1;
}

.tpm-join-panel {
  border-radius: 16px;
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

@media (max-width: 767px) {
  .tpm-join-shell {
    background-attachment: scroll;
  }
}

.tpm-login-header {
  padding: 1.25rem 2rem 0.5rem;
  position: relative;
  z-index: 2;
}

.tpm-login-header .tpm-brand-img {
  width: min(158px, 40vw);
}

.tpm-login-header-tagline {
  padding-top: 0.35rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  letter-spacing: 0.06em;
  font-size: 0.65rem;
}

.tpm-login-main {
  padding: 1rem 2rem 2rem;
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
}

.tpm-login-headline {
  font-size: 1.65rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
  margin-bottom: 1.25rem;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.tpm-login-sub {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.tpm-login-features {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tpm-login-features li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.85rem;
}

.tpm-login-features .feat-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.95);
  color: var(--tpm-green-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.tpm-login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(6, 42, 32, 0.22);
  padding: 2rem 2rem 1.75rem;
  max-width: 440px;
  position: relative;
}

.tpm-login-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--tpm-green-deep);
  color: var(--tpm-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin: 0 auto 1rem;
  border: 3px solid rgba(212, 175, 55, 0.5);
}

.tpm-login-card-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #0a1f18;
}

.tpm-login-card-lead {
  text-align: center;
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.tpm-input-pill {
  border-radius: 999px !important;
  padding: 0.65rem 1rem 0.65rem 2.75rem !important;
  border: 1px solid #e2e8f0 !important;
  font-size: 0.875rem;
  height: auto;
}

.tpm-input-icon-wrap {
  position: relative;
}

.tpm-input-icon-wrap .input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  z-index: 3;
  pointer-events: none;
}

.tpm-toggle-password {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8 !important;
  padding: 0.25rem 0.5rem;
  z-index: 3;
}

.tpm-link-green {
  color: var(--tpm-green-mid) !important;
  font-weight: 600;
}

.tpm-link-green:hover {
  color: var(--tpm-gold-dark) !important;
  text-decoration: none;
}

.tpm-btn-gradient {
  background: linear-gradient(90deg, #0a3d2e 0%, #0d5c45 45%, #d4af37 100%);
  border: 0;
  color: #fff !important;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 8px 20px rgba(10, 61, 46, 0.35);
}

.tpm-btn-gradient:hover {
  filter: brightness(1.05);
  color: #fff;
}

.tpm-btn-arrow {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.tpm-login-divider {
  text-align: center;
  margin: 1.25rem 0 1rem;
  font-size: 0.75rem;
  color: #94a3b8;
  position: relative;
}

.tpm-login-divider span {
  background: #fff;
  padding: 0 0.75rem;
  position: relative;
  z-index: 1;
}

.tpm-login-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px solid #e2e8f0;
}

.tpm-login-footer {
  background: rgba(4, 26, 20, 0.92);
  border-top: 2px solid var(--tpm-gold);
  padding: 0.85rem 1rem 1rem;
  text-align: center;
  position: relative;
  z-index: 2;
}

.tpm-login-footer-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 1.5rem;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--tpm-gold-light);
  margin-bottom: 0.35rem;
}

.tpm-login-footer-pills i {
  font-size: 0.45rem;
  margin-right: 0.25rem;
  opacity: 0.8;
}

.tpm-login-copyright {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.55);
}

.tpm-notify-menu {
  width: min(22rem, 92vw);
  max-height: 70vh;
  overflow: auto;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.tpm-notify-item,
.tpm-notify-card {
  white-space: normal;
  text-align: left;
}

.tpm-notify-card {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid #e2e8f0;
  background: transparent;
  padding: 0.75rem 0.25rem;
  margin: 0;
}

.tpm-notify-card:last-of-type {
  border-bottom: 0;
}

.tpm-notify-unread {
  background: #fff7ed;
  font-weight: 700;
}

.tpm-notify-card.tpm-notify-unread {
  border-left: 3px solid #b45309;
  padding-left: 0.6rem;
}

.tpm-notify-title {
  font-weight: 700;
}

.tpm-notify-card:not(.tpm-notify-unread) .tpm-notify-title {
  font-weight: 600;
}

.tpm-notify-body,
.tpm-notify-time {
  font-weight: 400;
  font-size: 0.8125rem;
  color: #64748b;
}

.tpm-notify-unread .tpm-notify-body {
  color: #1e293b;
}

.tpm-broadcast-chip .close {
  float: none;
  font-size: 1rem;
  line-height: 1;
}

.tpm-popup-thumb {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  background: #f8fafc;
}

.tpm-popup-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.72);
}

.tpm-popup-overlay[hidden] {
  display: none !important;
}

body.tpm-popup-lock {
  overflow: hidden;
}

.tpm-popup-dialog {
  position: relative;
  max-width: 100%;
  max-height: 100%;
}

.tpm-popup-dialog img {
  display: block;
  max-width: min(92vw, 960px);
  max-height: calc(100vh - 6.5rem);
  width: auto;
  height: auto;
  margin: 0 auto;
  background: #fff;
}

.tpm-popup-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  min-width: 44px;
  min-height: 44px;
}

@media (max-width: 991.98px) {
  .tpm-login-card {
    max-width: 100%;
    margin-top: 0.5rem;
  }

  .tpm-login-header,
  .tpm-login-main {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Genealogy list tree — corporate styling (matches portal green / gold) */
.tpm-genealogy-board {
  background: var(--tpm-content-bg);
  padding: 1rem 1.15rem 1.25rem;
  border-color: #d8e0dc !important;
}

.tpm-genealogy-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tpm-genealogy-children {
  margin: 0.4rem 0 0.1rem;
  padding: 0 0 0 1.25rem;
  border-left: 2px solid #c5d4ce;
}

.tpm-genealogy-item + .tpm-genealogy-item {
  margin-top: 0.4rem;
}

.tpm-genealogy-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 0.9rem 0.65rem 0.75rem;
  border-radius: 6px;
  color: #1a2e28;
  background: #fff;
  border: 1px solid #dde4e0;
  cursor: pointer;
  box-shadow: var(--tpm-card-shadow);
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.tpm-genealogy-card.has-children:hover {
  background: #fafcfb;
  border-color: #b8c9c2;
  box-shadow: 0 4px 14px rgba(6, 42, 32, 0.1);
}

.tpm-genealogy-card--depth-0,
.tpm-genealogy-item-root > .tpm-genealogy-card {
  border-left: 4px solid var(--tpm-gold-dark);
  background: linear-gradient(90deg, #fffef9 0%, #ffffff 55%);
}

.tpm-genealogy-card--depth-1 {
  border-left: 4px solid var(--tpm-green-mid);
}

.tpm-genealogy-card--depth-2 {
  border-left: 4px solid #2d6a4f;
}

.tpm-genealogy-card--depth-3 {
  border-left: 4px solid #3d5a80;
}

.tpm-genealogy-card--depth-4 {
  border-left: 4px solid #64748b;
}

.tpm-genealogy-card--loading {
  background: #f1f5f3;
  border-left: 4px solid #94a3b8;
  color: #64748b;
  cursor: default;
  justify-content: center;
  font-size: 0.875rem;
}

.tpm-genealogy-avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  background: var(--tpm-green-mid);
  border: 2px solid #e8eeeb;
}

.tpm-genealogy-avatar--0 {
  background: linear-gradient(145deg, var(--tpm-green-deep), var(--tpm-green-mid));
}

.tpm-genealogy-avatar--1 {
  background: linear-gradient(145deg, #2d6a4f, #40916c);
}

.tpm-genealogy-avatar--2 {
  background: linear-gradient(145deg, #3d5a80, #5a7a9e);
}

.tpm-genealogy-avatar--3 {
  background: linear-gradient(145deg, var(--tpm-gold-dark), var(--tpm-gold));
  color: #1a2e28;
}

.tpm-genealogy-avatar--4 {
  background: linear-gradient(145deg, #475569, #64748b);
}

.tpm-genealogy-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.tpm-genealogy-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: #0f241c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tpm-genealogy-id {
  font-size: 0.8125rem;
  color: #64748b;
  margin-top: 0.15rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.tpm-genealogy-chevron {
  flex: 0 0 auto;
  font-size: 0.85rem;
  color: var(--tpm-green-deep);
  opacity: 0.75;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.tpm-genealogy-card.has-children:hover .tpm-genealogy-chevron {
  opacity: 1;
}

.tpm-genealogy-item.is-expanded > .tpm-genealogy-card .tpm-genealogy-chevron {
  transform: rotate(90deg);
  color: var(--tpm-gold-dark);
  opacity: 1;
}

.tpm-genealogy-empty {
  padding: 0.4rem 0.5rem 0.4rem 2.5rem;
  color: #64748b;
}

.tpm-genealogy-item.is-selected > .tpm-genealogy-card {
  border-color: var(--tpm-gold);
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.45), var(--tpm-card-shadow);
  background: #fffef9;
}

.tpm-tree-details .tpm-panel-body div + div {
  margin-top: 0.35rem;
}

.tpm-genealogy-item.is-loading > .tpm-genealogy-card {
  opacity: 0.92;
}

/* Member network — sunflower / level tree view */
.tpm-sf-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: min(70vh, 720px);
  background: var(--tpm-content-bg);
}

.tpm-sf-canvas {
  transform-origin: top center;
  padding: 1.25rem 1rem 2rem;
  min-width: min(100%, 320px);
}

.tpm-sunflower-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tpm-sf-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  margin: 0 0.35rem;
}

.tpm-sf-children-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  padding-top: 0.5rem;
  gap: 0.5rem;
}

.tpm-sf-children-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 2px;
  background: #c5d4ce;
}

.tpm-sf-stem {
  width: 2px;
  height: 1.25rem;
  background: linear-gradient(180deg, var(--tpm-gold-dark), var(--tpm-green-mid));
  border-radius: 1px;
}

.tpm-sf-node {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid #dde4e0;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--tpm-card-shadow);
  cursor: pointer;
  text-align: left;
  max-width: 11rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tpm-sf-node:hover,
.tpm-sf-node.is-selected {
  border-color: var(--tpm-gold);
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.4), var(--tpm-card-shadow);
}

.tpm-sf-node-root {
  border-left: 4px solid var(--tpm-gold-dark);
  max-width: 13rem;
}

.tpm-sf-node.is-inactive {
  opacity: 0.88;
}

.tpm-sf-node-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--tpm-green-deep), var(--tpm-green-mid));
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tpm-sf-node-root .tpm-sf-node-avatar {
  background: linear-gradient(145deg, var(--tpm-gold-dark), var(--tpm-gold));
  color: #1a2e28;
}

.tpm-sf-node-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.tpm-sf-node-name {
  font-weight: 600;
  font-size: 0.8125rem;
  color: #0f241c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tpm-sf-node-id,
.tpm-sf-node-level {
  font-size: 0.7rem;
  color: #64748b;
}

.tpm-sf-more {
  text-align: center;
  margin: 0.25rem 0 0;
}

.tpm-sf-detail-panel .tpm-panel-body div + div {
  margin-top: 0.25rem;
}

@media (max-width: 767.98px) {
  .tpm-sf-scroll {
    max-height: none;
  }

  .tpm-sf-children-row {
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}
