:root {
  --primary: #7c3aed;
  --primary-dark: #5b21b6;
  --bg: #f7f6fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1e1b4b;
  --muted: #6b7280;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.center { text-align: center; }
.muted { color: var(--muted); }
.err { color: var(--danger); font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
.strong { font-weight: 700; }
code { background: #eef; padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }

.brand { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-mark { color: var(--primary); }
.brand-admin { color: var(--muted); font-weight: 600; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 2rem; width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.06); display: flex; flex-direction: column; gap: 0.75rem;
}
.login-card .brand { font-size: 1.25rem; margin-bottom: 0.25rem; }

/* Buttons */
.btn {
  border: none; border-radius: 9px; padding: 0.6rem 1rem; font-size: 0.875rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all 0.15s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; }

/* Shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1.25rem; padding: 0.75rem 1.25rem;
  background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 0.8rem; }
.tabs { display: flex; gap: 0.25rem; }
.tab {
  border: none; background: transparent; padding: 0.45rem 0.85rem; border-radius: 8px;
  font-weight: 600; color: var(--muted); cursor: pointer; font-family: inherit; font-size: 0.875rem;
}
.tab:hover { background: #f3f4f6; color: var(--text); }
.tab.active { background: #ede9fe; color: var(--primary-dark); }

.content { padding: 1.5rem; max-width: 1200px; width: 100%; margin: 0 auto; }
.section-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.section-head h1 { font-size: 1.35rem; margin: 0; }
.count { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.search {
  flex: 1; min-width: 200px; max-width: 340px; padding: 0.5rem 0.75rem; border: 1px solid var(--border);
  border-radius: 9px; font-family: inherit; font-size: 0.875rem;
}
.search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,58,237,0.12); }
.note { color: var(--muted); font-size: 0.8rem; margin: -0.25rem 0 1rem; }

/* Stat cards */
.stat-row { display: flex; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.25rem; min-width: 150px; flex: 1; }
.stat-num { font-size: 1.5rem; font-weight: 800; }
.stat-lbl { color: var(--muted); font-size: 0.75rem; margin-top: 0.15rem; }

/* Table */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  text-align: left; padding: 0.7rem 0.9rem; color: var(--muted); font-weight: 700; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 0.65rem 0.9rem; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #faf9ff; }
.u-email { font-weight: 600; }
.u-sub { color: var(--muted); font-size: 0.72rem; margin-top: 0.1rem; word-break: break-all; }

.chip {
  display: inline-block; background: #ede9fe; color: var(--primary-dark); font-weight: 600;
  font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 999px; margin: 0 0.2rem 0.2rem 0;
}
.pill { font-size: 0.7rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; text-transform: capitalize; }
.pill--trialing { background: #ede9fe; color: var(--primary-dark); }
.pill--active { background: #dcfce7; color: #15803d; }
.pill--past_due, .pill--unpaid { background: #fee2e2; color: var(--danger); }
.pill--canceled { background: #f3f4f6; color: var(--muted); }

.tier { font-weight: 700; text-transform: capitalize; }
.tier-ov { font-size: 0.62rem; background: #fef3c7; color: #b45309; padding: 0 0.35rem; border-radius: 999px; margin-left: 0.35rem; text-transform: uppercase; font-weight: 700; }
.tier-select { padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 7px; font-family: inherit; font-size: 0.8rem; background: #fff; }
.saving { color: var(--muted); font-size: 0.72rem; margin-left: 0.4rem; }

@media (max-width: 640px) {
  .content { padding: 1rem; }
  .who { display: none; }
}
