/* =====================================================================
   ECOLOGICS AFFILIATE & MLM BINARY PLATFORM — Design System
   Palette: White base / Green primary (from logo) / Gold-Yellow secondary
   ===================================================================== */

:root {
  /* Brand palette pulled from the E-cologics leaf-and-ring mark */
  --eco-green-900: #0d3d1c;
  --eco-green-700: #1a6b32;
  --eco-green-600: #1f8a3d;
  --eco-green-500: #2fa84e;   /* primary */
  --eco-green-100: #e5f5ea;
  --eco-green-50:  #f3fbf5;

  --eco-gold-700: #a8760a;
  --eco-gold-600: #c8940f;
  --eco-gold-500: #e0ac1c;   /* secondary */
  --eco-gold-300: #f0cc63;
  --eco-gold-100: #fdf3d9;

  --eco-white: #ffffff;
  --eco-ink-900: #16241a;
  --eco-ink-600: #4b5c50;
  --eco-ink-400: #8a9a8f;
  --eco-border: #e2ece4;
  --eco-danger: #c0392b;
  --eco-danger-bg: #fdecea;
  --eco-success-bg: #e8f7ec;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-card: 0 4px 24px rgba(13, 61, 28, 0.08);
  --shadow-pop: 0 10px 40px rgba(13, 61, 28, 0.16);

  --font-display: 'Poppins', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* Member portal PWA installation controls */
.pwa-install-button{position:fixed;right:18px;bottom:18px;z-index:1100;border:0;border-radius:999px;padding:12px 18px;background:#0b5d2a;color:#fff;font:700 .86rem Inter,sans-serif;box-shadow:0 10px 28px rgba(11,93,42,.3);cursor:pointer}.pwa-install-button:hover{background:#084b22}.pwa-install-tip{position:fixed;left:16px;right:16px;bottom:78px;z-index:1101;max-width:430px;margin:auto;align-items:center;gap:10px;padding:14px 16px;border:1px solid #cfe4d6;border-radius:14px;background:#fff;color:#173d26;box-shadow:0 14px 35px rgba(18,59,35,.2)}.pwa-install-tip strong{white-space:nowrap}.pwa-install-tip span{flex:1;font-size:.8rem;line-height:1.35;color:#607568}.pwa-install-tip button{border:0;background:transparent;color:#587063;font-size:1.5rem;line-height:1;cursor:pointer}@media(max-width:480px){.pwa-install-button{right:12px;bottom:12px}.pwa-install-tip{bottom:68px;align-items:flex-start;flex-wrap:wrap}.pwa-install-tip span{min-width:180px}}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--eco-green-50);
  color: var(--eco-ink-900);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .display {
  font-family: var(--font-display);
  color: var(--eco-green-900);
  margin: 0 0 .5rem;
  font-weight: 600;
}

a { color: var(--eco-green-600); text-decoration: none; }
a:hover { color: var(--eco-green-700); }

img { max-width: 100%; display: block; }

::selection { background: var(--eco-gold-300); color: var(--eco-green-900); }

:focus-visible {
  outline: 3px solid var(--eco-gold-500);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   Auth Layout (Login / Register)
   --------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: linear-gradient(160deg, var(--eco-green-900) 0%, var(--eco-green-700) 45%, var(--eco-green-600) 100%);
}

.auth-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem 3.5rem;
  color: var(--eco-white);
  overflow: hidden;
}

.auth-visual::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto auto;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(224,172,28,.35), transparent 70%);
  border-radius: 50%;
}

.auth-visual::after {
  content: "";
  position: absolute;
  left: -12%;
  bottom: -18%;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(255,255,255,.10), transparent 70%);
  border-radius: 50%;
}

.auth-visual .brand-logo {
  width: 108px;
  height: auto;
  margin-bottom: 2rem;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.25));
}

.auth-visual h1 {
  color: var(--eco-white);
  font-size: 2.35rem;
  line-height: 1.15;
  max-width: 480px;
}

.auth-visual .accent { color: var(--eco-gold-300); }

.auth-visual p {
  color: rgba(255,255,255,.85);
  max-width: 440px;
  font-size: 1.02rem;
  line-height: 1.6;
}

.auth-stats {
  display: flex;
  gap: 2.25rem;
  margin-top: 2.5rem;
  position: relative;
  z-index: 1;
}

.auth-stats div strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--eco-gold-300);
}

.auth-stats div span {
  font-size: .8rem;
  color: rgba(255,255,255,.75);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.auth-form-panel {
  background: var(--eco-white);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
}

.auth-card .mobile-logo { display: none; }

.auth-card h2 {
  font-size: 1.6rem;
}

.auth-card .subtitle {
  color: var(--eco-ink-600);
  margin-bottom: 1.75rem;
  font-size: .95rem;
}

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.form-group { margin-bottom: 1.15rem; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--eco-ink-900);
  margin-bottom: .4rem;
}

label .req { color: var(--eco-danger); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: .78rem .95rem;
  border: 1.5px solid var(--eco-border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-family: var(--font-body);
  background: var(--eco-white);
  color: var(--eco-ink-900);
  transition: border-color .15s ease, box-shadow .15s ease;
}

/* ERP/admin forms often use an omitted type attribute, which browsers treat
   as text but which does not match input[type="text"]. Keep every data-entry
   field visually consistent without affecting radios, checkboxes, or files. */
.page-content .form-group input:not([type]),
.page-content .form-group input[type="date"] {
  width: 100%;
  padding: .78rem .95rem;
  border: 1.5px solid var(--eco-border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-family: var(--font-body);
  background: var(--eco-white);
  color: var(--eco-ink-900);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.page-content .form-row > .form-group { min-width: 0; }
.page-content input, .page-content select, .page-content textarea { box-sizing: border-box; }
.page-content .table-wrap select { min-width: 150px; }
.page-content .table-wrap .btn { white-space: nowrap; }
.erp-export-actions { margin: 1.25rem 0 .9rem; flex-wrap: wrap; }
.page-content .grid + .alert { margin-top: 1rem; }
.page-content .erp-export-actions + .alert { margin-top: 0; }

/* Live customer/technical support */
.support-chat { max-width: 900px; }
.chat-meta { padding:.75rem 1rem; background:var(--eco-green-50); border-radius:var(--radius-sm); font-size:.85rem; color:var(--eco-ink-600); margin-bottom:.75rem; }
.chat-messages { height:430px; overflow-y:auto; padding:1rem; background:#f7faf8; border:1px solid var(--eco-border); border-radius:var(--radius-sm); }
.chat-row { display:flex; margin:.55rem 0; }
.chat-row.mine { justify-content:flex-end; }
.chat-bubble { max-width:72%; padding:.7rem .9rem; border-radius:14px; background:var(--eco-white); border:1px solid var(--eco-border); box-shadow:0 2px 7px rgba(10,50,25,.06); }
.chat-row.mine .chat-bubble { background:var(--eco-green-500); color:white; border-color:var(--eco-green-500); }
.chat-bubble strong,.chat-bubble small { display:block; font-size:.72rem; opacity:.78; }
.chat-bubble small { margin-top:.35rem; }
.chat-compose { display:flex; gap:.75rem; align-items:flex-end; margin-top:.85rem; }
.chat-compose textarea { flex:1; resize:vertical; }
.support-admin-grid { display:grid; grid-template-columns:340px minmax(0,1fr); gap:1rem; }
.support-inbox { max-height:650px; overflow-y:auto; }
.conversation-item { width:100%; display:flex; flex-direction:column; text-align:left; gap:.2rem; border:0; border-bottom:1px solid var(--eco-border); background:white; padding:.85rem; cursor:pointer; font-family:var(--font-body); }
.conversation-item:hover,.conversation-item:focus { background:var(--eco-green-50); }
.conversation-item span,.conversation-item small { color:var(--eco-ink-400); }
.chat-meta { display:flex; flex-direction:column; gap:.2rem; }
.support-resolution { display:flex; flex-direction:column; gap:.4rem; margin:0 0 .85rem; padding:1rem; border:1px solid #9fd5af; border-left:5px solid var(--eco-green-500); border-radius:var(--radius-sm); background:#effaf2; color:var(--eco-ink-700); font-size:.86rem; }
.support-resolution strong { color:var(--eco-green-700); font-size:.95rem; }
.support-resolve-panel { margin-top:1rem; padding:1rem; border:1px solid var(--eco-border); border-radius:var(--radius-sm); background:#fbfdfb; }
.support-resolve-panel h4 { margin:0 0 .75rem; }
.support-resolve-panel .form-row { align-items:flex-start; }
.support-resolve-panel textarea { min-height:90px; resize:vertical; }
@media(max-width:800px){.support-admin-grid{grid-template-columns:1fr}.chat-messages{height:360px}.chat-bubble{max-width:88%}.chat-compose{flex-direction:column;align-items:stretch}}

input:focus, select:focus, textarea:focus {
  border-color: var(--eco-green-500);
  box-shadow: 0 0 0 4px rgba(47,168,78,.12);
  outline: none;
}

.help-text { font-size: .78rem; color: var(--eco-ink-400); margin-top: .3rem; }

.side-toggle {
  display: flex;
  gap: .75rem;
}

.side-toggle label {
  flex: 1;
  border: 1.5px solid var(--eco-border);
  border-radius: var(--radius-sm);
  padding: .7rem;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  color: var(--eco-ink-600);
  margin: 0;
  transition: all .15s ease;
}

.side-toggle input { display: none; }
.side-toggle input:checked + span { color: var(--eco-white); }
.side-toggle label:has(input:checked) {
  background: var(--eco-green-500);
  border-color: var(--eco-green-500);
  color: var(--eco-white);
}

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .8rem 1.4rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .95rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform .1s ease, box-shadow .15s ease, background .15s ease;
  font-family: var(--font-body);
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--eco-green-600), var(--eco-green-500));
  color: var(--eco-white);
  box-shadow: 0 8px 20px rgba(47,168,78,.28);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--eco-green-700), var(--eco-green-600)); color: var(--eco-white); }

.btn-gold {
  background: linear-gradient(135deg, var(--eco-gold-600), var(--eco-gold-500));
  color: var(--eco-green-900);
  box-shadow: 0 8px 20px rgba(224,172,28,.3);
}
.btn-gold:hover { background: linear-gradient(135deg, var(--eco-gold-700), var(--eco-gold-600)); color: var(--eco-green-900); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--eco-green-500);
  color: var(--eco-green-600);
}
.btn-outline:hover { background: var(--eco-green-50); color: var(--eco-green-700); }

.btn-danger { background: var(--eco-danger); color: var(--eco-white); }
.btn-sm { padding: .5rem .9rem; font-size: .82rem; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------------
   Alerts
   --------------------------------------------------------------------- */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: 1.1rem;
  border-left: 4px solid transparent;
}
.alert-error { background: var(--eco-danger-bg); color: var(--eco-danger); border-color: var(--eco-danger); }
.alert-success { background: var(--eco-success-bg); color: var(--eco-green-700); border-color: var(--eco-green-500); }
.alert-info { background: var(--eco-gold-100); color: var(--eco-gold-700); border-color: var(--eco-gold-500); }

/* ---------------------------------------------------------------------
   App Shell (Dashboard + Admin)
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--eco-green-900), var(--eco-green-700));
  color: var(--eco-white);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform .2s ease;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1.4rem 1.4rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand img { width: 40px; }
.sidebar-brand span { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.sidebar-brand small { display: block; color: var(--eco-gold-300); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }

.nav-group { padding: 1rem .8rem; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.5); margin: 1rem .6rem .4rem; }

.nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .68rem .9rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.82);
  font-size: .89rem;
  font-weight: 500;
  margin-bottom: .15rem;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: var(--eco-white); }
.nav-link.active { background: var(--eco-gold-500); color: var(--eco-green-900); font-weight: 700; }
.nav-link .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .6; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.75rem;
  background: var(--eco-white);
  border-bottom: 1px solid var(--eco-border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--eco-green-700);
}

.topbar-title h1 { font-size: 1.15rem; margin: 0; }
.topbar-title small { color: var(--eco-ink-400); font-size: .78rem; }

.topbar-user { display: flex; align-items: center; gap: .8rem; flex-shrink: 0; }
.theme-toggle {
  width: 38px; height: 38px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1.5px solid var(--eco-border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.05rem;
  padding: 0;
  transition: background .15s ease;
}
.theme-toggle:hover { background: var(--eco-green-50); }
.theme-toggle-icon-light { display: none; }
html[data-theme="dark"] .theme-toggle-icon-dark { display: none; }
html[data-theme="dark"] .theme-toggle-icon-light { display: inline; }
.avatar {
  width: 38px; height: 38px; min-width: 38px; min-height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--eco-gold-500), var(--eco-green-500));
  color: var(--eco-white); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; overflow: hidden;
}

.page-content { padding: 1.75rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------------------------------------------------------------------
   Cards / Stats / Tables
   --------------------------------------------------------------------- */
.grid { display: grid; gap: 1.25rem; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--eco-white);
  border: 1px solid var(--eco-border);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--eco-ink-400);
  margin-bottom: .3rem;
  font-weight: 700;
}

.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 1.7rem; color: var(--eco-green-800, var(--eco-green-700)); font-weight: 700; }
.stat-card .stat-icon {
  position: absolute; right: 1.1rem; top: 1.1rem;
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--eco-green-100); color: var(--eco-green-600); font-size: 1.2rem;
}
.stat-card.gold .stat-icon { background: var(--eco-gold-100); color: var(--eco-gold-700); }
.stat-card .stat-trend { font-size: .78rem; color: var(--eco-green-600); margin-top: .3rem; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2rem 0 1rem;
}
.section-title h2 { font-size: 1.05rem; margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  text-align: left;
  padding: .8rem 1rem;
  background: var(--eco-green-50);
  color: var(--eco-green-800, var(--eco-green-700));
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--eco-border);
}
tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--eco-border); color: var(--eco-ink-900); }
tbody tr:hover { background: var(--eco-green-50); }
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--eco-border); background: var(--eco-white); }

.badge {
  display: inline-block;
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
/* ---- Processing loaders (see assets/js/main.js ecoButtonLoading /
   the global form-submit listener) ---- */
.btn-spinner {
  display: inline-block; width: 13px; height: 13px; vertical-align: -2px; margin-right: 2px;
  border: 2px solid rgba(0,0,0,.15); border-top-color: currentColor;
  border-radius: 50%; animation: ecoSpin .6s linear infinite;
}
@keyframes ecoSpin { to { transform: rotate(360deg); } }
button.is-loading, input[type="submit"].is-loading { cursor: wait !important; opacity: .85; }
html[data-theme="dark"] .btn-spinner { border-color: rgba(255,255,255,.25); border-top-color: currentColor; }

.badge-green { background: var(--eco-green-100); color: var(--eco-green-700); }
.badge-gold { background: var(--eco-gold-100); color: var(--eco-gold-700); }
.badge-gray { background: #eef1ef; color: var(--eco-ink-600); }
.badge-red { background: var(--eco-danger-bg); color: var(--eco-danger); }

/* ---------------------------------------------------------------------
   Binary Tree Visualization
   --------------------------------------------------------------------- */
.binary-tree-wrap { overflow-x: auto; padding: 1.5rem .5rem; }
.tree { display: flex; flex-direction: column; align-items: center; }
.tree-node-row { display: flex; justify-content: center; }
.tree-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
}
.node-box {
  min-width: 128px;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  background: var(--eco-white);
  border: 2px solid var(--eco-green-500);
  text-align: center;
  font-size: .78rem;
  box-shadow: var(--shadow-card);
}
.node-box.empty { border-style: dashed; border-color: var(--eco-ink-400); color: var(--eco-ink-400); }
.node-box.node-add-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  text-decoration: none;
  cursor: pointer;
  color: var(--eco-green-600);
  border-color: var(--eco-green-400, var(--eco-green-500));
  font-weight: 700;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.node-box.node-add-link:hover {
  background: var(--eco-green-50);
  border-color: var(--eco-green-600);
  border-style: solid;
  transform: translateY(-2px);
}
.node-box.locked {
  border-style: dashed;
  border-color: var(--eco-ink-400);
  color: var(--eco-ink-400);
  background: repeating-linear-gradient(135deg, var(--eco-white), var(--eco-white) 6px, var(--eco-green-50) 6px, var(--eco-green-50) 12px);
  cursor: not-allowed;
  font-weight: 600;
}
.node-add-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--eco-green-500);
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.node-box.inactive { border-color: var(--eco-gold-500); }
.node-box strong { display: block; font-size: .82rem; color: var(--eco-green-800, var(--eco-green-700)); }
.node-avatar, .node-avatar-placeholder {
  width: 42px; min-width: 42px; max-width: 42px;
  height: 42px; min-height: 42px; max-height: 42px;
  flex-shrink: 0; border-radius: 50%; object-fit: cover;
  margin: 0 auto .35rem; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--eco-green-500);
}
.node-box { display: inline-block; }
.node-avatar-placeholder { background: linear-gradient(135deg, var(--eco-gold-500), var(--eco-green-500)); color: #fff; font-weight: 700; font-size: .95rem; font-family: var(--font-display); }
.node-children { display: flex; gap: 2.5rem; margin-top: 1.75rem; position: relative; }
.node-children::before {
  content: "";
  position: absolute;
  top: -1.75rem;
  left: 50%;
  width: 1px;
  height: 1.75rem;
  background: var(--eco-border);
}

/* ---------------------------------------------------------------------
   Landing minimal footer note / misc
   --------------------------------------------------------------------- */
.muted { color: var(--eco-ink-400); }
.text-right { text-align: right; }
.flex { display: flex; align-items: center; }
.gap-sm { gap: .5rem; }
.gap-md { gap: 1rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-card .mobile-logo { display: flex; justify-content: center; margin-bottom: 1.5rem; }
  .auth-card .mobile-logo img { width: 84px; }
}

@media (max-width: 768px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-pop);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar .menu-toggle { display: block; }
  .page-content { padding: 1.1rem; }
  .auth-form-panel { padding: 2rem 1.25rem; }
  .node-children { gap: 1rem; }
  .node-box { min-width: 100px; font-size: .7rem; }

  /* Decluttered mobile header: the account-type badge and page subtitle
     are redundant with what's already shown in the page content below,
     so they're the first things dropped to give the title room and keep
     the notification bell + avatar from getting squeezed. */
  .topbar { padding: .75rem 1rem; gap: .5rem; }
  .topbar-title { min-width: 0; }
  .topbar-title small { display: none; }
  .topbar-user { gap: .5rem; }
  .topbar-user .badge { display: none; }
}

@media (max-width: 480px) {
  .auth-card h2 { font-size: 1.35rem; }
  .topbar-title h1 { font-size: 1rem; }
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(13,61,28,.45);
  z-index: 35;
}
.sidebar-backdrop.show { display: block; }

/* ---------------------------------------------------------------------
   Announcement Popup (Affiliate Dashboard)
   --------------------------------------------------------------------- */
.announcement-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(13,61,28,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
  z-index: 1200;
}
.announcement-modal-backdrop[hidden] { display: none; }
.announcement-modal {
  position: relative;
  width: 100%; max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--eco-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  animation: eco-modal-pop .18s ease;
}
@keyframes eco-modal-pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.announcement-modal-close {
  position: absolute; top: .6rem; right: .6rem;
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #fff;
  font-size: 1.3rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.announcement-modal-close:hover { background: rgba(0,0,0,.65); }
.announcement-modal-img { width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.announcement-modal-body { padding: 1.4rem; }
.announcement-modal-body h3 { font-size: 1.25rem; }
.announcement-modal-body p { color: var(--eco-ink-600); line-height: 1.55; margin: 0 0 1.25rem; white-space: pre-line; }

/* ---------------------------------------------------------------------
   News & Updates feed (dashboard/news.php)
   --------------------------------------------------------------------- */
.news-post { display: flex; gap: 1.1rem; padding: 1.1rem 0; border-bottom: 1px solid var(--eco-border); }
.news-post:last-child { border-bottom: none; }
.news-post-img { width: 140px; height: 100px; flex-shrink: 0; object-fit: cover; border-radius: var(--radius-sm); background: var(--eco-green-50); }
.news-post-body { min-width: 0; }
.news-post-body h3 { font-size: 1.02rem; margin-bottom: .25rem; }
.news-post-date { font-size: .76rem; color: var(--eco-ink-400); margin-bottom: .4rem; }
.news-post-body p { color: var(--eco-ink-600); font-size: .9rem; line-height: 1.55; white-space: pre-line; margin: 0; }
@media (max-width: 560px) { .news-post { flex-direction: column; } .news-post-img { width: 100%; height: 160px; } }

html[data-theme="dark"] .announcement-modal { background: #16211a; }
html[data-theme="dark"] .announcement-modal-body p { color: #b7c4bb; }
html[data-theme="dark"] .news-post { border-color: #2a3830; }
html[data-theme="dark"] .news-post-img { background: #16211a; }
html[data-theme="dark"] .news-post-date { color: #8fa398; }
html[data-theme="dark"] .news-post-body p { color: #b7c4bb; }

/* ---------------------------------------------------------------------
   Admin Panel — Dark Theme
   Activated only when <html data-theme="dark"> is set (Admin > topbar
   toggle, see admin/includes/header.php + assets/js/main.js). The
   Affiliate Dashboard never sets this attribute, so it always stays on
   the light theme above regardless of what an Admin has chosen.
   The sidebar's own dark-green branding is intentionally left unchanged
   in both themes - only the main content area, cards, tables, and forms
   switch.
   --------------------------------------------------------------------- */
html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="dark"] body {
  background: #0f1712;
  color: #e8f0ea;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] .display {
  color: #6fe0a0;
}

html[data-theme="dark"] a { color: #6fe0a0; }
html[data-theme="dark"] a:hover { color: #8fe8b6; }

html[data-theme="dark"] label { color: #e8f0ea; }
html[data-theme="dark"] .help-text,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .topbar-title small { color: #8fa398; }

html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="file"],
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .page-content .form-group input:not([type]) {
  background: #16211a;
  color: #e8f0ea;
  border-color: #2a3830;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #6b7c72; }

html[data-theme="dark"] .topbar {
  background: #131c16;
  border-color: #2a3830;
}
html[data-theme="dark"] .theme-toggle { border-color: #2a3830; color: #e8f0ea; }
html[data-theme="dark"] .theme-toggle:hover { background: #1b241d; }

html[data-theme="dark"] .card,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .node-box,
html[data-theme="dark"] .auth-form-panel {
  background: #16211a;
  border-color: #2a3830;
}

html[data-theme="dark"] .chat-messages { background: #12201a; }
html[data-theme="dark"] .chat-bubble { background: #1b241d; border-color: #2a3830; }
html[data-theme="dark"] .conversation-item { background: #16211a; border-color: #2a3830; }
html[data-theme="dark"] .conversation-item:hover,
html[data-theme="dark"] .conversation-item:focus { background: #1b241d; }
html[data-theme="dark"] .support-resolution { background: #123821; border-color: #1f5c34; }
html[data-theme="dark"] .support-resolve-panel { background: #16211a; border-color: #2a3830; }

html[data-theme="dark"] table { color: #e8f0ea; }
html[data-theme="dark"] thead th {
  background: #131c16;
  color: #6fe0a0;
  border-color: #2a3830;
}
html[data-theme="dark"] tbody td { color: #e8f0ea; border-color: #2a3830; }
html[data-theme="dark"] tbody tr:hover { background: #1b241d; }

html[data-theme="dark"] .stat-card .stat-value { color: #6fe0a0; }
html[data-theme="dark"] .stat-card .stat-icon { background: #163d26; color: #6fe0a0; }
html[data-theme="dark"] .stat-card.gold .stat-icon { background: #3a2f10; color: #f0cc63; }
html[data-theme="dark"] .stat-card .stat-trend { color: #6fe0a0; }

html[data-theme="dark"] .badge-green { background: #163d26; color: #6fe0a0; }
html[data-theme="dark"] .badge-gold { background: #3a2f10; color: #f0cc63; }
html[data-theme="dark"] .badge-gray { background: #232e27; color: #b7c4bb; }
html[data-theme="dark"] .badge-red { background: #3a1c1a; color: #f28b82; }

html[data-theme="dark"] .alert-error { background: #3a1c1a; color: #f28b82; border-color: #c0392b; }
html[data-theme="dark"] .alert-success { background: #123821; color: #6fe0a0; border-color: #2fa84e; }
html[data-theme="dark"] .alert-info { background: #3a2f10; color: #f0cc63; border-color: #e0ac1c; }

html[data-theme="dark"] .btn-outline { color: #6fe0a0; border-color: #2fa84e; }
html[data-theme="dark"] .btn-outline:hover { background: #163d26; color: #8fe8b6; }

html[data-theme="dark"] .side-toggle label { border-color: #2a3830; color: #b7c4bb; }

html[data-theme="dark"] .node-box strong { color: #6fe0a0; }
html[data-theme="dark"] .node-box.empty,
html[data-theme="dark"] .node-box.locked { color: #6b7c72; border-color: #3a4a40; }
html[data-theme="dark"] .node-box.locked {
  background: repeating-linear-gradient(135deg, #16211a, #16211a 6px, #12201a 6px, #12201a 12px);
}
html[data-theme="dark"] .node-box.node-add-link { color: #6fe0a0; }
html[data-theme="dark"] .node-box.node-add-link:hover { background: #163d26; }
html[data-theme="dark"] .node-children::before { background: #2a3830; }

html[data-theme="dark"] .page-content .form-group input:not([type]):focus,
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 4px rgba(111,224,160,.15);
}

/* ---- Show/Hide password toggle (auto-applied to all password fields) ---- */
.pw-field { position: relative; }
.pw-field input { padding-right: 3.4rem !important; }
.pw-toggle-btn {
  position: absolute; top: 50%; right: .5rem; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  color: var(--eco-green-700, #0b5d2a); text-transform: uppercase;
}
.pw-toggle-btn:hover { text-decoration: underline; }
html[data-theme="dark"] .pw-toggle-btn { color: #7fd99a; }

/* ---- Dashboard notification bell (Friend requests/accepts, Comments on
   your posts, Chat messages) ---- */
.notif-bell-wrap { position: relative; flex-shrink: 0; }
.notif-bell-btn { position: relative; background: none; border: none; font-size: 1.3rem; cursor: pointer; padding: .3rem .5rem; line-height: 1; }
.notif-badge {
  position: absolute; top: -2px; right: -2px; background: #e0433c; color: #fff; font-size: .62rem; font-weight: 800;
  min-width: 16px; height: 16px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.notif-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); width: 320px; max-width: calc(100vw - 2rem); max-height: 420px;
  overflow-y: auto; background: var(--eco-white); border: 1px solid var(--eco-border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); z-index: 200;
}
.notif-dropdown-head { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--eco-border); }
.notif-mark-all { background: none; border: none; color: var(--eco-green-700); font-size: .78rem; font-weight: 600; cursor: pointer; }
.notif-item { display: block; width: 100%; text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--eco-border); background: none; text-decoration: none; color: inherit; font-size: .84rem; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--eco-green-50); }
.notif-item.unread { background: var(--eco-green-50); font-weight: 600; }
.notif-item .notif-time { display: block; color: var(--eco-ink-600); font-size: .72rem; font-weight: 400; margin-top: .2rem; }
html[data-theme="dark"] .notif-dropdown { background: #16211a; border-color: #2a3830; }
html[data-theme="dark"] .notif-dropdown-head { border-color: #2a3830; }
html[data-theme="dark"] .notif-item { border-color: #2a3830; }
html[data-theme="dark"] .notif-item:hover, html[data-theme="dark"] .notif-item.unread { background: #1b241d; }

/* ---- E-Community (Feed, Friends, Chat, Recharge Followers) ---- */
.community-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.community-tabs a {
  padding: .55rem 1rem; border-radius: 999px; background: var(--eco-white); border: 1px solid var(--eco-border);
  color: var(--eco-ink-700); font-size: .85rem; font-weight: 600; text-decoration: none;
}
.community-tabs a.active { background: var(--eco-green-500); border-color: var(--eco-green-500); color: #fff; }
.community-tabs a:hover:not(.active) { background: var(--eco-green-50); }

.voucher-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .85rem; }
.voucher-card {
  position: relative; display: block; text-align: center; padding: 1.1rem .75rem; border: 2px solid var(--eco-border);
  border-radius: var(--radius-sm); cursor: pointer; background: var(--eco-white);
}
.voucher-card input { position: absolute; top: .6rem; right: .6rem; }
.voucher-card:has(input:checked) { border-color: var(--eco-green-500); background: var(--eco-green-50); }
.voucher-price { font-size: 1.25rem; font-weight: 800; color: var(--eco-green-700); }
.voucher-followers { font-size: .82rem; color: var(--eco-ink-600); margin-top: .25rem; }

.friend-row {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .8rem 0; border-bottom: 1px solid var(--eco-border);
}
.friend-row:last-child { border-bottom: none; }

/* ---- Post cards (shared by the E-Community Feed and every Portfolio's
   Wall - one look for the same unified post system) ---- */
.pf-post {
  background: var(--eco-white); border: 1px solid var(--eco-border); border-radius: var(--radius-sm);
  padding: 1rem 1.15rem; margin-bottom: .9rem; box-shadow: 0 1px 3px rgba(13,61,28,.05);
  transition: box-shadow .18s ease;
}
.pf-post:hover { box-shadow: 0 4px 14px rgba(13,61,28,.08); }
.pf-post-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; font-size: .88rem; margin-bottom: .4rem; }
.pf-post-head .post-author-name { color: var(--eco-green-800, var(--eco-green-700)); }
.pf-post-body { color: var(--eco-ink-700); line-height: 1.55; margin: 0 0 .6rem; white-space: pre-wrap; }
.pf-post-image { width: 100%; max-height: 340px; object-fit: cover; border-radius: 8px; margin-bottom: .6rem; }

.pf-post-owner-actions { display: flex; gap: .35rem; flex-shrink: 0; }
.pf-edit-btn, .pf-delete-btn {
  background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer;
  font-size: .85rem; line-height: 1; padding: .3rem .4rem; opacity: .7; transition: opacity .15s ease, background .15s ease;
}
.pf-edit-btn:hover, .pf-delete-btn:hover { opacity: 1; background: var(--eco-green-50); }

.pf-post-edit-form { margin: .3rem 0 .75rem; }
.pf-edit-textarea {
  width: 100%; resize: vertical; padding: .6rem .7rem; border: 1px solid var(--eco-border);
  border-radius: 8px; font: inherit; color: var(--eco-ink-800, var(--eco-ink-700));
}
.pf-edit-current-photo { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; }
.pf-edit-current-photo img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.pf-edit-photo-row { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; margin-top: .5rem; font-size: .82rem; }
.pf-edit-photo-row label { display: inline-flex; align-items: center; gap: .35rem; color: var(--eco-ink-600); cursor: pointer; }
.pf-edit-actions { display: flex; gap: .5rem; margin-top: .75rem; }
.pf-edit-error { margin-top: .6rem; padding: .5rem .7rem; font-size: .82rem; }

.pf-post-actions { display: flex; gap: .6rem; margin-top: .2rem; }
.pf-like-btn, .pf-comment-toggle {
  display: inline-flex; align-items: center; gap: .4rem; background: var(--eco-green-50);
  border: 1px solid transparent; border-radius: 999px; cursor: pointer; font-size: .82rem; font-weight: 600;
  color: var(--eco-ink-600); padding: .4rem .95rem; transition: background .18s ease, border-color .18s ease, color .18s ease, transform .12s ease;
}
.pf-like-btn .pf-like-count, .pf-comment-toggle .pf-comment-count { font-variant-numeric: tabular-nums; }
.pf-like-btn:hover, .pf-comment-toggle:hover { border-color: var(--eco-green-500); color: var(--eco-green-700); }
.pf-like-btn:active, .pf-comment-toggle:active { transform: scale(.94); }
.pf-like-btn.liked { background: var(--eco-green-500); color: #fff; }
.pf-like-btn.liked:hover { color: #fff; border-color: var(--eco-green-500); }
@keyframes pfLikePop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
.pf-like-btn.pf-pop { animation: pfLikePop .3s ease; }

.pf-comments { margin-top: .75rem; border-top: 1px dashed var(--eco-border); padding-top: .65rem; }
.pf-comments-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.pf-comment-row { font-size: .83rem; background: var(--eco-green-50); border-radius: 6px; padding: .4rem .6rem; }
.pf-comment-row strong { color: var(--eco-green-700); }
.pf-comment-form { display: flex; gap: .4rem; }
.pf-comment-form input { flex: 1; padding: .45rem .6rem; border: 1px solid var(--eco-border); border-radius: 999px; font-size: .83rem; }

html[data-theme="dark"] .community-tabs a { background: #16211a; border-color: #2a3830; color: #e6efe9; }
html[data-theme="dark"] .community-tabs a.active { background: var(--eco-green-500); color: #08210f; }
html[data-theme="dark"] .voucher-card { background: #16211a; border-color: #2a3830; }
html[data-theme="dark"] .voucher-card:has(input:checked) { background: #123821; border-color: #6fe0a0; }
html[data-theme="dark"] .friend-row { border-color: #2a3830; }
html[data-theme="dark"] .pf-post { background: #16211a; border-color: #2a3830; }
html[data-theme="dark"] .pf-comment-row { background: #1b241d; }
html[data-theme="dark"] .pf-like-btn, html[data-theme="dark"] .pf-comment-toggle { background: #1b241d; color: #c9d6ce; }
html[data-theme="dark"] .pf-like-btn:hover, html[data-theme="dark"] .pf-comment-toggle:hover { color: #7fd99a; border-color: #7fd99a; }
html[data-theme="dark"] .pf-like-btn.liked { background: var(--eco-green-500); color: #08210f; }
html[data-theme="dark"] .pf-edit-btn:hover, html[data-theme="dark"] .pf-delete-btn:hover { background: #1b241d; }
html[data-theme="dark"] .pf-edit-textarea { background: #16211a; border-color: #2a3830; color: #e6efe9; }

/* ---------------------------------------------------------------------
   E-Academy & Product Banner Slider (dashboard section + full page)
   --------------------------------------------------------------------- */
.academy-shop-grid { align-items: stretch; }
.academy-card, .product-slider-card { display: flex; flex-direction: column; }
.academy-banner-img {
  width: 100%; height: 160px; object-fit: cover; border-radius: var(--radius-sm, 10px);
  display: block;
}
.academy-meeting-content { font-size: .88rem; color: var(--eco-ink-600); line-height: 1.6; margin: 0 0 .6rem; white-space: pre-line; }
.academy-join-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .3rem; }

.product-slider { position: relative; overflow: hidden; border-radius: var(--radius-sm, 10px); background: var(--eco-green-50); }
.product-slider-track { display: flex; transition: transform .45s ease; }
.product-slider-slide { flex: 0 0 100%; }
.product-slider-slide img { width: 100%; height: 160px; object-fit: cover; display: block; }
.product-slider-dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: .4rem; }
.product-slider-dot {
  width: 8px; height: 8px; border-radius: 999px; border: none; padding: 0;
  background: rgba(255,255,255,.55); cursor: pointer;
}
.product-slider-dot.active { background: var(--eco-white); width: 20px; border-radius: 999px; }
.product-slider-caption {
  font-size: .85rem; color: var(--eco-ink-600); line-height: 1.5;
  margin: .6rem 0 0; min-height: 1.3em; /* reserve space so slides without a description don't jump the layout */
}

@media (max-width: 768px) {
  .academy-banner-img, .product-slider-slide img { height: 130px; }
}

/* E-Academy full page: Levels & Modules accordion */
.ecademy-level {
  background: var(--eco-white); border: 1px solid var(--eco-border); border-radius: var(--radius-md, 12px);
  margin-bottom: 1rem; padding: 0; overflow: hidden;
}
.ecademy-level summary {
  list-style: none; cursor: pointer; padding: 1rem 1.25rem; display: flex; align-items: center;
  justify-content: space-between; gap: .75rem; font-weight: 700; color: var(--eco-green-800, var(--eco-green-700));
}
.ecademy-level summary::-webkit-details-marker { display: none; }
.ecademy-level summary::after { content: '▾'; margin-left: auto; color: var(--eco-ink-400); transition: transform .2s ease; }
.ecademy-level[open] summary::after { transform: rotate(180deg); }
.ecademy-level summary .ecademy-level-title { margin-right: auto; }
.ecademy-level-body { padding: 0 1.25rem 1.25rem; border-top: 1px solid var(--eco-border); }
.ecademy-module {
  padding: .9rem 0; border-bottom: 1px dashed var(--eco-border);
}
.ecademy-module:last-child { border-bottom: none; }
.ecademy-module h4 { margin: 0 0 .35rem; color: var(--eco-green-700); }
.ecademy-module p { margin: 0 0 .6rem; font-size: .9rem; color: var(--eco-ink-600); white-space: pre-line; }
.ecademy-video-wrap { position: relative; width: 100%; padding-top: 56.25%; border-radius: 8px; overflow: hidden; }
.ecademy-video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

html[data-theme="dark"] .ecademy-level { background: #16211a; border-color: #2a3830; }
html[data-theme="dark"] .ecademy-level-body { border-color: #2a3830; }
html[data-theme="dark"] .ecademy-module { border-color: #2a3830; }
html[data-theme="dark"] .academy-meeting-content, html[data-theme="dark"] .ecademy-module p { color: #c9d6ce; }
html[data-theme="dark"] .product-slider { background: #16211a; }
