/* ============================================================
   ABUNDANCE — design system v2
   Direction: pure black, Inter throughout, restrained accent.
   Lime is reserved for actions/active states only — not decoration.
   ============================================================ */

/* Self-hosted Inter (SIL OFL 1.1 — see assets/fonts/LICENSE.txt).
   Self-hosting instead of Google Fonts removes two external origin
   connections (fonts.googleapis.com + fonts.gstatic.com) from every page
   load — each one costs a DNS lookup + TLS handshake before the font can
   even start downloading. Serving from the same origin as app.css lets the
   font load in parallel with it instead of after a separate round trip,
   which is a direct LCP/CLS win and one less third party for Lighthouse
   to flag. font-display: swap keeps text visible with a fallback font
   while Inter loads, rather than an invisible flash. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/inter-700.woff2') format('woff2');
}

:root {
  /* ---- Color: ink & page (pure black) ---- */
  --ink:        #FAFAF4;
  --ink-soft:   #B8BAAC;
  --ink-faint:  #9C9E90;
  --ink-muted:  #8A8C7E;
  --paper:      #000000;
  --surface:    #0B0C08;
  --surface-2:  #111208;
  --surface-hover: #14160D;
  --border:     #1E1F17;
  --border-strong: #2A2C1F;

  /* ---- Color: brand accent (vivid chartreuse) — reserved for action/active ---- */
  --accent:      #AEEA1B;
  --accent-deep: #93C817;
  --accent-tint: #141609;
  --accent-ink:  #0A0B06;

  /* ---- Color: semantic ---- */
  --wine:       #E4756D;
  --wine-tint:  #1A0A08;
  --amber:      #E0A94A;
  --amber-tint: #241A08;
  --amber-strong: #E0A94A;

  /* ---- Color: rank tiers (used only for badges) ---- */
  --silver:      #C8C9BC;
  --silver-tint: #1C1C18;
  --gold:        #D4AF37;
  --gold-tint:   #241C08;
  --platinum:    #7FD6E0;
  --platinum-tint: #0E1A1D;
  --diamond:     #C79FE0;
  --diamond-tint: #161018;
  --ambassador:      #F2C879;
  --ambassador-tint: #241B0A;

  /* ---- Color: leg tinting (team tree) ---- */
  --leg-left:      #B4E85C;
  --leg-left-tint: #1E2A0C;
  --leg-left-line: #5A7A24;
  --leg-right:      #D9C285;
  --leg-right-tint: #241C08;
  --leg-right-line: #7A621F;

  /* ---- Type: single family throughout ---- */
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* ---- Spacing (4px base) ---- */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem; --sp-10: 2.5rem;
  --sp-12: 3rem; --sp-16: 4rem; --sp-20: 5rem;

  /* ---- Radius: pill-first system ---- */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-full: 999px;
  --shadow-sm: 0 1px 0 rgba(255,255,255,.02), 0 2px 10px rgba(0,0,0,.5);
  --shadow-md: 0 1px 0 rgba(255,255,255,.03), 0 10px 30px rgba(0,0,0,.6);
  --ring-accent: 0 0 0 1px var(--accent);

  --ease: cubic-bezier(.22,.61,.36,1);
}

/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 var(--sp-2); letter-spacing: -0.02em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 var(--sp-3); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); }
::selection { background: var(--accent-deep); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ============================================================
   Page-load reveal
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  .app-main > *, .auth-card {
    animation: rise .5s var(--ease) both;
  }
  .app-main > *:nth-child(1) { animation-delay: 0ms; }
  .app-main > *:nth-child(2) { animation-delay: 40ms; }
  .app-main > *:nth-child(3) { animation-delay: 80ms; }
  .app-main > *:nth-child(4) { animation-delay: 120ms; }
  .app-main > *:nth-child(5) { animation-delay: 160ms; }
  .app-main > *:nth-child(n+6) { animation-delay: 200ms; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ============================================================
   Shell: sidebar app layout
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--sp-5) var(--sp-3);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .18s var(--ease);
  overflow-x: hidden;
}

/* Collapsed rail: icons only, no left accent bar (active state shown via
   icon color instead — there's no room for a bar at this width), matching
   the "version 1" collapsed-rail treatment from the design pass. */
.app-sidebar.collapsed { width: 64px; padding: var(--sp-5) 8px; }
.app-sidebar.collapsed .brand { justify-content: center; padding-bottom: 14px; }
.app-sidebar.collapsed .brand-word,
.app-sidebar.collapsed .sidebar-profile-name,
.app-sidebar.collapsed .sidebar-rank,
.app-sidebar.collapsed .nav-label,
.app-sidebar.collapsed .sidebar-tier,
.app-sidebar.collapsed .sidebar-logout span,
.app-sidebar.collapsed .nav-link span:last-child {
  display: none;
}
.app-sidebar.collapsed .sidebar-profile { flex-direction: column; padding-bottom: var(--sp-3); }
.app-sidebar.collapsed .nav-link {
  justify-content: center; border-left: none; border-radius: var(--r-sm); padding: 10px 0;
}
.app-sidebar.collapsed .nav-link.active { background: var(--surface-2); }
.app-sidebar.collapsed .nav-link.active svg { color: var(--accent); opacity: 1; }
.app-sidebar.collapsed .sidebar-foot { flex-direction: column; gap: 10px; }
.app-sidebar.collapsed #sidebar-collapse-btn svg { transform: rotate(180deg); }
#sidebar-collapse-btn { background: none; border: none; cursor: pointer; }
#sidebar-collapse-btn svg { transition: transform .18s var(--ease); }

.brand {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 18px;
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}
.brand svg { flex-shrink: 0; }
.brand-word { font-family: var(--font-display); font-weight: 700; font-size: 1rem; letter-spacing: -.01em; }
.mobile-bar .brand { padding: 0; margin-bottom: 0; border-bottom: none; }

.sidebar-profile {
  display: flex; align-items: center; gap: var(--sp-3); text-align: left;
  padding: 0 var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-4);
}
.who-avatar {
  width: 32px; height: 32px; border-radius: var(--r-full);
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: .8rem;
  flex-shrink: 0;
}
.who-avatar-lg {
  width: 32px; height: 32px; font-size: .8rem;
  background: var(--surface-2); color: var(--accent);
  border: 1px solid var(--accent);
}
.sidebar-profile-name { font-family: var(--font-display); font-weight: 600; font-size: .82rem; margin-bottom: 4px; }
.sidebar-rank { display: inline-flex; }

.nav-group { margin-bottom: var(--sp-4); }
.nav-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .1em;
  color: #4A4C42; font-weight: 600; padding: 0 var(--sp-3); margin-bottom: 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px 8px 11px;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  color: var(--ink-faint);
  font-size: .8rem; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.nav-link svg { opacity: .85; width: 15px; height: 15px; }
.nav-link:hover { background: var(--surface-hover); color: var(--ink); }
.nav-link.active { background: var(--surface-2); color: var(--ink); border-left-color: var(--accent); font-weight: 600; }
.nav-link.active svg { color: var(--accent); opacity: 1; }
.nav-icon-chip { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.sidebar-tier {
  background: var(--surface-2); border-radius: var(--r-sm);
  padding: 11px 12px; margin-bottom: var(--sp-3);
}
.sidebar-tier-label {
  font-size: .6rem; font-weight: 600; color: var(--ink-muted);
  letter-spacing: .06em; text-transform: uppercase; margin-bottom: 4px;
}
.sidebar-tier-value { font-size: .78rem; font-weight: 600; color: var(--ink-soft); }

.sidebar-foot {
  margin-top: auto; padding-top: var(--sp-3); border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.sidebar-logout {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--ink-faint); font-size: .8rem; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.sidebar-logout svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-logout:hover { background: var(--surface-hover); color: var(--wine); }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border-radius: var(--r-sm);
  color: var(--ink-faint); position: relative;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--accent); }

.app-content { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.app-main {
  flex: 1; min-width: 0;
  padding: var(--sp-8) var(--sp-10) var(--sp-16);
  max-width: 960px;
}

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; gap: var(--sp-5);
  padding: var(--sp-4) var(--sp-8);
  border-bottom: 1px solid var(--border);
  background: var(--paper);
  position: sticky; top: 0; z-index: 15;
}
.topbar .brand { margin-bottom: 0; padding: 0; border: none; }
.topbar-search {
  flex: 1; max-width: 260px; display: flex; align-items: center; gap: var(--sp-2);
  padding: .5rem .85rem; border-radius: var(--r-full);
  background: var(--surface-2); border: none;
  color: var(--ink-faint);
}
.topbar-search svg { flex-shrink: 0; width: 14px; height: 14px; }
/* form.topbar-search (not just .topbar-search) deliberately used here: the
   generic input[type=text] rule further down this file has the exact same
   specificity as a plain ".topbar-search input" selector, and — being
   declared later — was winning the tie and leaving its filled-underline
   bottom border visible on this search box. Adding the tag qualifier bumps
   specificity just enough to reliably win regardless of source order. */
form.topbar-search input {
  border: none; background: transparent; padding: 0; width: 100%;
  color: var(--ink); font-size: .82rem;
}
form.topbar-search input:hover,
form.topbar-search input:focus { border: none; outline: none; box-shadow: none; }
.topbar-search input::placeholder { color: var(--ink-muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }

/* ---- Checkbox-hack popups (Quick Invite, notification bell) ---- */
.popup-toggle { display: none; }
.popup-wrap { position: relative; display: flex; }
.popup-panel {
  display: none; position: absolute; top: calc(100% + var(--sp-2)); right: 0;
  width: 288px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-md); padding: var(--sp-5);
  z-index: 30;
}
.popup-toggle:checked ~ .popup-panel { display: block; }
.invite-link-row {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--surface-2); border-radius: var(--r-sm);
  padding: 11px 14px; margin: var(--sp-3) 0;
}
.invite-link-row input {
  border: none; background: transparent; padding: 0; flex: 1;
  font-size: .72rem; font-family: var(--font-mono); color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.invite-link-row input:focus { outline: none; box-shadow: none; }
.invite-share-row { display: flex; align-items: center; gap: 8px; margin-bottom: var(--sp-3); }
.invite-share-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border-radius: var(--r-full);
  padding: 8px 12px; font-size: .68rem; font-weight: 500; color: var(--ink-soft);
  flex: 1; justify-content: center; white-space: nowrap;
}
.invite-share-btn svg { width: 15px; height: 15px; }
.invite-reward {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--accent-tint); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: .74rem; line-height: 1.45; color: #D5EBA0;
}
.invite-reward svg { flex-shrink: 0; margin-top: 1px; color: var(--accent); width: 14px; height: 14px; }
.invite-qr {
  display: flex; justify-content: center; margin-bottom: var(--sp-3);
}
.invite-qr img, .invite-qr svg,
.invite-qr-panel img, .invite-qr-panel svg {
  background: #EDECE2; border-radius: var(--r-sm); padding: 8px; box-shadow: 0 0 0 1px var(--border);
}
.invite-qr-panel { flex-shrink: 0; }

.invite-leg-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.invite-leg-tab {
  background: var(--surface-2); border: none; color: var(--ink-faint);
  font-family: inherit; font-size: .74rem; font-weight: 600;
  padding: 6px 13px; border-radius: var(--r-full); cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.invite-leg-tab:hover { color: var(--ink-soft); }
.invite-leg-tab.active { background: var(--accent); color: var(--accent-ink); }
.bell-btn { cursor: pointer; }
.bell-count {
  position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 3px;
  background: var(--wine); color: #fff; border-radius: var(--r-full);
  font-size: .6rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.notif-panel { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: block; padding: var(--sp-3); border-radius: var(--r-sm);
  color: var(--ink); font-size: .82rem; border-bottom: 1px solid var(--border);
}
.notif-item:last-of-type { border-bottom: none; }
.notif-item:hover { background: var(--surface-hover); }
.notif-item.unread { position: relative; padding-left: var(--sp-4); }
.notif-item.unread::before {
  content: ""; position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}

.mobile-bar { display: none; }
.mobile-nav-panel { display: none; }
/* This checkbox drives the mobile hamburger menu purely via CSS (its
   paired <label class="hamburger"> is the only thing meant to be
   clickable) — it must never render as a visible control itself, at any
   screen size. Previously only hidden inside the mobile media query
   below, so on desktop widths the raw native checkbox showed up as a
   stray box near the top of the sidebar. */
#nav-toggle { display: none; }

@media (max-width: 860px) {
  .app-sidebar { display: none; }
  .topbar { display: none; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
  }
  .app-shell { flex-direction: column; }
  .app-main { padding: var(--sp-6) var(--sp-5) var(--sp-12); max-width: none; }

  /* #nav-toggle stays display:none (set unconditionally above) even on
     mobile — only .mobile-nav-panel's max-height responds to :checked. */
  .mobile-nav-panel {
    display: block;
    max-height: 0; overflow: hidden; background: var(--surface);
    border-bottom: 1px solid var(--border);
    transition: max-height .25s var(--ease);
  }
  #nav-toggle:checked ~ .mobile-nav-panel { max-height: 480px; }
  .mobile-nav-panel .nav-link { margin: var(--sp-1) var(--sp-4); }
  .hamburger { cursor: pointer; padding: var(--sp-2); display: flex; }
}

/* ============================================================
   Auth shell (login / register / reset)
   ============================================================ */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6);
}
.auth-card {
  width: 100%; max-width: 384px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  padding: 24px 28px 28px;
}
.auth-card .brand { margin-bottom: 20px; justify-content: center; border: none; padding: 0; }
.auth-card h1 { font-size: 1.2rem; text-align: center; margin-bottom: var(--sp-1); }
.auth-sub { text-align: center; color: var(--ink-faint); font-size: .8rem; margin-bottom: var(--sp-5); }
.auth-foot { text-align: center; margin-top: var(--sp-5); font-size: .84rem; color: var(--ink-faint); }

.password-field { position: relative; }
.password-field input { padding-right: 38px; }
.password-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--ink-faint); display: flex; align-items: center;
}
.password-toggle:hover { color: var(--ink); }
.password-toggle svg { width: 16px; height: 16px; }

.code-input {
  text-align: center; font-size: 1.25rem; font-weight: 600; letter-spacing: .5em;
  border-bottom-color: var(--accent);
}

.locked-field {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border-radius: var(--r-sm) var(--r-sm) 0 0;
  border-bottom: 2px solid var(--border-strong);
  padding: 9px 13px; color: var(--ink-soft); font-size: .85rem;
}
.locked-field svg { color: var(--ink-muted); flex-shrink: 0; width: 14px; height: 14px; }

/* Legal document pages (Terms, Privacy) — wider reading column than the
   login-style auth-card, plus a prominent draft/pending-review banner. */
.legal-card { max-width: 720px; text-align: left; }
.legal-card .brand { justify-content: flex-start; }
.legal-card h1 { text-align: left; font-size: 1.5rem; margin-bottom: .25rem; }
.legal-card .auth-sub { text-align: left; }
.legal-card h2 { font-size: 1rem; margin-top: 2rem; margin-bottom: .5rem; }
.legal-card p, .legal-card li { color: var(--ink-soft); font-size: .88rem; line-height: 1.7; }
.legal-card ul, .legal-card ol { padding-left: 1.25rem; margin: 0 0 1rem; }
.legal-draft-banner {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--amber-tint); border: 1px solid #4A3712; border-left: 3px solid var(--amber);
  border-radius: var(--r-sm); padding: 14px 16px; margin-bottom: 1.5rem;
  font-size: .82rem; color: #F0D9A8; line-height: 1.6;
}
.legal-draft-banner svg { color: var(--amber); flex-shrink: 0; margin-top: 2px; }
.legal-updated { font-size: .76rem; color: var(--ink-muted); margin-bottom: 1.5rem; }

/* Invite landing page (invite.php) */
.invite-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; margin: 0 auto 14px;
}
.invite-icon-circle {
  width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; color: var(--ink-faint);
}
.invite-icon-circle svg { width: 20px; height: 20px; }
.badge-lg { padding: 6px 15px; font-size: .78rem; }
.badge-lg svg { width: 13px; height: 13px; }

/* Admin: withdrawal request cards */
.card-review { position: relative; overflow: hidden; border-color: var(--border-strong); }
.card-review::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--amber); }
.addr-strip {
  background: var(--surface-2); border-radius: 6px; padding: 7px 10px; margin: 8px 0;
  font-family: var(--font-mono); font-size: .78rem; color: var(--ink-faint); word-break: break-all;
}
.withdrawal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 6px; }
.withdrawal-id { font-size: .84rem; color: var(--ink-faint); margin-bottom: 3px; }
.withdrawal-sub { font-size: .74rem; color: var(--ink-muted); }
.withdrawal-amount { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; color: var(--ink); text-align: right; }
.withdrawal-amount small { font-size: .7rem; color: var(--ink-faint); font-weight: 500; }

/* ============================================================
   Cards & stats
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-6);
  margin-bottom: var(--sp-5);
}
.card > h2 { margin-bottom: var(--sp-4); }
.card-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-4); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 15px;
}
.stat-icon-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-icon-chip {
  width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); color: var(--ink-muted); flex-shrink: 0;
}
.stat-icon-chip svg { width: 14px; height: 14px; }
.stat-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-faint); font-weight: 600;
}
.stat-value {
  font-family: var(--font-display); font-weight: 600; font-size: 1.55rem;
  line-height: 1.15; color: var(--ink); letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat-value small { font-family: var(--font-body); font-size: .78rem; font-weight: 500; color: var(--ink-faint); margin-left: .35em; }
.stat-hint { font-size: .72rem; color: var(--ink-muted); margin-top: 3px; }

.figure { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: 600; }

.divider { border: none; border-top: 1px solid var(--border); margin: var(--sp-5) 0; }

/* ============================================================
   Badges (rank + status)
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: .35em;
  padding: 4px 10px; border-radius: var(--r-full);
  font-size: .72rem; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; flex-shrink: 0; }
.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-active   { background: var(--accent-tint); color: #AEE076; }
.badge-inactive { background: var(--border-strong); color: var(--ink-soft); }
.badge-pending  { background: var(--amber-tint); color: var(--amber); }
.badge-danger   { background: var(--wine-tint); color: var(--wine); }
.badge-silver   { background: var(--silver-tint); color: var(--silver); }
.badge-gold     { background: var(--gold-tint); color: var(--gold); }
.badge-platinum { background: var(--platinum-tint); color: var(--platinum); }
.badge-diamond  { background: var(--diamond-tint); color: var(--diamond); }
.badge-ambassador { background: var(--ambassador-tint); color: var(--ambassador); }

.callout {
  display: flex; align-items: center; gap: 10px;
  border-radius: var(--r-sm); padding: 12px 16px;
  font-size: .82rem; margin-bottom: var(--sp-5);
  border: 1px solid transparent; border-left-width: 3px;
}
.callout svg { flex-shrink: 0; width: 16px; height: 16px; }
.callout-action {
  margin-left: auto; flex-shrink: 0;
}
.callout-warn { background: var(--amber-tint); color: #F0D9A8; border-color: #4A3712; }
.callout-error { background: var(--wine-tint); color: #F0B5AE; border-color: #4A2016; }
.callout-success { background: var(--accent-tint); color: #D5EBA0; border-color: #3A4A1C; }
.callout-quiet { background: transparent; padding: 6px 4px; border: none; color: var(--ink-muted); font-size: .78rem; }

/* ============================================================
   Forms
   ============================================================ */
label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-faint); margin: var(--sp-4) 0 7px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=email], input[type=password], input:not([type]), select {
  width: 100%; padding: 9px 13px; font: inherit; font-size: .85rem;
  background: var(--surface-2); color: var(--ink);
  border: none; border-bottom: 2px solid var(--border-strong);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: border-color .15s var(--ease);
}
input::placeholder { color: var(--ink-muted); }
input::placeholder { color: var(--ink-muted); }
input:hover, select:hover { border-bottom-color: var(--ink-faint); }
input:focus, select:focus {
  outline: none; border-bottom-color: var(--accent);
}
input:disabled { color: var(--ink-muted); cursor: not-allowed; opacity: .7; }
.field-hint { font-size: .74rem; color: var(--ink-faint); margin-top: 6px; line-height: 1.5; }

button, .btn {
  font: inherit; font-weight: 600; font-size: .84rem;
  padding: 8px 20px; border-radius: var(--r-full); border: none;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease), opacity .15s var(--ease);
}
button svg, .btn svg { width: 14px; height: 14px; flex-shrink: 0; }
button, .btn-primary {
  background: var(--accent); color: var(--accent-ink);
}
button:hover, .btn-primary:hover { background: var(--accent-deep); }
button:active, .btn-primary:active { transform: translateY(1px); }
.btn-secondary { background: var(--surface-2); color: var(--ink-soft); }
.btn-secondary:hover { background: var(--surface-hover); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--ink-faint); color: var(--ink); }
.btn-danger { background: transparent; color: var(--wine); border: 1px solid #4A2016; }
.btn-danger:hover { background: var(--wine-tint); }
.btn-disabled, button:disabled, .btn[disabled] {
  background: var(--surface-2); color: var(--ink-muted); border: 1px solid var(--border-strong);
  cursor: not-allowed; opacity: 1;
}
.btn-disabled:hover, button:disabled:hover { background: var(--surface-2); transform: none; }
.btn-sm { padding: 8px 16px; font-size: .76rem; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; margin: 0 calc(var(--sp-6) * -1); padding: 0 var(--sp-6); }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th {
  text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); font-weight: 600; padding: 0 var(--sp-3) var(--sp-2); border-bottom: 1px solid var(--border);
}
td { padding: var(--sp-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover { background: var(--surface-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================================
   Tier picker (package selection) — escalating treatment
   ============================================================ */
.contract-length-group { display: flex; gap: .75rem; flex-wrap: wrap; }
.contract-length-pill {
  /* Reset margin — this reuses <label> to wrap a hidden radio input, not as
     a form field label, so the generic label{margin:...} spacing (and its
     label:first-child override, which only zeroes the FIRST label in a
     row) must not apply here. Without this, the first pill in the row
     renders a different size than its siblings. */
  margin: 0; min-width: 96px; justify-content: center;
  position: relative; display: inline-flex; align-items: center; gap: .45rem;
  padding: 9px 18px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--ink-faint); font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: border-color .15s var(--ease), color .15s var(--ease), background .15s var(--ease);
}
.contract-length-pill input { position: absolute; opacity: 0; pointer-events: none; }
.contract-length-pill:hover { border-color: var(--ink-faint); }
.contract-length-pill.selected { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.contract-length-pill.selected::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
}

.tier-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--sp-4); }
.tier-card {
  /* Reset margin — see the identical comment on .contract-length-pill just
     above: this reuses <label> to wrap a hidden radio input, and the
     generic label{margin:...} + label:first-child rules elsewhere in this
     file would otherwise make the first card in the grid a different
     size than its siblings. */
  margin: 0;
  position: relative; display: block;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px 18px;
  cursor: pointer; text-align: left;
  transition: border-color .15s var(--ease), transform .1s var(--ease);
}
.tier-card:hover { border-color: var(--ink-faint); transform: translateY(-2px); }
.tier-card input { position: absolute; opacity: 0; pointer-events: none; }
.tier-card.selected { border: 2px solid var(--accent); background: var(--accent-tint); padding: 19px 17px; }
.tier-card.popular:not(.selected) { border-color: #3A4022; }
.tier-icon-chip {
  width: 26px; height: 26px; border-radius: 8px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); color: var(--ink-muted);
}
.tier-icon-chip svg { width: 14px; height: 14px; }
.tier-card.selected .tier-icon-chip { color: var(--accent); }
.tier-card.popular:not(.selected) .tier-icon-chip { background: var(--accent-tint); color: var(--accent); border: none; }
.tier-badge {
  position: absolute; top: -11px; left: 18px;
  background: var(--accent); color: var(--accent-ink);
  font-size: .62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--r-full);
}
.tier-badge.selected-badge { left: auto; right: 18px; }
.tier-badge.quiet {
  top: 16px; background: var(--accent-tint); color: var(--accent);
  border: 1px solid #3A3D26;
}
.tier-name { font-size: .62rem; color: var(--ink-faint); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 7px; }
.tier-card.selected .tier-name, .tier-card.popular .tier-name { color: var(--accent); }
.tier-price { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; }
.tier-price small { font-family: var(--font-body); font-size: .68rem; color: var(--ink-faint); font-weight: 500; }
.tier-selected-mark {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  color: var(--accent); font-size: .78rem; font-weight: 600;
  padding-top: 14px; margin-top: 20px; border-top: 1px solid #171A0D; text-align: center;
}
.tier-selected-sub { font-size: .68rem; color: var(--ink-muted); margin-top: 3px; }

.tier-summary-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 20px; margin-top: var(--sp-5);
}
.tier-summary-label { font-size: .64rem; font-weight: 600; color: var(--ink-faint); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 3px; }
.tier-summary-value { font-size: .92rem; font-weight: 600; color: var(--ink); }

/* ============================================================
   Org tree (team page) — pure CSS connectors, leg-tinted nodes
   ============================================================ */
.org-tree { padding: var(--sp-4) 0; }
.org-level { display: flex; justify-content: center; }
.org-level .org-slot { flex: 1; display: flex; justify-content: center; padding: 0 var(--sp-2); }
.org-connectors { height: 26px; position: relative; }
.org-connectors::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 50%;
  width: 1.5px; background: var(--border-strong); transform: translateX(-50%);
}
.org-connectors.two::after {
  content: ""; position: absolute; left: 25%; right: 25%; bottom: 50%; height: 1.5px;
  background: var(--border-strong);
}
.org-connectors.two .stem-l, .org-connectors.two .stem-r { position: absolute; bottom: 0; top: 50%; width: 1.5px; background: var(--border-strong); }
.org-connectors.two .stem-l { left: 25%; background: var(--leg-left-line); }
.org-connectors.two .stem-r { left: 75%; background: var(--leg-right-line); }
.org-connectors.four::after { display: none; }
.org-connectors.four .spread { position: absolute; bottom: 50%; height: 1.5px; background: var(--border-strong); }
.org-connectors.four .spread.l { left: 12.5%; right: 62.5%; }
.org-connectors.four .spread.r { left: 62.5%; right: 12.5%; }
.org-connectors.four .stem { position: absolute; bottom: 0; top: 50%; width: 1.5px; background: var(--border-strong); }
.org-connectors.four .s1 { left: 12.5%; } .org-connectors.four .s2 { left: 37.5%; }
.org-connectors.four .s3 { left: 62.5%; } .org-connectors.four .s4 { left: 87.5%; }
.org-connectors.four .spread.l, .org-connectors.four .s1, .org-connectors.four .s2 { background: var(--leg-left-line); }
.org-connectors.four .spread.r, .org-connectors.four .s3, .org-connectors.four .s4 { background: var(--leg-right-line); }

.leg-badge {
  position: absolute; top: -10px; left: 25%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-full);
  padding: 2px 10px; font-size: .64rem; font-weight: 600; color: var(--ink-soft);
  white-space: nowrap; z-index: 1;
}

.org-node-link { display: block; text-decoration: none; color: inherit; cursor: pointer; }
.org-node {
  width: 100%; max-width: 152px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden;
  text-align: center;
  transition: border-color .15s var(--ease);
}
.org-node:hover { border-color: var(--ink-faint); }
.org-node-tag {
  padding: 5px; font-size: .62rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
}
.org-node-body { padding: 12px 10px; }
.org-node.self { border: 2px solid var(--accent); }
.org-node.self .org-node-tag { background: var(--accent); color: var(--accent-ink); }
.org-node.leg-left { border-color: var(--leg-left-line); }
.org-node.leg-left .org-node-tag { background: var(--leg-left-tint); color: var(--leg-left); }
.org-node.leg-right { border-color: var(--leg-right-line); }
.org-node.leg-right .org-node-tag { background: var(--leg-right-tint); color: var(--leg-right); }
.org-node.empty {
  border: 1.5px dashed var(--border-strong); background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100px; padding: 16px 8px;
}
.org-node-plus {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px dashed var(--border-strong);
  display: flex; align-items: center; justify-content: center; margin-bottom: 6px; color: #4A4C3C;
}
.org-avatar { margin: 0 auto var(--sp-2); }
.org-node:not(.self) .org-avatar {
  background: var(--surface-2); border: 2px solid var(--border-strong); color: var(--ink-soft);
}
.org-node.leg-left .org-avatar { border-color: var(--leg-left-line); color: var(--leg-left); }
.org-node.leg-right .org-avatar { border-color: var(--leg-right-line); color: var(--leg-right); }
.org-node-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); margin-bottom: var(--sp-1); }
.org-node-name { font-weight: 600; font-size: .8rem; margin-bottom: 5px; }
.org-node-rank { display: inline-flex; align-items: center; gap: 3px; font-size: .64rem; padding: 2px 7px; }
.org-node-bv { font-size: .72rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; margin-top: var(--sp-1); }

/* Team page: search bar and tree toolbar */
.team-search-form { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.team-search-form input { flex: 1; }
.tree-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.zoom-controls { display: flex; gap: var(--sp-2); }
.icon-btn-sm {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); color: var(--ink-soft);
  font-size: .9rem; user-select: none; cursor: default;
}
.tree-stats { display: flex; gap: var(--sp-6); }
.tree-stats > div { display: flex; flex-direction: column; align-items: flex-end; }
.tree-stats .stat-label { margin-bottom: 0; }
.tree-stats .figure { font-size: 1.1rem; }

/* Invite card (My team) — permanent horizontal card, not just a popup */
.invite-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: var(--sp-5);
  display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap;
}
.invite-card-body { flex: 1; min-width: 240px; }
.invite-card-title { font-size: .92rem; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.invite-card-sub { font-size: .78rem; color: var(--ink-muted); margin-bottom: 16px; }

/* ============================================================
   Hero banner (dashboard)
   ============================================================ */
.hero {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-8); margin-bottom: var(--sp-5);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6);
}
.hero-text h1 { margin-bottom: 2px; }
.hero-icons { display: none; }
@media (max-width: 640px) { .hero { flex-direction: column; align-items: flex-start; } }

.chart-card canvas { max-width: 100%; }

/* ============================================================
   Stat icon chip (paired with a stat tile)
   ============================================================ */
.stat-icon { display: inline-flex; margin-bottom: var(--sp-2); }

/* ============================================================
   Misc utility
   ============================================================ */
.muted { color: var(--ink-faint); font-size: .85rem; }
.mono { font-family: var(--font-mono); font-size: .82rem; word-break: break-all; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.section-gap { margin-top: var(--sp-8); }

/* ============================================================
   Dashboard: trend, mini bars — used sparingly, not decoratively
   ============================================================ */
.stat-trend { display: inline-flex; align-items: center; gap: .3em; font-size: .76rem; font-weight: 600; margin-top: 4px; }
.stat-trend.up { color: var(--accent); }
.stat-trend.down { color: var(--wine); }
.card-highlight { border: 2px solid var(--accent); }
.mini-bar { height: 3px; border-radius: var(--r-full); background: var(--border-strong); overflow: hidden; margin-top: var(--sp-2); }
.mini-bar > span { display: block; height: 100%; background: var(--accent); border-radius: var(--r-full); }

/* Network Summary: left/right split with status chips */
.network-split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.network-col {
  background: var(--surface-2); border-radius: var(--r-sm); padding: 12px 14px;
}
.network-col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.network-status-chip {
  font-size: .625rem; font-weight: 700; padding: 4px 10px; border-radius: var(--r-full);
}
.network-status-chip.active { background: var(--accent-tint); color: #AEE076; }
.network-status-chip.lagging { background: var(--border-strong); color: var(--ink-soft); }
.network-count { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; }
.network-count small { font-family: var(--font-body); font-size: .7rem; font-weight: 500; color: var(--ink-faint); margin-left: .4em; }
.network-bar-row { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp-3); font-size: .76rem; color: var(--ink-faint); }
@media (max-width: 560px) { .network-split { grid-template-columns: 1fr; } }

/* Rank Progress: radial ring */
.rank-ring-wrap { display: flex; flex-direction: column; align-items: center; padding: var(--sp-2) 0; }
.rank-ring-pct { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; }
.rank-ring-label { font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin-top: -.2rem; }
.rank-progress-rows { width: 100%; margin-top: var(--sp-5); }
.rank-progress-row { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); font-size: .82rem; }
.rank-progress-row:last-child { border-bottom: none; }

/* Recent Activity feed */
.activity-list { display: flex; flex-direction: column; }
.activity-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: none; }
.activity-icon {
  width: 34px; height: 34px; border-radius: var(--r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--ink-muted);
}
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: .85rem; font-weight: 600; }
.activity-meta { font-size: .74rem; color: var(--ink-faint); margin-top: .1rem; }
.activity-amount { font-family: var(--font-display); font-weight: 600; text-align: right; white-space: nowrap; }

/* Empty states (history tables, referral lists, etc.) */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 16px 8px;
}
.empty-state svg { color: #54564A; margin-bottom: 9px; width: 24px; height: 24px; }
.empty-state-title { font-size: .78rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 3px; }
.empty-state-sub { font-size: .7rem; color: var(--ink-faint); }

/* Broadcast toast (admin announcements) */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--r-sm);
  box-shadow: var(--shadow-md); padding: 18px 16px 18px 20px;
  opacity: 0; transform: translateY(12px);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-warning { border-left-color: var(--amber); }
.toast-icon { color: var(--accent); flex-shrink: 0; display: flex; }
.toast-warning .toast-icon { color: var(--amber); }
.toast-message { flex: 1; font-size: .84rem; color: var(--ink); line-height: 1.5; }
.toast-close {
  width: 26px; height: 26px; border-radius: 50%;
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--ink-faint); flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.toast-close:hover { background: var(--surface-hover); color: var(--ink); }
.toast-close svg { width: 12px; height: 12px; }
@media (max-width: 480px) {
  .toast { left: 16px; right: 16px; max-width: none; bottom: 16px; }
}
