:root {
  --bg: #0b0c10;
  --bg-elevated: #14151b;
  --surface: #1a1c24;
  --surface-2: #22242e;
  --border: #2c2f3a;
  --text: #f2f3f7;
  --text-dim: #9a9db0;
  --text-faint: #6b6e7f;
  --accent: #5b5bf6;
  --accent-hover: #6f6ffb;
  --accent-soft: rgba(91, 91, 246, 0.15);
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }

/* ── Icons ───────────────────────────────────────────────────────────── */
.gc-icon { flex-shrink: 0; vertical-align: middle; }
.sidebar-link .gc-icon { opacity: 0.85; }
.sidebar-link.active .gc-icon { opacity: 1; }

/* ── Brand lockup (Webblyfy mark + product wordmark) ─────────────────── */
/* webblyfy-mark.png is the official white mark on a transparent background -
   used as-is on the dark UI (no filter). On the light theme it's inverted to
   black so it stays visible. */
.brand-logo { width: 24px; height: 24px; display: inline-block; object-fit: contain; }
.powered-by { display: inline-flex; align-items: center; gap: 6px; color: var(--text-faint); font-size: 12px; }
.powered-by img { width: 15px; height: 15px; object-fit: contain; opacity: 0.85; }
:root[data-theme="light"] .brand-logo,
:root[data-theme="light"] .powered-by img { filter: invert(1); }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

.container-narrow {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Top nav ─────────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(11, 12, 16, 0.85);
  backdrop-filter: blur(10px);
  z-index: 50;
}
.nav .brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav .brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-links a { color: var(--text-dim); font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--text); }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: rgba(248, 113, 113, 0.12); color: var(--danger); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards / surfaces ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Forms ───────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control::placeholder { color: var(--text-faint); }
textarea.form-control { resize: vertical; min-height: 70px; }
.form-row { display: flex; gap: 12px; }
.form-row > .form-group { flex: 1; }
.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* ── Image uploader ──────────────────────────────────────────────────── */
.uploader { display: flex; align-items: center; gap: 14px; }
.uploader-thumb {
  width: 64px; height: 64px; flex-shrink: 0;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 11px; text-align: center;
  overflow: hidden;
}
.uploader-thumb.round { border-radius: 50%; }
.uploader-thumb img { width: 100%; height: 100%; object-fit: cover; }
.uploader-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.uploader input[type=file] { display: none; }

/* ── Badges / chips ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border-radius: 100px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-free { background: rgba(154, 157, 176, 0.15); color: var(--text-dim); }
.badge-success { background: rgba(52, 211, 153, 0.15); color: var(--success); }

/* ── Alerts ──────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-error { background: rgba(248, 113, 113, 0.1); color: #fca5a5; border: 1px solid rgba(248, 113, 113, 0.25); }
.alert-success { background: rgba(52, 211, 153, 0.1); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, 0.25); }
.alert-info { background: var(--accent-soft); color: #c2c2ff; border: 1px solid rgba(91, 91, 246, 0.25); }

/* ── Layout helpers ──────────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
}

/* ── App shell (dashboard pages) ─────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
}
.sidebar-link:hover { background: var(--surface); color: var(--text); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); }
.main-content { flex: 1; padding: 32px; max-width: 920px; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .main-content { padding: 20px; }
}

/* ── Stat tiles ──────────────────────────────────────────────────────── */
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-tile .value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.stat-tile .label { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* ── Bar chart (CSS-only) ────────────────────────────────────────────── */
.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.bar-chart .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }

/* ── Public card page ────────────────────────────────────────────────── */
.pcard {
  max-width: 420px;
  margin: 40px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.pcard-header {
  padding: 36px 28px 24px;
  text-align: center;
  color: #fff;
}
.pcard-avatar {
  width: 88px; height: 88px;
  border-radius: 50%;
  margin: 0 auto 14px;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.15);
}
.pcard-name { font-size: 22px; font-weight: 800; margin: 0; }
.pcard-title { font-size: 14px; opacity: 0.9; margin: 4px 0 0; }
.pcard-body { padding: 24px 28px; }
.pcard-actions { display: flex; gap: 10px; margin-bottom: 20px; }
.pcard-links { display: flex; flex-direction: column; gap: 8px; }
.pcard-link {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  color: var(--text); font-size: 14px; font-weight: 500;
}
.pcard-link:hover { background: var(--surface); }
.pcard-qr { background: #fff; padding: 14px; border-radius: 14px; display: inline-block; }
.pcard-footer { padding: 16px 28px; text-align: center; font-size: 12px; color: var(--text-faint); border-top: 1px solid var(--border); }

/* ── Pricing ─────────────────────────────────────────────────────────── */
.plan-card { position: relative; }
.plan-card.featured { border-color: var(--accent); }
.plan-price { font-size: 36px; font-weight: 800; letter-spacing: -0.02em; margin: 8px 0; }
.plan-price span { font-size: 14px; color: var(--text-dim); font-weight: 500; }
.plan-features { list-style: none; padding: 0; margin: 20px 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--text-dim); }
.plan-features li { display: flex; gap: 8px; }
.plan-features li::before { content: '✓'; color: var(--success); font-weight: 700; }

/* ── Spinner ─────────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tables ──────────────────────────────────────────────────────────── */
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th { text-align: left; color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data-table td { padding: 12px; border-bottom: 1px solid var(--border); }
table.data-table tr:last-child td { border-bottom: none; }

footer.site-footer { text-align: center; padding: 40px 24px; color: var(--text-faint); font-size: 13px; }

/* ── Password field with show/hide toggle ────────────────────────────── */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 44px; }
.pw-toggle {
  position: absolute; top: 0; right: 0; height: 100%; width: 42px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 0;
}
.pw-toggle:hover { color: var(--text-dim); }
.pw-toggle.on { color: var(--accent); }

/* ── Consent checkbox (signup) ───────────────────────────────────────── */
.consent { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.consent input[type="checkbox"] { width: 18px; height: 18px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
.consent a { color: var(--accent); }

/* ── Scan business card (Add Lead) ───────────────────────────────────── */
.scan-dropzone {
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 18px; text-align: center; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.scan-dropzone .row { gap: 8px; }
.scan-status { font-size: 13px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 8px; }
.scan-spinner {
  width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: gc-spin 0.7s linear infinite;
}
@keyframes gc-spin { to { transform: rotate(360deg); } }

/* ── Billing sections (key/value rows, like GridRank) ────────────────── */
.billing-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px; }
.billing-section h2 { margin: 0 0 14px; font-size: 16px; font-weight: 700; }
.billing-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.billing-row:last-of-type { border-bottom: none; }
.billing-row .k { color: var(--text-dim); font-size: 14px; }
.billing-row .v { color: var(--text); font-size: 14px; font-weight: 600; text-align: right; }
.billing-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.billing-divider { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.status-pill { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 10px; border-radius: 100px; background: rgba(154,157,176,0.15); color: var(--text-dim); }
.status-pill.active, .status-pill.trialing { background: rgba(52,211,153,0.15); color: var(--success); }
.status-pill.past_due, .status-pill.canceled, .status-pill.unpaid { background: rgba(248,113,113,0.15); color: var(--danger); }

/* Dark-mode switch (Display section) */
.wb-theme-switch { position: relative; width: 46px; height: 26px; border: none; padding: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 100px; cursor: pointer; transition: background 0.18s; }
.wb-theme-switch.is-on { background: var(--accent); border-color: var(--accent); }
.wb-theme-switch .wb-theme-switch-thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.18s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.wb-theme-switch.is-on .wb-theme-switch-thumb { transform: translateX(20px); }
.wb-theme-switch .wb-theme-switch-track { display: none; }

/* ── Light theme (toggled from Billing → Display) ────────────────────── */
:root[data-theme="light"] {
  --bg: #f4f5f8;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f2f6;
  --border: #e3e5ec;
  --text: #16181f;
  --text-dim: #5a5f70;
  --text-faint: #8a8f9e;
  --accent-soft: rgba(91, 91, 246, 0.12);
  --shadow: 0 10px 30px rgba(20, 22, 28, 0.08);
}
:root[data-theme="light"] .nav { background: rgba(255, 255, 255, 0.85); }
