/* ============================================================
   TalkMoney Dashboard — Design System
   Palette:  #0E2A52 (ink navy) · #1B5FE0 (action blue)
             #D9A63C (gold)     · #F4F6FB (canvas)
             #16C784 (positive) · #E0492F (alert)
   Type:     Sora (display) · Inter (body) · IBM Plex Mono (data)
   Signature: concentric "network rings" motif — used for the
   5-level referral map, rank progress, and avatar frames — a
   literal echo of TalkMoney's real referral structure.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --ink: #0E2A52;
  --ink-soft: #3B5178;
  --action: #1B5FE0;
  --action-dark: #144CB8;
  --gold: #D9A63C;
  --gold-soft: #F4E3BB;
  --canvas: #F4F6FB;
  --card: #FFFFFF;
  --line: #E4E9F2;
  --positive: #16C784;
  --alert: #E0492F;
  --text: #16233F;
  --text-mute: #5C6C8C;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(14, 42, 82, 0.04), 0 8px 24px rgba(14, 42, 82, 0.06);
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0;
  line-height: 1.15;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; overflow-wrap: break-word; word-break: break-word; }

a { color: var(--action); text-decoration: none; }
button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- App shell ---------------------------------------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--ink);
  color: #DCE6FA;
  padding: 24px 16px;
  display: none; /* shown from tablet breakpoint up */
  flex-direction: column;
  gap: 4px;
}

.sidebar .brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  padding: 0 12px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar .brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: #B9C7E6;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: var(--action); color: #fff; }
.nav-link .icon { width: 18px; text-align: center; }

.main {
  flex: 1;
  min-width: 0;
  padding: 20px 16px 90px;
}

@media (min-width: 860px) {
  .sidebar { display: flex; }
  .main { padding: 32px 40px; }
  .copy-link-mobile { display: none; }
}

/* ---------- Topbar --------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.topbar .greeting { font-family: var(--font-display); font-size: 20px; color: var(--ink); }
.topbar .sub { color: var(--text-mute); font-size: 13px; margin-top: 2px; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
}
.icon-btn .badge-dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--alert);
}

.avatar-ring {
  width: 44px; height: 44px; border-radius: 50%;
  padding: 2px;
  background: conic-gradient(var(--gold) 0deg, var(--action) 200deg, var(--line) 200deg);
  display: flex; align-items: center; justify-content: center;
}
.avatar-ring img, .avatar-ring .fallback {
  width: 100%; height: 100%; border-radius: 50%;
  object-fit: cover; background: var(--action); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  border: 2px solid #fff;
}

/* ---------- Cards ------------------------------------------------ */
.grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  padding: 18px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-header h3 { font-size: 15px; }
.card-header .link { font-size: 13px; font-weight: 600; }

.stat-card .label { font-size: 12.5px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .value { font-family: var(--font-mono); font-size: 26px; font-weight: 600; color: var(--ink); margin-top: 6px; }
.stat-card .delta { font-size: 12.5px; margin-top: 4px; font-weight: 600; }
.delta.up { color: var(--positive); }
.delta.down { color: var(--alert); }

/* ---------- Buttons ------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px;
  border: none; cursor: pointer;
}
.btn-primary { background: var(--action); color: #fff; }
.btn-primary:hover { background: var(--action-dark); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-block { width: 100%; }

/* ---------- Lists / rows ---------------------------------------- */
.row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .title { font-weight: 600; font-size: 14px; }
.row .meta { font-size: 12.5px; color: var(--text-mute); margin-top: 2px; }

.status-pill {
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.status-pill.completed, .status-pill.active { background: #E4F9F0; color: #0E9A66; }
.status-pill.pending { background: var(--gold-soft); color: #7A5710; }
.status-pill.failed, .status-pill.suspended { background: #FBE4DF; color: var(--alert); }

/* ---------- Signature: Network rings ----------------------------- */
.network-rings {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.ring-cell { text-align: center; }
.ring-cell .ring {
  width: 100%; aspect-ratio: 1;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--canvas);
  border: 3px solid var(--line);
  font-family: var(--font-mono); font-weight: 600; font-size: 15px; color: var(--ink);
}
.ring-cell.has-activity .ring { border-color: var(--action); background: #EAF1FE; }
.ring-cell .lvl-label { font-size: 11px; color: var(--text-mute); margin-top: 6px; font-weight: 600; }

.rank-ring {
  width: 92px; height: 92px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--gold) calc(var(--pct, 0) * 1%), var(--line) 0);
  flex-shrink: 0;
}
.rank-ring .inner {
  width: 74px; height: 74px; border-radius: 50%; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.rank-ring .inner .pct { font-family: var(--font-mono); font-weight: 700; font-size: 16px; color: var(--ink); }
.rank-ring .inner .lbl { font-size: 9.5px; color: var(--text-mute); }

/* ---------- Badges ------------------------------------------------ */
.badge-chip {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 8px;
  border-radius: var(--radius-md);
  background: var(--canvas);
  border: 1px solid var(--line);
  text-align: center;
}
.badge-chip .glyph {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(145deg, var(--gold), #B9832A);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
}
.badge-chip .name { font-size: 12px; font-weight: 700; color: var(--ink); }

/* ---------- Empty states ------------------------------------------ */
.empty-state {
  text-align: center; padding: 34px 12px; color: var(--text-mute);
}
.empty-state .glyph { font-size: 28px; margin-bottom: 8px; }
.empty-state p { margin: 4px 0 0; font-size: 13.5px; }

/* ---------- Mobile bottom tab bar --------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
}
.tabbar .tab-link {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; border: none; background: transparent; cursor: pointer;
  color: var(--text-mute); font-size: 10.5px; font-weight: 600;
}
.tabbar .tab-link .icon { font-size: 18px; }
.tabbar .tab-link.active { color: var(--action); }

@media (min-width: 860px) { .tabbar { display: none; } }

/* ---------- Utility ------------------------------------------------ */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-mute); font-weight: 700; margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }
.container { max-width: 1080px; margin: 0 auto; }
